/* =========================================================================
   Stephud design system — "instrument" build.
   Dense, monospaced, hairline-ruled. Dark-first, with a paper-terminal light
   theme. Everything is driven by the tokens below, so themes and density swap
   without touching component rules.
   ========================================================================= */

/* ------------------------------------------------------------- 1. tokens */

:root {
  color-scheme: dark light;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --step-0: 0.6875rem;
  --step-1: 0.75rem;
  --step-2: 0.8125rem;
  --step-3: 0.9375rem;
  --step-4: 1.125rem;
  --step-5: 1.4375rem;
  --step-6: 1.875rem;
  --step-7: clamp(1.9rem, 1.1rem + 2.9vw, 2.9rem);

  --sp-1: 0.25rem; --sp-2: 0.375rem; --sp-3: 0.625rem; --sp-4: 0.875rem;
  --sp-5: 1.25rem; --sp-6: 1.75rem;  --sp-7: 2.5rem;   --sp-8: 3.5rem;

  /* squared-off, instrument-panel corners */
  --r-sm: 2px; --r-md: 3px; --r-lg: 4px; --r-xl: 6px; --r-full: 999px;

  --shadow-1: 0 1px 0 rgb(0 0 0 / 0.28);
  --shadow-2: 0 2px 10px rgb(0 0 0 / 0.35);
  --shadow-3: 0 14px 44px rgb(0 0 0 / 0.55);

  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
  --dur: 110ms;

  --nav-h: 46px;
  --status-h: 26px;
  --row-h: 30px;      /* table row height, overridden by density */
  --cell-y: 0.4rem;

  --accent-h: 152; --accent-s: 72%; --accent-l: 44%;
}

/* compact density */
:root[data-density="compact"] {
  --row-h: 24px;
  --cell-y: 0.2rem;
  --sp-5: 1rem; --sp-6: 1.25rem; --sp-7: 1.75rem; --sp-8: 2.5rem;
}

/* accent palettes — instrument channel colours */
[data-accent="signal"] { --accent-h: 152; --accent-s: 72%; --accent-l: 44%; }
[data-accent="cyan"]   { --accent-h: 187; --accent-s: 80%; --accent-l: 42%; }
[data-accent="amber"]  { --accent-h: 38;  --accent-s: 92%; --accent-l: 48%; }
[data-accent="sky"]    { --accent-h: 205; --accent-s: 88%; --accent-l: 48%; }
[data-accent="violet"] { --accent-h: 265; --accent-s: 70%; --accent-l: 58%; }
[data-accent="emerald"]{ --accent-h: 158; --accent-s: 70%; --accent-l: 40%; }
[data-accent="rose"]   { --accent-h: 342; --accent-s: 78%; --accent-l: 52%; }
[data-accent="slate"]  { --accent-h: 212; --accent-s: 16%; --accent-l: 50%; }

/* ------------------------------------------------------------- 2. themes */

:root,
[data-theme="dark"] {
  --bg:        hsl(220 16% 7%);
  --bg-alt:    hsl(220 16% 9%);
  --surface:   hsl(220 15% 11%);
  --surface-2: hsl(220 14% 14%);
  --surface-3: hsl(220 13% 18%);
  --border:    hsl(220 12% 20%);
  --border-2:  hsl(220 11% 28%);
  --rule:      hsl(220 12% 16%);
  --text:      hsl(210 16% 90%);
  --text-2:    hsl(214 10% 66%);
  --text-3:    hsl(215 9% 48%);
  --accent:      hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) + 12%));
  --accent-ink:  hsl(var(--accent-h) 78% 66%);
  --accent-soft: hsl(var(--accent-h) 46% 16%);
  --accent-line: hsl(var(--accent-h) 60% 30%);
  --accent-on:   hsl(220 24% 6%);
  --success: hsl(150 60% 50%);  --success-soft: hsl(150 40% 14%);
  --warn:    hsl(40 92% 58%);   --warn-soft:    hsl(40 46% 15%);
  --danger:  hsl(356 78% 62%);  --danger-soft:  hsl(356 42% 17%);
  --info:    hsl(200 82% 58%);  --info-soft:    hsl(200 46% 15%);
  --zebra:   hsl(220 14% 12.5%);
  --overlay: hsl(220 24% 3% / 0.72);
}

[data-theme="light"] {
  --bg:        hsl(210 20% 97%);
  --bg-alt:    hsl(210 18% 94%);
  --surface:   hsl(0 0% 100%);
  --surface-2: hsl(210 20% 96%);
  --surface-3: hsl(210 18% 92%);
  --border:    hsl(212 16% 84%);
  --border-2:  hsl(212 14% 72%);
  --rule:      hsl(212 18% 90%);
  --text:      hsl(215 28% 12%);
  --text-2:    hsl(215 12% 38%);
  --text-3:    hsl(215 10% 52%);
  --accent:      hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 4%));
  --accent-ink:  hsl(var(--accent-h) 78% 26%);
  --accent-soft: hsl(var(--accent-h) 62% 93%);
  --accent-line: hsl(var(--accent-h) 50% 74%);
  --accent-on:   #fff;
  --success: hsl(150 62% 30%);  --success-soft: hsl(150 52% 93%);
  --warn:    hsl(35 90% 38%);   --warn-soft:    hsl(40 90% 92%);
  --danger:  hsl(356 70% 45%);  --danger-soft:  hsl(356 80% 95%);
  --info:    hsl(205 76% 42%);  --info-soft:    hsl(205 82% 94%);
  --zebra:   hsl(210 22% 98%);
  --overlay: hsl(215 28% 20% / 0.4);
  --shadow-1: 0 1px 0 rgb(16 24 40 / 0.06);
  --shadow-2: 0 2px 10px rgb(16 24 40 / 0.1);
  --shadow-3: 0 14px 40px rgb(16 24 40 / 0.2);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:        hsl(210 20% 97%);
    --bg-alt:    hsl(210 18% 94%);
    --surface:   hsl(0 0% 100%);
    --surface-2: hsl(210 20% 96%);
    --surface-3: hsl(210 18% 92%);
    --border:    hsl(212 16% 84%);
    --border-2:  hsl(212 14% 72%);
    --rule:      hsl(212 18% 90%);
    --text:      hsl(215 28% 12%);
    --text-2:    hsl(215 12% 38%);
    --text-3:    hsl(215 10% 52%);
    --accent:      hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 4%));
    --accent-ink:  hsl(var(--accent-h) 78% 26%);
    --accent-soft: hsl(var(--accent-h) 62% 93%);
    --accent-line: hsl(var(--accent-h) 50% 74%);
    --accent-on:   #fff;
    --success: hsl(150 62% 30%);  --success-soft: hsl(150 52% 93%);
    --warn:    hsl(35 90% 38%);   --warn-soft:    hsl(40 90% 92%);
    --danger:  hsl(356 70% 45%);  --danger-soft:  hsl(356 80% 95%);
    --info:    hsl(205 76% 42%);  --info-soft:    hsl(205 82% 94%);
    --zebra:   hsl(210 22% 98%);
    --overlay: hsl(215 28% 20% / 0.4);
    --shadow-1: 0 1px 0 rgb(16 24 40 / 0.06);
    --shadow-2: 0 2px 10px rgb(16 24 40 / 0.1);
    --shadow-3: 0 14px 40px rgb(16 24 40 / 0.2);
  }
}

/* --------------------------------------------------------------- 3. base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: var(--status-h);
  font-family: var(--font-sans);
  font-size: var(--step-2);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.18; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: var(--step-6); }
h2 { font-size: var(--step-5); }
h3 { font-size: var(--step-4); }
h4 { font-size: var(--step-3); }
p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--sp-5) 0; }

:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); color: var(--text); }

/* thin instrument scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 0; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--accent-on);
  padding: var(--sp-3) var(--sp-4); font-weight: 650;
}
.skip-link:focus { left: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------- 4. layout */

.wrap { width: min(1440px, 100% - 1.75rem); margin-inline: auto; }
.wrap-narrow { width: min(780px, 100% - 1.75rem); margin-inline: auto; }
.stack > * + * { margin-top: var(--gap, var(--sp-4)); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.spacer { flex: 1; }
.section { padding-block: var(--sp-6); }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); font-size: var(--step-1); }
.center { text-align: center; }
.mono { font-family: var(--font-mono); font-size: 0.94em; letter-spacing: -0.01em; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* uppercase micro-label used on every panel header */
.eyebrow {
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3);
}

/* ---------------------------------------------------------------- 5. nav */

.nav {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.nav-inner { height: 100%; display: flex; align-items: center; gap: var(--sp-3); }

.brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-weight: 700; font-size: var(--step-3); letter-spacing: -0.02em;
  color: var(--text); text-decoration: none; flex-shrink: 0;
  padding-right: var(--sp-3); margin-right: var(--sp-1);
  border-right: 1px solid var(--border);
  height: 100%;
}
.brand:hover { text-decoration: none; color: var(--accent-ink); }
.brand-mark {
  width: 22px; height: 22px; display: grid; place-items: center;
  color: var(--accent); flex-shrink: 0;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }

.nav-links { display: flex; align-items: center; gap: 1px; }
.nav-link {
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 550; font-size: var(--step-1);
  font-family: var(--font-mono); letter-spacing: -0.01em;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] {
  color: var(--accent-ink); background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-search { flex: 1; max-width: 420px; position: relative; }
/* Scoped to .nav so it outranks the `input[type="search"]` padding shorthand in
   section 7, which is defined later at the same specificity — without this the
   placeholder starts underneath the ⌕ glyph. */
.nav .nav-search input { padding-left: 1.9rem; font-family: var(--font-mono); }
.nav-search::before {
  content: "⌕"; position: absolute; left: 0.55rem; top: 50%; transform: translateY(-50%);
  font-size: 0.95rem; color: var(--text-3); pointer-events: none;
}
/* Scoped to .nav so it outranks `.btn { display: inline-flex }`, which is defined
   further down the file — otherwise the hamburger shows on desktop, where the
   menu it opens is already on screen and clicking it does nothing. */
.nav .nav-toggle { display: none; }

.avatar {
  width: 24px; height: 24px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: var(--surface-3); color: var(--accent-ink);
  font-family: var(--font-mono); font-weight: 700; font-size: 10px;
  border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: var(--step-5); border-radius: var(--r-md); }
.avatar-sm { width: 20px; height: 20px; font-size: 9px; }

.menu {
  position: absolute; right: 0; top: calc(100% + 5px); min-width: 214px; z-index: 70;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); padding: var(--sp-1); overflow: hidden;
}
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-2) var(--sp-3); border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text); font: inherit; font-size: var(--step-1);
  text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item.is-danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--rule); margin: var(--sp-1) 0; }

/* ------------------------------------------------------------ 6. toolbar */

.toolbar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
}
.toolbar-sep { width: 1px; align-self: stretch; background: var(--border); margin-inline: var(--sp-1); }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r-sm); overflow: hidden; }
.seg button {
  padding: 0.25rem 0.55rem; border: 0; background: var(--surface);
  color: var(--text-2); font: inherit; font-family: var(--font-mono);
  font-size: var(--step-0); cursor: pointer; line-height: 1.7;
}
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.is-on { background: var(--accent-soft); color: var(--accent-ink); }

/* --------------------------------------------------------- 7. controls */

.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-2);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0.35rem 0.7rem; min-height: 28px;
  border: 1px solid var(--btn-bd); border-radius: var(--r-sm);
  background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-size: var(--step-1); font-weight: 600; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--accent-on); --btn-bd: var(--accent); font-weight: 700; }
.btn-primary:hover { --btn-bg: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) + 18%)); border-color: transparent; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--text-2); }
.btn-ghost:hover { --btn-bg: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-soft { --btn-bg: var(--accent-soft); --btn-fg: var(--accent-ink); --btn-bd: var(--accent-line); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn-danger-soft { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-bd: transparent; }
.btn-sm { padding: 0.2rem 0.45rem; min-height: 22px; font-size: var(--step-0); }
.btn-lg { padding: 0.6rem 1.1rem; min-height: 38px; font-size: var(--step-3); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 28px; min-height: 28px; }
.btn.is-active { --btn-bg: var(--accent-soft); --btn-fg: var(--accent-ink); --btn-bd: var(--accent-line); }

.field { display: block; }
.field > label, .label {
  display: block; margin-bottom: var(--sp-2);
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600;
  color: var(--text-3); letter-spacing: 0.08em; text-transform: uppercase;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="url"], textarea, select {
  width: 100%; padding: 0.35rem 0.55rem; min-height: 28px;
  border: 1px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: var(--step-2);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input:hover, textarea:hover, select:hover { border-color: var(--text-3); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
select {
  appearance: none; padding-right: 1.6rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 54%, calc(100% - 9px) 54%;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
}
::placeholder { color: var(--text-3); opacity: 1; }
.hint { font-size: var(--step-0); color: var(--text-3); margin-top: var(--sp-2); }
.err { font-size: var(--step-0); color: var(--danger); margin-top: var(--sp-2); font-weight: 600; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }

.check { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--step-1); }
.check input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }

.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 34px; height: 18px; border-radius: var(--r-full); background: var(--surface-3);
  border: 1px solid var(--border-2); position: relative;
  transition: background var(--dur) var(--ease); flex-shrink: 0;
}
.switch-track::after {
  content: ""; position: absolute; inset: 2px auto 2px 2px; width: 12px;
  border-radius: var(--r-full); background: var(--text-2);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(15px); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 1px solid var(--accent); outline-offset: 2px; }

/* A one-of-several choice where each option needs a line of explanation —
   the access modes on a guide. The selected one is drawn as a filled row so
   the default reads as chosen rather than as merely first. */
.choice-set { display: grid; gap: var(--sp-2); }
.choice {
  display: flex; align-items: flex-start; gap: var(--sp-3); cursor: pointer;
  padding: var(--sp-3); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--surface-1);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.choice:hover { border-color: var(--border-3, var(--accent)); background: var(--surface-2); }
.choice input { width: 15px; height: 15px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.choice > span { display: grid; gap: 2px; }
.choice strong { font-weight: 600; }
.choice .dim { font-size: var(--step-0); }
.choice.is-on { border-color: var(--accent); background: var(--accent-soft); }
.choice.is-on strong { color: var(--accent-ink); }
.choice:focus-within { outline: 1px solid var(--accent); outline-offset: 2px; }

/* --------------------------------------------------------- 8. surfaces */

.card, .panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.card-pad { padding: var(--sp-4); }
.panel { padding: var(--sp-4); }

/* panel with a titled header strip */
.panel-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) var(--sp-4);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  border-radius: var(--r-md) var(--r-md) 0 0;
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-2);
}

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.1rem 0.4rem; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600;
  color: var(--text-2); white-space: nowrap; line-height: 1.6;
}
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }
.chip-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
a.chip:hover { text-decoration: none; border-color: var(--text-3); color: var(--text); }
.chip-btn { cursor: pointer; font: inherit; font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600; }
.chip-btn.is-on { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }

/* removable filter token */
.token {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.1rem 0.2rem 0.1rem 0.45rem; border-radius: var(--r-sm);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent-ink); font-family: var(--font-mono); font-size: var(--step-0);
  white-space: nowrap;
}
.token b { font-weight: 700; }
.token button {
  border: 0; background: none; color: inherit; cursor: pointer;
  padding: 0 0.2rem; font-size: 0.9em; line-height: 1; opacity: 0.7;
}
.token button:hover { opacity: 1; }

/* difficulty pips */
.diff { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
.diff-pip { width: 4px; height: 10px; background: var(--surface-3); }
.diff-pip.on { background: var(--d-color, var(--accent)); }
.diff[data-level="1"] { --d-color: hsl(150 60% 46%); }
.diff[data-level="2"] { --d-color: hsl(96 52% 46%); }
.diff[data-level="3"] { --d-color: hsl(45 90% 50%); }
.diff[data-level="4"] { --d-color: hsl(22 90% 55%); }
.diff[data-level="5"] { --d-color: hsl(356 76% 58%); }

/* ------------------------------------------------- 9. guide cards/grid */

.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.gcard {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.gcard:hover { border-color: var(--accent-line); background: var(--surface-2); }
.gcard-link { color: inherit; text-decoration: none; display: flex; flex-direction: column; height: 100%; }
.gcard-link:hover { text-decoration: none; }

.gcard-cover {
  aspect-ratio: 21 / 9; position: relative; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center;
  border-bottom: 1px solid var(--border);
}
.gcard-cover img { width: 100%; height: 100%; object-fit: cover; }
.gcard-cover .cover-glyph { font-size: 1.9rem; position: relative; z-index: 1; }
.gcard-badges { position: absolute; top: 5px; left: 5px; z-index: 2; display: flex; gap: 3px; flex-wrap: wrap; }
.gcard-badges .chip { background: rgb(0 0 0 / 0.66); color: #fff; border-color: rgb(255 255 255 / 0.14); }
.gcard-save {
  position: absolute; top: 5px; right: 5px; z-index: 3;
  width: 22px; height: 22px; border-radius: var(--r-sm);
  border: 1px solid rgb(255 255 255 / 0.16);
  background: rgb(0 0 0 / 0.6); color: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 12px; line-height: 1;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.gcard:hover .gcard-save, .gcard-save.is-on, .gcard-save:focus-visible { opacity: 1; }
.gcard-save.is-on { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }

.gcard-body { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; }
.gcard-title { font-size: var(--step-3); font-weight: 650; line-height: 1.25; }
.gcard-summary {
  font-size: var(--step-1); color: var(--text-2); flex: 1; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gcard-meta {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding-top: var(--sp-2); border-top: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: var(--step-0); color: var(--text-3);
}
.gcard-progress { height: 3px; background: var(--surface-3); overflow: hidden; }
.gcard-progress > i { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------- 10. data table view */

.dtable-wrap {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); overflow: auto; max-height: 62vh;
}
.dtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--step-1); }
.dtable thead th {
  position: sticky; top: 0; z-index: 2;
  padding: 0 var(--sp-3); height: 26px; text-align: left; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border-2);
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.07em;
  user-select: none;
}
.dtable thead th.sortable { cursor: pointer; }
.dtable thead th.sortable:hover { color: var(--text); background: var(--surface-3); }
.dtable thead th .sort-ind { color: var(--accent); margin-left: 3px; }
.dtable thead th + th { border-left: 1px solid var(--border); }

.dtable tbody tr { height: var(--row-h); cursor: pointer; }
.dtable tbody tr:nth-child(even) { background: var(--zebra); }
.dtable tbody tr:hover { background: var(--surface-2); }
.dtable tbody tr.is-selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.dtable tbody tr.is-selected td { color: var(--text); }
.dtable tbody td {
  padding: var(--cell-y) var(--sp-3); border-bottom: 1px solid var(--rule);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 460px;
}
.dtable td.num { font-family: var(--font-mono); text-align: right; color: var(--text-2); }
.dtable td.mono { font-family: var(--font-mono); color: var(--text-2); }
.dtable .row-title { font-weight: 600; color: var(--text); }

/* difficulty-keyed row tint, like a colouring rule set */
.dtable tbody tr[data-level="1"] .row-title { color: hsl(150 55% 58%); }
.dtable tbody tr[data-level="2"] .row-title { color: hsl(96 48% 58%); }
.dtable tbody tr[data-level="3"] .row-title { color: hsl(45 82% 60%); }
.dtable tbody tr[data-level="4"] .row-title { color: hsl(22 84% 64%); }
.dtable tbody tr[data-level="5"] .row-title { color: hsl(356 72% 66%); }
[data-theme="light"] .dtable tbody tr[data-level="1"] .row-title { color: hsl(150 62% 28%); }
[data-theme="light"] .dtable tbody tr[data-level="2"] .row-title { color: hsl(96 52% 28%); }
[data-theme="light"] .dtable tbody tr[data-level="3"] .row-title { color: hsl(38 88% 32%); }
[data-theme="light"] .dtable tbody tr[data-level="4"] .row-title { color: hsl(20 84% 40%); }
[data-theme="light"] .dtable tbody tr[data-level="5"] .row-title { color: hsl(356 68% 45%); }

/* lower detail pane */
.detail-pane {
  margin-top: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden;
}
.detail-head {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--step-0);
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2);
}
.detail-body { padding: var(--sp-4); display: grid; gap: var(--sp-5); grid-template-columns: 1.4fr 1fr; }
.detail-tree { list-style: none; margin: 0; padding: 0; font-family: var(--font-mono); font-size: var(--step-1); }
.detail-tree li { padding: 2px 0 2px var(--sp-4); position: relative; color: var(--text-2); }
.detail-tree li::before {
  content: "├─"; position: absolute; left: 0; color: var(--text-3);
}
.detail-tree li:last-child::before { content: "└─"; }
.detail-tree li b { color: var(--text); font-weight: 600; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--sp-4); font-family: var(--font-mono); font-size: var(--step-1); }
.kv dt { color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; font-size: var(--step-0); align-self: center; }
.kv dd { margin: 0; color: var(--text); }

/* ------------------------------------------------------- 11. progress */

.pbar { height: 5px; background: var(--surface-3); overflow: hidden; border-radius: var(--r-sm); }
.pbar > i { display: block; height: 100%; background: var(--accent); transition: width 260ms var(--ease); }
.pbar-lg { height: 8px; }

.ring { --p: 0; width: 40px; height: 40px; position: relative; flex-shrink: 0; }
.ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
}
.ring::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface); }
.ring > span {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 1;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
}

/* ---------------------------------------------------------- 12. steps */

.steps { display: flex; flex-direction: column; gap: var(--sp-3); counter-reset: step; }

.step {
  position: relative; scroll-margin-top: calc(var(--nav-h) + 12px);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 2px solid var(--border-2);
  border-radius: var(--r-md); padding: var(--sp-4);
  transition: border-color var(--dur) var(--ease);
}
.step:hover { border-left-color: var(--accent-line); }
.step.is-done { border-left-color: var(--success); }
.step.is-done .step-num { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.step-head { display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.step-num {
  width: 26px; height: 22px; flex-shrink: 0; border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 700; font-size: var(--step-1);
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text-2);
}
.step-title { font-size: var(--step-4); font-weight: 650; line-height: 1.2; }
.step-body { font-size: var(--step-2); line-height: 1.68; color: var(--text); max-width: 78ch; }
.step-body p + p { margin-top: var(--sp-3); }
.step-img { border-radius: var(--r-sm); margin-top: var(--sp-3); border: 1px solid var(--border); }
.step-foot { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--rule); }

.callout {
  display: flex; gap: var(--sp-3); margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  border: 1px solid var(--c-accent, var(--info));
  border-left-width: 2px;
  background: var(--c-bg, var(--info-soft));
  font-size: var(--step-1); line-height: 1.55;
}
.callout-tip { --c-accent: var(--info); --c-bg: var(--info-soft); }
.callout-warning { --c-accent: var(--danger); --c-bg: var(--danger-soft); }
.callout-glyph { flex-shrink: 0; font-size: var(--step-2); }

.step-check {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 0.25rem 0.65rem; border-radius: var(--r-sm);
  border: 1px solid var(--border-2); background: var(--surface);
  font-family: var(--font-mono); font-size: var(--step-1); font-weight: 600;
  color: var(--text-2); cursor: pointer; transition: all var(--dur) var(--ease);
}
.step-check:hover { border-color: var(--success); color: var(--text); }
.step-check.is-done { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.step-check .box {
  width: 14px; height: 14px; border-radius: 1px; border: 1px solid currentColor;
  display: grid; place-items: center; font-size: 10px; flex-shrink: 0;
}

.supply-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.supply {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--step-1); cursor: pointer;
}
.supply:hover { background: var(--surface-2); }
.supply input { accent-color: var(--accent); width: 13px; height: 13px; cursor: pointer; }
.supply.checked span { text-decoration: line-through; color: var(--text-3); }
.supply-qty { margin-left: auto; font-size: var(--step-0); color: var(--text-3); }

/* ---------------------------------------------------- 12b. spec sheet */

.spec-sheet {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); margin-bottom: var(--sp-5); overflow: hidden;
}
.spec-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-2);
}
.spec-group + .spec-group { border-top: 1px solid var(--rule); }
.spec-section {
  margin: 0; padding: var(--sp-2) var(--sp-3);
  background: var(--bg-alt);
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-ink);
  border-bottom: 1px solid var(--rule);
}
.spec-rows { margin: 0; padding: 0; }
.spec-row {
  display: grid; grid-template-columns: minmax(140px, 34%) 1fr;
  gap: var(--sp-3); align-items: baseline;
  padding: var(--cell-y) var(--sp-3);
  border-bottom: 1px solid var(--rule);
}
.spec-row:last-child { border-bottom: 0; }
.spec-row:nth-child(even) { background: var(--zebra); }
.spec-row dt {
  font-family: var(--font-mono); font-size: var(--step-0);
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3);
}
.spec-row dd {
  margin: 0; font-family: var(--font-mono); font-size: var(--step-2);
  color: var(--text); font-weight: 600; overflow-wrap: anywhere;
}

/* index-table thumbnails */
.thumb {
  width: 46px; height: 28px; border-radius: 2px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2);
  display: grid; place-items: center; position: relative; flex-shrink: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb span { font-size: 13px; position: relative; z-index: 1; }
.dtable td.thumb-cell { padding-block: 2px; width: 54px; }

.detail-thumb {
  width: 128px; height: 78px; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2);
  display: grid; place-items: center; position: relative; flex-shrink: 0;
}
.detail-thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail-thumb span { font-size: 30px; position: relative; z-index: 1; }

/* --------------------------------------------------------- 13. tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--step-1); }
thead th {
  text-align: left; padding: var(--sp-2) var(--sp-3); white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border-2);
  font-family: var(--font-mono); font-size: var(--step-0); font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.07em;
  position: sticky; top: 0; z-index: 1;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); background: var(--surface-3); }
tbody td { padding: var(--cell-y) var(--sp-3); border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:nth-child(even) { background: var(--zebra); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.is-checked { background: var(--accent-soft); }
th.num, td.num { text-align: right; }
td.num { font-family: var(--font-mono); color: var(--text-2); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 3px; }

/* bulk-action bar that slides in when rows are ticked */
.bulkbar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  font-family: var(--font-mono); font-size: var(--step-1); color: var(--accent-ink);
}

/* ---------------------------------------------------------- 14. admin */

.admin { display: grid; grid-template-columns: 200px 1fr; gap: var(--sp-5); align-items: start; }
.admin-nav {
  position: sticky; top: calc(var(--nav-h) + var(--sp-3));
  display: flex; flex-direction: column; gap: 1px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-2);
}
.admin-nav button {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-2) var(--sp-2); border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-2);
  font: inherit; font-family: var(--font-mono); font-size: var(--step-1); font-weight: 600;
  text-align: left; cursor: pointer;
}
.admin-nav button:hover { background: var(--surface-2); color: var(--text); }
.admin-nav button.is-active { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 2px 0 0 var(--accent); }
.admin-nav .count { margin-left: auto; font-size: var(--step-0); color: var(--text-3); }

.stat-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3);
  border-top: 2px solid var(--accent-line);
}
.stat-label {
  font-family: var(--font-mono); font-size: var(--step-0); color: var(--text-3);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
}
.stat-value {
  font-family: var(--font-mono); font-size: var(--step-6); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1; margin-top: 2px; color: var(--text);
}
.stat-note { font-size: var(--step-0); color: var(--text-3); font-family: var(--font-mono); }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 46px; }
.spark > i { flex: 1; min-width: 2px; background: var(--surface-3); }
.spark > i.hot { background: var(--accent); }

.bar-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.bar-row {
  display: grid; grid-template-columns: 148px 1fr 34px; gap: var(--sp-3); align-items: center;
  font-family: var(--font-mono); font-size: var(--step-1);
}
.bar-track { height: 6px; background: var(--surface-3); overflow: hidden; }
.bar-track > i { display: block; height: 100%; background: var(--accent); }

/* log severity keying */
.log-line { color: var(--text-2); }
.log-info b { color: var(--info); }
.log-good b { color: var(--success); }
.log-warn b { color: var(--warn); }
.log-bad b { color: var(--danger); }

/* --------------------------------------------------------- 15. badges */

.badge-card {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
}
.badge-card.locked { opacity: 0.6; }
.badge-card.earned { border-color: var(--accent-line); background: var(--surface-2); }
.badge-medal {
  width: 40px; height: 40px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; font-size: 19px;
  background: var(--surface-2); border: 1px solid var(--border-2);
}
.badge-card.earned .badge-medal { background: var(--accent-soft); border-color: var(--accent); }
.badge-card[data-tier="silver"].earned .badge-medal { border-color: hsl(210 12% 62%); }
.badge-card[data-tier="gold"].earned .badge-medal { border-color: hsl(43 82% 52%); }

/* --------------------------------------------------------- 16. editor */

.editor { display: grid; grid-template-columns: 1fr 340px; gap: var(--sp-5); align-items: start; }
.editor-preview { position: sticky; top: calc(var(--nav-h) + var(--sp-3)); max-height: calc(100vh - var(--nav-h) - 3rem); overflow-y: auto; }

.step-editor { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.step-editor + .step-editor { margin-top: var(--sp-3); }
.step-editor.dragging { opacity: 0.4; }
.step-editor.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.step-editor-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--step-1);
}
.drag-handle { cursor: grab; color: var(--text-3); padding: 0 3px; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.step-editor-body { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); }

.dropzone {
  border: 1px dashed var(--border-2); border-radius: var(--r-sm);
  padding: var(--sp-4); text-align: center; cursor: pointer;
  color: var(--text-3); font-family: var(--font-mono); font-size: var(--step-1);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.dropzone img { border-radius: var(--r-sm); margin: 0 auto; max-height: 150px; width: auto; }

/* ---------------------------------------------------------- 17. modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--overlay); padding: var(--sp-4);
}
.modal {
  width: min(520px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: var(--sp-5);
}
.modal-title {
  font-family: var(--font-mono); font-size: var(--step-2); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--text);
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--rule);
}
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }

/* ----------------------------------------------- 18. command palette */

.palette-backdrop {
  position: fixed; inset: 0; z-index: 130; background: var(--overlay);
  display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh;
}
.palette {
  width: min(620px, calc(100% - 2rem));
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-3); overflow: hidden;
}
.palette input {
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  padding: var(--sp-3) var(--sp-4); min-height: 42px;
  font-family: var(--font-mono); font-size: var(--step-3); background: var(--surface);
}
.palette input:focus { box-shadow: none; border-color: var(--border); }
.palette-list { list-style: none; margin: 0; padding: var(--sp-1); max-height: 46vh; overflow-y: auto; }
.palette-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  font-size: var(--step-2); cursor: pointer; color: var(--text);
}
.palette-item .kind {
  font-family: var(--font-mono); font-size: var(--step-0); color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; width: 46px; flex-shrink: 0;
}
.palette-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .meta { font-family: var(--font-mono); font-size: var(--step-0); color: var(--text-3); }
.palette-item.is-active { background: var(--accent-soft); color: var(--accent-ink); }
.palette-item.is-active .kind, .palette-item.is-active .meta { color: var(--accent-ink); }
.palette-foot {
  display: flex; gap: var(--sp-4); padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--border); background: var(--surface-2);
  font-family: var(--font-mono); font-size: var(--step-0); color: var(--text-3);
}
.palette-empty { padding: var(--sp-5); text-align: center; color: var(--text-3); font-family: var(--font-mono); font-size: var(--step-1); }

/* ------------------------------------------------------ 19. status bar */

.statusbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  height: var(--status-h);
  display: flex; align-items: center; gap: 0;
  background: var(--bg-alt); border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--step-0); color: var(--text-3);
  padding-inline: var(--sp-3);
}
.statusbar .seg-item {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 var(--sp-3); height: 100%; white-space: nowrap;
  border-right: 1px solid var(--border);
}
.statusbar .seg-item:first-child { padding-left: 0; }
.statusbar .seg-item b { color: var(--text-2); font-weight: 600; }
.statusbar .push { margin-left: auto; border-right: 0; border-left: 1px solid var(--border); }
.statusbar .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.statusbar .dot.live { background: var(--success); box-shadow: 0 0 5px var(--success); }
.statusbar .dot.busy { background: var(--warn); }
.statusbar .dot.down { background: var(--danger); }
.statusbar button {
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer;
  padding: 0 var(--sp-2); height: 100%;
}
.statusbar button:hover { color: var(--text); background: var(--surface-2); }

/* -------------------------------------------------------- 20. toasts */

.toasts {
  position: fixed; right: var(--sp-3); bottom: calc(var(--status-h) + var(--sp-3)); z-index: 120;
  display: flex; flex-direction: column; gap: var(--sp-2); max-width: min(360px, calc(100vw - 1.5rem));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border-2);
  border-left: 2px solid var(--t-accent, var(--accent));
  box-shadow: var(--shadow-2); font-size: var(--step-1);
  animation: slide-in 160ms var(--ease);
}
.toast.leaving { animation: slide-out 130ms var(--ease) forwards; }
.toast-success { --t-accent: var(--success); }
.toast-error { --t-accent: var(--danger); }
.toast-badge { --t-accent: hsl(43 82% 52%); }
.toast-glyph { font-size: var(--step-2); }

@keyframes slide-in  { from { opacity: 0; transform: translateX(16px); } }
@keyframes slide-out { to   { opacity: 0; transform: translateX(16px); } }

/* ------------------------------------------------------- 21. utility */

.empty {
  text-align: center; padding: var(--sp-7) var(--sp-4);
  border: 1px dashed var(--border-2); border-radius: var(--r-md); color: var(--text-2);
}
.empty-glyph { font-size: 2rem; margin-bottom: var(--sp-2); opacity: 0.55; }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-3) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: shimmer 1.1s infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 210px; }

.tabs { display: flex; gap: 1px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: var(--sp-2) var(--sp-4); border: 0; background: none; cursor: pointer;
  font: inherit; font-family: var(--font-mono); font-size: var(--step-1); font-weight: 600;
  color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); background: var(--accent-soft); }

.pagination { display: flex; justify-content: center; align-items: center; gap: var(--sp-2); }

/* hero — kept technical: grid backdrop, no soft gradients */
.hero {
  padding: var(--sp-7) 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(to right, var(--rule) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(ellipse 60% 120% at 8% 0%, var(--accent-soft), transparent 62%),
    var(--bg-alt);
  position: relative;
}
.hero h1 { font-size: var(--step-7); max-width: 17ch; letter-spacing: -0.03em; }
.hero-lede { font-size: var(--step-3); color: var(--text-2); max-width: 58ch; margin-top: var(--sp-3); }

.filmstrip { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-2); }
.film {
  flex: 0 0 124px; aspect-ratio: 16/10; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--border); position: relative;
  display: grid; place-items: center; font-size: 1.4rem; text-decoration: none;
  transition: border-color var(--dur) var(--ease);
}
.film:hover { border-color: var(--accent); text-decoration: none; }
.film-label {
  position: absolute; inset: auto 0 0 0; padding: 14px 5px 4px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.82));
  color: #fff; font-size: 10px; font-weight: 600; line-height: 1.2;
  font-family: var(--font-mono);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.rating { display: inline-flex; gap: 1px; }
.star {
  background: none; border: 0; padding: 0 1px; cursor: pointer; font-size: var(--step-3);
  line-height: 1; color: var(--surface-3); transition: color 90ms var(--ease);
}
.star.on { color: hsl(43 90% 54%); }
.star:hover { color: hsl(43 90% 64%); }
.rating[data-readonly="true"] .star { cursor: default; }

.guide-layout { display: grid; grid-template-columns: 252px 1fr; gap: var(--sp-5); align-items: start; }
.guide-side { position: sticky; top: calc(var(--nav-h) + var(--sp-3)); display: flex; flex-direction: column; gap: var(--sp-3); }

.mobile-progress { display: none; }

/* --------------------------------------------------- 22. player mode */

.player-backdrop {
  position: fixed; inset: 0; z-index: 90; background: var(--bg);
  display: flex; flex-direction: column;
}
.player-top {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border); background: var(--bg-alt);
  font-family: var(--font-mono); font-size: var(--step-1);
}
.player-main { flex: 1; overflow-y: auto; padding: var(--sp-6) var(--sp-4); }
.player-card { width: min(720px, 100%); margin-inline: auto; }
.player-step-title { font-size: var(--step-6); margin-bottom: var(--sp-3); }
.player-body { font-size: var(--step-3); line-height: 1.72; }
.player-bottom {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border); background: var(--bg-alt);
}
.player-dots { display: flex; gap: 2px; flex: 1; justify-content: center; flex-wrap: wrap; }
.player-dot {
  width: 22px; height: 5px; border: 0; padding: 0; cursor: pointer;
  background: var(--surface-3); transition: background var(--dur) var(--ease);
}
.player-dot.done { background: var(--success); }
.player-dot.current { background: var(--accent); }

kbd {
  display: inline-block; padding: 0 4px; border-radius: 2px; font-family: var(--font-mono);
  font-size: 10px; background: var(--surface-2); border: 1px solid var(--border-2);
  border-bottom-width: 2px; color: var(--text-2); line-height: 1.5;
}

/* ----------------------------------------------------- 23. responsive */

@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .editor-preview { position: static; max-height: none; }
  .guide-layout { grid-template-columns: 1fr; }
  .guide-side { position: static; }
  .admin { grid-template-columns: 1fr; }
  .admin-nav { position: static; flex-direction: row; overflow-x: auto; }
  .admin-nav .count { display: none; }
  .detail-body { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --step-6: 1.5rem; --step-5: 1.25rem; }
  .nav-search, .nav-links { display: none; }
  .nav .nav-toggle { display: inline-flex; }
  /* The open menu is one stacked panel: search on top, links under it. Both used
     to be absolutely positioned at the same offset, so the search sat on top of
     the links and the toggle looked like it did nothing. */
  .nav.is-open { height: auto; }
  .nav.is-open .nav-inner {
    flex-wrap: wrap; height: auto; row-gap: var(--sp-2);
    padding-bottom: var(--sp-2); align-items: center;
  }
  .nav.is-open .nav-search { display: block; order: 90; flex: 0 0 100%; max-width: none; }
  .nav.is-open .nav-links {
    display: flex; flex-direction: column; align-items: stretch; gap: 1px;
    order: 91; flex: 0 0 100%;
  }
  .nav.is-open .nav-link { padding: var(--sp-3); }
  .grid { grid-template-columns: 1fr; }
  .dtable-wrap { max-height: 50vh; }
  .statusbar .seg-item.optional { display: none; }
  .mobile-progress {
    display: flex; align-items: center; gap: var(--sp-2);
    position: fixed; left: var(--sp-2); right: var(--sp-2); bottom: calc(var(--status-h) + var(--sp-2)); z-index: 55;
    padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
    background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow-2);
  }
  .toasts { left: var(--sp-2); right: var(--sp-2); bottom: calc(var(--status-h) + 46px); max-width: none; }
}

/* ---------------------------------------------------------- 24. print */

@media print {
  .nav, .toasts, .guide-side, .step-check, .no-print, .mobile-progress, .statusbar { display: none !important; }
  body { background: #fff; color: #000; padding-bottom: 0; }
  .step { break-inside: avoid; border: 1px solid #ccc; }
  .step-title { font-size: 15pt; }
  a { color: #000; text-decoration: none; }
  .guide-layout { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}
