/* ==========================================================================
   LLM Lab — design system (main.css)
   Owner: F2. Chapter agents: please do NOT edit this file; add page-specific
   rules in a <style> block in your chapter page, prefixed with your chapter
   id (e.g. `.ch03-…`). Request shared changes in NOTES/<agent>.md.

   Contents
     1. Tokens (light + dark themes, palettes)
     2. Reset & base typography
     3. App chrome: top nav, layout, sidebar TOC, footer
     4. Chapter header, roadmap banner, meta
     5. Long-form prose: headings, lists, links, figures, tables, code
     6. Callouts (info / pitfall / try / book / success)
     7. Widget cards & controls (buttons, sliders, toggles, selects, inputs)
     8. Core components (matrix, heatmap, charts, stepper, tokens, shapes, code panel)
     9. Quiz & flashcards
    10. Home page, cards, dashboard, glossary
    11. Diagrams (SVG)
    12. Utilities, print, reduced motion
   ========================================================================== */

/* 1. TOKENS ================================================================ */
:root {
  color-scheme: light;

  /* Typography */
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-prose: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1.0625rem;   /* 17px prose */
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;
  --fs-3xl: clamp(2rem, 4.5vw, 3.25rem);
  --lh-prose: 1.68;
  --lh-tight: 1.25;

  /* Spacing & shape */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem;  --sp-6: 2rem;   --sp-7: 3rem;    --sp-8: 4.5rem;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 16px; --radius-pill: 999px;
  --measure: 46rem;          /* prose column width */
  --wide: 58rem;             /* widgets may use this width */
  --sidebar-w: 17rem;
  --nav-h: 3.5rem;

  /* Light theme colors */
  --bg: #f8f7f3;
  --bg-elev: #ffffff;
  --bg-sunken: #f0eee8;
  --bg-hover: #eceae3;
  --text: #1c2129;
  --text-muted: #5a6371;
  --text-faint: #8a919c;
  --border: #e2dfd6;
  --border-strong: #c9c5ba;
  --accent: #3451b2;
  --accent-hover: #26408f;
  --accent-soft: #e6ebfa;
  --accent-contrast: #ffffff;
  --focus: #3451b2;
  --shadow-sm: 0 1px 2px rgba(20, 24, 31, .06);
  --shadow: 0 1px 2px rgba(20, 24, 31, .05), 0 6px 20px rgba(20, 24, 31, .06);
  --shadow-lg: 0 12px 40px rgba(20, 24, 31, .14);

  /* Semantic */
  --info: #0b6bb3;       --info-bg: #e8f2fb;
  --pitfall: #b5440b;    --pitfall-bg: #fdf0e6;
  --try: #087a5b;        --try-bg: #e6f5ef;
  --book: #7a3e9d;       --book-bg: #f4ecf9;
  --success: #12805c;    --success-bg: #e3f4ec;
  --danger: #c0392b;     --danger-bg: #fbeaea;
  --warning: #9a6700;    --warning-bg: #fff6dc;

  /* Roadmap stages (Okabe–Ito based, colorblind-safe) */
  --stage-0: #6b7280;    /* orientation / extras */
  --stage-1: #0072b2;    /* Stage 1: build */
  --stage-2: #009e73;    /* Stage 2: pretrain */
  --stage-3: #d55e00;    /* Stage 3: fine-tune */
  --stage-1-bg: #e5f1f8; --stage-2-bg: #e2f4ee; --stage-3-bg: #fbece2; --stage-0-bg: #efeff1;

  /* Categorical palette: Okabe–Ito (colorblind-safe) */
  --cat-0: #0072b2; --cat-1: #e69f00; --cat-2: #009e73; --cat-3: #cc79a7;
  --cat-4: #56b4e9; --cat-5: #d55e00; --cat-6: #8c6d1f; --cat-7: #6b7280;

  /* Sequential palette: viridis (9 stops, low → high) */
  --seq-0: #440154; --seq-1: #472d7b; --seq-2: #3b528b; --seq-3: #2c728e; --seq-4: #21918c;
  --seq-5: #28ae80; --seq-6: #5ec962; --seq-7: #addc30; --seq-8: #fde725;

  /* Diverging palette: blue ↔ neutral ↔ orange (signed values; colorblind-safe) */
  --div-0: #2166ac; --div-1: #4393c3; --div-2: #92c5de; --div-3: #d1e5f0; --div-4: #f5f3ef;
  --div-5: #fddbc7; --div-6: #f4a582; --div-7: #d6604d; --div-8: #b2182b;

  /* Token chip colors (light pastel, readable text) */
  --tok-0: #dbeafe; --tok-1: #fde68a; --tok-2: #bbf7d0; --tok-3: #fbcfe8;
  --tok-4: #c7d2fe; --tok-5: #fed7aa; --tok-6: #a5f3fc; --tok-7: #e9d5ff;
  --tok-text: #1c2129;

  /* Code (syntax colors used for highlight.js tokens) */
  --code-bg: #f3f1ec;
  --code-text: #24292f;
  --code-border: #e4e0d6;
  --code-line-hl: rgba(52, 81, 178, .12);
  --code-line-hl-bar: #3451b2;
  --syn-keyword: #a626a4;
  --syn-string: #2f7d32;
  --syn-number: #b45309;
  --syn-comment: #7a828e;
  --syn-func: #1f5fbf;
  --syn-builtin: #0e7490;
  --syn-meta: #9a3412;
}

/* Dark theme tokens. Applied when the OS prefers dark (and the user has not
   forced light), or when the user forces dark via the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12151b; --bg-elev: #1a1e26; --bg-sunken: #0e1116; --bg-hover: #232833;
    --text: #e6e8ec; --text-muted: #a3abb8; --text-faint: #737c8a;
    --border: #2b313c; --border-strong: #3d4552;
    --accent: #8ea6ff; --accent-hover: #b0c0ff; --accent-soft: #1f2843; --accent-contrast: #0e1116;
    --focus: #8ea6ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
    --info: #6cb6f5; --info-bg: #13263a; --pitfall: #f59a62; --pitfall-bg: #34200f;
    --try: #4fd1a5; --try-bg: #0f2d24; --book: #cf9cf0; --book-bg: #2a1c35;
    --success: #4fd1a5; --success-bg: #0f2d24; --danger: #ff7b72; --danger-bg: #3a1716;
    --warning: #e3b341; --warning-bg: #332708;
    --stage-0: #9aa1ad; --stage-1: #56b4e9; --stage-2: #2fcf9e; --stage-3: #ff8a3d;
    --stage-1-bg: #10283a; --stage-2-bg: #0f2d24; --stage-3-bg: #35200f; --stage-0-bg: #1f232b;
    --cat-0: #56b4e9; --cat-1: #e69f00; --cat-2: #2fcf9e; --cat-3: #e39ac6;
    --cat-4: #9ad3f5; --cat-5: #ff8a3d; --cat-6: #d9b45a; --cat-7: #9aa1ad;
    --div-4: #2a2f38; --div-3: #2f4b63; --div-5: #5b3a32;
    --tok-0: #1e3a5f; --tok-1: #4a3b0c; --tok-2: #14432c; --tok-3: #4f1d3a;
    --tok-4: #2c2f66; --tok-5: #4f2f12; --tok-6: #134552; --tok-7: #3b2459;
    --tok-text: #eef0f3;
    --code-bg: #161a21; --code-text: #d7dce4; --code-border: #2b313c;
    --code-line-hl: rgba(142, 166, 255, .14); --code-line-hl-bar: #8ea6ff;
    --syn-keyword: #d19df5; --syn-string: #8fd18f; --syn-number: #f5b26b; --syn-comment: #7f8896;
    --syn-func: #82b4ff; --syn-builtin: #5fd4e6; --syn-meta: #ff9e7a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12151b; --bg-elev: #1a1e26; --bg-sunken: #0e1116; --bg-hover: #232833;
  --text: #e6e8ec; --text-muted: #a3abb8; --text-faint: #737c8a;
  --border: #2b313c; --border-strong: #3d4552;
  --accent: #8ea6ff; --accent-hover: #b0c0ff; --accent-soft: #1f2843; --accent-contrast: #0e1116;
  --focus: #8ea6ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
  --info: #6cb6f5; --info-bg: #13263a; --pitfall: #f59a62; --pitfall-bg: #34200f;
  --try: #4fd1a5; --try-bg: #0f2d24; --book: #cf9cf0; --book-bg: #2a1c35;
  --success: #4fd1a5; --success-bg: #0f2d24; --danger: #ff7b72; --danger-bg: #3a1716;
  --warning: #e3b341; --warning-bg: #332708;
  --stage-0: #9aa1ad; --stage-1: #56b4e9; --stage-2: #2fcf9e; --stage-3: #ff8a3d;
  --stage-1-bg: #10283a; --stage-2-bg: #0f2d24; --stage-3-bg: #35200f; --stage-0-bg: #1f232b;
  --cat-0: #56b4e9; --cat-1: #e69f00; --cat-2: #2fcf9e; --cat-3: #e39ac6;
  --cat-4: #9ad3f5; --cat-5: #ff8a3d; --cat-6: #d9b45a; --cat-7: #9aa1ad;
  --div-4: #2a2f38; --div-3: #2f4b63; --div-5: #5b3a32;
  --tok-0: #1e3a5f; --tok-1: #4a3b0c; --tok-2: #14432c; --tok-3: #4f1d3a;
  --tok-4: #2c2f66; --tok-5: #4f2f12; --tok-6: #134552; --tok-7: #3b2459;
  --tok-text: #eef0f3;
  --code-bg: #161a21; --code-text: #d7dce4; --code-border: #2b313c;
  --code-line-hl: rgba(142, 166, 255, .14); --code-line-hl-bar: #8ea6ff;
  --syn-keyword: #d19df5; --syn-string: #8fd18f; --syn-number: #f5b26b; --syn-comment: #7f8896;
  --syn-func: #82b4ff; --syn-builtin: #5fd4e6; --syn-meta: #ff9e7a;
}

/* 2. RESET & BASE ========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 1rem); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video, canvas { max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }
kbd {
  font-family: var(--font-mono); font-size: .8em; padding: .1em .4em; border-radius: 4px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--bg-elev);
}
.skip-link {
  position: absolute; left: -999px; top: .5rem; z-index: 1000; background: var(--accent);
  color: var(--accent-contrast); padding: .5rem .9rem; border-radius: var(--radius-sm);
}
.skip-link:focus { left: .5rem; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 3. APP CHROME ============================================================ */
.topnav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav .brand {
  display: inline-flex; align-items: center; gap: .55rem; text-decoration: none;
  color: var(--text); font-weight: 700; letter-spacing: -.01em; white-space: nowrap;
}
.brand-mark {
  display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 8px;
  background: linear-gradient(135deg, var(--stage-1), var(--stage-2) 55%, var(--stage-3));
  color: #fff; font-size: .78rem; font-weight: 800; letter-spacing: -.02em;
}
.topnav .crumb {
  color: var(--text-muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-width: 0;
}
.topnav .spacer { flex: 1; }
.topnav .nav-links { display: flex; align-items: center; gap: .25rem; }
.topnav .nav-links a, .icon-btn {
  display: inline-flex; align-items: center; gap: .35rem; height: 2.25rem; padding: 0 .7rem;
  border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none;
  font-size: var(--fs-sm); font-weight: 550; border: 1px solid transparent; background: none; cursor: pointer;
}
.topnav .nav-links a:hover, .icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.topnav .nav-links a[aria-current="page"] { color: var(--text); background: var(--bg-hover); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.menu-btn { display: none; }
.progress-bar-top {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 60;
  background: linear-gradient(90deg, var(--stage-1), var(--stage-2), var(--stage-3));
  transition: width .1s linear;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0;
  max-width: 88rem;
  margin: 0 auto;
}
.layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--nav-h); align-self: start;
  height: calc(100vh - var(--nav-h)); overflow-y: auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-6) var(--sp-5);
  border-right: 1px solid var(--border);
  font-size: var(--fs-sm);
  scrollbar-width: thin;
}
.sidebar h2 {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); margin: var(--sp-5) 0 var(--sp-2); font-weight: 700;
}
.sidebar h2:first-child { margin-top: 0; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: flex; align-items: flex-start; gap: .5rem; padding: .38rem .55rem; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; line-height: 1.35; border-left: 2px solid transparent;
}
.toc a:hover { background: var(--bg-hover); color: var(--text); }
.toc a.active { color: var(--text); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.toc .check {
  flex: none; width: 1rem; height: 1rem; margin-top: .1rem; border-radius: 50%;
  border: 1.5px solid var(--border-strong); display: inline-grid; place-items: center; font-size: .62rem; color: transparent;
}
.toc a.done .check { background: var(--success); border-color: var(--success); color: #fff; }
.sidebar .chapter-progress { margin-top: var(--sp-2); }
.meter {
  height: 6px; border-radius: var(--radius-pill); background: var(--bg-sunken); overflow: hidden;
  border: 1px solid var(--border);
}
.meter > span { display: block; height: 100%; background: var(--success); border-radius: inherit; transition: width .4s ease; }
.sidebar .meter-label { display: flex; justify-content: space-between; color: var(--text-muted); font-size: var(--fs-xs); margin-top: .35rem; }
.sidebar .chapter-list a { padding: .3rem .55rem; }
.sidebar .chapter-list a .num {
  flex: none; min-width: 2.1rem; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); padding-top: .1rem;
}
.sidebar .chapter-list a.soon { opacity: .55; }
.sidebar-backdrop { display: none; }

.content {
  min-width: 0;
  padding: var(--sp-6) clamp(1rem, 4vw, 3.5rem) var(--sp-8);
}
:where(.content) > * { max-width: var(--wide); margin-left: auto; margin-right: auto; }

.site-footer {
  border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-sm);
  padding: var(--sp-6) var(--sp-4); text-align: center;
}
.site-footer p { margin: .3rem auto; max-width: 48rem; }

/* 4. CHAPTER HEADER & ROADMAP ============================================== */
.chapter-header { margin-bottom: var(--sp-6); }
.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 var(--sp-2);
}
.eyebrow .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--stage-color, var(--accent)); }
.chapter-header h1 {
  font-size: var(--fs-3xl); line-height: 1.08; letter-spacing: -.025em; margin: 0 0 var(--sp-3); font-weight: 780;
}
.chapter-header .lede {
  font-family: var(--font-prose); font-size: var(--fs-md); color: var(--text-muted); max-width: var(--measure);
  line-height: 1.6; margin: 0 0 var(--sp-5);
}
.chapter-meta {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--sp-4);
  margin-top: var(--sp-5);
}
.meta-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-sm);
}
.meta-card h2 {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint);
  margin: 0 0 var(--sp-2); font-weight: 700;
}
.meta-card ul { margin: 0; padding-left: 1.1rem; }
.meta-card li { margin: .25rem 0; line-height: 1.45; }
.meta-links { display: flex; flex-direction: column; gap: .5rem; }
.meta-links .row { display: grid; grid-template-columns: 1.4rem minmax(0, 1fr); align-items: start; gap: .4rem; font-size: var(--fs-sm); color: var(--text-muted); }
.meta-links .row > .row-body { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.meta-links code { font-size: .78rem; }

.roadmap { margin: var(--sp-4) 0 var(--sp-2); }
.roadmap-stages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.rm-stage {
  position: relative; border-radius: var(--radius); padding: .6rem .7rem .7rem;
  background: var(--bg-elev); border: 1px solid var(--border);
  transition: border-color .2s, box-shadow .2s, opacity .2s;
}
.rm-stage[data-stage="1"] { --sc: var(--stage-1); --sbg: var(--stage-1-bg); }
.rm-stage[data-stage="2"] { --sc: var(--stage-2); --sbg: var(--stage-2-bg); }
.rm-stage[data-stage="3"] { --sc: var(--stage-3); --sbg: var(--stage-3-bg); }
.rm-stage::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: var(--radius) 0 0 var(--radius); background: var(--sc);
}
.rm-stage.current { background: var(--sbg); border-color: var(--sc); box-shadow: 0 0 0 1px var(--sc) inset; }
.rm-stage-head { display: flex; flex-direction: column; gap: .05rem; margin-bottom: .45rem; }
.rm-stage-title { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--sc); }
.rm-stage-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.rm-steps { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; margin: 0; padding: 0; }
.rm-step {
  display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .5rem .22rem .3rem;
  border-radius: var(--radius-pill); font-size: .74rem; line-height: 1.2; font-weight: 550;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); text-decoration: none;
  cursor: pointer; transition: transform .12s, background .15s, color .15s, border-color .15s;
}
button.rm-step { font: inherit; font-size: .74rem; font-weight: 550; }
.rm-step .n {
  display: inline-grid; place-items: center; width: 1.15rem; height: 1.15rem; border-radius: 50%;
  font-size: .66rem; font-weight: 800; background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--border);
}
.rm-step:hover { border-color: var(--sc); color: var(--text); transform: translateY(-1px); }
.rm-step.current { background: var(--sc); color: #fff; border-color: var(--sc); }
.rm-step.current .n { background: rgba(255,255,255,.25); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .rm-step.current, :root[data-theme="dark"] .rm-step.current .n { color: #0e1116; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rm-step.current, :root:not([data-theme="light"]) .rm-step.current .n { color: #0e1116; } }
.rm-step.selected { outline: 2px solid var(--sc); outline-offset: 1px; }
.rm-step.done .n { background: var(--success); color: #fff; border-color: var(--success); }
.rm-extras { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; align-items: center; font-size: var(--fs-xs); color: var(--text-muted); }
.rm-extras .label { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-right: .15rem; }
.rm-extra {
  display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: var(--radius-pill);
  border: 1px dashed var(--border-strong); color: var(--text-muted); text-decoration: none; font-weight: 550; background: transparent;
}
.rm-extra:hover { color: var(--text); border-style: solid; }
.rm-extra.current { border: 1px solid var(--text); color: var(--text); background: var(--bg-elev); font-weight: 700; }
.rm-detail {
  margin-top: .6rem; padding: var(--sp-4); border-radius: var(--radius); background: var(--bg-elev);
  border: 1px solid var(--border); border-left: 4px solid var(--sc, var(--accent)); font-size: var(--fs-sm);
}
.rm-detail h3 { margin: 0 0 .3rem; font-size: var(--fs-md); }
.rm-detail p { margin: .3rem 0; color: var(--text-muted); }
.rm-detail .builds { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0; }

/* 5. PROSE ================================================================= */
:where(.content) section { padding-top: var(--sp-3); margin-bottom: var(--sp-7); }
:where(.content) h2 {
  font-size: var(--fs-xl); line-height: var(--lh-tight); letter-spacing: -.015em; margin: var(--sp-6) 0 var(--sp-4);
  font-weight: 750; max-width: var(--measure);
}
:where(.content) section > h2:first-child { margin-top: 0; }
:where(.content) h2 .sec-num { color: var(--text-faint); font-weight: 650; margin-right: .35rem; font-variant-numeric: tabular-nums; }
:where(.content) h3 { font-size: var(--fs-lg); line-height: 1.3; margin: var(--sp-6) 0 var(--sp-3); font-weight: 700; letter-spacing: -.01em; max-width: var(--measure); }
:where(.content) h4 { font-size: var(--fs-md); margin: var(--sp-5) 0 var(--sp-2); font-weight: 700; max-width: var(--measure); }
.prose, :where(.content) section > p, :where(.content) section > ul, :where(.content) section > ol, :where(.content) section > blockquote,
:where(.content) .prose-block {
  font-family: var(--font-prose); font-size: var(--fs-base); line-height: var(--lh-prose); max-width: var(--measure);
}
:where(.content) p { margin: 0 0 1.05em; }
:where(.content) ul, :where(.content) ol { padding-left: 1.4rem; margin: 0 0 1.1em; }
:where(.content) li { margin: .3em 0; }
:where(.content) li::marker { color: var(--text-faint); }
:where(.content) blockquote {
  margin: var(--sp-4) 0; padding: .2rem 0 .2rem var(--sp-4); border-left: 3px solid var(--border-strong); color: var(--text-muted);
}
:where(.content) strong { font-weight: 700; }
dfn, .term {
  font-style: normal; border-bottom: 1.5px dotted var(--accent); cursor: help; text-decoration: none;
}
dfn:focus-visible { outline-offset: 1px; }
.section-tag {
  display: inline-flex; align-items: center; gap: .35rem; font-size: var(--fs-xs); font-weight: 650;
  color: var(--book); background: var(--book-bg); border-radius: var(--radius-pill); padding: .15rem .6rem;
  text-decoration: none; font-family: var(--font-ui); vertical-align: middle;
}
.step-label {
  display: inline-block; font-family: var(--font-ui); font-size: var(--fs-xs); font-weight: 750; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint); margin: var(--sp-5) 0 var(--sp-2);
}
.step-label.intuition { color: var(--stage-1); }
.step-label.play { color: var(--stage-2); }
.step-label.hood { color: var(--stage-3); }
.step-label.check { color: var(--book); }

figure { margin: var(--sp-5) 0; }
figure.diagram {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--sp-4); box-shadow: var(--shadow-sm);
}
figure.diagram svg { display: block; width: 100%; height: auto; }
figcaption { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-3); line-height: 1.5; }
figcaption b { color: var(--text); }

.table-wrap { overflow-x: auto; margin: var(--sp-4) 0 var(--sp-5); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: .55rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data thead th {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  background: var(--bg-sunken); font-weight: 700; white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--bg-hover); }
table.data td.num, table.data th.num { text-align: right; }
table.data caption { caption-side: bottom; padding: .6rem .8rem; font-size: var(--fs-xs); color: var(--text-muted); text-align: left; }

code, pre { font-family: var(--font-mono); }
:not(pre) > code {
  font-size: .86em; padding: .12em .38em; border-radius: 5px; background: var(--code-bg);
  border: 1px solid var(--code-border); color: var(--code-text); overflow-wrap: anywhere;
}
pre {
  margin: var(--sp-4) 0 var(--sp-5); padding: var(--sp-4); overflow-x: auto; border-radius: var(--radius);
  background: var(--code-bg); border: 1px solid var(--code-border); color: var(--code-text);
  font-size: .86rem; line-height: 1.6; tab-size: 4;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }
/* highlight.js tokens mapped to our theme variables (no external theme CSS needed) */
.hljs { color: var(--code-text); background: transparent; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: var(--syn-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute { color: var(--syn-string); }
.hljs-number, .hljs-symbol, .hljs-bullet { color: var(--syn-number); }
.hljs-comment, .hljs-quote { color: var(--syn-comment); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-section { color: var(--syn-func); }
.hljs-built_in, .hljs-title.class_ { color: var(--syn-builtin); }
.hljs-meta, .hljs-decorator, .hljs-params .hljs-meta { color: var(--syn-meta); }
.hljs-deletion { color: var(--danger); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }

.katex { font-size: 1.07em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .4rem 0; margin: var(--sp-4) 0; }
.math-block { max-width: var(--measure); }

/* 6. CALLOUTS ============================================================== */
.callout {
  --c: var(--info); --cbg: var(--info-bg);
  position: relative; margin: var(--sp-5) 0; padding: var(--sp-4) var(--sp-5) var(--sp-4) calc(var(--sp-5) + 1.6rem);
  border-radius: var(--radius); background: var(--cbg); border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  font-family: var(--font-ui); font-size: .97rem; line-height: 1.6; max-width: var(--measure); color: var(--text);
}
.callout::before {
  content: "ℹ️"; position: absolute; left: var(--sp-4); top: calc(var(--sp-4) + .05rem); font-size: 1.05rem; line-height: 1.5;
}
.callout > .callout-title, .callout > strong:first-child {
  display: block; font-weight: 750; color: var(--c); margin-bottom: .25rem; font-size: var(--fs-sm); letter-spacing: .01em;
}
.callout p { margin: .35em 0; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout ul, .callout ol { margin: .35em 0; padding-left: 1.2rem; }
.callout.info { --c: var(--info); --cbg: var(--info-bg); }
.callout.pitfall { --c: var(--pitfall); --cbg: var(--pitfall-bg); }
.callout.pitfall::before { content: "⚠️"; }
.callout.try { --c: var(--try); --cbg: var(--try-bg); }
.callout.try::before { content: "🧪"; }
.callout.book { --c: var(--book); --cbg: var(--book-bg); }
.callout.book::before { content: "📖"; }
.callout.success { --c: var(--success); --cbg: var(--success-bg); }
.callout.success::before { content: "✅"; }
.callout.key { --c: var(--accent); --cbg: var(--accent-soft); }
.callout.key::before { content: "🔑"; }
.pitfalls-list { list-style: none; padding: 0; margin: 0; }
.pitfalls-list > li { padding: .6rem 0; border-top: 1px dashed color-mix(in srgb, var(--pitfall) 35%, transparent); }
.pitfalls-list > li:first-child { border-top: 0; padding-top: .2rem; }
.pitfalls-list .wrong { color: var(--pitfall); font-weight: 650; }
.pitfalls-list .right { color: var(--success); font-weight: 650; }

/* 7. WIDGET CARDS & CONTROLS =============================================== */
.widget-card {
  margin: var(--sp-5) 0 var(--sp-6); background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden;
}
.widget-card > header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); background: var(--bg-sunken);
}
.widget-card > header h3, .widget-card > header .widget-title {
  margin: 0; font-size: var(--fs-md); font-weight: 720; letter-spacing: -.005em; display: flex; align-items: center; gap: .5rem;
}
.widget-card > header .widget-kind {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--stage-2);
  background: var(--stage-2-bg); border-radius: var(--radius-pill); padding: .15rem .55rem;
}
.widget-card > .widget-body, .widget-card > [data-widget] { padding: var(--sp-5); }
.widget-card > .callout { margin: 0; border-radius: 0; border: 0; border-top: 1px solid var(--border); max-width: none; }
.widget-error {
  padding: var(--sp-4); border-radius: var(--radius); background: var(--danger-bg); color: var(--danger);
  font-size: var(--fs-sm); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.widget-loading { color: var(--text-faint); font-size: var(--fs-sm); padding: var(--sp-4); }
.w-row { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); align-items: center; }
.w-row.spread { justify-content: space-between; }
.w-stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.w-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.w-panel {
  border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); background: var(--bg);
}
.w-panel > h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.w-note { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }
.w-readout {
  display: inline-flex; align-items: baseline; gap: .4rem; padding: .35rem .7rem; border-radius: var(--radius-sm);
  background: var(--bg-sunken); border: 1px solid var(--border); font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
}
.w-readout b { font-family: var(--font-mono); font-size: 1rem; color: var(--text); }
/* Multi-line readout: <div class="w-readout block">line 1<br>line 2</div> (or .w-readout-block).
   A block box, so <br> and wrapped text flow as lines instead of inline-flex columns. */
.w-readout.block, .w-readout-block {
  display: block; max-width: 100%; line-height: 1.7; overflow-wrap: anywhere;
}
.w-readout-block { padding: .35rem .7rem; border-radius: var(--radius-sm); background: var(--bg-sunken);
  border: 1px solid var(--border); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.w-readout-block b { font-family: var(--font-mono); font-size: 1rem; color: var(--text); }
.w-readout.block:empty, .w-readout-block:empty { display: none; }
.w-big { font-size: var(--fs-xl); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.live-region { min-height: 1.5em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.35rem; padding: .45rem .95rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
  font-size: var(--fs-sm); font-weight: 620; cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 1.9rem; padding: .25rem .65rem; font-size: var(--fs-xs); }
.btn.large { min-height: 2.9rem; padding: .7rem 1.3rem; font-size: var(--fs-base); border-radius: var(--radius); }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-elev); }
.seg button { border: 0; background: none; padding: .4rem .8rem; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; color: var(--text-muted); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }

.control { display: inline-flex; flex-direction: column; gap: .3rem; min-width: 12rem; font-size: var(--fs-sm); }
.control-label { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; color: var(--text-muted); font-weight: 600; }
.control-value { font-family: var(--font-mono); color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.control-help { font-size: var(--fs-xs); color: var(--text-faint); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 1.4rem; background: transparent; cursor: pointer; margin: 0;
  --pct: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--pct), var(--bg-sunken) var(--pct)); border: 1px solid var(--border);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--bg-sunken); border: 1px solid var(--border); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 1.15rem; height: 1.15rem; border-radius: 50%; margin-top: -6.5px;
  background: var(--bg-elev); border: 2px solid var(--accent); box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 1rem; height: 1rem; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--accent);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 35%, transparent); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 35%, transparent); }

.toggle { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track {
  position: relative; width: 2.4rem; height: 1.35rem; border-radius: 999px; background: var(--border-strong); transition: background .2s; flex: none;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.35rem - 4px); height: calc(1.35rem - 4px);
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(1.05rem); }
.toggle input:focus-visible + .track { outline: 2.5px solid var(--focus); outline-offset: 2px; }

select, .select, input[type="text"], input[type="number"], input[type="search"], textarea, .input {
  min-height: 2.35rem; padding: .4rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text); font-size: var(--fs-sm); max-width: 100%;
}
select { padding-right: 2rem; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 5rem; resize: vertical; font-family: var(--font-mono); }

/* 8. CORE COMPONENTS ======================================================= */
/* Tooltip shared by charts & glossary */
.ll-tooltip {
  position: fixed; z-index: 200; pointer-events: none; max-width: 22rem;
  background: var(--text); color: var(--bg); padding: .45rem .65rem; border-radius: var(--radius-sm);
  font-size: var(--fs-xs); line-height: 1.45; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .12s;
  font-family: var(--font-ui);
}
.ll-tooltip.show { opacity: 1; }
.ll-tooltip b { font-weight: 700; }
.ll-tooltip code { background: transparent; border: 0; color: inherit; }
.gloss-tip {
  position: absolute; z-index: 120; width: min(22rem, calc(100vw - 2rem)); padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-family: var(--font-ui); font-size: var(--fs-sm); line-height: 1.5;
}
.gloss-tip .t { font-weight: 750; display: block; margin-bottom: .2rem; }
.gloss-tip .src { display: block; margin-top: .4rem; font-size: var(--fs-xs); color: var(--text-faint); }

/* MatrixView */
.mv { display: inline-block; max-width: 100%; overflow-x: auto; vertical-align: top; }
.mv-caption { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); margin-bottom: .35rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.mv table { border-collapse: separate; border-spacing: 2px; font-family: var(--font-mono); font-size: .8rem; font-variant-numeric: tabular-nums; }
.mv th { font-weight: 600; color: var(--text-muted); font-size: .72rem; padding: 0 .35rem; white-space: nowrap; }
.mv th.row { text-align: right; }
.mv td {
  min-width: 3.1rem; height: 1.9rem; text-align: center; padding: 0 .3rem; border-radius: 4px;
  background: var(--bg-sunken); border: 1px solid var(--border); transition: background .15s, outline-color .15s;
}
.mv td.hl, .mv td.hl-row, .mv td.hl-col { outline: 2px solid var(--accent); outline-offset: -2px; }
.mv td.hl-row, .mv td.hl-col { outline-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.mv td.dim { opacity: .35; }
.mv td.hover { outline: 2px solid var(--text); outline-offset: -2px; }
.mv tr:hover th.row, .mv th.col.hover { color: var(--text); }
.mv input {
  width: 3.6rem; border: 0; background: transparent; text-align: center; font: inherit; color: inherit; padding: .25rem 0; min-height: 0;
}
.mv input:focus { outline: none; }
.mv td:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--bg-elev); }
.mv-bracket { display: flex; align-items: stretch; gap: 2px; }

/* Heatmap */
.hm { position: relative; max-width: 100%; }
.hm-title { font-size: var(--fs-sm); font-weight: 700; margin-bottom: .35rem; }
.hm-wrap { display: flex; align-items: flex-start; gap: var(--sp-3); max-width: 100%; overflow-x: auto; }
.hm svg { display: block; overflow: visible; flex: none; }
.hm svg:focus { outline: none; }
.hm svg:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.hm .lbl { font-family: var(--font-mono); font-size: 11px; fill: var(--text-muted); }
.hm .lbl.active { fill: var(--text); font-weight: 700; }
.hm .val { font-family: var(--font-mono); font-size: 10px; pointer-events: none; font-variant-numeric: tabular-nums; }
.hm .cell { stroke: var(--bg-elev); stroke-width: 1; transition: opacity .15s; }
.hm .cell.masked { fill: url(#hm-hatch); }
.hm .focus-ring { fill: none; stroke: var(--text); stroke-width: 2; pointer-events: none; }
.hm-colorbar { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.hm-colorbar .bar { width: 12px; border-radius: 3px; border: 1px solid var(--border); }
.hm-colorbar.horizontal { flex-direction: row; align-items: center; }
.hm-colorbar.horizontal .bar { height: 10px; width: 140px; }
.hm-readout { font-size: var(--fs-xs); color: var(--text-muted); margin-top: .35rem; min-height: 1.3em; font-family: var(--font-mono); }

/* Charts (BarChart / LineChart) */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis line, .chart .axis path { stroke: var(--border-strong); }
.chart .grid line { stroke: var(--border); stroke-dasharray: 2 3; }
.chart .tick { font-family: var(--font-ui); font-size: 11px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart .axis-label { font-family: var(--font-ui); font-size: 11.5px; fill: var(--text-muted); font-weight: 600; }
.chart .bar { transition: height .35s ease, y .35s ease, width .35s ease, fill .2s, opacity .2s; cursor: default; }
.chart .bar.clickable { cursor: pointer; }
.chart .bar:hover, .chart .bar.hover { opacity: .82; }
.chart .bar-label { font-family: var(--font-mono); font-size: 10.5px; fill: var(--text); font-variant-numeric: tabular-nums; }
.chart .cat-label { font-family: var(--font-ui); font-size: 11.5px; fill: var(--text); }
.chart .cat-label.mono { font-family: var(--font-mono); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .12; }
.chart .crosshair { stroke: var(--text-faint); stroke-dasharray: 3 3; }
.chart .annot line { stroke: var(--text-faint); stroke-dasharray: 4 3; }
.chart .annot text { font-family: var(--font-ui); font-size: 11px; fill: var(--text-muted); }
.chart .dot { stroke: var(--bg-elev); stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: var(--fs-xs); color: var(--text-muted); margin-top: .4rem; }
.chart-legend .sw { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.chart-legend .sw.dashed { height: 0; border-top: 2px dashed currentColor; border-radius: 0; vertical-align: 3px; }

/* Stepper */
.stepper { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.stepper-bar { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; border-bottom: 1px solid var(--border); background: var(--bg-sunken); flex-wrap: wrap; }
.stepper-dots { display: flex; gap: 4px; flex: 1; min-width: 6rem; }
.stepper-dots button {
  flex: 1; height: 6px; min-width: 6px; border-radius: 999px; border: 0; background: var(--border-strong); cursor: pointer; padding: 0;
}
.stepper-dots button.done { background: color-mix(in srgb, var(--accent) 50%, var(--border-strong)); }
.stepper-dots button.current { background: var(--accent); }
.stepper-count { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stepper-body { padding: var(--sp-3) var(--sp-4); }
.stepper-title { font-weight: 720; margin: 0 0 .25rem; font-size: var(--fs-base); }
.stepper-desc { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.55; }
.stepper-desc p { margin: .3em 0; }

/* TokenStrip */
.tokens { display: flex; flex-wrap: wrap; gap: 4px 3px; align-items: flex-end; line-height: 1; }
.tok {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: .28rem .4rem .22rem; border-radius: 6px; background: var(--tok-0); color: var(--tok-text);
  font-family: var(--font-mono); font-size: .86rem; white-space: pre; border: 1px solid transparent;
  transition: transform .12s, box-shadow .12s, opacity .2s, background .2s; cursor: default;
}
.tok .id { font-size: .64rem; opacity: .7; font-variant-numeric: tabular-nums; }
.tok .ws { opacity: .45; }
.tok[data-c="1"] { background: var(--tok-1); } .tok[data-c="2"] { background: var(--tok-2); }
.tok[data-c="3"] { background: var(--tok-3); } .tok[data-c="4"] { background: var(--tok-4); }
.tok[data-c="5"] { background: var(--tok-5); } .tok[data-c="6"] { background: var(--tok-6); }
.tok[data-c="7"] { background: var(--tok-7); }
.tok.plain { background: var(--bg-sunken); border-color: var(--border); }
.tok.hl { box-shadow: 0 0 0 2px var(--accent); transform: translateY(-2px); }
.tok.dim { opacity: .3; }
.tok.mask { background: repeating-linear-gradient(135deg, var(--bg-sunken), var(--bg-sunken) 4px, var(--border) 4px, var(--border) 8px); color: var(--text-muted); border: 1px dashed var(--border-strong); }
.tok.special { border: 1px dashed var(--text-muted); }
.tok.selectable { cursor: pointer; }
.tok.selected { box-shadow: 0 0 0 2px var(--text); }
.tok.target { box-shadow: 0 0 0 2px var(--stage-3); }
.tok.new { animation: tok-pop .4s ease; }
@keyframes tok-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* ShapeBadge */
.shape-badge {
  display: inline-flex; align-items: stretch; border-radius: 6px; overflow: hidden; vertical-align: middle;
  font-family: var(--font-mono); font-size: .78rem; border: 1px solid var(--border-strong); background: var(--bg-elev);
  line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.shape-badge .sb-label { padding: .28rem .45rem; background: var(--bg-sunken); color: var(--text-muted); border-right: 1px solid var(--border-strong); font-family: var(--font-ui); font-weight: 650; font-size: .72rem; display: inline-flex; align-items: center; }
.shape-badge .sb-dims { display: inline-flex; align-items: center; padding: .14rem .35rem; gap: 1px; }
.shape-badge .sb-dim { display: inline-flex; flex-direction: column; align-items: center; padding: .1rem .22rem; border-radius: 4px; }
.shape-badge .sb-dim b { font-weight: 700; color: var(--text); }
.shape-badge .sb-dim small { font-size: .58rem; color: var(--text-faint); margin-top: 2px; font-family: var(--font-ui); }
.shape-badge .sb-dim:nth-child(4n+1) b { color: var(--cat-0); }
.shape-badge .sb-dim:nth-child(4n+2) b { color: var(--cat-5); }
.shape-badge .sb-dim:nth-child(4n+3) b { color: var(--cat-2); }
.shape-badge .sb-dim:nth-child(4n+4) b { color: var(--cat-3); }
.shape-badge .sb-br { color: var(--text-faint); padding: 0 .05rem; align-self: center; }
.shape-badge .sb-sep { color: var(--text-faint); align-self: center; }
.shape-badge.changed { animation: sb-flash .6s ease; }
@keyframes sb-flash { 0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 50%, transparent); } 100% { box-shadow: none; } }

/* CodePanel */
.code-panel { border: 1px solid var(--code-border); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; margin: var(--sp-4) 0; }
.code-panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .5rem .35rem .85rem; border-bottom: 1px solid var(--code-border); font-size: var(--fs-xs); color: var(--text-muted); }
.code-panel-head .title { font-family: var(--font-mono); font-weight: 600; }
.code-panel pre { margin: 0; border: 0; border-radius: 0; padding: .6rem 0; background: transparent; }
.code-panel .ln { display: block; padding: 0 var(--sp-4) 0 0; border-left: 3px solid transparent; transition: background .2s, border-color .2s; min-height: 1.6em; }
.code-panel .ln::before {
  content: attr(data-n); display: inline-block; width: 2.6rem; padding-right: .9rem; text-align: right; color: var(--text-faint);
  user-select: none; -webkit-user-select: none; font-size: .78em;
}
.code-panel.no-numbers .ln::before { content: none; }
.code-panel.no-numbers .ln { padding-left: var(--sp-4); }
.code-panel .ln.hl { background: var(--code-line-hl); border-left-color: var(--code-line-hl-bar); }
.code-panel.has-hl .ln:not(.hl) { opacity: .62; }
.copy-btn { font-size: var(--fs-xs); }

/* 9. QUIZ & FLASHCARDS ===================================================== */
.quiz { display: flex; flex-direction: column; gap: var(--sp-4); }
.quiz-summary {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--border);
  position: sticky; top: calc(var(--nav-h) + .5rem); z-index: 5; box-shadow: var(--shadow-sm);
}
.quiz-summary .score { font-weight: 750; font-variant-numeric: tabular-nums; }
.quiz-summary .best { color: var(--text-muted); font-size: var(--fs-sm); }
.q-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-sm); transition: border-color .2s;
}
.q-card.correct { border-color: color-mix(in srgb, var(--success) 60%, var(--border)); }
.q-card.wrong { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.q-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; font-size: var(--fs-xs); color: var(--text-faint); font-weight: 650; flex-wrap: wrap; }
.q-head .q-num { color: var(--text-muted); }
.q-type { text-transform: uppercase; letter-spacing: .06em; padding: .1rem .45rem; border-radius: var(--radius-pill); background: var(--bg-sunken); border: 1px solid var(--border); }
.q-prompt { font-size: var(--fs-base); line-height: 1.55; margin-bottom: .75rem; }
.q-prompt p { margin: .3em 0; }
.q-options { display: flex; flex-direction: column; gap: .45rem; list-style: none; padding: 0; margin: 0 0 .8rem; }
.q-option {
  display: flex; align-items: flex-start; gap: .65rem; padding: .6rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); cursor: pointer; line-height: 1.45; transition: border-color .15s, background .15s;
}
.q-option:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.q-option input { margin-top: .25rem; accent-color: var(--accent); flex: none; }
.q-option.is-correct { border-color: var(--success); background: var(--success-bg); }
.q-option.is-wrong { border-color: var(--danger); background: var(--danger-bg); }
.q-option.missed { border-style: dashed; border-color: var(--success); }
.q-order { list-style: none; padding: 0; margin: 0 0 .8rem; display: flex; flex-direction: column; gap: .4rem; counter-reset: ord; }
.q-order li {
  display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem .45rem .7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); counter-increment: ord; cursor: grab;
}
.q-order li::before { content: counter(ord); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); width: 1.2rem; }
.q-order li .txt { flex: 1; line-height: 1.4; }
.q-order li.dragging { opacity: .5; }
.q-order li.is-correct { border-color: var(--success); background: var(--success-bg); }
.q-order li.is-wrong { border-color: var(--danger); background: var(--danger-bg); }
.q-order .mv-btns { display: flex; gap: .2rem; }
.q-order .mv-btns button { width: 1.9rem; height: 1.9rem; border-radius: 5px; border: 1px solid var(--border); background: var(--bg-elev); cursor: pointer; color: var(--text-muted); }
.q-order .mv-btns button:hover { color: var(--text); border-color: var(--border-strong); }
.q-input-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.q-input-row input { width: 14rem; font-family: var(--font-mono); }
.q-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.q-feedback { margin-top: .8rem; padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: var(--fs-sm); line-height: 1.55; }
.q-feedback.ok { background: var(--success-bg); }
.q-feedback.bad { background: var(--danger-bg); }
.q-feedback .verdict { font-weight: 750; display: block; margin-bottom: .2rem; }
.q-feedback.ok .verdict { color: var(--success); }
.q-feedback.bad .verdict { color: var(--danger); }
.q-card pre { margin: .5rem 0 .8rem; font-size: .82rem; }
.quiz.inline .q-card { box-shadow: none; background: var(--bg); border-style: dashed; }
.quiz.inline .quiz-summary { display: none; }

.fc { display: flex; flex-direction: column; gap: var(--sp-4); }
.fc-boxes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; }
.fc-box {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .4rem .3rem; text-align: center; background: var(--bg);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.fc-box b { display: block; font-size: var(--fs-lg); color: var(--text); font-variant-numeric: tabular-nums; }
.fc-box .stack { height: 4px; border-radius: 999px; background: var(--bg-sunken); margin-top: .3rem; overflow: hidden; }
.fc-box .stack span { display: block; height: 100%; background: var(--seq-4); }
.fc-box:nth-child(1) .stack span { background: var(--cat-5); }
.fc-box:nth-child(2) .stack span { background: var(--cat-1); }
.fc-box:nth-child(3) .stack span { background: var(--cat-4); }
.fc-box:nth-child(4) .stack span { background: var(--cat-0); }
.fc-box:nth-child(5) .stack span { background: var(--cat-2); }
.fc-stage { perspective: 1400px; }
.fc-card {
  position: relative; width: 100%; min-height: 15rem; cursor: pointer; border: 0; padding: 0; background: none; text-align: left;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3,.7,.3,1); display: block;
}
.fc-card.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elev); box-shadow: var(--shadow);
  padding: var(--sp-5) var(--sp-6); display: flex; flex-direction: column; justify-content: center; gap: .5rem;
  font-size: var(--fs-md); line-height: 1.55; overflow: auto;
}
.fc-face.back { transform: rotateY(180deg); background: var(--accent-soft); }
.fc-face .fc-meta { position: absolute; top: .7rem; left: 1rem; right: 1rem; display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-faint); font-weight: 650; }
.fc-face .fc-hint { position: absolute; bottom: .7rem; left: 0; right: 0; text-align: center; font-size: var(--fs-xs); color: var(--text-faint); }
.fc-face p { margin: .3em 0; }
.fc-controls { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.fc-done { text-align: center; padding: var(--sp-6) var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.fc-done .big { font-size: 2.2rem; }

/* 10. HOME, CARDS, DASHBOARD, GLOSSARY ===================================== */
.hero {
  position: relative; padding: var(--sp-7) 0 var(--sp-6); margin-bottom: var(--sp-5);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--sp-6); row-gap: 0; align-items: center; align-content: start;
}
.hero > :not(.hero-art) { grid-column: 1; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.04; letter-spacing: -.035em; margin: 0 0 var(--sp-4); font-weight: 800; max-width: 18ch; }
.hero h1 .grad {
  background: linear-gradient(90deg, var(--stage-1), var(--stage-2) 50%, var(--stage-3)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lede { font-family: var(--font-prose); font-size: clamp(1.05rem, 2vw, 1.25rem); line-height: 1.6; color: var(--text-muted); max-width: 40rem; margin: 0 0 var(--sp-5); }
.hero .cta { display: flex; gap: .6rem; flex-wrap: wrap; }
.hero-art { grid-column: 2; grid-row: 1 / span 4; width: 15rem; height: auto; opacity: .95; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: var(--sp-5) 0 var(--sp-4); }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }

.steps4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); counter-reset: s4; }
.step4 { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: var(--sp-4); box-shadow: var(--shadow-sm); position: relative; }
.step4 .ic { font-size: 1.5rem; }
.step4 h3 { margin: .4rem 0 .3rem; font-size: var(--fs-md); }
.step4 p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.5; }
.step4 .where { display: inline-block; margin-top: .6rem; font-size: var(--fs-xs); font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr)); gap: var(--sp-4); }
.ch-card {
  --sc: var(--stage-0); --sbg: var(--stage-0-bg);
  position: relative; display: flex; flex-direction: column; gap: .5rem; padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-5);
  border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--text); transition: transform .15s, box-shadow .15s, border-color .15s; overflow: hidden;
}
.ch-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sc); }
.ch-card[data-stage="1"] { --sc: var(--stage-1); --sbg: var(--stage-1-bg); }
.ch-card[data-stage="2"] { --sc: var(--stage-2); --sbg: var(--stage-2-bg); }
.ch-card[data-stage="3"] { --sc: var(--stage-3); --sbg: var(--stage-3-bg); }
a.ch-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--sc); color: var(--text); text-decoration: none; }
.ch-card .top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ch-card .num { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700; color: var(--sc); background: var(--sbg); padding: .15rem .5rem; border-radius: var(--radius-pill); }
.ch-card h3 { margin: 0; font-size: var(--fs-md); line-height: 1.3; }
.ch-card p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.5; flex: 1; }
.ch-card .foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: var(--fs-xs); color: var(--text-faint); }
.ch-card.soon { opacity: .72; box-shadow: none; background: transparent; border-style: dashed; }
.ch-card.soon::after { content: none; }
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .5rem; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge.soon { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge.done { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ring { --p: 0; width: 2.1rem; height: 2.1rem; border-radius: 50%; flex: none;
  background: conic-gradient(var(--success) calc(var(--p) * 1%), var(--bg-sunken) 0); display: grid; place-items: center; }
.ring::after { content: attr(data-label); width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--bg-elev); display: grid; place-items: center; font-size: .56rem; font-weight: 800; color: var(--text-muted); }

.dash { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.stat {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: var(--sp-4); box-shadow: var(--shadow-sm);
}
.stat .k { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.stat .v { font-size: var(--fs-2xl); font-weight: 780; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: .25rem 0; }
.stat .s { font-size: var(--fs-xs); color: var(--text-muted); }
.dash-table td .meter { min-width: 6rem; }

.glossary-tools { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-4); position: sticky; top: var(--nav-h); background: var(--bg); padding: .6rem 0; z-index: 4; }
.glossary-tools input[type="search"] { flex: 1; min-width: 14rem; font-size: var(--fs-base); min-height: 2.7rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  border: 1px solid var(--border-strong); background: var(--bg-elev); border-radius: var(--radius-pill); padding: .2rem .65rem;
  font-size: var(--fs-xs); font-weight: 650; cursor: pointer; color: var(--text-muted);
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.gloss-letter { font-size: var(--fs-lg); font-weight: 800; color: var(--text-faint); margin: var(--sp-5) 0 var(--sp-2); border-bottom: 1px solid var(--border); padding-bottom: .2rem; }
.gloss-list { margin: 0; }
.gloss-item { padding: var(--sp-3) 0; border-bottom: 1px dashed var(--border); scroll-margin-top: calc(var(--nav-h) + 4rem); }
.gloss-item:target { background: var(--accent-soft); border-radius: var(--radius-sm); padding-left: .6rem; }
.gloss-item dt { font-weight: 750; font-size: var(--fs-md); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.gloss-item dd { margin: .25rem 0 0; font-family: var(--font-prose); line-height: 1.6; max-width: var(--measure); color: var(--text); }
.gloss-item mark { background: color-mix(in srgb, var(--cat-1) 35%, transparent); color: inherit; border-radius: 2px; }

.cheatsheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--sp-3); }
.cheatsheet .cs {
  border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); background: var(--bg-elev); font-size: var(--fs-sm); line-height: 1.55;
}
.cheatsheet .cs h4 { margin: 0 0 .4rem; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.cheatsheet .cs ul { margin: 0; padding-left: 1.1rem; }

.complete-row { display: flex; justify-content: flex-end; margin-top: var(--sp-5); padding-top: var(--sp-3); border-top: 1px dashed var(--border); }
.complete-btn[aria-pressed="true"] { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-7); }
.prevnext a, .prevnext span {
  display: flex; flex-direction: column; gap: .2rem; padding: var(--sp-4); border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-elev); text-decoration: none; color: var(--text);
}
.prevnext a:hover { border-color: var(--accent); }
.prevnext .dir { font-size: var(--fs-xs); color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.prevnext .t { font-weight: 700; }
.prevnext .next { text-align: right; grid-column: 2; }
.prevnext .soon { opacity: .6; border-style: dashed; }

/* 11. DIAGRAMS ============================================================= */
.dg { font-family: var(--font-ui); }
.dg text { fill: var(--text); font-size: 13px; }
.dg .muted, .dg text.muted { fill: var(--text-muted); }
.dg .small { font-size: 11px; }
.dg .mono { font-family: var(--font-mono); }
.dg .bold { font-weight: 700; }
.dg-box { fill: var(--bg-elev); stroke: var(--border-strong); stroke-width: 1.25; }
.dg-box.accent { fill: var(--accent-soft); stroke: var(--accent); }
.dg-box.s1 { fill: var(--stage-1-bg); stroke: var(--stage-1); }
.dg-box.s2 { fill: var(--stage-2-bg); stroke: var(--stage-2); }
.dg-box.s3 { fill: var(--stage-3-bg); stroke: var(--stage-3); }
.dg-box.book { fill: var(--book-bg); stroke: var(--book); }
.dg-box.muted { fill: var(--bg-sunken); stroke: var(--border); }
.dg-box.dashed { stroke-dasharray: 5 4; }
.dg-arrow { stroke: var(--text-muted); stroke-width: 1.6; fill: none; }
.dg-arrow.accent { stroke: var(--accent); }
.dg-arrow.dashed { stroke-dasharray: 5 4; }
.dg-arrowhead { fill: var(--text-muted); }
.dg-arrowhead.accent { fill: var(--accent); }
.dg .c1 { fill: var(--stage-1); } .dg .c2 { fill: var(--stage-2); } .dg .c3 { fill: var(--stage-3); } .dg .cb { fill: var(--book); } .dg .ca { fill: var(--accent); }

/* 12. RESPONSIVE, UTILITIES, PRINT ========================================= */
@media (max-width: 1100px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-art { display: none; }
}
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--nav-h); left: 0; bottom: 0; height: auto; width: min(20rem, 86vw); z-index: 45;
    background: var(--bg-elev); transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: var(--nav-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 44; }
  .chapter-meta { grid-template-columns: minmax(0, 1fr); }
  .steps4, .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  :root { --fs-base: 1.03rem; }
  .roadmap-stages { grid-template-columns: minmax(0, 1fr); }
  .w-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .topnav .crumb { display: none; }
  .topnav .nav-links .label { display: none; }
  .widget-card > .widget-body, .widget-card > [data-widget] { padding: var(--sp-4) var(--sp-3); }
  .widget-card > header { padding: var(--sp-3); }
  .callout { padding: var(--sp-3) var(--sp-4) var(--sp-3) calc(var(--sp-4) + 1.5rem); }
  .callout::before { left: .75rem; top: calc(var(--sp-3) + .05rem); }
  .q-card { padding: var(--sp-3) var(--sp-4); }
  .fc-face { padding: var(--sp-5) var(--sp-4); font-size: var(--fs-base); }
  .control { min-width: 0; width: 100%; }
  .prevnext { grid-template-columns: 1fr; }
  .prevnext .next { grid-column: 1; }
}
@media (max-width: 480px) {
  .steps4, .dash { grid-template-columns: minmax(0, 1fr); }
  .content { padding-left: 1rem; padding-right: 1rem; }
  .fc-boxes { gap: .25rem; }
  .q-input-row input { width: 100%; }
}

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt-4 { margin-top: var(--sp-4) !important; } .mb-4 { margin-bottom: var(--sp-4) !important; }
.hidden, [hidden] { display: none !important; }
.c-s1 { color: var(--stage-1); } .c-s2 { color: var(--stage-2); } .c-s3 { color: var(--stage-3); }
.c-success { color: var(--success); } .c-danger { color: var(--danger); } .c-accent { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .topnav, .sidebar, .complete-row, .prevnext, .widget-card, .progress-bar-top, .site-footer { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
}
