/* =====================================================================
   Claude Code Mastery · Signal design system
   A well-made CLI: graphite paper, one milestone ink, headings written as commands.
   Dark by default, light via <html data-theme="light">. Milestone ink from <body data-milestone>.
   Chrome only: page figures are styled by their own pages. The f-* classes below are an opt-in vocabulary.
   ===================================================================== */

/* ---------- Tokens · dark (default) ---------- */
:root {
  color-scheme: dark;
  /* surfaces: page → sunken → card → heads/fills */
  --bg: #0E100F;
  --bg-2: #111412;          /* sunken surfaces inside panels: inputs, stats, quiz options */
  --panel: #141715;         /* cards, widget bodies, quiz (Signal --bg-2) */
  --panel-2: #181C19;       /* heads, subtle fills */
  --panel-3: #1D221E;       /* inline code, stronger fills (Signal --bg-3) */
  --bg-3: var(--panel-3);
  --line: #242925;          /* hairlines */
  --line-2: #39413A;        /* stronger rules, borders */
  /* text */
  --ink: #E8EDE4;           /* headings, emphasis */
  --text: var(--ink);       /* v1 name: strong text */
  --text-2: #A9B1A7;        /* body (Signal --text) */
  --muted: #8D968C;         /* secondary text, ≥ 4.5:1 on every surface above and on the -soft tints */
  --faint: #4B534B;         /* decoration only: tree guides, glyphs. Never text. */
  --soft: 10%;              /* strength of the -soft tints: muted text, and each ink on its own tint, stay ≥ 4.5:1 */
  /* milestone inks */
  --core: #C6F24E;          /* lime */
  --agents: #5BE3C0;        /* mint */
  --delivery: #FFB84D;       /* amber */
  --autonomy: #FF7AD9;       /* pink */
  --accent: var(--core);
  --hl-ink: #0E100F;        /* text on an accent fill */
  /* semantic */
  --ok: #8BE07A;
  --warn: #E9CF5B;
  --bad: #FF6B5E;
  --info: #8DBBE0;
  --violet: #BBA6F2;
  /* code: dark in both themes */
  --code-bg: #090B0A;
  --code-text: #DCE4D7;
  --code-line: #1F2420;
  --code-muted: #828C80;    /* comments, labels: ≥ 5:1 on --code-bg in both themes */
  /* figure tokens (DESIGN-LEARNINGS §3.1) */
  --f-bg: #0A0C0B;
  --f-line: #414A43;
  --f-ink: #D9E0D4;
  --f-muted: #7E887C;
  --f-top: #1A1F1C;
  --f-left: #141815;
  --f-right: #101311;
  --f-detail: #2C342E;
  --f-sub: color-mix(in oklab, var(--f-ink) 60%, var(--f-muted));   /* small labels on tinted shapes: ≥ 4.5:1 on every node tint */
  /* shape and type */
  --r: 3px;
  --radius: 3px;
  --radius-sm: 3px;
  --shadow: 0 14px 34px -14px rgba(0, 0, 0, .7);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  /* layout: rail | article | notes */
  --rail-w: 250px;
  --col-w: 680px;
  --note-w: 220px;
  --gap: 56px;
  --pad: 40px;
  --topbar-h: 56px;
  --status-h: 30px;
  --wide: calc(var(--col-w) + var(--gap) + var(--note-w));
  --sidebar-w: var(--rail-w);   /* v1 names, kept for page styles */
  --content-w: var(--wide);
}

/* ---------- Tokens · light ---------- */
[data-theme="light"] {
  color-scheme: light;
  --bg: #F2F3ED;
  --bg-2: #F6F7F2;
  --panel: #FBFBF7;
  --panel-2: #EEF0E8;
  --panel-3: #E6E9DF;
  --line: #D9DCD1;
  --line-2: #BFC4B6;
  --ink: #111411;
  --text-2: #383F38;
  --muted: #5C635A;
  --faint: #A1A79C;
  /* spec inks, darkened a touch so ink text passes 4.5:1 on --panel-3 and on its own -soft tint */
  --core: #466C00;
  --agents: #006F5A;
  --delivery: #905300;
  --autonomy: #A9257F;
  --hl-ink: #FFFFFF;
  --ok: #356919;           /* a shade darker than v2 (#386E1B): ok text stays ≥ 4.5:1 on a doubled --ok-soft tint */
  --warn: #735E00;
  --bad: #AE301C;
  --info: #2B6690;
  --violet: #6A4BBF;
  --code-bg: #111411;
  --code-line: #262B27;
  --f-bg: #FBFBF7;
  --f-line: #959B8F;
  --f-ink: #1C211C;
  --f-muted: #646B62;
  --f-top: #FFFFFF;
  --f-left: #EBEDE4;
  --f-right: #DDE0D5;
  --f-detail: #CBD0C2;
  --shadow: 0 14px 30px -16px rgba(28, 36, 20, .3);
}

/* Milestone ink, and every token derived from it (custom properties resolve where they are declared, so derive on body). */
body[data-milestone="core"]    { --accent: var(--core); }
body[data-milestone="agents"]  { --accent: var(--agents); }
body[data-milestone="delivery"] { --accent: var(--delivery); }
body[data-milestone="autonomy"] { --accent: var(--autonomy); }
body {
  --code-acc: #C6F24E;      /* dark-theme ink of this milestone, used on code surfaces in both themes */
  --accent-soft: color-mix(in srgb, var(--accent) var(--soft), transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --ok-soft: color-mix(in srgb, var(--ok) var(--soft), transparent);
  --warn-soft: color-mix(in srgb, var(--warn) var(--soft), transparent);
  --bad-soft: color-mix(in srgb, var(--bad) var(--soft), transparent);
  --info-soft: color-mix(in srgb, var(--info) var(--soft), transparent);
  --violet-soft: color-mix(in srgb, var(--violet) var(--soft), transparent);
  /* figures: one ink plus one highlight */
  --f-grid: color-mix(in srgb, var(--accent) 7%, transparent);
  --f-acc: var(--accent);
  --f-acc-ink: var(--accent);
  --f-acc-soft: color-mix(in oklab, var(--accent) 22%, var(--f-bg));
  --f-hot-top: color-mix(in oklab, var(--accent) 32%, var(--f-bg));
  --f-hot-left: color-mix(in oklab, var(--accent) 55%, var(--f-bg));
  --f-hot-right: color-mix(in oklab, var(--accent) 70%, var(--f-bg));
  /* code tokens: keys in the ink, strings in ok, comments ≥ 4.5:1 */
  --tok-kw: var(--code-acc);
  --tok-key: color-mix(in oklab, var(--code-acc) 82%, var(--code-text));
  --tok-str: color-mix(in oklab, #8BE07A 78%, var(--code-text));
  --tok-num: #E9CF5B;
  --tok-fn: #A9CDE8;
  --tok-com: var(--code-muted);
}
body[data-milestone="agents"]  { --code-acc: #5BE3C0; }
body[data-milestone="delivery"] { --code-acc: #FFB84D; }
body[data-milestone="autonomy"] { --code-acc: #FF7AD9; }
[data-theme="light"] body { --f-grid: rgba(17, 20, 17, .05); --f-acc-ink: color-mix(in oklab, var(--accent) 85%, #000); }

/* Code surfaces stay dark in both themes: inside them, every token takes its dark-theme value. */
[data-theme="light"] :is(pre, .out, .lab-term) {
  --bg: #0E100F; --bg-2: #111412; --panel: #141715; --panel-2: #181C19; --panel-3: #1D221E;
  --line: #242925; --line-2: #39413A; --ink: #E8EDE4; --text: #E8EDE4; --text-2: #A9B1A7; --muted: #8D968C; --faint: #4B534B;
  --accent: var(--code-acc); --hl-ink: #0E100F; --soft: 10%;
  --ok: #8BE07A; --warn: #E9CF5B; --bad: #FF6B5E; --info: #8DBBE0; --violet: #BBA6F2;
  --core: #C6F24E; --agents: #5BE3C0; --delivery: #FFB84D; --autonomy: #FF7AD9;
  --accent-soft: color-mix(in srgb, var(--code-acc) 10%, transparent); --accent-line: color-mix(in srgb, var(--code-acc) 45%, transparent);
  --ok-soft: color-mix(in srgb, #8BE07A 10%, transparent); --warn-soft: color-mix(in srgb, #E9CF5B 10%, transparent);
  --bad-soft: color-mix(in srgb, #FF6B5E 10%, transparent); --info-soft: color-mix(in srgb, #8DBBE0 10%, transparent);
  --violet-soft: color-mix(in srgb, #BBA6F2 10%, transparent);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 18px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
html.no-smooth { scroll-behavior: auto !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font: 16.5px/1.68 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.has-status { padding-bottom: var(--status-h); }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent-line); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

h1, h2, h3, h4, h5 { color: var(--ink); line-height: 1.25; margin: 1.6em 0 .55em; font-weight: 600; letter-spacing: -.01em; }
h1 { font: 600 44px/1.08 var(--mono); letter-spacing: -.035em; margin-top: 0; }
h2 { font: 500 17px/1.35 var(--mono); letter-spacing: 0; }
h3 { font-size: 1.28rem; }
h4 { font-size: 1.06rem; }
h5 { font: 500 12.5px/1.4 var(--mono); letter-spacing: .01em; color: var(--muted); }
p { margin: .7em 0; }
ul, ol { padding-left: 1.35em; }
li { margin: .25em 0; }
li::marker { color: var(--muted); }
strong, b { color: var(--ink); font-weight: 600; }
em { color: inherit; }
small, .small { font-size: .86em; color: var(--muted); }
code, kbd, samp { font-family: var(--mono); font-size: .86em; }
:not(pre) > code {
  background: var(--panel-3);
  color: var(--ink);
  padding: .08em .2em;            /* tight sides so commas and parentheses hug the chip */
  margin: 0;
  border-radius: var(--r);
  overflow-wrap: anywhere;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;    /* a chip that wraps keeps its padding on both lines */
}
.out :not(pre) > code { padding: .1em .38em; }   /* code surfaces keep their own chip spacing */
kbd {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2); border-bottom-width: 2px;
  padding: .04em .4em; border-radius: var(--r); white-space: nowrap;
}
mark { background: var(--warn-soft); color: inherit; padding: 0 .15em; border-radius: 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; }
.skip-link:focus { left: 12px; background: var(--panel); color: var(--ink); padding: 8px 12px; border: 1px solid var(--accent); border-radius: var(--r); font: 13px var(--mono); }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Top nav ---------- */
:root { --page-max: calc(var(--rail-w) + var(--gap) + var(--wide) + 2 * var(--pad)); }
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 max(var(--pad), calc((100% - var(--page-max)) / 2 + var(--pad)));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font: 13px/1 var(--mono);
}
.topbar .brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--ink); text-decoration: none; }
.topbar .brand .logo {
  position: relative; flex: none; width: 26px; height: 22px; border: 1.5px solid var(--accent); border-radius: var(--r);
}
.topbar .brand .logo::after { content: "❯"; position: absolute; inset: 0; display: grid; place-items: center; font: 700 12px/1 var(--mono); color: var(--accent); }
.topbar .tb-path { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand:hover .tb-path { color: var(--accent); }
.tb-nav { display: flex; gap: 20px; margin-left: auto; }
.tb-nav a, .tb-theme, .tb-prog { color: var(--text-2); text-decoration: none; white-space: nowrap; }
.tb-nav a:hover, .tb-theme:hover, .tb-prog:hover { color: var(--ink); }
.tb-nav a.here { color: var(--ink); }
.tb-nav .k, .tb-theme .k, .tb-prog .k, .rail-links .k { color: var(--accent); }
.tb-prog { font: inherit; background: none; border: 0; padding: 4px 0; cursor: pointer; }   /* p progress: opens the progress dialog */
.tb-theme { font: inherit; background: none; border: 0; border-left: 1px solid var(--line); padding: 4px 0 4px 20px; cursor: pointer; }
.tb-btn {
  font: 13px/1 var(--mono); color: var(--ink); background: transparent; border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 5px 8px; cursor: pointer;
}
.menu-toggle { display: none; font-size: 15px; padding: 3px 8px 4px; }

/* ---------- Page layout: rail | article | notes ---------- */
.page { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--pad); }
.page.has-rail {
  display: grid; grid-template-columns: var(--rail-w) minmax(0, var(--col-w)) var(--note-w);
  column-gap: var(--gap); align-items: start;
}
.page.has-rail > main#content { grid-column: 2; grid-row: 1; min-width: 0; padding: 40px 0 96px; font-size: 18px; line-height: 1.72; }
main#content:focus { outline: none; }
.page.no-sidebar > main#content { padding: 44px 0 96px; }

/* Rail */
.sidebar {
  grid-column: 1; grid-row: 1; position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h) - var(--status-h));
}
.sidebar .rail-in {
  height: 100%; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain;
  padding: 44px 2px 28px 0; font: 13px/1.5 var(--mono);
}
.sidebar .rail-in::-webkit-scrollbar { display: none; }
.sidebar .rail-in a:focus-visible { outline-offset: -2px; }   /* the rail scrolls, so a ring outside the link is clipped */
.sidebar .sb-title { font: 12px/1 var(--mono); color: var(--muted); margin: 30px 0 12px; }
.sidebar .sb-title:first-child { margin-top: 0; }
.tree, .tree ol, .rail-links { list-style: none; margin: 0; padding: 0; }
.tree li, .rail-links li { margin: 0; }
.tree a { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; padding: 3px 0; color: var(--text-2); text-decoration: none; }
.tree a:hover { color: var(--ink); }
.tree > li > a::before { content: "├──"; content: "├──" / ""; color: var(--faint); }
.tree > li:last-child > a::before { content: "└──"; content: "└──" / ""; }
.toc-sub { display: none; margin: 1px 0 6px 4px; border-left: 1px solid var(--faint); }
.toc > li.open > .toc-sub { display: block; }
.toc-sub a { column-gap: 7px; padding: 2px 0 2px 11px; font-size: 12.5px; color: var(--muted); }
.toc-sub a::before { content: "─"; content: "─" / ""; color: var(--faint); }
.tree a.in { color: var(--ink); }
.tree a.active, .tree a.active:hover { color: var(--accent); }
.tree a.done .tl::after, .sess-list a.done .tl::after { content: " ✓"; content: " ✓" / " done"; color: var(--ok); }
.sess-list a { color: var(--muted); }
.sess-list .sn { color: var(--muted); }
.sess-list a.current, .sess-list a.current .sn { color: var(--accent); }
.rail-prog { margin: 22px 0 0; }
.p-ascii { display: block; font: 13px/1 var(--mono); color: var(--ink); white-space: pre; letter-spacing: -.02em; }
.rail-sub { font: 12px/1.4 var(--mono); color: var(--muted); margin: 8px 0 0; }
.rail-sub b { color: var(--ink); font-weight: 500; }
.rail-links a { display: block; padding: 2px 0; color: var(--text-2); text-decoration: none; }
.rail-links a:hover { color: var(--ink); }

/* ---------- Heroes ---------- */
.session-hero { padding: 6px 0 40px; margin: 0 0 8px; border-bottom: 1px solid var(--line); }
.hero-cmd {
  display: inline-flex; align-items: center; max-width: 100%; overflow: hidden; white-space: nowrap;
  padding: 10px 14px; margin: 0 0 28px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--panel);
  font: 14px/1 var(--mono); color: var(--text-2);
}
.hero-cmd .pr { color: var(--accent); font-weight: 700; margin-right: 8px; }
.hero-cmd .typed { white-space: pre; }
.cursor { display: inline-block; flex: none; width: 8px; height: 16px; margin-left: 2px; background: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.kicker, .session-hero .eyebrow { font: 13px/1.3 var(--mono); letter-spacing: .02em; color: var(--muted); margin: 0 0 16px; }
.kicker::before, .session-hero .eyebrow::before { content: "# "; content: "# " / ""; color: var(--accent); }
.session-hero h1, .hub-hero h1, .page-hero h1 { font: 600 50px/1.08 var(--mono); letter-spacing: -.035em; color: var(--ink); margin: 0 0 20px; max-width: var(--col-w); overflow-wrap: break-word; }
.dek, .session-hero .goal { font: 20px/1.58 var(--font); color: var(--text-2); margin: 0 0 34px; max-width: var(--col-w); }
dl.meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 24px; margin: 0; max-width: var(--wide); }
dl.meta dt { font: 12px/1 var(--mono); color: var(--muted); margin: 0 0 8px; }
dl.meta dt::after { content: ":"; }
dl.meta dd { margin: 0; font: 14px/1.45 var(--mono); color: var(--ink); }
dl.meta .wide { grid-column: 1 / -1; }
.prog-path { color: var(--text-2); }
.prog-path .cur { color: var(--accent); font-weight: 600; }
.prog-path .arr { color: var(--muted); }
.agenda-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 32px; }
.agenda-card {
  display: block; padding: 12px 14px 13px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--panel);
  color: var(--ink); text-decoration: none; transition: border-color .15s;
}
.agenda-card:hover { border-color: var(--accent); color: var(--ink); }
.agenda-card b { display: flex; align-items: baseline; gap: 10px; font: 600 15px/1.35 var(--font); }
.agenda-card .ac-n { font: 500 12px var(--mono); color: var(--accent); }
.agenda-card .ac-t { flex: 1; }
.agenda-card .state { font: 500 11.5px var(--mono); color: var(--ok); white-space: nowrap; }
.agenda-card .ac-items { display: block; margin-top: 6px; font: 12px/1.55 var(--mono); color: var(--muted); }
.agenda-card.done { border-color: color-mix(in srgb, var(--ok) 50%, var(--line-2)); }

/* ---------- Topics, concepts, headings ---------- */
main#content { counter-reset: topic; }
.session-intro { margin: 40px 0 8px; }
section.topic { margin: 76px 0 0; padding-top: 30px; border-top: 1px solid var(--line); display: flow-root; counter-increment: topic; counter-reset: concept; }
section.wrap-up { margin: 76px 0 0; padding-top: 30px; border-top: 1px solid var(--line); display: flow-root; }
section.topic > h2, section.wrap-up > h2, h2[data-cmd] {
  display: flex; align-items: baseline; gap: 14px; margin: 0 0 12px;
  font: 500 17px/1.35 var(--mono); letter-spacing: 0; color: var(--ink);
}
.h-cmd { min-width: 0; overflow-wrap: anywhere; }
.h-cmd .h-p { color: var(--accent); }
.h-cmd .h-slug { color: var(--ink); }
h2 .num { margin-left: auto; font: 12px/1 var(--mono); color: var(--muted); white-space: nowrap; }
h2 .num::before { content: "# "; }
.topic-items { margin: 0 0 26px; font: 12.5px/1.6 var(--mono); color: var(--text-2); }
.topic-items .ti-k { color: var(--muted); }
.topic-items .ti-k::after { content: ":"; }
.topic-items .ti-sep { color: var(--muted); }
.topic-lede { font-size: 1.08em; line-height: 1.66; color: var(--ink); }
article.concept { margin: 52px 0; counter-increment: concept; }
article.concept > h3 { font: 600 24px/1.3 var(--font); letter-spacing: -.015em; color: var(--ink); margin: 0 0 16px; }
article.concept > h3::before {
  content: counter(topic, decimal-leading-zero) "." counter(concept);
  content: counter(topic, decimal-leading-zero) "." counter(concept) / "";
  display: inline-block; margin-right: 12px; font: 500 13px/1 var(--mono); letter-spacing: 0; color: var(--accent); vertical-align: .22em;
}
:is(article.concept, section.topic, .session-intro, section.wrap-up) h4 { font: 600 18.5px/1.4 var(--font); letter-spacing: -.008em; color: var(--ink); margin: 1.8em 0 .55em; }
:is(article.concept, section.topic, .session-intro, section.wrap-up) > p { margin: 0 0 1.05em; }
:is(article.concept, section.topic, .session-intro, section.wrap-up) > :is(ul, ol) { margin: 0 0 1.1em; }
:is(article.concept, section.topic, .session-intro, section.wrap-up) > :is(ul, ol) > li { margin: .35em 0; }

/* ---------- Margin notes ---------- */
aside.note { font: 12.5px/1.6 var(--mono); color: var(--muted); }
aside.note .note-k { display: block; color: var(--accent); margin-bottom: 4px; }
aside.note .note-k::before { content: "// "; content: "// " / ""; }
aside.note b, aside.note strong { color: var(--ink); font-weight: 600; }
aside.note a { color: var(--ink); }
aside.note code { font-size: .96em; padding: .04em .18em; }
code.nw { white-space: nowrap; overflow-wrap: normal; word-break: normal; hyphens: none; }   /* short identifiers in notes and table cells (course.js marks them) never break at a hyphen */
aside.note { margin: 0 0 18px; padding: 8px 0 8px 14px; border-left: 2px solid var(--accent-line); }

/* ---------- Figure and widget frames ---------- */
figure.viz, .widget {
  position: relative; margin: 34px 0 38px; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden;
  font-size: 16px; line-height: 1.6;
}
figure.viz { background: var(--f-bg); color: var(--f-ink); padding: 0; }
.widget { background: var(--panel); color: var(--text-2); }
.fig-h, .viz-head, .widget-head {
  display: flex; align-items: flex-start; gap: 16px; padding: 15px 20px 13px; border-bottom: 1px dashed var(--line-2);
}
.fig-n { flex: none; padding-top: 2px; font: 12px/1.5 var(--mono); letter-spacing: .04em; color: var(--f-acc-ink); white-space: nowrap; }
.fig-n::before { content: "▍"; content: "▍" / ""; color: var(--accent); }
.fig-hd { flex: 1; min-width: 0; }
.fig-k { font: 12px/1.45 var(--mono); color: var(--muted); margin: 0 0 4px; }
.fig-t { font: 500 17px/1.35 var(--mono); color: var(--ink); letter-spacing: -.005em; }
.fig-s { font: 15px/1.5 var(--font); color: var(--muted); margin-top: 3px; }
.fig-h .fig-tag { flex: none; margin-left: auto; padding-top: 3px; font: 11.5px/1.5 var(--mono); letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.fig-h .fig-tag::before { content: "["; } .fig-h .fig-tag::after { content: "]"; }
figure.viz .fig-t { color: var(--f-ink); }
figure.viz :is(.fig-s, .fig-k, .fig-tag) { color: var(--f-muted); }
.viz-body, .widget-body { padding: 18px 20px; }
figure.viz > .viz-body, figure.viz > .fig-b {
  background-image: radial-gradient(circle, var(--f-grid) .8px, transparent 1px); background-size: 8px 8px;
}
figure.viz > svg, figure.viz .viz-body > svg { display: block; width: 100%; height: auto; }
figure.viz > svg { padding: 14px 18px; }
figure.viz :not(pre) > code { background: color-mix(in oklab, var(--f-ink) 10%, var(--f-bg)); color: var(--f-ink); }
figure.viz figcaption, .widget > .caption, .fig-f {
  padding: 14px 20px 15px; border-top: 1px solid var(--line); font: 15px/1.55 var(--font); color: var(--muted);
}
figure.viz figcaption { color: var(--f-muted); }
.fig-f { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
.fig-f .fig-no { font: 500 12px/1.75 var(--mono); letter-spacing: .05em; color: var(--ink); white-space: nowrap; }
figure.viz .fig-f .fig-no { color: var(--f-ink); }
.fig-f .cap-t { display: block; min-width: 0; }
.fig-f a { color: var(--ink); }
.widget .widget-body .caption { margin-top: 12px; font-size: 14.5px; color: var(--muted); }
figure:not(.viz) { margin: 12px 0; }
figure:not(.viz) > figcaption { font: 12.5px/1.5 var(--mono); color: var(--muted); margin-top: 6px; }
.widget-error {
  margin: 10px 0; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--bad); background: var(--bad-soft);
  font: 12.5px/1.5 var(--mono); white-space: pre-wrap; color: var(--ink);
}

/* ---------- Layout primitives used inside pages ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.split-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
/* items never grow past their column (a long pre scrolls inside it instead of widening the page) */
.split > *, .split-3 > * { min-width: 0; }
@media (max-width: 760px) { .split, .split-3 { grid-template-columns: minmax(0, 1fr); } }
.panel { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); padding: 12px 14px; }
.panel h5 { margin: 0 0 8px; font: 500 12.5px/1.4 var(--mono); color: var(--muted); }
.session-intro .panel { background: var(--panel); border-color: var(--line-2); padding: 14px 16px; }
.out {
  font: 13px/1.55 var(--mono); background: var(--code-bg); color: var(--code-text);
  border-radius: var(--r); padding: 10px 12px; white-space: pre-wrap; word-break: break-word; min-height: 2.4em; max-height: 420px; overflow: auto;
  border: 1px solid var(--code-line);
}
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.stat { flex: 1 1 120px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); padding: 9px 12px; }
.stat .k { font: 11.5px/1.4 var(--mono); color: var(--muted); }
.stat .v { font: 600 20px/1.3 var(--mono); color: var(--ink); letter-spacing: -.02em; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2); font: 12px/1.5 var(--mono); white-space: nowrap;
}
.chip.accent { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); }
/* no multi-hue pills: the old semantic chip classes render as the neutral chip (.chip.accent is the one highlight) */
.chip:is(.ok, .warn, .bad, .info, .violet) { border-color: var(--line-2); background: var(--panel-2); color: var(--text-2); }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* token pills (tokenizers, streams) */
.tokens { display: flex; flex-wrap: wrap; gap: 3px; font: 13px/1.2 var(--mono); }
.tok {
  padding: 3px 5px; border-radius: var(--r); border: 1px solid transparent; white-space: pre; position: relative;
  background: color-mix(in srgb, hsl(var(--h, 78) 70% 60%) 20%, transparent);
  border-color: color-mix(in srgb, hsl(var(--h, 78) 70% 60%) 48%, transparent);
  color: var(--ink);
}
.tok.sel { outline: 2px solid var(--accent); }
.tok small { display: block; font-size: .78em; color: var(--text-2); }   /* muted fails on the hue tints in dark */

/* chat / transcript */
.transcript { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.msg {
  border: 1px solid var(--line); border-left: 2px solid var(--line-2); border-radius: var(--r);
  padding: 8px 12px; background: var(--bg-2); font-size: 15px; line-height: 1.55; color: var(--text-2);
  min-width: 0; overflow-wrap: anywhere;   /* long unbroken tokens (stream-json lines, paths) wrap instead of widening the page */
}
.msg > .role { display: block; margin-bottom: 3px; font: 500 11.5px/1.4 var(--mono); letter-spacing: .02em; color: var(--muted); }
.msg.system { border-left-color: var(--violet); } .msg.system > .role { color: var(--violet); }
.msg.user { border-left-color: var(--info); } .msg.user > .role { color: var(--info); }
.msg.assistant { border-left-color: var(--accent); } .msg.assistant > .role { color: var(--accent); }
.msg.tool, .msg.tool_result { border-left-color: var(--warn); font: 13px/1.55 var(--mono); }
.msg.tool > .role, .msg.tool_result > .role { color: var(--warn); }
.msg.thinking { border-style: dashed; color: var(--muted); font-style: italic; }
.msg pre { margin: 6px 0 0; }

/* ---------- Buttons, inputs, controls ---------- */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0; cursor: pointer;
  font: 500 12.5px/1.25 var(--mono); letter-spacing: .01em; text-align: left;
  padding: 7px 12px; border-radius: var(--r); border: 1px solid var(--line-2); background: transparent; color: var(--ink);
  text-decoration: none; transition: border-color .15s, background-color .15s, color .15s;
}
.btn::before { content: "$\00a0"; content: "$\00a0" / ""; color: var(--accent); flex: none; }
.btn.icon::before { content: none; }
.btn.icon { min-width: 32px; padding-left: 8px; padding-right: 8px; }
.btn:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--hl-ink); }
.btn.primary::before { color: var(--hl-ink); }
.btn.primary:hover { background: color-mix(in oklab, var(--accent) 86%, var(--ink)); color: var(--hl-ink); }
.btn.ghost { border-color: var(--line); color: var(--text-2); }
.btn.ghost:hover { color: var(--ink); border-color: var(--accent); }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.ok { border-color: color-mix(in srgb, var(--ok) 60%, var(--line-2)); }
.btn.ok::before { color: var(--ok); }
.btn.ok:hover { border-color: var(--ok); }
.btn.active, .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.btn.primary.active, .btn.primary[aria-pressed="true"] { background: var(--accent); color: var(--hl-ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }

input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="url"], input:not([type]), select, textarea {
  font: 13px/1.4 var(--mono); color: var(--ink); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px 9px; outline: none; max-width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 90px; font: 13px/1.55 var(--mono); resize: vertical; }
select { cursor: pointer; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
label { cursor: pointer; }
.ctrl { display: grid; grid-template-columns: 150px minmax(0, 1fr) 70px; gap: 12px; align-items: center; margin: 7px 0; }
.ctrl .lbl { font: 12.5px/1.35 var(--mono); color: var(--text-2); }
.ctrl .val { font: 12.5px/1 var(--mono); color: var(--accent); text-align: right; }
.ctrl-inline { display: inline-flex; gap: 8px; align-items: center; font: 12.5px/1.4 var(--mono); color: var(--text-2); margin-right: 14px; }

/* ---------- Callouts: 1px box, mono kicker "! pitfall · title" ---------- */
.callout {
  --k: var(--muted); --kg: "#"; --kw: "note";
  position: relative; margin: 24px 0; padding: 13px 18px 14px; border-radius: var(--r);
  border: 1px solid color-mix(in srgb, var(--k) 30%, var(--line-2)); background: var(--panel);
  font-size: 16px; line-height: 1.62; color: var(--text-2);
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title { display: block; margin-bottom: 5px; font: 500 12.5px/1.45 var(--mono); letter-spacing: .01em; color: var(--k); }
.callout .callout-title::before { content: var(--kg) " " var(--kw) " · "; content: var(--kg) " " var(--kw) " · " / var(--kw) ": "; }
.callout:not(:has(> .callout-title))::before { content: var(--kg) " " var(--kw); display: block; margin-bottom: 5px; font: 500 12.5px/1.45 var(--mono); color: var(--k); }
.callout.note    { --k: var(--info);   --kg: "i";  --kw: "note"; }
.callout.tip     { --k: var(--ok);     --kg: "+";  --kw: "tip"; }
.callout.warn    { --k: var(--warn);   --kg: "!";  --kw: "warn"; }
.callout.pitfall { --k: var(--warn);   --kg: "!";  --kw: "pitfall"; }
.callout.danger  { --k: var(--bad);    --kg: "!!"; --kw: "danger"; }
.callout.expert  { --k: var(--violet); --kg: "∑";  --kw: "expert"; }
.callout.example { --k: var(--accent); --kg: "→";  --kw: "example"; }
.callout.analogy { --k: var(--muted);  --kg: "≈";  --kw: "analogy"; }

/* ---------- Deep dives, plain details ---------- */
details.deep-dive { margin: 26px 0; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); }
details.deep-dive > summary {
  position: relative; display: block; cursor: pointer; list-style: none; padding: 13px 46px 13px 18px;
  font: 600 16.5px/1.45 var(--font); color: var(--ink);
}
details.deep-dive > summary::-webkit-details-marker { display: none; }
details.deep-dive > summary::before { content: "∑ expert"; content: "∑ expert" / "expert:"; display: inline-block; margin-right: 12px; font: 500 12px/1 var(--mono); color: var(--violet); vertical-align: .1em; }
details.deep-dive > summary::after { content: "+"; content: "+" / ""; position: absolute; right: 18px; top: 12px; font: 400 17px/1.3 var(--mono); color: var(--muted); }
details.deep-dive[open] > summary { border-bottom: 1px dashed var(--line-2); }
details.deep-dive[open] > summary::after { content: "−"; content: "−" / ""; }
details.deep-dive > summary:hover::after { color: var(--accent); }
details.deep-dive > .dd-body, details.deep-dive > div { padding: 16px 20px 8px; font-size: 16.5px; line-height: 1.68; }
details.plain { margin: 16px 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
details.plain > summary { cursor: pointer; padding: 9px 14px; font: 500 13px/1.45 var(--mono); color: var(--ink); }
details.plain > summary::marker { color: var(--accent); }
details.plain > :not(summary) { padding: 0 16px 12px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; line-height: 1.5; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 500 12px/1.45 var(--mono); letter-spacing: .01em; color: var(--muted); background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--r); margin: 22px 0; background: var(--panel); }
.table-wrap table { margin: 0; }

/* ---------- Code ---------- */
pre {
  position: relative; background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-line);
  border-radius: var(--r); padding: 16px 18px; overflow-x: auto; font: 13.5px/1.65 var(--mono); margin: 18px 0;
  tab-size: 2;
}
pre code { font: inherit; background: none; border: 0; padding: 0; color: inherit; border-radius: 0; overflow-wrap: normal; }
pre[data-lang]::after {
  content: attr(data-lang); position: absolute; top: 8px; right: 64px; font: 11px/1.4 var(--mono); letter-spacing: .04em; color: var(--code-muted);
}
pre.no-copy[data-lang]::after, pre.out[data-lang]::after { right: 10px; }
.copy-btn {
  position: absolute; top: 6px; right: 6px; font: 11px/1.4 var(--mono); padding: 2px 8px; border-radius: var(--r); cursor: pointer;
  background: var(--code-bg); border: 1px solid #343B35; color: var(--code-muted);
}
.copy-btn:hover { color: #E8EDE4; border-color: var(--code-acc); }
.t-kw { color: var(--tok-kw); }
.t-str { color: var(--tok-str); }
.t-num { color: var(--tok-num); }
.t-com { color: var(--tok-com); font-style: italic; }
.t-fn { color: var(--tok-fn); }
.t-key { color: var(--tok-key); }

/* ---------- Tabs ---------- */
.tabs { margin: 22px 0; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.tab-bar { display: flex; flex-wrap: wrap; gap: 0 2px; padding: 0 10px; border-bottom: 1px solid var(--line); }   /* labels wrap onto a second row instead of clipping */
.tab-bar button {
  font: 500 12.5px/1.3 var(--mono); color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; padding: 10px 10px 8px; cursor: pointer; white-space: normal; text-align: left; max-width: 100%; overflow-wrap: anywhere;
}
.tab-bar button:hover { color: var(--ink); }
.tab-bar button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-bar button:focus-visible { outline-offset: -2px; }
.tabs > .tab { display: none; padding: 8px 18px 16px; font-size: 16.5px; line-height: 1.65; }
.tabs > .tab.active { display: block; }
.tabs > .tab > pre:first-child { margin-top: 12px; }

/* ---------- Quiz ---------- */
.quiz { margin: 38px 0; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); overflow: hidden; font-size: 16.5px; line-height: 1.6; }
.quiz-head { display: flex; align-items: baseline; gap: 10px; padding: 13px 18px 12px; border-bottom: 1px dashed var(--line-2); font: 500 14px/1.4 var(--mono); color: var(--ink); }
.quiz-head .qk { color: var(--accent); font-weight: 700; }
.quiz-head .score { margin-left: auto; font: 12px/1.4 var(--mono); color: var(--muted); white-space: nowrap; }
.quiz-q { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); }
.quiz-q:last-child { border-bottom: 0; }
.quiz-q .qtext { font-weight: 600; color: var(--ink); margin-bottom: 10px; line-height: 1.5; }
.quiz-q .qtext .qn { font: 500 13px/1 var(--mono); color: var(--accent); margin-right: 9px; }
.quiz-q .hint { font: 12px/1.4 var(--mono); color: var(--muted); margin: -4px 0 8px; }
.quiz-opt {
  display: flex; gap: 11px; align-items: flex-start; padding: 9px 12px; margin: 6px 0; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--bg-2); cursor: pointer; font-size: 15.5px; line-height: 1.5; color: var(--text-2);
  transition: border-color .15s;
}
.quiz-opt:hover { border-color: var(--accent); color: var(--ink); }
.quiz-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.quiz-opt input { margin-top: 5px; flex: none; }
.quiz-q.answered .quiz-opt { cursor: default; }
.quiz-q.answered .quiz-opt:hover { border-color: var(--line-2); }
.quiz-opt.correct, .quiz-q.answered .quiz-opt.correct:hover { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--bg-2)); color: var(--ink); }
.quiz-opt.wrong, .quiz-q.answered .quiz-opt.wrong:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg-2)); color: var(--ink); }
.quiz-opt.missed, .quiz-q.answered .quiz-opt.missed:hover { border-color: var(--ok); border-style: dashed; }
.quiz-opt small.muted { color: var(--muted); }
.quiz-explain { display: none; margin-top: 10px; padding: 10px 14px; border-radius: var(--r); background: var(--bg-2); border-left: 2px solid var(--accent); font-size: 15px; color: var(--text-2); }
.quiz-q.answered .quiz-explain { display: block; }
.quiz-explain .q-ok { color: var(--ok); }
.quiz-explain .q-bad { color: var(--bad); }
.quiz-actions { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

/* ---------- Flashcards ---------- */
.flashcards { margin: 26px 0; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.flashcards > .fc-head { display: flex; align-items: baseline; gap: 12px; padding: 13px 18px 12px; border-bottom: 1px dashed var(--line-2); font: 500 15px/1.4 var(--mono); color: var(--ink); }
.flashcards > .fc-head .tag { order: 2; margin-left: auto; font: 11.5px/1.5 var(--mono); color: var(--muted); }
.flashcards > .fc-head .tag::before { content: "["; } .flashcards > .fc-head .tag::after { content: "]"; }
.flashcards > .fc-head .fc-title::before { content: "▍"; content: "▍" / ""; color: var(--accent); margin-right: 2px; }
.fc-stage { perspective: 1200px; height: 220px; margin: 18px 18px 0; }
.fc-card { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .5s; cursor: pointer; border-radius: var(--r); }
.fc-card.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: var(--r); border: 1px solid var(--line-2);
  display: grid; place-items: center; padding: 26px 30px; text-align: center; background: var(--bg-2); font-size: 18px; line-height: 1.5; color: var(--ink);
}
.fc-face.back { transform: rotateY(180deg); background: color-mix(in srgb, var(--accent) 9%, var(--panel)); border-color: var(--accent-line); font-size: 16px; color: var(--ink); }
.fc-face .fc-label { position: absolute; top: 10px; left: 14px; font: 11.5px/1 var(--mono); color: var(--muted); }
.fc-nav { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 12px 18px 16px; font: 12.5px var(--mono); color: var(--muted); }

/* ---------- Glossary terms ---------- */
.term { border-bottom: 1px dotted var(--accent); cursor: help; }
.term:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.term-pop {
  position: absolute; z-index: 80; max-width: 360px; padding: 11px 14px 12px; border-radius: var(--r);
  font: 14.5px/1.55 var(--font); background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); color: var(--text-2); pointer-events: none;
}
.term-pop b { display: block; margin-bottom: 4px; font: 500 13px/1.4 var(--mono); color: var(--accent); }

/* ---------- Exercises, labs, takeaways, compare cards ---------- */
.exercise { margin: 26px 0; border: 1px solid var(--line-2); border-radius: var(--r); padding: 15px 18px 14px; background: var(--panel); font-size: 16.5px; line-height: 1.62; }
.exercise > h4:first-child, .exercise > .ex-title { margin: 0 0 8px; font: 500 13px/1.4 var(--mono); letter-spacing: .01em; color: var(--ink); }
.exercise > h4:first-child::before, .exercise > .ex-title::before { content: "$ "; content: "$ " / ""; color: var(--accent); }
.exercise details > summary { cursor: pointer; font: 500 13px/1.5 var(--mono); color: var(--ink); }
.exercise details > summary::marker { color: var(--accent); }
.exercise details[open] > summary { margin-bottom: 6px; }
.lab { margin: 26px 0; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.lab-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 12px 18px; border-bottom: 1px dashed var(--line-2); }
.lab-head .tag { font: 500 12px/1.4 var(--mono); color: var(--accent); white-space: nowrap; }
.lab-head .tag::before { content: "▍"; content: "▍" / ""; }
.lab-head b { font: 600 15.5px/1.4 var(--font); color: var(--ink); }
.lab-head .spacer { flex: 1; }
.lab-body { padding: 8px 18px 14px; font-size: 16px; line-height: 1.62; }
.lab-body pre { margin: 10px 0; }
/* the lab card's link to its walkthrough on the lab page: <p class="lab-go"><a href="../labs/<sid>.html#lab-<stem>">…</a></p> */
.lab .lab-go { margin: 14px 0 4px; }
.lab .lab-go a {
  display: inline-flex; align-items: center; padding: 7px 12px; border: 1px solid var(--line-2); border-radius: var(--r);
  font: 500 12.5px/1.25 var(--mono); letter-spacing: .01em; color: var(--ink); text-decoration: none;
  transition: border-color .15s, background-color .15s;
}
.lab .lab-go a::before { content: "$\00a0"; content: "$\00a0" / ""; color: var(--accent); }
.lab .lab-go a::after { content: "\00a0▸"; content: "\00a0▸" / ""; color: var(--accent); }
.lab .lab-go a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.takeaways { margin: 30px 0; padding: 15px 20px 14px; border-radius: var(--r); border: 1px solid var(--accent-line); background: var(--accent-soft); font-size: 16.5px; line-height: 1.62; }
.takeaways > h4:first-child, .takeaways > .tk-title { margin: 0 0 6px; font: 500 13px/1.4 var(--mono); letter-spacing: .01em; color: var(--ink); }
.takeaways > h4:first-child::before, .takeaways > .tk-title::before { content: "✓ "; content: "✓ " / ""; color: var(--accent); }
.takeaways ul { margin: 0; }
.compare-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; margin: 20px 0; }
.compare-cards .card { min-width: 0; border: 1px solid var(--line-2); border-radius: var(--r); padding: 13px 15px; background: var(--panel); font-size: 15.5px; line-height: 1.55; }
.compare-cards .card > * { min-width: 0; max-width: 100%; }   /* a code block in a card scrolls inside it */
.compare-cards .card :is(h3, h5) { margin: 0 0 6px; font: 600 15px/1.4 var(--font); letter-spacing: 0; color: var(--ink); }
/* do / don't cards: one ink plus the accent. The heading carries the ✓ / ✗ label; .good gets the accent line, .bad a dashed neutral one */
.compare-cards .card.good { border-color: var(--accent-line); }
.compare-cards .card.bad { border-style: dashed; border-color: var(--line-2); }

/* ---------- Stepper ---------- */
.stepper-caption { margin-top: 14px; padding: 12px 0 2px; border-top: 1px solid var(--line); font-size: 15.5px; line-height: 1.6; min-height: 3.4em; }
.stepper-caption b:first-child { color: var(--accent); }
.stepper-ctrl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.stepper-ctrl .pos { font: 12px var(--mono); color: var(--muted); margin: 0 6px; }
.stepper-ctrl .dots { display: flex; gap: 4px; margin-left: auto; }
.stepper-ctrl .dots i { width: 8px; height: 8px; border-radius: 1px; background: var(--line-2); cursor: pointer; }
.stepper-ctrl .dots i.on { background: var(--accent); }

/* ---------- SVG: diagrams, charts, shared defs ---------- */
svg.diagram { display: block; width: 100%; height: auto; font-family: var(--font); }
svg.diagram .node :is(rect, ellipse, polygon, path.cyl) { fill: var(--f-top); stroke: var(--f-line); stroke-width: 1.3; transition: fill .25s, stroke .25s, opacity .25s; }
svg.diagram .node path.cyl-lid { fill: none !important; }   /* the lid is a line, whatever the node colour */
svg.diagram .node text { fill: var(--f-ink); font-size: 13px; font-weight: 600; }
svg.diagram .node text.sub { fill: var(--f-sub); font-size: 10.5px; font-weight: 500; }
svg.diagram .node.accent :is(rect, ellipse, polygon, path.cyl) { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 12%, var(--f-top)); }
svg.diagram .node.ok :is(rect, ellipse, polygon, path.cyl) { stroke: var(--ok); fill: color-mix(in srgb, var(--ok) 10%, var(--f-top)); }
svg.diagram .node.warn :is(rect, ellipse, polygon, path.cyl) { stroke: var(--warn); fill: color-mix(in srgb, var(--warn) 10%, var(--f-top)); }
svg.diagram .node.bad :is(rect, ellipse, polygon, path.cyl) { stroke: var(--bad); fill: color-mix(in srgb, var(--bad) 10%, var(--f-top)); }
svg.diagram .node.info :is(rect, ellipse, polygon, path.cyl) { stroke: var(--info); fill: color-mix(in srgb, var(--info) 10%, var(--f-top)); }
svg.diagram .node.violet :is(rect, ellipse, polygon, path.cyl) { stroke: var(--violet); fill: color-mix(in srgb, var(--violet) 10%, var(--f-top)); }
svg.diagram .node.muted :is(rect, ellipse, polygon, path.cyl) { stroke-dasharray: 4 3; fill: transparent; }
svg.diagram .node.muted text, svg.diagram .node.muted text.sub { fill: var(--f-muted); }
/* a muted node that gets highlighted sits on the accent tint: its labels go back to the tint-safe inks */
svg.diagram .node.muted.active text { fill: var(--f-ink); }
svg.diagram .node.muted.active text.sub { fill: var(--f-sub); }
svg.diagram .node.active :is(rect, ellipse, polygon, path.cyl) { stroke: var(--accent); stroke-width: 2.2; fill: color-mix(in srgb, var(--accent) 18%, var(--f-top)); }
/* Dimmed (inactive) steps: the shape fades, the labels stay readable in a muted ink a fifth of the way to --f-ink
   (≥ 4.5:1 on every faded node tint, both themes), so the active step still leads. */
svg.diagram .node.dim > :not(text) { opacity: .4; }
svg.diagram .node.dim text, svg.diagram .node.dim text.sub { fill: color-mix(in oklab, var(--f-muted) 80%, var(--f-ink)); }
svg.diagram .node.active.ok :is(rect, ellipse, polygon, path.cyl) { stroke: var(--ok); fill: color-mix(in srgb, var(--ok) 18%, var(--f-top)); }
svg.diagram .node.active.warn :is(rect, ellipse, polygon, path.cyl) { stroke: var(--warn); fill: color-mix(in srgb, var(--warn) 18%, var(--f-top)); }
svg.diagram .node.active.bad :is(rect, ellipse, polygon, path.cyl) { stroke: var(--bad); fill: color-mix(in srgb, var(--bad) 18%, var(--f-top)); }
svg.diagram .node.active.info :is(rect, ellipse, polygon, path.cyl) { stroke: var(--info); fill: color-mix(in srgb, var(--info) 18%, var(--f-top)); }
svg.diagram .node.active.violet :is(rect, ellipse, polygon, path.cyl) { stroke: var(--violet); fill: color-mix(in srgb, var(--violet) 18%, var(--f-top)); }
svg.diagram .edge path { fill: none; stroke: var(--f-line); stroke-width: 1.4; transition: stroke .25s, opacity .25s; }
svg.diagram .edge.dashed path { stroke-dasharray: 5 4; }
svg.diagram .edge.active path { stroke: var(--accent); stroke-width: 2.2; }
svg.diagram .edge.dim > :not(text) { opacity: .35; }
svg.diagram .edge.dim text { fill: var(--f-muted); }
[data-theme="light"] svg.diagram .node.dim > :not(text) { opacity: .5; }
[data-theme="light"] svg.diagram .edge.dim > :not(text) { opacity: .45; }
svg.diagram .edge text { fill: var(--f-muted); font-size: 11px; }
/* Sizes are the largest v1 layouts still fit: sub-labels 10.5 px (8 of 891 overflow their boxes at 10.75, 46 at 12),
   edge labels 11 px. Opt-in, per diagram, once its boxes are sized for it: both at the 12 px --f-sub size. */
svg.diagram.f-sub-12 .node text.sub, svg.diagram.f-sub-12 .edge text { font-size: 12px; }
svg.diagram .edge.active text { fill: var(--f-ink); }
svg.diagram .group rect { fill: transparent; stroke: var(--f-line); stroke-dasharray: 6 4; stroke-width: 1.1; }
svg.diagram .group text { fill: var(--f-muted); font: 500 11px var(--mono); letter-spacing: .02em; }
svg.diagram .pulse { fill: var(--accent); }
svg .axis line, svg .axis path { stroke: var(--line-2); }
svg .axis text { fill: var(--muted); font-size: 12px; }
svg .grid line { stroke: var(--line); stroke-dasharray: 2 3; }
svg text { fill: var(--text-2); font-family: var(--font); }
.chart text { font-family: var(--font); }
.chart .bar { fill: var(--accent); transition: all .3s; }
.chart .bar.hl { fill: var(--warn); }
.chart .bar.dim { opacity: .35; }
.chart .label { fill: var(--text-2); font-size: 11px; }
.chart .value { fill: var(--muted); font-size: 12px; font-family: var(--mono); }
/* shared defs: patterns, gradients and markers follow the theme through these classes */
.dz-bg { fill: var(--f-bg); } .dz-ink { fill: var(--f-line); } .dz-acc { fill: var(--f-acc); }
.hz-bg { fill: var(--f-top); } .hz-ink { stroke: var(--f-line); stroke-width: .7; } .hz-acc { stroke: var(--f-acc); stroke-width: 1; }
.gs-top-a { stop-color: var(--gtop-a, var(--f-top)); } .gs-top-b { stop-color: var(--gtop-b, var(--f-left)); }
.gs-hot-a { stop-color: color-mix(in oklab, var(--accent) 45%, var(--f-bg)); } .gs-hot-b { stop-color: color-mix(in oklab, var(--accent) 22%, var(--f-bg)); }
.arw { fill: var(--f-line); } .arw-acc { fill: var(--f-acc); }

/* ---------- Figure vocabulary (opt-in, for page-drawn figures; Course.prim helpers use it) ----------
   Tokens: --f-bg --f-line --f-ink --f-muted --f-sub --f-top --f-left --f-right --f-detail --f-grid, the one highlight
   --f-acc (strokes, fills) and --f-acc-ink (accent text on --f-bg), tints --f-acc-soft and --f-hot-top/left/right.
   Never put accent text on an accent fill: text on --f-acc goes in --hl-ink, text on a tint stays --f-ink. */
.arw-ink { fill: var(--f-ink); } .arw-muted { fill: var(--f-muted); }
.f-lbl { font: 500 14.5px/1.25 var(--mono); letter-spacing: -.005em; color: var(--f-ink); fill: var(--f-ink); }
.f-sub { font: 400 12px/1.35 var(--mono); color: var(--f-muted); fill: var(--f-muted); }
.f-val { font: 500 13px/1.3 var(--mono); color: var(--f-ink); fill: var(--f-ink); }
.f-acc-t { color: var(--f-acc-ink); fill: var(--f-acc-ink); }
svg .f-line { fill: none; stroke: var(--f-line); stroke-width: 1; }
svg .f-leader { fill: none; stroke: var(--f-line); stroke-width: 1; }
svg .f-guide { fill: none; stroke: var(--f-line); stroke-width: 1; stroke-dasharray: 6 6; opacity: .6; }
svg .f-acc-line { fill: none; stroke: var(--f-acc); stroke-width: 1.6; }
svg .f-face-top { fill: var(--f-top); stroke: var(--f-line); stroke-width: 1; stroke-linejoin: round; }
svg .f-face-left { fill: var(--f-left); stroke: var(--f-line); stroke-width: 1; stroke-linejoin: round; }
svg .f-face-right { fill: var(--f-right); stroke: var(--f-line); stroke-width: 1; stroke-linejoin: round; }
svg .f-face-top.hot { fill: var(--f-hot-top); stroke: var(--f-acc); }
svg .f-face-left.hot { fill: var(--f-hot-left); stroke: var(--f-acc); }
svg .f-face-right.hot { fill: var(--f-hot-right); stroke: var(--f-acc); }
svg .f-fill { fill: var(--f-top); stroke: var(--f-line); stroke-width: 1; }
svg .f-fill.hot, svg .f-tint { fill: var(--f-acc-soft); stroke: var(--f-acc); }
svg .f-ghost { fill: none; stroke: var(--f-line); stroke-width: 1; stroke-dasharray: 4 4; }
/* clickable parts (Course.prim.parts): pointer, and a focus ring for keyboard users */
[data-part] { cursor: pointer; }
svg [data-part]:focus { outline: none; }
svg [data-part]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Topic completion, pager ---------- */
.topic-complete {
  display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; clear: both;
  margin: 44px 0 0; padding: 11px 14px 11px 16px; border-radius: var(--r); border: 1px dashed var(--line-2);
  font: 13px/1.5 var(--mono); color: var(--muted);
}
.topic-complete .tc-t::before { content: "// "; content: "// " / ""; color: var(--muted); }
.topic-complete.done { border-style: solid; border-color: color-mix(in srgb, var(--ok) 50%, var(--line-2)); background: var(--ok-soft); color: var(--text-2); }
.topic-complete.done .tc-t::before { content: none; }
.topic-complete.done b { color: var(--ink); font-weight: 500; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 84px; clear: both; }
.pager a {
  display: block; padding: 14px 18px 15px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel);
  font: 600 16px/1.4 var(--font); color: var(--ink); text-decoration: none;
}
.pager a:hover { border-color: var(--accent); color: var(--ink); }
.pager a small { display: block; margin-bottom: 4px; font: 500 12px/1.4 var(--mono); color: var(--muted); }
.pager a.next { text-align: right; }

/* ---------- Author: follow card (end of a session) and site footer (every page) ---------- */
.follow {
  position: relative; margin-top: 84px; padding: 20px 22px 18px; border: 1px solid var(--accent-line); border-radius: var(--r);
  background: var(--accent-soft); clear: both;
}
.follow::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--accent); }
.follow p { margin: 0; }
.follow .fl-k { font: 12.5px/1.4 var(--mono); color: var(--muted); }
.follow .fl-k::before { content: "| "; content: "| " / ""; color: var(--accent); font-weight: 700; }
.follow .fl-t { margin-top: 8px; font: 600 17px/1.45 var(--font); color: var(--ink); }
.follow .fl-s { margin-top: 4px; font-size: 15px; line-height: 1.55; color: var(--text-2); }
.follow .btn-row { margin: 14px 0 0; }
.follow + .pager { margin-top: 24px; }
.site-foot {
  max-width: var(--page-max); margin: 0 auto; padding: 18px var(--pad) 28px;
  font: 12px/1.6 var(--mono); color: var(--muted);
}
.site-foot::before { content: ""; display: block; border-top: 1px solid var(--line); margin-bottom: 16px; }
.site-foot p { margin: 0 0 4px; }
.site-foot a { color: var(--text-2); }
.site-foot a:hover { color: var(--accent); }

/* ---------- Status line (tmux) ---------- */
.statusline {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; height: var(--status-h);
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  font: 12.5px/1 var(--mono); background: var(--accent); color: var(--hl-ink);
}
.statusline .sl-sess { font-weight: 700; white-space: nowrap; }
.statusline .sl-win { display: flex; gap: 12px; min-width: 0; flex: 0 1 auto; overflow: hidden; white-space: nowrap; }
.statusline .sl-win a { color: inherit; text-decoration: none; font-weight: 400; }
.statusline .sl-win a:hover { text-decoration: underline; text-decoration-color: currentColor; }
.statusline .sl-win a.on { font-weight: 700; }
.statusline .sl-win a.on::after { content: "*"; }
.statusline a:focus-visible { outline: 2px solid var(--hl-ink); outline-offset: 1px; }
.statusline .sl-grow { flex: 1; }
.statusline .sl-segs { display: flex; gap: 14px; white-space: nowrap; }
.statusline .sl-done, .statusline .sl-pct { white-space: nowrap; }
/* ⇅ progress: back up, move or import (Course.progressUI); inverted while it nudges for a backup */
.statusline .sl-prog {
  flex: none; align-self: stretch; display: inline-flex; align-items: center; gap: .5ch; margin: 0 -14px 0 0; padding: 0 14px;
  font: inherit; color: inherit; background: transparent; border: 0; border-left: 1px solid color-mix(in srgb, var(--hl-ink) 30%, transparent);
  white-space: nowrap; cursor: pointer;
}
.statusline .sl-prog:hover { text-decoration: underline; text-decoration-color: currentColor; text-underline-offset: 2px; }
.statusline .sl-prog:focus-visible { outline: 2px solid var(--hl-ink); outline-offset: -4px; }
.statusline .sl-prog.is-nudge { background: var(--hl-ink); color: var(--accent); font-weight: 700; }
.statusline .sl-prog.is-nudge:focus-visible { outline-color: var(--accent); }
.statusline .sl-ps:empty { display: none; }
.statusline .sl-prog .sl-ps { display: none; }

/* ---------- Dialogs: <dialog class="c-dlg"> in the top layer (progress; expanded figures) ---------- */
dialog.c-dlg {
  width: min(600px, calc(100vw - 24px)); max-width: none; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  margin: auto; padding: 0; overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); color: var(--text-2); box-shadow: var(--shadow);
  font: 15.5px/1.6 var(--font);
}
dialog.c-dlg::backdrop { background: rgba(0, 0, 0, .58); }
[data-theme="light"] dialog.c-dlg::backdrop { background: rgba(17, 20, 17, .42); }
.dlg-h {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; min-height: 52px;
  padding: 8px 8px 8px 18px; border-bottom: 1px dashed var(--line-2); background: var(--panel);
}
.dlg-t { flex: 1; min-width: 0; margin: 0; font: 500 15px/1.35 var(--mono); letter-spacing: 0; color: var(--ink); overflow-wrap: anywhere; }
.dlg-t::before { content: "▍"; content: "▍" / ""; color: var(--accent); }
.dlg-x {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  font: 400 22px/1 var(--mono); color: var(--text-2); background: transparent; border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer;
}
.dlg-x:hover { color: var(--ink); border-color: var(--accent); }
.dlg-b { padding: 14px 18px 18px; }
.dlg-b > :first-child, .pg-panel > :first-child { margin-top: 0; }
.dlg-b p { margin: 0 0 10px; }
.dlg-b .btn-row { margin: 14px 0 6px; }

/* the progress panel: in the dialog and on the hub (#progress-panel) */
.pg-now { color: var(--ink); }
.pg-last { font: 13px/1.5 var(--mono); color: var(--muted); }
.pg-k { margin: 22px 0 6px; font: 500 12.5px/1.45 var(--mono); letter-spacing: .01em; color: var(--muted); }
.pg-k::before { content: "// "; content: "// " / ""; }
.pg-hint { font-size: 14px; line-height: 1.55; color: var(--muted); }
.pg-big { color: var(--ink); }
.pg-ok { font: 13px/1.5 var(--mono); color: var(--ink); }
.pg-err { font: 13px/1.5 var(--mono); color: var(--ink); padding: 8px 12px; border: 1px solid var(--bad); border-radius: var(--r); background: var(--bad-soft); }
.pg-out { margin: 8px 0 4px; }
.pg-out .pg-ok, .pg-out .pg-err { margin: 0 0 8px; }
.pg-field { width: 100%; min-width: 0; }
.pg-open { margin: 10px 0 4px; }
.pg-lbl { display: block; margin: 0 0 6px; font: 12.5px/1.4 var(--mono); color: var(--text-2); }
.pg-row { display: flex; gap: 8px; align-items: stretch; }
.pg-row .pg-field { flex: 1; }
.pg-hub { max-width: var(--col-w); margin: 14px 0 6px; padding: 14px 18px 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); }
.pg-hub .pg-panel > p { max-width: none; }
/* the nudge: quiet, bottom right above the status line; never modal */
.pg-nudge {
  position: fixed; z-index: 46; right: 12px; bottom: calc(var(--status-h) + 10px); width: min(360px, calc(100vw - 24px));
  padding: 12px 14px 4px; border: 1px solid var(--accent-line); border-radius: var(--r); background: var(--panel); box-shadow: var(--shadow);
  font: 14.5px/1.5 var(--font); color: var(--text-2);
}
.pg-nudge p { margin: 0; }
.pg-nudge .btn-row { margin: 10px 0 8px; }

/* ---------- Lab pages and lab sheets ---------- */
section.lab-sheet { margin: 76px 0 0; padding-top: 30px; border-top: 1px solid var(--line); display: flow-root; }
body.page-lab section.lab-sheet:first-of-type { margin-top: 48px; padding-top: 0; border-top: 0; }   /* the hero's rule already separates it */
section.lab-sheet > h2[data-cmd] { flex-wrap: wrap; row-gap: 8px; margin-bottom: 10px; }
section.lab-sheet > h2 .lab-h { order: 3; flex: 1 1 100%; font: 600 26px/1.25 var(--font); letter-spacing: -.015em; color: var(--ink); }
.lab-meta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0 0 20px; font: 12.5px/1.6 var(--mono); color: var(--text-2); }
.lab-meta .k { color: var(--muted); }
.lab-meta .k::after { content: ":"; }
.lab-meta .sep { color: var(--muted); }
.lab-meta code { font-size: 1em; padding: 0; background: none; }
.lab-goal { font-size: 1.08em; line-height: 1.66; color: var(--ink); }
.lab-needs, .lab-try, .lab-look, .lab-real { margin: 24px 0; }
.lab-needs::before, .lab-try::before, .lab-look::before, .lab-real::before { display: block; margin-bottom: 8px; font: 500 12.5px/1.45 var(--mono); letter-spacing: .01em; }
.lab-needs::before { content: "// you'll need"; content: "// you'll need" / "You'll need:"; color: var(--muted); }
.lab-needs ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lab-needs li { margin: 0; padding: 2px 9px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel-2); font: 12.5px/1.5 var(--mono); color: var(--ink); }
.lab-needs li code { background: none; padding: 0; }
pre.lab-cmd::before { content: "# run from labs/"; content: "# run from labs/" / "Run from labs/:"; display: block; margin-bottom: 2px; color: var(--tok-com); font-style: italic; }
figure.lab-out { margin: 26px 0 30px; }
.lab-term { border: 1px solid var(--code-line); border-radius: var(--r); background: var(--code-bg); color: var(--code-text); overflow: hidden; }
.lab-term-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 9px 14px 8px; border-bottom: 1px dashed var(--line-2); font: 12px/1.45 var(--mono); color: var(--code-muted); }
.lab-term-h .lt-k { color: var(--code-text); }
.lab-term-h .lt-k::before { content: "▍"; content: "▍" / ""; color: var(--accent); }
.lab-term-h .lt-tag { margin-left: auto; }
.lab-term-h .lt-tag::before { content: "["; } .lab-term-h .lt-tag::after { content: "]"; }
.lab-term-cmd { padding: 10px 14px 0; font: 13px/1.6 var(--mono); color: var(--code-text); overflow-wrap: anywhere; }
.lab-term-cmd .pr { color: var(--accent); }
pre.lab-term-pre { position: relative; margin: 0; padding: 8px 0 12px; border: 0; border-radius: 0; max-height: 560px; overflow: auto; font: 12.5px/1.6 var(--mono); }
pre.lab-term-pre:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lab-term-pre .ln { display: block; width: max-content; min-width: 100%; padding-right: 16px; border-left: 2px solid transparent; white-space: pre; transition: background-color .12s; }
.lab-term-pre .ln-no { display: inline-block; width: 4.5ch; padding-right: 1ch; text-align: right; color: var(--code-muted); user-select: none; }
.lab-term-pre .ln-pin { display: inline-block; width: 3.4ch; text-align: center; user-select: none; }
.lab-term-pre .ln-pin b { display: inline-block; min-width: 2.2ch; padding: 0 .35ch; border: 1px solid var(--accent); border-radius: var(--r); font: 600 11px/1.5 var(--mono); color: var(--accent); }
.lab-term-pre .ln.hot { background: color-mix(in srgb, var(--accent) 14%, transparent); border-left-color: var(--accent); }
.lab-term-pre .ln.hot .ln-no { color: var(--code-text); }
.lab-term-pre .ln-pin b.hot { background: var(--accent); color: var(--hl-ink); }
ol.lab-callouts { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
ol.lab-callouts > li {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 12px; align-items: baseline; margin: 0; padding: 8px 12px 9px;
  border: 1px solid var(--line); border-left: 2px solid var(--line-2); border-radius: var(--r); background: var(--panel);
  font-size: 15.5px; line-height: 1.55; color: var(--text-2); transition: border-color .12s, background-color .12s;
}
ol.lab-callouts > li.hot { border-color: var(--accent-line); border-left-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
ol.lab-callouts > li:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
ol.lab-callouts .co-n { min-width: 2.2ch; padding: 0 .35ch; border: 1px solid var(--accent); border-radius: var(--r); font: 600 12px/1.55 var(--mono); color: var(--ink); text-align: center; }
ol.lab-callouts > li.hot .co-n { background: var(--accent); border-color: var(--accent); color: var(--hl-ink); }
.lab-try::before { content: "$ try this · break it"; content: "$ try this · break it" / "Try this, break it:"; color: var(--ink); }
.lab-try ul, .lab-look ul { margin: 0; padding-left: 1.3em; }
.lab-try li::marker { content: "→  "; color: var(--accent); }
.lab-real { padding: 13px 18px 14px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--panel); font-size: 16px; line-height: 1.62; }
.lab-real::before { content: "! --real · opt-in · costs money"; content: "! --real · opt-in · costs money" / "Real runs, opt-in, cost money:"; color: var(--ink); }
.lab-real > :last-child { margin-bottom: 0; }
.lab-real pre { margin: 10px 0; }
.lab-real .lab-real-safe { margin: 10px 0 0; font: 12.5px/1.55 var(--mono); color: var(--muted); }
.lab-real .lab-real-safe code { white-space: nowrap; }
.lab-look { padding: 14px 20px 14px; border: 1px solid var(--accent-line); border-radius: var(--r); background: var(--accent-soft); }
.lab-look::before { content: "✓ what to look for"; content: "✓ what to look for" / "What to look for:"; color: var(--ink); }
/* phones and tablets: labs run on a laptop (runtime note in the lab hero and the labs index); the zip link (hosted) */
.lab-laptop { display: none; max-width: var(--col-w); margin: 0 0 22px; padding: 10px 14px; border: 1px solid var(--accent-line); border-left-width: 2px;
  border-radius: var(--r); background: var(--accent-soft); font-size: 15px; line-height: 1.55; color: var(--text-2); }
.lab-laptop b { color: var(--ink); }
@media (max-width: 1023px), (pointer: coarse) { .lab-laptop { display: block; } }
.lab-hero .lab-laptop { margin: -14px 0 30px; }   /* right under the dek */
.page-hero .lab-laptop { margin: -10px 0 26px; }
.labs-dl { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 20px 0 0; font-size: 15px; }
.labs-dl-meta { font: 12px/1.4 var(--mono); color: var(--muted); }
.labs-dl-none { display: block; color: var(--muted); }
.lab-placeholder { padding: 12px 16px; border: 1px dashed var(--line-2); border-radius: var(--r); font: 13px/1.5 var(--mono); color: var(--muted); }
.rail-back { margin: 0 0 8px; font: 13px/1.45 var(--mono); }
.rail-back a { color: var(--text-2); text-decoration: none; }
.rail-back a:hover { color: var(--ink); }
.rail-topics a { font-size: 12.5px; color: var(--muted); }
/* labs index */
body.page-labs main#content { max-width: calc(var(--page-max) - 2 * var(--pad)); }
.lx-ms { margin-top: 18px; }
.lx-ms > .dek { font-size: 17px; margin: 0 0 18px; max-width: var(--col-w); }
.lx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 960px) { .lx-grid { grid-template-columns: minmax(0, 1fr); } }
.lx-sess { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); padding: 13px 16px 12px; }
.lx-sess h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 8px; font: 600 16px/1.35 var(--font); }
.lx-sess h3 .n { font: 500 12.5px var(--mono); color: var(--ms, var(--accent)); }
.lx-sess h3 a { color: var(--ink); }
.lx-sess .lx-readme { margin-left: auto; font: 12px/1.4 var(--mono); }
.lx-sess .lx-readme a { color: var(--text-2); }
.lx-sess ul { margin: 0; padding: 0; list-style: none; }
.lx-sess li { margin: 0; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14.5px; line-height: 1.5; color: var(--text-2); }
.lx-sess li > a { display: inline-block; margin-bottom: 2px; font: 500 13px/1.45 var(--mono); color: var(--ink); }
.lx-sess li > a code { font-size: 1em; padding: 0; background: none; }
.lx-sess li .lx-what { display: block; }

/* ---------- Hub ---------- */
body.page-hub main#content, body.page-cheatsheets main#content { max-width: calc(var(--page-max) - 2 * var(--pad)); }
body.page-glossary main#content { max-width: var(--wide); margin: 0; }
.page.no-sidebar main > h2[data-cmd] { margin: 72px 0 14px; padding-top: 28px; border-top: 1px solid var(--line); }
.page.no-sidebar main > :is(.hub-hero, .page-hero) + h2[data-cmd] { margin-top: 44px; padding-top: 0; border-top: 0; }
.recs > p { grid-column: 1 / -1; }
.page.no-sidebar main > h3 { font: 600 19px/1.35 var(--font); margin: 34px 0 12px; }
.page.no-sidebar main > p { max-width: var(--col-w); }
.hub-hero { padding: 8px 0 44px; border-bottom: 1px solid var(--line); }
.page-hero { padding: 8px 0 8px; }
.page-hero .dek { margin-bottom: 26px; }
.hub-hero h1 { max-width: 24ch; }
.hub-hero .dek { max-width: 46em; font-size: 18.5px; line-height: 1.66; }
.hub-hero dl.meta { grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0 0 30px; max-width: var(--wide); }
.hub-hero .stat-row { max-width: var(--wide); margin: 0 0 18px; }
.hub-hero .stat { background: var(--panel); border-color: var(--line-2); }
.cmap { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .cmap { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .cmap { grid-template-columns: minmax(0, 1fr); } }
.cmap-col { display: flex; flex-direction: column; gap: 8px; }
.cmap-head { margin-bottom: 4px; }
.cmap-head b { display: block; font: 600 13px/1.4 var(--mono); color: var(--ms); }
.cmap-head b::before { content: "~/"; content: "~/" / ""; }
.cmap-head span { display: block; min-height: 3em; font: 11.5px/1.45 var(--mono); color: var(--muted); }
.cmap-tile {
  position: relative; overflow: hidden; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 3px 8px; align-items: baseline;
  padding: 10px 12px 13px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  text-decoration: none; transition: opacity .2s, border-color .2s;
}
.cmap-tile:hover { border-color: var(--ms); color: var(--ink); }
.cmap-tile .n { font: 600 12px/1.3 var(--mono); color: var(--ms); }
.cmap-tile .t { font: 600 14.5px/1.3 var(--font); }
.cmap-tile .p { font: 11.5px/1.3 var(--mono); color: var(--muted); }
.cmap-tile.complete .p { color: var(--ok); }
.cmap-tile .sub { grid-column: 2 / 4; font: 12px/1.45 var(--font); color: var(--muted); }
.cmap-tile .fill { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--ms); }
.cmap-tile.hl { border-color: var(--ms); box-shadow: 0 0 0 1px var(--ms); }
.cmap-tile.dim { border-color: var(--line); background: color-mix(in srgb, var(--panel) 45%, var(--bg)); }
.cmap-tile.dim :is(.n, .t, .p, .sub) { color: var(--muted); }
.cmap-tile.dim .fill { opacity: .35; }
.milestones { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.ms-card { position: relative; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); padding: 18px 18px 14px; overflow: hidden; }
.ms-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--ms); }
.ms-card .ms-eyebrow { font: 500 12.5px/1.4 var(--mono); color: var(--ms); }
.ms-card h3 { margin: 8px 0 8px; font: 600 19px/1.32 var(--font); letter-spacing: -.01em; color: var(--ink); }
.ms-card .goal { color: var(--text-2); font-size: 15px; line-height: 1.55; margin: 0 0 10px; }
.ms-card .prog { font: 12px/1.5 var(--mono); color: var(--muted); margin-bottom: 10px; }
.ms-card .ms-ascii { display: block; font: 13px/1 var(--mono); color: var(--ink); white-space: pre; letter-spacing: -.02em; margin: 0 0 12px; }
.ms-card ol { list-style: none; padding: 0; margin: 0; }
.ms-card li { margin: 0; }
.ms-card li a { display: flex; gap: 10px; align-items: baseline; padding: 5px 6px; border-radius: var(--r); color: var(--ink); font-size: 15px; text-decoration: none; }
.ms-card li a:hover { background: var(--panel-2); }
.ms-card li a .n { width: 22px; flex: none; font: 600 12px var(--mono); color: var(--ms); }
.ms-card li a .pct { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.ms-card li a.complete .pct { color: var(--ok); }
.outcome-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 210px; gap: 14px; align-items: center; padding: 13px 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); margin: 8px 0; max-width: var(--wide); }
.outcome-row .on { font: 600 15px var(--mono); color: var(--muted); }
.outcome-row h3 { margin: 0; font: 600 16px/1.4 var(--font); color: var(--ink); }
.outcome-row p { margin: 3px 0 0; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.rating { display: flex; gap: 4px; justify-content: flex-end; }
.rating button { width: 34px; height: 30px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text-2); cursor: pointer; font: 600 13px var(--mono); }
.rating button:hover { border-color: var(--accent); color: var(--ink); }
.rating button.on { background: var(--accent); color: var(--hl-ink); border-color: var(--accent); }
@media (max-width: 760px) { .outcome-row { grid-template-columns: minmax(0, 1fr); } .rating { justify-content: flex-start; } }
.recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; max-width: var(--wide); }
.rec { border: 1px solid var(--line-2); border-radius: var(--r); padding: 11px 14px 12px; background: var(--panel); font-size: 15px; }
.rec .small { font: 11.5px/1.5 var(--mono); }
.rec .why { font: 12px/1.5 var(--mono); color: var(--muted); }
body.page-hub .compare-cards { max-width: var(--wide); }
/* the hub's front door: one card that links the intro machine */
.hero-door {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 18px; align-items: center; max-width: var(--wide);
  margin: -6px 0 34px; padding: 14px 18px 15px; border: 1px solid var(--accent-line); border-radius: var(--r);
  background: var(--accent-soft); color: var(--ink); text-decoration: none; transition: border-color .15s;
}
.hero-door:hover { border-color: var(--accent); color: var(--ink); }
.hero-door .hd-k { grid-column: 1; font: 500 12px/1.5 var(--mono); color: var(--ink); }
.hero-door .hd-k::before { content: "▍"; content: "▍" / ""; color: var(--accent); }
.hero-door .hd-t { grid-column: 1; font: 500 18px/1.35 var(--mono); letter-spacing: -.01em; color: var(--ink); }
.hero-door .hd-s { grid-column: 1; font: 15.5px/1.5 var(--font); color: var(--text-2); }
.hero-door .hd-go { grid-column: 2; grid-row: 1 / span 3; font: 500 14px/1 var(--mono); color: var(--ink); white-space: nowrap; }
.hero-door .hd-go::before { content: "❯ "; content: "❯ " / ""; color: var(--accent); }
.hero-door:hover .hd-go { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
@media (max-width: 720px) { .hero-door { grid-template-columns: minmax(0, 1fr); } .hero-door .hd-go { grid-column: 1; grid-row: auto; margin-top: 8px; } }

/* ---------- Intro page: the machine as a lit exhibit, the session map ---------- */
body.page-intro main#content { max-width: 1100px; }
body.page-intro .page-hero { padding: 8px 0 36px; border-bottom: 1px solid var(--line); }
body.page-intro .page-hero .dek { max-width: var(--col-w); }
body.page-intro .page-hero dl.meta { margin: 0; }
@media (min-width: 960px) { body.page-intro .page-hero dl.meta { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
body.page-intro main > ul, body.page-intro main > ol { max-width: var(--col-w); }
body.page-intro main > ul > li { margin: .4em 0; }
/* the Colorfigures paper stays ivory in both themes: a lit card on the graphite workbench */
figure.viz.exhibit { --x-paper: #F2EFE7; --x-glow: color-mix(in srgb, #F2EFE7 11%, transparent); }
[data-theme="light"] figure.viz.exhibit { --x-glow: rgba(28, 36, 20, .10); }
figure.viz.exhibit > .viz-body {
  padding: 18px 18px 20px;
  background-color: var(--f-bg);
  background-image: radial-gradient(ellipse 70% 60% at 50% 42%, var(--x-glow), transparent 72%), radial-gradient(circle, var(--f-grid) .8px, transparent 1px);
  background-size: auto, 8px 8px;
}
.exhibit-frame {
  display: block; width: 100%; height: 760px; border: 0; border-radius: var(--r); background: var(--x-paper);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 26px 60px -26px rgba(0, 0, 0, .85), 0 0 90px -20px var(--x-glow);
}
[data-theme="light"] .exhibit-frame { box-shadow: 0 0 0 1px var(--line-2), 0 22px 48px -26px rgba(28, 36, 20, .45); }
@media (max-width: 720px) { figure.viz.exhibit > .viz-body { padding: 10px; } .exhibit-frame { height: 680px; } }
/* session map: one tree per milestone */
.smap { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 26px; margin: 18px 0 8px; }
@media (max-width: 1100px) { .smap { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .smap { grid-template-columns: minmax(0, 1fr); } }
.smap-ms { min-width: 0; }
.smap-ms h3 { margin: 0 0 4px; font: 600 14px/1.4 var(--mono); letter-spacing: 0; color: var(--ink); }
.smap-ms h3 .p { color: var(--ms, var(--accent)); }
.smap-ms .smap-goal { margin: 0 0 12px; min-height: 6em; font: 13px/1.5 var(--font); color: var(--muted); }
@media (max-width: 600px) { .smap-ms .smap-goal { min-height: 0; } }
.smap .tree a { font: 13.5px/1.45 var(--mono); padding: 4px 0; color: var(--ink); }
.smap .tree a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ms, var(--accent)); }
.smap .tree .sn { color: var(--ms, var(--accent)); }
.smap .tree li { margin: 0 0 6px; }
.smap .tree .st { display: block; margin: 0 0 0 4px; padding: 0 0 4px 27px; border-left: 1px solid var(--faint); font: 12px/1.45 var(--mono); color: var(--muted); }
.smap .tree li:last-child .st { border-left-color: transparent; }
.smap .tree a.done .tl::after { content: " ✓"; content: " ✓" / " done"; color: var(--ok); }

/* ---------- Glossary ---------- */
.gloss-search { position: sticky; top: var(--topbar-h); z-index: 10; background: var(--bg); padding: 12px 0 12px; }
.gloss-search input { width: 100%; font: 15px/1.4 var(--mono); padding: 11px 14px; background: var(--panel); }
.alpha { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 14px; }
.alpha a { font: 12.5px/1 var(--mono); padding: 5px 7px; border-radius: var(--r); border: 1px solid var(--line-2); color: var(--text-2); text-decoration: none; }
.alpha a:hover { border-color: var(--accent); color: var(--ink); }
#gloss-list { margin: 8px 0 0; }
.gloss-entry { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: 4px 28px; padding: 15px 0; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--topbar-h) + 80px); }
.gloss-entry dt { grid-column: 1; grid-row: 1 / span 2; font: 600 15px/1.45 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.gloss-entry dt .small { display: block; font: 12px/1.45 var(--mono); font-weight: 400; margin-top: 3px; }
.gloss-entry dd { grid-column: 2; margin: 0; color: var(--text-2); font-size: 16.5px; line-height: 1.62; }
.gloss-entry .src { font: 12px/1.5 var(--mono); color: var(--muted); }
@media (max-width: 760px) { .gloss-entry { grid-template-columns: minmax(0, 1fr); } .gloss-entry dt, .gloss-entry dd { grid-column: 1; grid-row: auto; } }

/* ---------- Cheat sheets ---------- */
.cs-ms { margin-top: 56px; }
.cs-ms > .dek { font-size: 17px; margin: 0 0 6px; }
.cs-ms > .cs-path { font: 12.5px/1.5 var(--mono); color: var(--muted); margin: 0 0 8px; }
.cs-ms > h3 { font: 600 18px/1.35 var(--font); margin: 30px 0 12px; }
.cs-ms > h3 .n { font: 500 13px var(--mono); color: var(--ms, var(--accent)); margin-right: 10px; }
.cs-grid { columns: 3 290px; column-gap: 14px; }
.cs-block { break-inside: avoid; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); padding: 13px 16px 12px; margin: 0 0 14px; }
.cs-block .from { font: 11.5px/1.4 var(--mono); color: var(--muted); }
.cs-block h4 { margin: 4px 0 6px; font: 600 15.5px/1.35 var(--font); color: var(--ink); }
.cs-block ul { margin: 4px 0 0; padding-left: 1.1em; font-size: 14.5px; line-height: 1.55; }

/* ---------- Misc ---------- */
.kbd-legend { font: 12px var(--mono); color: var(--muted); }
.hidden { display: none !important; }
.fade-in { animation: fade .3s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes dash { to { stroke-dashoffset: -18; } }
.flowing path { stroke-dasharray: 6 6; animation: dash .6s linear 12; }
.toast {
  position: fixed; bottom: calc(var(--status-h) + 18px); left: 50%; transform: translateX(-50%); z-index: 90;
  padding: 10px 16px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  font: 13px/1.4 var(--mono); color: var(--ink);
}

/* ---------- Wide frames, notes column (≥ 1240 px; below that see Responsive) ---------- */
@media (min-width: 1240px) {
  .page.has-rail .session-hero { margin-right: calc(-1 * (var(--note-w) + var(--gap))); }
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > :is(figure.viz, .widget),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > .tabs:has(> .tab > :is(figure.viz, .widget)),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > .table-wrap:has(tr > :nth-child(4)),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > .compare-cards:has(> :nth-child(3)),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > pre.pre-wide {
    margin-right: calc(-1 * (var(--note-w) + var(--gap))); clear: right;
  }
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > aside.note {
    float: right; clear: right; width: var(--note-w); margin: 4px calc(-1 * (var(--note-w) + var(--gap))) 18px 0;
    padding: 0 0 0 14px; border-left: 1px solid var(--line-2);
  }
  /* lab sheets: real-output panels, long commands and wide tables span the article and notes columns */
  section.lab-sheet > :is(figure.lab-out, pre.pre-wide, .table-wrap:has(tr > :nth-child(4))) { margin-right: calc(-1 * (var(--note-w) + var(--gap))); clear: right; }
  section.lab-sheet > aside.note {
    float: right; clear: right; width: var(--note-w); margin: 4px calc(-1 * (var(--note-w) + var(--gap))) 18px 0;
    padding: 0 0 0 14px; border-left: 1px solid var(--line-2);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1399px) { :root { --rail-w: 220px; --gap: 44px; --note-w: 200px; } }
/* Below 1240 px: one column. The rail hides behind ≡ (an overlay), so frames keep a readable scale: the content is as
   wide as the article plus notes columns (--wide) and figures, widgets and the other wide blocks (the ≥ 1240 list
   above) use all of it, while prose, notes and narrow blocks keep the article measure (--col-w). */
@media (max-width: 1239px) {
  .page.has-rail { display: block; }
  .page.has-rail > main#content { max-width: var(--wide); }
  .menu-toggle { display: inline-block; }
  .sidebar {
    position: fixed; z-index: 60; top: var(--topbar-h); bottom: var(--status-h); left: 0; height: auto; align-self: auto; width: min(320px, 88vw);
    padding: 0 18px; background: var(--bg); border-right: 1px solid var(--line-2); box-shadow: var(--shadow);
    transform: translateX(-102%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
  }
  .sidebar .rail-in { padding-top: 22px; }
  body.sb-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  body.sb-open::after { content: ""; position: fixed; inset: var(--topbar-h) 0 var(--status-h) 0; z-index: 55; background: rgba(0, 0, 0, .45); }
}
@media screen and (max-width: 1239px) {
  /* the article measure for everything except frames and the wide blocks; topic headings span the section rule, so
     their 01/06 counter sits at its right end */
  .page.has-rail > main#content > :not(.session-hero, .session-intro, section, article),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > :not(article, section, h2, figure.viz, .widget, .tabs, .table-wrap, .compare-cards, pre),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > .tabs:not(:has(> .tab > :is(figure.viz, .widget))),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > .table-wrap:not(:has(tr > :nth-child(4))),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > .compare-cards:not(:has(> :nth-child(3))),
  :is(article.concept, section.topic, .session-intro, section.wrap-up) > pre:not(.pre-wide) { max-width: var(--col-w); }
  section.lab-sheet > :not(h2, figure.lab-out, pre, .table-wrap),
  section.lab-sheet > pre:not(.pre-wide) { max-width: var(--col-w); }
}
@media (max-width: 959px) {
  :root { --pad: 20px; }
  .page.has-rail > main#content { padding-top: 28px; }
  .session-hero h1, .hub-hero h1, .page-hero h1 { font-size: 36px; }
  .dek, .session-hero .goal { font-size: 18px; }
  dl.meta, .hub-hero dl.meta { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .statusline .sl-win a:not(.on) { display: none; }
  .fig-f { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .ctrl { grid-template-columns: 110px minmax(0, 1fr) 60px; }
}
@media (max-width: 560px) {
  /* a long typed command wraps instead of being cut off */
  .hero-cmd { align-items: flex-start; line-height: 1.4; padding: 8px 12px; }
  .hero-cmd .typed { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
  .hero-cmd .cursor { align-self: flex-end; margin-bottom: 2px; }
}
@media (max-width: 720px) {
  .tb-nav { display: none; }
  /* no rail to hold the course links: the nav wraps onto a second, scrollable row */
  html.no-rail { --topbar-h: 88px; }
  html.no-rail .topbar { flex-wrap: wrap; align-content: center; row-gap: 10px; column-gap: 14px; }
  html.no-rail .tb-nav { display: flex; order: 3; flex: 1 1 100%; margin-left: 0; gap: 10px; font-size: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  html.no-rail .tb-nav::-webkit-scrollbar { display: none; }
  .tb-theme { margin-left: auto; border-left: 0; padding-left: 0; }
  .page.has-rail > main#content { font-size: 17px; }
  /* phone frames: fig number and tag share the first row, the title block takes the full width below them */
  .fig-h { flex-wrap: wrap; gap: 6px 12px; }
  .fig-h .fig-hd { order: 3; flex: 1 1 100%; }
  .fig-h .fig-tag { margin-left: auto; padding-top: 2px; }
  .statusline .sl-segs { display: none; }
  .topbar .tb-prog { display: none; }   /* phones: the status line's ⇅ button does it */
  /* the status line's progress button shrinks to "⇅" (or "⇅ 12 new"), so the window name keeps its room */
  .statusline .sl-prog { min-width: 44px; justify-content: center; padding: 0 12px; margin-right: -14px; }
  .statusline .sl-prog .sl-pl { display: none; }
  .statusline .sl-prog .sl-ps:not(:empty) { display: inline; }
  dialog.c-dlg { width: calc(100vw - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .dlg-b { padding: 12px 14px 16px; }
}
/* Tap targets on phones and touch screens (a phone in landscape is wider than 720 px): the status line and the dialogs'
   controls are 44 px tall */
@media (max-width: 720px), (pointer: coarse) {
  :root { --status-h: 44px; }
  .dlg-x { width: 44px; height: 44px; }
  dialog.c-dlg .btn, .pg-hub .btn, .pg-nudge .btn { min-height: 44px; }
  dialog.c-dlg .pg-field, .pg-hub .pg-field { min-height: 44px; font-size: 16px; }   /* 16 px: iOS doesn't zoom into the field */
}
@media (max-width: 360px) {
  /* narrower than the five links: the row scrolls, and its right edge fades so the cut is visible */
  html.no-rail .tb-nav { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); padding-right: 24px; }
}

/* ---------- Narrow screens (< 1024 px): readable pans, the expand view (course.js "narrow"; DS-NOTES §10) ----------
   The runtime sets these attributes only below 1024 px and removes them above, so wider screens never match. */
[data-nr~="pan"], [data-nr~="grow"] { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
[data-nr~="pan"] > svg, [data-nr~="grow"] > svg, [data-nr~="grow"] > div > svg { min-width: var(--nr-w) !important; max-width: none !important; }
.nr-wrap { display: block; }
[data-nr~="contain"] { contain: inline-size; }   /* the min-width stays inside the pan, never widens what holds it */
[data-nr]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fig-h .nr-x {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin: -6px 0; padding: 0 11px;
  font: 500 12.5px/1 var(--mono); color: var(--ink); background: transparent; border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer;
}
.fig-h .nr-x span { color: var(--accent); font-size: 14px; }
.fig-h .nr-x:hover { border-color: var(--accent); }
.fig-h:has(> .nr-hint) { flex-wrap: wrap; }
.fig-h .nr-hint { order: 5; flex: 1 1 100%; font: 12px/1.4 var(--mono); color: var(--f-muted); }
.widget > .fig-h .nr-hint { color: var(--muted); }
html.nr-lock { overflow: hidden; }
.nr-ph { display: block; }
dialog.nr-dlg {   /* a child of main#content: !important beats the article measure that main's children get below 1240 px */
  width: 100vw !important; height: 100vh; height: 100dvh; max-width: none !important; max-height: none; margin: 0 !important; border: 0; border-radius: 0; box-shadow: none;
  background: var(--bg);
}
.nr-dlg .dlg-h { flex-wrap: wrap; }
.nr-dlg .dlg-t { font-size: 13.5px; }
.nr-dlg .nr-turn { display: none; order: 3; flex: 1 1 100%; font: 12px/1.4 var(--mono); color: var(--muted); }
@media (orientation: portrait) and (pointer: coarse) and (max-height: 1023px) { .nr-dlg .nr-turn { display: block; } }   /* phones: their landscape stays below 1024 px */
.nr-body { padding: 8px 8px 28px; }
.nr-body > :is(figure.viz, .widget) { margin: 0; }
.nr-body > figure.viz > .viz-body, .nr-body > .widget > .widget-body { padding-left: 8px; padding-right: 8px; }   /* fit the width: in landscape most drawings then need no pan */
.nr-dlg .fig-h :is(.nr-x, .nr-hint) { display: none; }

/* Narrow screens: inline controls shrink to the frame instead of being cut off by it (a select is as wide as its
   longest option; in a flex row its label wouldn't shrink below that) */
@media (max-width: 1023px) {
  .ctrl-inline { min-width: 0; max-width: 100%; flex-wrap: wrap; }
  .ctrl-inline > :is(select, input) { min-width: 0; max-width: 100%; flex: 0 1 auto; }
  :is(figure.viz, .widget) :is(select, input[type="text"], input[type="search"], input:not([type])) { max-width: 100%; }
}

/* Tap targets on phones and touch screens: shared controls are at least 44 px (figures' own SVG parts are the pages') */
@media (max-width: 720px), (pointer: coarse) {
  .btn, button.btn, .tab-bar button, .rating button, .fc-nav .btn, .fig-h .nr-x, .lab .lab-go a { min-height: 44px; }
  .fig-h .nr-x { margin: -10px 0; }
  .btn.icon, .tb-btn { min-width: 44px; }
  .btn, button.btn, .tab-bar button, .rating button { min-width: 44px; }
  details > summary { min-height: 44px; padding-block: 10px; }   /* disclosure rows; deep dives and plain details keep their own padding */
  /* buttons inside figures and widgets (step lists, column heads, keycaps, tabs): a 44 px target */
  :is(figure.viz, .widget) button { min-height: 44px; min-width: 44px; }
  /* labs index and cheat sheets: session headings and README links are links on their own line */
  .lx-ms h3 > a, .cs-ms h3 > a, .lx-readme a { display: inline-flex; align-items: center; min-height: 44px; }
  .tb-btn, .tb-theme, .tb-prog, .topbar .brand { min-height: 44px; }
  .tb-theme, .tb-prog { display: inline-flex; align-items: center; gap: .6ch; }   /* the space between the key and the label collapses in flex */
  html.no-rail .topbar { row-gap: 0; }
  html.no-rail .tb-nav a { display: inline-flex; align-items: center; gap: .6ch; min-height: 44px; }
  select, input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="url"], input:not([type]) { min-height: 44px; }
  input[type="range"] { min-height: 44px; }
  .quiz-opt { min-height: 44px; }
  /* checkbox and radio labels in figures and widgets (all flex rows, mostly .ctrl-inline): a 44 px tall row */
  :is(figure.viz, .widget) label:has(> input[type="checkbox"], > input[type="radio"]) { min-height: 44px; }
  .alpha a { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; }
  .sidebar .tree a, .sidebar .rail-links a, .rail-back a { min-height: 44px; align-content: center; }
  .sidebar .rail-links a, .rail-back a { display: flex; align-items: center; }
  .statusline .sl-win { align-self: stretch; }
  .statusline .sl-win a { display: inline-flex; align-items: center; }
  pre:has(> .copy-btn) { padding-top: 54px; }
  .copy-btn { min-height: 44px; min-width: 64px; }
  pre[data-lang]::after { top: 18px; right: auto; left: 18px; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .cursor, .flowing path, .fade-in { animation: none !important; }
}

/* ---------- Print: light tokens, light code, no chrome ---------- */
@media print {
  :root, [data-theme] {
    color-scheme: light;
    --bg: #fff; --bg-2: #F6F7F2; --panel: #fff; --panel-2: #EEF0E8; --panel-3: #E6E9DF; --line: #D9DCD1; --line-2: #BFC4B6;
    --ink: #111411; --text: #111411; --text-2: #2C322C; --muted: #555C54; --faint: #A1A79C;
    --core: #466C00; --agents: #006F5A; --delivery: #905300; --autonomy: #A9257F; --hl-ink: #fff;
    --ok: #386E1B; --warn: #735E00; --bad: #AE301C; --info: #2B6690; --violet: #6A4BBF;
    --f-bg: #fff; --f-line: #959B8F; --f-ink: #1C211C; --f-muted: #555C54; --f-top: #fff; --f-left: #EBEDE4; --f-right: #DDE0D5; --f-detail: #CBD0C2;
    /* code prints light, so it reads on paper with or without background graphics */
    --code-bg: #F6F7F2; --code-text: #111411; --code-line: #BFC4B6; --code-muted: #555C54;
  }
  /* code surfaces take the page's print tokens (on screen the light theme gives them dark-theme values) */
  [data-theme] :is(pre, .out, .lab-term) {
    --bg: inherit; --bg-2: inherit; --panel: inherit; --panel-2: inherit; --panel-3: inherit; --line: inherit; --line-2: inherit;
    --ink: inherit; --text: inherit; --text-2: inherit; --muted: inherit; --faint: inherit; --accent: inherit; --hl-ink: inherit; --soft: inherit;
    --ok: inherit; --warn: inherit; --bad: inherit; --info: inherit; --violet: inherit;
    --core: inherit; --agents: inherit; --delivery: inherit; --autonomy: inherit;
    --accent-soft: inherit; --accent-line: inherit; --ok-soft: inherit; --warn-soft: inherit; --bad-soft: inherit; --info-soft: inherit; --violet-soft: inherit;
  }
  body, body[data-milestone] {
    --code-acc: var(--accent);
    --tok-kw: var(--accent); --tok-key: color-mix(in oklab, var(--accent) 80%, var(--ink)); --tok-str: var(--ok);
    --tok-num: var(--warn); --tok-fn: var(--info); --tok-com: var(--code-muted);
  }
  body { --f-grid: transparent; padding: 0 !important; background: #fff; }
  .topbar, .sidebar, .statusline, .topic-complete, .pager, .copy-btn, .menu-toggle, .skip-link, .hero-cmd, .toast, .term-pop, .pg-nudge, dialog.c-dlg, .pg-hub, #reset-btn, .nr-x, .nr-hint, .lab-laptop { display: none !important; }
  [data-nr] { overflow: visible !important; contain: none !important; }
  [data-nr] > svg, [data-nr] > div > svg { min-width: 0 !important; }   /* a printout fits the page instead of panning */
  #cs-filter, #gloss-filter, .alpha, .gloss-search { display: none !important; }
  .page, .page.has-rail { display: block; max-width: none; padding: 0; }
  .page.has-rail > main#content { padding: 0; max-width: none; }
  aside.note { float: none !important; width: auto !important; margin: 0 0 12px !important; }
  figure.viz, .widget, .tabs, .table-wrap, .compare-cards, .session-hero { margin-right: 0 !important; }
  figure.viz, .widget, details.deep-dive, .quiz, .cs-block { break-inside: avoid; }
  details.deep-dive > :not(summary) { display: block; }
  a { color: inherit; }
  /* code wraps instead of being clipped at the page edge */
  pre, .out { white-space: pre-wrap; overflow: visible; max-height: none; overflow-wrap: anywhere; }
  pre code { white-space: inherit; overflow-wrap: anywhere; }
  pre[data-lang]::after { right: 10px; }
  /* every tab panel prints, each under its tab label */
  .tab-bar { display: none; }
  .tabs > .tab { display: block; }
  .tabs > .tab + .tab { border-top: 1px dashed var(--line-2); }
  .tabs > .tab::before { content: attr(data-tab-label); display: block; margin: 12px 0 2px; font: 500 12px/1.4 var(--mono); color: var(--muted); }
  /* cheat sheets: denser, so a milestone takes a few pages rather than one per session */
  body.page-cheatsheets .page-hero .dek { margin-bottom: 12px; }
  body.page-cheatsheets .cs-ms { margin-top: 24px; }
  body.page-cheatsheets .cs-ms > h3 { margin: 16px 0 6px; font-size: 15px; break-after: avoid; }
  body.page-cheatsheets .cs-grid { columns: 2; column-gap: 10px; }
  body.page-cheatsheets .cs-block { padding: 7px 10px 6px; margin: 0 0 8px; }
  body.page-cheatsheets .cs-block h4 { margin: 2px 0 3px; font-size: 13.5px; }
  body.page-cheatsheets .cs-block ul { font-size: 12.5px; line-height: 1.42; }
  body.page-cheatsheets .cs-block li { margin: .12em 0; }
}
