/* ===== Fonts (self-hosted, no external calls) ===== */
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-700.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono-600.woff2') format('woff2');
}

/* ===== Design tokens ===== */
:root {
  --bg: #faf9f6;
  --bg-elevated: #ffffff;
  --bg-panel: #ffffff;
  --bg-panel-2: #f3f2ec;
  --border: #e6e3da;
  --border-strong: #d1cdc0;
  --text: #201e19;
  --text-dim: #5c594e;
  --text-faint: #928e7f;
  --accent: #b45309;
  --accent-dim: #92400e;
  --accent-bg: rgba(180, 83, 9, 0.07);
  --accent-bg-strong: rgba(180, 83, 9, 0.14);
  --danger: #d33b2c;
  --danger-bg: rgba(211, 59, 44, 0.08);
  --success: #16794a;
  --success-bg: rgba(22, 121, 74, 0.08);
  --info: #0969a2;
  --info-bg: rgba(9, 105, 162, 0.08);

  --font-sans: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --radius: 3px;
  --radius-lg: 6px;
  --shadow-sm: 0 1px 2px rgba(32, 30, 25, 0.05);
  --shadow-md: 0 6px 20px rgba(32, 30, 25, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(32, 30, 25, 0.06) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: #171410;
}

/* ===== scrollbars ===== */
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: var(--bg-elevated);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid var(--bg-elevated);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}

/* ===== layout shell ===== */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: rgba(250, 249, 246, 0.88);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
}

.brand__mark {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.brand__sub {
  color: var(--text-faint);
  font-weight: 400;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.topnav a {
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.topnav a:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-panel);
}

.topnav a.is-active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-bg);
}

main {
  flex: 1;
  min-height: 0;
}

/* hide the page's own nav/breadcrumb when loaded inside the sidebar shell's iframe */
html.is-embedded .topbar,
html.is-embedded .breadcrumb {
  display: none;
}

html.is-embedded .workarea {
  padding-top: 14px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
}

footer.sitefoot {
  border-top: 1px solid var(--border);
  padding: 20px 28px;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== tag / label ===== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  background: var(--accent-bg);
  padding: 3px 8px;
  border-radius: var(--radius);
  text-transform: uppercase;
}

.tag--dim {
  color: var(--text-dim);
  border-color: var(--border-strong);
  background: var(--bg-panel);
}

/* ===== buttons ===== */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--text-dim);
  background: var(--bg-panel-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8ef;
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--bg-panel);
}

.btn--sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 1px 4px;
}

/* ===== panel ===== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.panel__title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel__title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.panel__title .dot.is-ok {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.panel__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.panel__body {
  padding: 14px;
}

.panel__body--flush {
  padding: 0;
}

/* ===== form controls ===== */
label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

select,
input[type='text'],
input[type='number'] {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 9px;
  border-radius: var(--radius);
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  padding: 3px 0;
}

.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.check .hint {
  color: var(--text-faint);
  font-size: 11px;
}

/* ===== hero (homepage) ===== */
.hero {
  padding: 64px 0 40px;
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 50px);
  line-height: 1.1;
  margin: 0 0 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  max-width: 16ch;
}

.hero p {
  color: var(--text-dim);
  max-width: 56ch;
  font-size: 16px;
  margin: 0;
}

/* ===== tool grid / cards ===== */
.toolgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  padding: 8px 0 72px;
}

.toolcard {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s, background 0.15s, box-shadow 0.15s;
}

.toolcard:hover {
  border-color: var(--accent-dim);
  background: var(--bg-panel-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.toolcard__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.toolcard__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.toolcard__icon svg {
  width: 19px;
  height: 19px;
}

.toolcard__idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  padding-top: 4px;
}

.toolcard h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.toolcard p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.toolcard__foot {
  margin-top: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 7px;
}

/* ===== toast ===== */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-panel-2);
  border: 1px solid var(--accent-dim);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ===== tool page workspace ===== */
.workarea {
  padding: 22px 0 60px;
}

.workhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.workhead h1 {
  font-size: 22px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.workhead .tag {
  font-size: 10px;
}

.breadcrumb {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.breadcrumb a {
  color: var(--text-dim);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.split--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.layout-2col {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 900px) {
  .split,
  .split--3,
  .layout-2col {
    grid-template-columns: 1fr;
  }
}

.editorwrap {
  height: 460px;
  overflow: hidden;
}

.editorwrap .CodeMirror {
  height: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-elevated);
  color: var(--text);
}

.plain-editor {
  display: block;
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: none;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-elevated);
  color: var(--text);
}

.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  flex: 1;
  min-width: 110px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.stat__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.stat__value {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text);
  margin-top: 4px;
}

.stat__value.is-good {
  color: var(--success);
}

.stat__value.is-bad {
  color: var(--danger);
}

.opt-section {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
}

.opt-section:last-child {
  border-bottom: none;
}

.opt-section__title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0 8px;
}

.preset-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-row .btn {
  flex: 1;
}

.console {
  height: 100%;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-elevated);
}

.console__line {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

.console__line .lvl {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  color: var(--text-faint);
}

.console__line.log .lvl { color: var(--text-dim); }
.console__line.warn { background: rgba(255, 176, 32, 0.06); }
.console__line.warn .lvl { color: var(--accent); }
.console__line.error { background: var(--danger-bg); }
.console__line.error .lvl { color: var(--danger); }
.console__line.info .lvl { color: var(--info); }
.console__empty {
  padding: 30px 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

.transform-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transform-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.transform-item__body h4 {
  margin: 0 0 3px;
  font-size: 13px;
}

.transform-item__body p {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-faint);
  max-width: 40ch;
}

.hint-block {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  padding: 12px 14px;
}

.hint-block.is-bad {
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
}

.hint-block.is-info {
  border: 1px solid var(--info);
  background: var(--info-bg);
  color: var(--info);
  padding: 10px 14px;
}

.hint-block code {
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ===== file upload / image tools ===== */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.dropzone__icon {
  color: var(--accent);
  margin-bottom: 10px;
}

.dropzone__title {
  font-size: 14px;
  color: var(--text);
  margin: 0 0 4px;
}

.dropzone__hint {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  margin: 0;
}

.checkerboard {
  background-image:
    linear-gradient(45deg, #e2e0d6 25%, transparent 25%),
    linear-gradient(-45deg, #e2e0d6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e0d6 75%),
    linear-gradient(-45deg, transparent 75%, #e2e0d6 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #f5f4ee;
}

.img-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  max-height: 440px;
  overflow: auto;
  border-radius: var(--radius);
}

.img-preview img,
.img-preview canvas {
  max-width: 100%;
  max-height: 420px;
  display: block;
}

.img-preview__empty {
  color: var(--text-faint);
  font-size: 12px;
  font-family: var(--font-mono);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type='range'] {
  flex: 1;
  accent-color: var(--accent);
}

.slider-row .val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  min-width: 44px;
  text-align: right;
}

input[type='color'] {
  width: 34px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  cursor: pointer;
}

.file-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.file-meta strong {
  color: var(--text-dim);
  font-weight: 500;
}
