/* ============================================================
   THE AI ENGINEER'S FIELD MANUAL — design system
   Identity: graph-paper precision meets Head First warmth.
   Type: Bricolage Grotesque (display/UI) · Source Serif 4 (prose)
         JetBrains Mono (code, data, diagram labels)
   ============================================================ */

/* ---------- Fonts (variable, self-contained) ---------- */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(fonts/bricolage-var.woff2) format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url(fonts/sourceserif-var.woff2) format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url(fonts/sourceserif-var-italic.woff2) format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url(fonts/jetbrains-var.woff2) format('woff2');
}

/* ---------- Tokens: light (bare :root) ---------- */
:root {
  --paper:      #F6F7F4;
  --card:       #FFFFFF;
  --card-2:     #EFF1EC;   /* recessed panel */
  --ink:        #1C2430;
  --muted:      #5A6472;
  --line:       #D9DDD4;
  --line-soft:  #E6E9E2;
  --accent:     #2457C5;   /* drafting blue */
  --accent-soft:#E4EBFA;   /* accent tint ground */
  --on-accent:  #FFFFFF;
  --mark:       #FFD84A;   /* highlighter yellow */
  --mark-ink:   #4A3B00;
  --good:       #1D7A4F;
  --good-soft:  #E1F0E7;
  --warn:       #A8641C;
  --warn-soft:  #F6EBDB;
  --bad:        #B0392E;
  --bad-soft:   #F7E5E2;
  --code-bg:    #10151D;   /* code stays dark in both themes */
  --code-ink:   #D9E0EA;
  --code-head:  #1A2230;
  --code-head-ink:#8FA0B8;
  --grid-line:  rgba(36, 87, 197, 0.07);  /* graph paper */
  --shadow:     0 1px 2px rgba(28,36,48,.06), 0 8px 24px rgba(28,36,48,.07);
}

/* ---------- Tokens: dark (system preference) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #12161E;
    --card:       #1A2029;
    --card-2:     #151B23;
    --ink:        #E6E9E4;
    --muted:      #97A1AD;
    --line:       #2B3441;
    --line-soft:  #232B36;
    --accent:     #7DA3F2;
    --accent-soft:#1D2A44;
    --on-accent:  #0E1523;
    --mark:       #E3BC3F;
    --mark-ink:   #141000;
    --good:       #52B384;
    --good-soft:  #16281F;
    --warn:       #D19A55;
    --warn-soft:  #2C2317;
    --bad:        #E07B6E;
    --bad-soft:   #2F1D1A;
    --code-bg:    #0C1118;
    --code-ink:   #D5DCE6;
    --code-head:  #131A24;
    --code-head-ink:#7E8FA6;
    --grid-line:  rgba(125, 163, 242, 0.06);
    --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}

/* ---------- Tokens: explicit dark toggle ---------- */
:root[data-theme="dark"] {
  --paper:      #12161E;
  --card:       #1A2029;
  --card-2:     #151B23;
  --ink:        #E6E9E4;
  --muted:      #97A1AD;
  --line:       #2B3441;
  --line-soft:  #232B36;
  --accent:     #7DA3F2;
  --accent-soft:#1D2A44;
  --on-accent:  #0E1523;
  --mark:       #E3BC3F;
  --mark-ink:   #141000;
  --good:       #52B384;
  --good-soft:  #16281F;
  --warn:       #D19A55;
  --warn-soft:  #2C2317;
  --bad:        #E07B6E;
  --bad-soft:   #2F1D1A;
  --code-bg:    #0C1118;
  --code-ink:   #D5DCE6;
  --code-head:  #131A24;
  --code-head-ink:#7E8FA6;
  --grid-line:  rgba(125, 163, 242, 0.06);
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3, h4, .display {
  font-family: 'Bricolage Grotesque', 'Avenir Next', 'Segoe UI', sans-serif;
  line-height: 1.15;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); font-weight: 800; margin: 0 0 .5rem; }
h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); font-weight: 700; margin: 3rem 0 1rem; }
h3 { font-size: 1.22rem; font-weight: 650; margin: 2.2rem 0 .7rem; }
h4 { font-size: 1.02rem; font-weight: 650; margin: 1.6rem 0 .5rem; }
p, ul, ol { margin: 0 0 1.05rem; }
li { margin-bottom: .35rem; }
strong { font-weight: 650; }
hr { border: none; border-top: 1px solid var(--line); margin: 2.5rem 0; }

/* Eyebrow label above section titles */
.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: .4rem;
}

/* Highlighted key term (use sparingly, like a marker pen) */
.hl {
  background: linear-gradient(transparent 8%, var(--mark) 8%, var(--mark) 88%, transparent 88%);
  color: inherit;
  padding: 0 .15em;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hl { color: var(--mark-ink); font-weight: 600; }
}
:root[data-theme="dark"] .hl { color: var(--mark-ink); font-weight: 600; }

/* ---------- Page scaffold ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem clamp(1rem, 3vw, 2rem);
  font-family: 'Bricolage Grotesque', sans-serif;
}
.topbar .brand {
  font-weight: 800; font-size: .95rem; color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.topbar .brand .tick { color: var(--accent); }
.topbar nav { margin-left: auto; display: flex; gap: .9rem; align-items: center; font-size: .85rem; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover, .topbar nav a[aria-current="page"] { color: var(--accent); }
.theme-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: .25rem .6rem; cursor: pointer;
  font: inherit; font-size: .78rem;
}
.theme-btn:hover { color: var(--ink); border-color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem);
}
@media (min-width: 1080px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); gap: 3rem; }
}
.sidebar { display: none; }
@media (min-width: 1080px) {
  .sidebar {
    display: block;
    position: sticky; top: 3.2rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    padding: 1.6rem 0 2rem;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: .85rem;
  }
}
.sidebar .side-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .6rem;
}
.sidebar ol { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: block; color: var(--muted); text-decoration: none;
  padding: .28rem .6rem; border-left: 2px solid var(--line-soft);
}
.sidebar a:hover { color: var(--ink); border-left-color: var(--muted); }
.sidebar a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

main.content { min-width: 0; padding: 2rem 0 4rem; max-width: 74ch; }

/* Module hero */
.mod-hero { padding: 2.2rem 0 1rem; }
.mod-hero .modno {
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent);
}
.mod-hero .lede {
  font-size: 1.15rem; color: var(--muted); font-style: italic; max-width: 60ch;
}
.mod-meta {
  display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem;
  font-family: 'Bricolage Grotesque', sans-serif; font-size: .78rem;
}
.chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: .18rem .65rem; color: var(--muted); background: var(--card);
}
.chip.blue { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* Graph-paper band (hero backgrounds) */
.gridband {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* ---------- Course components ---------- */

/* Field report (THE HOOK): a client memo */
.hook {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin: 1.6rem 0 2rem;
  overflow: hidden;
}
.hook .hook-head {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
  padding: .5rem .95rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted);
}
.hook .hook-head::before { content: "▣"; color: var(--bad); }
.hook .hook-body { padding: 1.1rem 1.3rem .4rem; font-size: 1.02rem; }
.hook .hook-body p { font-style: italic; }   /* the whole field-report quote, however many paragraphs it runs to */
.hook .hook-from {
  padding: 0 1.3rem .95rem;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .85rem; color: var(--muted);
}

/* Brain Power: think before the answer is revealed */
.brain {
  border: 1.5px dashed var(--mark-ink);
  outline: 4px solid var(--mark);
  outline-offset: -5px;
  background: var(--card);
  border-radius: 8px;
  padding: 1rem 1.25rem .4rem;
  margin: 1.8rem 0;
}
:root[data-theme="dark"] .brain { border-color: var(--mark); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brain { border-color: var(--mark); }
}
.brain .brain-label {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  background: var(--mark); color: var(--mark-ink);
  display: inline-block; padding: .12rem .55rem; border-radius: 4px;
  margin: 0 0 .6rem;
}
.brain details { margin: .4rem 0 .9rem; }
.brain summary {
  cursor: pointer; font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .85rem; color: var(--accent); font-weight: 600;
}

/* Interview drill pages: collapsible answer inside each question */
.radar-q details.ans { margin: .35rem 0 .55rem; }
.radar-q details.ans > summary {
  cursor: pointer; list-style: none;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 650; font-size: .85rem; color: var(--accent);
}
.radar-q details.ans > summary::marker { content: ""; }
.radar-q details.ans > summary::-webkit-details-marker { display: none; }
.radar-q details.ans > summary::before { content: "▸ "; }
.radar-q details.ans[open] > summary::before { content: "▾ "; }
.radar-q details.ans[open] > summary { margin-bottom: .35rem; }

/* Under the Hood: optional math depth */
details.hood {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
  margin: 1.6rem 0;
}
details.hood > summary {
  cursor: pointer; list-style: none;
  padding: .7rem 1.1rem;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 650; font-size: .92rem; color: var(--ink);
}
details.hood > summary::before { content: "⚙ "; color: var(--muted); }
details.hood > summary::marker { content: ""; }
details.hood[open] > summary { border-bottom: 1px solid var(--line); }
details.hood .hood-body { padding: .9rem 1.2rem .3rem; font-size: .98rem; }

/* Step-by-step: collapsible plain-English algorithm above each code block */
details.algo {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  margin: 1.2rem 0 .5rem;
}
details.algo > summary {
  cursor: pointer; list-style: none;
  padding: .6rem 1.1rem;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 650; font-size: .9rem; color: var(--accent);
}
details.algo > summary::before { content: "☰ "; }
details.algo > summary::marker { content: ""; }
details.algo[open] > summary { border-bottom: 1px solid var(--line); }
details.algo .algo-body { padding: .8rem 1.3rem .5rem; font-size: .95rem; }
details.algo .algo-body ol { margin: .3rem 0 .8rem; padding-left: 1.3rem; }
details.algo .algo-body li { margin: .4rem 0; }

/* No Dumb Questions */
.faq { margin: 1.8rem 0; }
.faq .faq-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 1.05rem; margin-bottom: .8rem;
}
.faq dl { margin: 0; border-left: 3px solid var(--line); padding-left: 1.1rem; }
.faq dt { font-weight: 650; font-style: italic; margin-top: .9rem; }
.faq dt::before { content: "Q: "; color: var(--accent); font-style: normal; font-weight: 700; }
.faq dd { margin: .25rem 0 0; }
.faq dd::before { content: "A: "; color: var(--muted); font-weight: 700; }

/* The Lab: deliverable with acceptance criteria */
.lab {
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  background: var(--card);
  margin: 2rem 0;
  overflow: hidden;
}
.lab .lab-head {
  background: var(--accent); color: var(--on-accent);
  padding: .55rem 1.1rem;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700; font-size: .9rem; letter-spacing: .04em;
}
.lab .lab-body { padding: 1rem 1.25rem .4rem; }
.lab ul.checklist { list-style: none; padding-left: 0; }
.lab ul.checklist li { padding-left: 1.7em; position: relative; }
.lab ul.checklist li::before {
  content: "☐"; position: absolute; left: .2em; color: var(--accent); font-weight: 700;
}

/* Interview Radar */
.radar {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem .4rem;
  margin: 1.8rem 0;
}
.radar .radar-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--warn); margin-bottom: .5rem;
}
.radar .radar-label::before { content: "◎ "; }
.radar .radar-lede { color: var(--muted); font-size: .95rem; margin-top: 0; }
.radar .radar-q {
  border-top: 1px dashed var(--line);
  padding-top: 1rem;
  margin-top: 1.1rem;
}
.radar .radar-q:first-of-type { border-top: none; margin-top: .2rem; padding-top: 0; }
.radar .rq-question {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700; font-size: 1.04rem; line-height: 1.35;
  margin: 0 0 .5rem;
}
.radar .rq-k {
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--warn);
  margin-right: .3rem;
  white-space: nowrap;
}
.radar .rq-test { margin: .3rem 0 .6rem; color: var(--muted); font-size: .95rem; }
.radar .rq-answer {
  border-left: 3px solid var(--warn);
  padding: .05rem 0 .05rem .95rem;
  margin: .6rem 0;
}
.radar .rq-answer > p { margin: .45rem 0; }
.radar .rq-answer > ul { margin: .45rem 0; padding-left: 1.25rem; }
.radar .rq-answer > ul > li { margin: .3rem 0; }
.radar .rq-land { margin: .55rem 0 .3rem; }

/* Boardroom translation (business lens) */
.biz {
  border-left: 4px solid var(--good);
  background: var(--good-soft);
  border-radius: 0 8px 8px 0;
  padding: .9rem 1.2rem .3rem;
  margin: 1.8rem 0;
}
.biz .biz-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--good); margin-bottom: .5rem;
}
.biz .biz-label::before { content: "$ "; }

/* Watch it break (failure callout) */
.break {
  border-left: 4px solid var(--bad);
  background: var(--bad-soft);
  border-radius: 0 8px 8px 0;
  padding: .9rem 1.2rem .3rem;
  margin: 1.8rem 0;
}
.break .break-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--bad); margin-bottom: .5rem;
}
.break .break-label::before { content: "✗ "; }

/* You already know this (SWE bridge) */
.bridge {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  padding: .9rem 1.2rem .3rem;
  margin: 1.8rem 0;
}
.bridge .bridge-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .5rem;
}
.bridge .bridge-label::before { content: "↔ "; }

/* ---------- Code ---------- */
.codeblock {
  border-radius: 10px;
  overflow: hidden;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}
.codeblock .code-head {
  display: flex; align-items: center; gap: .7rem;
  background: var(--code-head); color: var(--code-head-ink);
  padding: .45rem .95rem;
  font-family: 'JetBrains Mono', monospace; font-size: .74rem;
}
.codeblock .code-head .fname { font-weight: 700; color: #C4CEDC; }
.codeblock .code-head .tag {
  margin-left: auto;
  border: 1px solid currentColor; border-radius: 999px;
  padding: .05rem .55rem; font-size: .66rem; letter-spacing: .05em;
  white-space: nowrap;
}
.codeblock .code-head .tag.offline { color: #6FCF97; }
.codeblock .code-head .tag.apikey { color: #F２C94C; }
.codeblock .code-head .tag.apikey { color: #F2C94C; }
.codeblock pre {
  margin: 0;
  background: var(--code-bg); color: var(--code-ink);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem; line-height: 1.6;
  tab-size: 4;
}
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .85em;
}
p code, li code, td code, dd code {
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: .05em .3em;
}
/* Syntax token classes (pre-highlighted spans) */
.tok-kw  { color: #C792EA; }  /* keyword */
.tok-str { color: #A5D6A7; }  /* string */
.tok-com { color: #64748B; font-style: italic; }  /* comment */
.tok-fn  { color: #82AAFF; }  /* function/call */
.tok-num { color: #F78C6C; }  /* number */
.tok-cls { color: #FFCB6B; }  /* class/type */

/* ---------- Figures & diagrams ---------- */
figure.diagram {
  margin: 1.8rem 0;
  padding: 1.3rem 1.2rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}
figure.diagram svg {
  display: block;
  margin: 0 auto;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink);
}
figure.diagram figcaption {
  margin-top: .9rem;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .85rem;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
  padding-top: .6rem;
}
figure.diagram figcaption .figno { font-weight: 700; color: var(--ink); }
/* Semantic diagram colors (work on both grounds) */
.dg-accent { color: var(--accent); }
.dg-good   { color: var(--good); }
.dg-bad    { color: var(--bad); }
.dg-warn   { color: var(--warn); }
.dg-muted  { color: var(--muted); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; margin: 1.5rem 0; }
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: .92rem;
  font-variant-numeric: tabular-nums;
}
table.data caption {
  text-align: left; font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .85rem; color: var(--muted); margin-bottom: .5rem;
}
table.data th {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .8rem; letter-spacing: .04em; text-transform: uppercase;
  text-align: left; color: var(--muted);
  border-bottom: 2px solid var(--ink);
  padding: .45rem .7rem;
}
table.data td { border-bottom: 1px solid var(--line-soft); padding: .5rem .7rem; vertical-align: top; }
table.data tr:hover td { background: var(--card-2); }

/* ---------- Recap & pager ---------- */
.recap {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 0 0 10px 10px;
  padding: 1.1rem 1.4rem .5rem;
  margin: 2.5rem 0;
}
.recap ul { list-style: none; padding-left: 0; }
.recap li { padding-left: 1.6em; position: relative; }
.recap li::before { content: "✓"; position: absolute; left: .1em; color: var(--good); font-weight: 700; }

.pager {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 3rem; padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-family: 'Bricolage Grotesque', sans-serif;
}
.pager a {
  text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .7rem 1rem; max-width: 46%;
  background: var(--card);
}
.pager a:hover { border-color: var(--accent); }
.pager .dir { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; display: block; }
.pager .next { margin-left: auto; text-align: right; }

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
footer.site {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.4rem clamp(1rem, 3vw, 2rem);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .8rem; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between;
}

/* ---------- Skill-test engine ---------- */
.quiz-shell { max-width: 74ch; }
.q-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.q-mode {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 1.1rem 1.2rem; cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  transition: border-color .12s ease, transform .12s ease;
}
.q-mode:hover { border-color: var(--accent); transform: translateY(-2px); }
.q-mode h3 { margin: 0 0 .35rem; font-family: 'Bricolage Grotesque', sans-serif; }
.q-mode p { margin: 0; font-size: .9rem; color: var(--muted); }
.q-topics { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0 1.2rem; }
.q-topic-chip {
  font-family: 'JetBrains Mono', monospace; font-size: .7rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem;
  background: var(--card); color: var(--muted);
}
.q-topic-chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.q-head { display: flex; align-items: center; gap: 1rem; margin: 1.4rem 0 .6rem; font-family: 'Bricolage Grotesque', sans-serif; font-size: .85rem; color: var(--muted); }
.q-timerbar { flex: 1; height: 6px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line-soft); overflow: hidden; }
.q-timerbar > div { height: 100%; background: var(--accent); transition: width 1s linear; }
.q-timerbar.q-low > div { background: var(--bad); }
.q-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.3rem 1.1rem; box-shadow: var(--shadow); }
.q-card .q-text { font-size: 1.05rem; margin-bottom: .8rem; }
.q-options { display: grid; gap: .55rem; margin-top: 1rem; }
.q-opt {
  text-align: left; font: inherit; font-size: .96rem; color: var(--ink);
  background: var(--card-2); border: 1.5px solid var(--line); border-radius: 8px;
  padding: .65rem .9rem; cursor: pointer;
}
.q-opt:hover:not(:disabled) { border-color: var(--accent); }
.q-opt:disabled { cursor: default; }
.q-opt.q-picked { border-color: var(--accent); background: var(--accent-soft); }
.q-opt.q-right { border-color: var(--good); background: var(--good-soft); }
.q-opt.q-wrong { border-color: var(--bad); background: var(--bad-soft); }
.q-opt code { background: none; border: none; }
.q-explain { border-left: 4px solid var(--good); background: var(--good-soft); border-radius: 0 8px 8px 0; padding: .8rem 1rem; margin-top: 1rem; font-size: .95rem; }
.q-actions { display: flex; gap: .8rem; margin-top: 1.2rem; flex-wrap: wrap; }
.q-btn {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 650; font-size: .92rem;
  border-radius: 8px; padding: .6rem 1.1rem; cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: 1.5px solid var(--accent);
}
.q-btn.ghost { background: none; color: var(--accent); }
.q-score {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 2.6rem;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.q-verdict { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; margin: .2rem 0 1rem; }
.q-verdict.pass { color: var(--good); }
.q-verdict.fail { color: var(--bad); }
.q-review { margin-top: 1.5rem; }
.q-review .q-rev-item { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 1rem; background: var(--card); }
.q-rev-item .q-rev-no { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 700; letter-spacing: .1em; }
.q-rev-item .ok { color: var(--good); } .q-rev-item .bad { color: var(--bad); }
.q-progressdots { font-family: 'JetBrains Mono', monospace; font-size: .78rem; white-space: nowrap; }

/* ---- Drill: "Likely follow-ups" block inside a revealed answer (added 2026-08-28) ---- */
.radar .rq-follow { margin: .7rem 0 .4rem; padding: .6rem .85rem; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 0 6px 6px 0; }
.radar .rq-follow > .rq-k { display: block; margin-bottom: .35rem; }
.radar .rq-follow dl { margin: 0; }
.radar .rq-follow dt { font-weight: 650; margin-top: .5rem; }
.radar .rq-follow dt::before { content: "↳ "; color: var(--accent); }
.radar .rq-follow dd { margin: .2rem 0 .2rem 1.1rem; }
.radar .rq-follow dd p { margin: .3rem 0; }
.radar .rq-answer > ol { margin: .45rem 0; padding-left: 1.25rem; }
.radar .rq-answer > ol > li { margin: .3rem 0; }

/* In brief: the jargon-free one-line definition that opens a concept.
   The first reader needs it before the story; the second reader scans for it. */
.inbrief {
  border-left: 4px solid var(--accent);
  background: var(--card-2);
  border-radius: 0 8px 8px 0;
  padding: .85rem 1.1rem;
  margin: 1.2rem 0 1.6rem;
  font-size: 1.06rem;
  line-height: 1.55;
}
.inbrief::before {
  content: "IN ONE LINE";
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: .66rem; font-weight: 700; letter-spacing: .14em;
  color: var(--muted);
  margin-bottom: .35rem;
}

/* Quick reference: the revisit anchor that closes a concept.
   Not a mastery checklist - the actual facts, restated for someone who
   already learned this and is hunting one of them six months later. */
.qref {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 1.05rem 1.25rem;
  margin: 1.8rem 0;
}
.qref .qref-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 1rem;
  margin: 0 0 .7rem;
}
.qref .qref-title::before { content: "↩ "; color: var(--accent); }
.qref dl { margin: 0; }
.qref dt {
  font-weight: 700; margin-top: .7rem;
  font-family: 'JetBrains Mono', monospace; font-size: .92rem;
}
.qref dt:first-child { margin-top: 0; }
.qref dd { margin: .15rem 0 0; color: var(--ink); }
.qref ul { margin: .4rem 0 0; }
.qref li { margin: .22rem 0; }

/* ============================================================
   Head First devices (added 2026-09-15)
   Rationale and page references: research/head-first-pedagogy.md
   Live example: modules/08-rag.html
   ============================================================ */

/* Sharpen your pencil: the reader guesses BEFORE being taught.
   Add class "trace" for BE-the-machine exercises (reader plays the retriever, the tokenizer, the loop). */
.sharpen {
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem .5rem;
  margin: 1.8rem 0;
}
.sharpen .sharpen-label {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  display: inline-block; border-bottom: 3px solid var(--mark);
  padding-bottom: .1rem; margin: 0 0 .6rem;
}
.sharpen .sharpen-label::before { content: "✎ "; }
.sharpen.trace .sharpen-label::before { content: "⚙ "; }
.sharpen table.pencil { width: 100%; border-collapse: collapse; font-size: .92rem; margin: .4rem 0 .6rem; }
.sharpen table.pencil td { border-bottom: 1px solid var(--line-soft); padding: .5rem .6rem; vertical-align: top; }
.sharpen table.pencil td:first-child {
  font-family: 'JetBrains Mono', monospace; font-size: .8rem; white-space: pre-wrap; width: 46%;
  color: var(--ink);
}
.sharpen table.pencil td.blank { border-bottom: 1.5px dotted var(--muted); }
.sharpen table.pencil td.given, .sharpen table.pencil td.ans {
  font-family: 'Bricolage Grotesque', sans-serif; font-style: italic; color: var(--accent);
}
.sharpen ol.trace { padding-left: 1.4rem; }
.sharpen ol.trace li { margin: .3rem 0; }
.sharpen details { margin: .5rem 0 .9rem; }
.sharpen summary {
  cursor: pointer; font-family: 'Bricolage Grotesque', sans-serif;
  font-size: .85rem; color: var(--accent); font-weight: 600;
}

/* Fireside chat: two components with opposite responsibilities argue.
   Turn A sits in the left column, turn B in the right, staggered like the book. */
.fireside {
  border-top: 3px double var(--ink);
  border-bottom: 3px double var(--ink);
  padding: 1rem 0 .4rem;
  margin: 2.2rem 0;
}
.fireside .fireside-head {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--warn);
}
.fireside .fireside-head::before { content: "🔥 "; }
.fireside .fireside-topic {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700; font-size: 1.05rem; line-height: 1.35; margin: .3rem 0 1rem;
}
.fireside .fs-names {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem;
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: .95rem;
  border-bottom: 1px solid var(--line); padding-bottom: .4rem; margin-bottom: .8rem;
}
.fireside .fs-turn { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.fireside .fs-turn > p { margin: 0 0 1rem; font-size: .97rem; }
.fireside .fs-turn.a > p { grid-column: 1; }
.fireside .fs-turn.b > p { grid-column: 2; }
.fireside .fs-turn::before { display: none; }
@media (max-width: 640px) {
  .fireside .fs-names { display: none; }
  .fireside .fs-turn { grid-template-columns: 1fr; gap: .2rem; }
  .fireside .fs-turn > p { grid-column: 1; }
  .fireside .fs-turn::before {
    display: block; content: attr(data-who);
    font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: .78rem;
    color: var(--muted); margin-bottom: .15rem;
  }
  .fireside .fs-turn.b { padding-left: 1.4rem; }
}

/* Anatomy: one key line, every meaningful token numbered, keys below.
   Not inside .codeblock on purpose: the highlighter and copy button leave it alone. */
.anatomy {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin: 1.8rem 0;
  overflow: hidden;
}
.anatomy .anatomy-label {
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
  padding: .5rem .95rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted);
}
.anatomy .anatomy-label::before { content: "⌖ "; color: var(--accent); }
.anatomy pre {
  margin: 0;
  background: var(--code-bg); color: var(--code-ink);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .84rem; line-height: 1.9;
}
.anatomy pre .k, .anatomy ol.anatomy-keys li::before {
  display: inline-block; min-width: 1.4em; height: 1.4em; line-height: 1.4em;
  text-align: center; border-radius: 999px;
  background: var(--mark); color: var(--mark-ink);
  font-family: 'Bricolage Grotesque', sans-serif; font-size: .68rem; font-weight: 800;
  font-style: normal;
}
.anatomy pre .k { margin: 0 .2em; vertical-align: middle; }
.anatomy ol.anatomy-keys {
  list-style: none; margin: 0; padding: .9rem 1.1rem .4rem;
  counter-reset: ak; font-size: .95rem;
}
.anatomy ol.anatomy-keys li { counter-increment: ak; position: relative; padding-left: 2.2em; margin-bottom: .55rem; }
.anatomy ol.anatomy-keys li::before { content: counter(ak); position: absolute; left: .15em; top: .2em; }

/* Chant: the mechanism in three to five lines, meant to be said aloud. */
.chant {
  margin: 2rem 0;
  padding: 1rem 1.4rem .8rem;
  border-left: 5px solid var(--mark);
  background: var(--card);
  border-radius: 0 10px 10px 0;
}
.chant::before {
  content: "Say it out loud";
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: .66rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: .5rem;
}
.chant p {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 750; font-size: 1.28rem; line-height: 1.35; letter-spacing: -0.01em;
  margin: 0 0 .3rem;
}
.chant p strong { color: var(--accent); }

/* Relax: the permission note. "You are not expected to understand this yet, and here is where it is explained." */
p.relax {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-style: italic; font-size: .95rem; color: var(--muted);
  border-left: 3px dotted var(--muted);
  padding: .2rem 0 .2rem .9rem;
  margin: 1rem 0 1.2rem;
}
p.relax::before { content: "☞ "; font-style: normal; }

/* Bubble: the skeptic's doubt in their own voice, answered where it arises. */
.bubble { margin: 1.9rem 0; }
.bubble .bubble-say {
  position: relative; display: inline-block; max-width: 46ch;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 18px;
  padding: .8rem 1.1rem; margin: 0 0 .1rem;
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 1.04rem; font-weight: 600; line-height: 1.4;
}
.bubble .bubble-say::after {
  content: ""; position: absolute; left: 1.4rem; bottom: -.95rem;
  width: .7rem; height: .7rem; border-radius: 50%;
  background: var(--card); border: 1.5px solid var(--ink);
}
.bubble .bubble-say::before {
  content: ""; position: absolute; left: 2.5rem; bottom: -1.55rem;
  width: .4rem; height: .4rem; border-radius: 50%;
  background: var(--card); border: 1.5px solid var(--ink);
}
.bubble .bubble-who {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: .85rem; color: var(--muted);
  margin: 1.5rem 0 .7rem;
}
.bubble .bubble-ans { border-left: 3px solid var(--ink); padding: .1rem 0 .1rem 1rem; }
.bubble .bubble-ans::before {
  content: "Straight answer";
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: .66rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: .3rem;
}
.bubble .bubble-ans p { margin: 0 0 .7rem; }

/* ---- Pointed pictures (added 2026-09-15, later the same day) ----
   The reader complained that character passages and statistics prose were "just words".
   Three additions: (1) numbered keys under a figure, so the words live inside the picture;
   (2) a plain-words gloss under every fireside turn; (3) a gloss line inside a chant. */
figure.diagram ol.anatomy-keys { list-style: none; margin: .7rem 0 0; padding: 0; counter-reset: ak; font-size: .92rem; font-family: 'Source Serif 4', Georgia, serif; }
figure.diagram ol.anatomy-keys li { counter-increment: ak; position: relative; padding-left: 2.2em; margin-bottom: .45rem; }
figure.diagram ol.anatomy-keys li::before {
  content: counter(ak); position: absolute; left: .15em; top: .15em;
  display: inline-block; min-width: 1.4em; height: 1.4em; line-height: 1.4em; text-align: center; border-radius: 999px;
  background: var(--mark); color: var(--mark-ink);
  font-family: 'Bricolage Grotesque', sans-serif; font-size: .68rem; font-weight: 800; font-style: normal;
}
.fireside .fs-turn > p.fs-gloss {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: .84rem; line-height: 1.45; color: var(--muted);
  border-left: 2px dotted var(--muted); padding: .1rem 0 .1rem .65rem; margin: -.55rem 0 1.15rem;
}
.fireside .fs-turn > p.fs-gloss::before { content: "In plain words: "; font-weight: 700; }
.chant p.gloss {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 400; font-size: .9rem; line-height: 1.5;
  color: var(--muted); letter-spacing: 0; margin: .6rem 0 0;
}

/* The story spine: "where we are in the story" at the top of a section. Added 2026-09-15 after the
   reader said the statistics read like facts narrated by a storyteller rather than events in one story. */
p.thread {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: 0 8px 8px 0;
  padding: .75rem 1.05rem;
  margin: 1rem 0 1.4rem;
  font-size: .98rem;
  line-height: 1.55;
}
p.thread::before {
  content: "Where we are in the story";
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: .66rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--warn); margin-bottom: .3rem;
}

/* Cross-reference with hover preview and jump. Added 2026-09-15 after the reader said
   "the rule from section 06" sent them hunting with lost context. Hover shows the referenced
   thing in one sentence (data-tip); click jumps to the exact element, which is highlighted. */
a.xref {
  position: relative; color: var(--accent); text-decoration: none;
  border-bottom: 1px dotted var(--accent); white-space: nowrap;
}
a.xref::before { content: "↗"; font-size: .72em; margin-right: .12em; opacity: .8; }
a.xref:hover::after, a.xref:focus-visible::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: 1.55em; z-index: 40;
  width: 38ch; max-width: 80vw; white-space: normal;
  background: var(--ink); color: var(--paper);
  font-family: 'Bricolage Grotesque', sans-serif; font-size: .8rem; line-height: 1.45; font-weight: 500;
  padding: .5rem .7rem; border-radius: 6px; box-shadow: var(--shadow);
}
[id] { scroll-margin-top: 4.2rem; }
.xt:target, figure.diagram:target, p.thread:target, details.hood:target, .brain:target, .bubble:target {
  outline: 3px solid var(--mark); outline-offset: 5px; border-radius: 6px;
}

/* SVG text takes `fill`, not `color`: a <text> that carries only a dg-* class rendered black.
   Found by the module 03 pass on 2026-09-15. Text only, so rects/lines keep their own fill. */
figure.diagram svg text.dg-accent, figure.diagram svg text.dg-good, figure.diagram svg text.dg-bad,
figure.diagram svg text.dg-warn, figure.diagram svg text.dg-muted { fill: currentColor; }

/* ---- Follow-up questions (added 2026-09-15, night) ----
   The reader understood more by asking an AI chat follow-up questions than from the page itself.
   What worked there: their own question as the heading, a direct answer first, rows small enough to
   work by hand, a side-by-side table, one record traced end to end, and one line to keep.
   A .followups block holds 3–5 details.fu, each a question a first-time reader asks at that exact point. */
.followups {
  margin: 2rem 0;
  padding: 1rem 1.2rem .4rem;
  background: var(--card-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
}
.followups .followups-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .3rem;
}
.followups .followups-title::before { content: "? "; }
.followups .followups-lede { font-size: .95rem; color: var(--muted); margin: 0 0 .9rem; }
details.fu { margin: 0 0 .8rem; }
details.fu > summary {
  list-style: none; cursor: pointer;
  display: block; width: fit-content; max-width: min(58ch, 92%); margin-left: auto;
  background: var(--card); border: 1.5px solid var(--ink);
  border-radius: 18px 18px 4px 18px;
  padding: .55rem 1rem .6rem;
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 600; font-size: 1rem; line-height: 1.4;
}
details.fu > summary::-webkit-details-marker { display: none; }
details.fu > summary::marker { content: ""; }
details.fu > summary::before {
  content: "You ask"; display: block;
  font-family: 'JetBrains Mono', monospace; font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: .15rem;
}
details.fu > summary::after {
  content: "open the answer ▸"; display: block; text-align: right;
  font-family: 'JetBrains Mono', monospace; font-size: .62rem; color: var(--accent); margin-top: .25rem;
}
details.fu[open] > summary::after { content: "answer below ▾"; }
details.fu .fu-body {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 4px 12px 12px 12px;
  padding: .9rem 1.2rem .3rem; margin: .6rem 0 .2rem;
}
details.fu .fu-body p.fu-short { font-size: 1.03rem; font-weight: 600; line-height: 1.5; }
details.fu .fu-body p.fu-short::before, details.fu .fu-body p.fu-keep::before {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: .62rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: .2rem;
}
details.fu .fu-body p.fu-short::before { content: "Short answer"; }
details.fu .fu-body p.fu-keep { border-top: 1px dashed var(--line); padding-top: .7rem; margin-top: 1rem; font-weight: 600; }
details.fu .fu-body p.fu-keep::before { content: "Keep this"; color: var(--accent); }
details.fu .fu-body ol.calc { list-style: upper-alpha; padding-left: 1.6rem; }
details.fu .fu-body ol.calc li { margin: .45rem 0; }
details.fu .fu-body ol.calc li::marker { font-weight: 700; color: var(--accent); }
details.fu .fu-body figure.diagram { margin: 1.2rem 0; }
details.fu:target > summary { outline: 3px solid var(--mark); outline-offset: 4px; }

/* JetBrains Mono ships programming ligatures: "!=" draws as "≠", "->" as an arrow, ">=" as "≥".
   A reader copying code from a figure or a code block must see the characters they will type.
   Found by the follow-up questions pass on 2026-09-16 (module 09, Fig. 9.3e). */
figure.diagram svg, pre, code, kbd, samp { font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }

/* ===== Code ladder (added 2026-10-29) =====
   The course owner asked that code be taught "in chunks, then one big program".
   A .ladder holds 3–7 li.rung steps; each rung adds only the new lines, says what to run and what you should see.
   It ends with .ladder-whole: the complete program, with comment markers showing where each chunk lives. */
.ladder { margin: 2rem 0; padding: 1rem 1.2rem .6rem; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card-2); }
.ladder .ladder-title { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 .3rem; }
.ladder .ladder-title::before { content: "▤ "; }
.ladder .ladder-lede { font-size: .95rem; color: var(--muted); margin: 0 0 1rem; }
.ladder ol.ladder-steps { list-style: none; counter-reset: rung; padding: 0; margin: 0; }
.ladder li.rung { counter-increment: rung; position: relative; padding: 0 0 .6rem 2.4rem; margin: 0 0 1rem; border-left: 2px solid var(--line); margin-left: .8rem; }
.ladder li.rung::before { content: counter(rung); position: absolute; left: -.85rem; top: 0; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: var(--card); font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: .8rem; display: flex; align-items: center; justify-content: center; }
.ladder li.rung:last-child { border-left-color: transparent; }
.ladder p.rung-goal { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 1.05rem; margin: 0 0 .4rem; }
.ladder p.rung-new { font-size: .92rem; color: var(--muted); }
.ladder p.rung-new::before { content: "New in this chunk: "; font-weight: 700; color: var(--ink); }
.ladder p.rung-check { font-size: .92rem; border-left: 3px solid var(--accent); padding-left: .7rem; }
.ladder p.rung-check::before { content: "Run it and check: "; font-weight: 700; color: var(--accent); }
.ladder-whole { margin: 1.5rem 0 2rem; padding: 1rem 1.2rem .4rem; border: 2px solid var(--accent); border-radius: 12px; background: var(--card); }
.ladder-whole .ladder-whole-title { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 .3rem; }
.ladder-whole .ladder-whole-title::before { content: "▣ "; }
.ladder-whole .ladder-map { font-size: .92rem; color: var(--muted); }

/* ===== Stack decision (added 2026-10-29) =====
   Every module names its software stack, the realistic alternatives, why this one was chosen, and when to switch. */
.stack { margin: 2rem 0; padding: 1rem 1.2rem .6rem; border: 1.5px solid var(--line); border-left: 4px solid var(--accent); border-radius: 4px 12px 12px 4px; background: var(--card); }
.stack .stack-title { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 .3rem; }
.stack .stack-title::before { content: "⚙ "; }
.stack .stack-lede { font-size: .97rem; margin: 0 0 .8rem; }
.stack table.data td:nth-child(2) { font-weight: 700; }
.stack p.stack-verdict { border-top: 1px dashed var(--line); padding-top: .7rem; font-weight: 600; }
.stack p.stack-verdict::before { content: "The decision in one line: "; color: var(--accent); }

/* Code blocks inside a list item (ladder rungs) must not inherit the inline-code chip from `li code`. Found 2026-10-29 on 01c. */
li pre code, td pre code, dd pre code, .ladder pre code { background: none; border: 0; padding: 0; border-radius: 0; }

/* ===== Picture-it steps (added 2026-11-13) =====
   Colour-codes the labelled steps inside a topic so setup, evidence, cause and fix read as separate blocks.
   Classes are added by _style_labels.py from the bold lead-in of each paragraph or list item. */
h3.pi-h3 { margin-top: 3.2rem; padding-top: 1.5rem; border-top: 2px solid var(--line); }
h3.pi-h3::before { content: ""; display: block; width: 2.6rem; height: 4px; border-radius: 2px; background: var(--accent); margin: -1.6rem 0 1.2rem; }
h4.pi-h4 { margin: 2.2rem 0 .8rem; padding: .4rem .8rem; border-left: 4px solid var(--accent); border-radius: 0 6px 6px 0; background: linear-gradient(90deg, var(--accent-soft), transparent 85%); }

p.pi { --pi-c: var(--muted); --pi-bg: var(--card-2); margin: 1.5rem 0 .6rem; padding: .55rem .9rem; border-left: 4px solid var(--pi-c); border-radius: 0 8px 8px 0; background: var(--pi-bg); }
p.pi > strong:first-child { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pi-c); margin-right: .45rem; white-space: nowrap; }
p.pi > strong:first-child::before { margin-right: .4rem; }
p.pi-setup > strong:first-child::before { content: "▸"; }
p.pi-reveal { --pi-c: var(--warn); --pi-bg: color-mix(in srgb, var(--mark) 26%, var(--card)); border-left-color: var(--mark); }
p.pi-reveal > strong:first-child::before { content: "◉"; }
p.pi-trace, p.pi-how, p.pi-rule, p.pi-phase { --pi-c: var(--accent); --pi-bg: var(--accent-soft); }
p.pi-trace > strong:first-child::before { content: "⇢"; }
p.pi-how > strong:first-child::before { content: "⚙"; }
p.pi-phase > strong:first-child::before { content: "◆"; }
p.pi-see, p.pi-trap { --pi-c: var(--bad); --pi-bg: var(--bad-soft); }
p.pi-see > strong:first-child::before { content: "✗"; }
p.pi-trap > strong:first-child::before { content: "⚠"; }
p.pi-symptom, p.pi-design, p.pi-why { --pi-c: var(--warn); --pi-bg: var(--warn-soft); }
p.pi-why > strong:first-child::before, p.pi-design > strong:first-child::before { content: "?"; }
p.pi-fix, p.pi-now { --pi-c: var(--good); --pi-bg: var(--good-soft); }
p.pi-fix > strong:first-child::before { content: "✚"; }
p.pi-now > strong:first-child::before { content: "✓"; }

/* The block that follows a labelled step carries the step's colour on its edge. */
p.pi + .codeblock, p.pi + .tablewrap { margin-top: .5rem; }
p.pi-reveal + .codeblock { border-left: 4px solid var(--mark); }
p.pi-trace + .codeblock, p.pi-how + .codeblock { border-left: 4px solid var(--accent); }
p.pi-see + .codeblock, p.pi-trap + .codeblock { border-left: 4px solid var(--bad); }
p.pi-fix + .codeblock, p.pi-now + .codeblock { border-left: 4px solid var(--good); }

/* Works / Fails bullets and the interview takeaway. */
ul.pi-list { list-style: none; padding-left: 0; }
li.pi-ok, li.pi-no, li.pi-takeaway { list-style: none; padding: .5rem .9rem; border-radius: 8px; margin: .45rem 0; }
li.pi-ok { background: var(--good-soft); border-left: 4px solid var(--good); }
li.pi-no { background: var(--bad-soft); border-left: 4px solid var(--bad); }
li.pi-ok > strong:first-child { color: var(--good); }
li.pi-no > strong:first-child { color: var(--bad); }
li.pi-ok > strong:first-child::before { content: "✓ "; }
li.pi-no > strong:first-child::before { content: "✗ "; }
li.pi-takeaway { background: var(--card); border: 1.5px solid var(--accent); box-shadow: var(--shadow); padding: .75rem 1rem; }
li.pi-takeaway > strong:first-child { display: inline-block; font-family: 'Bricolage Grotesque', sans-serif; font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: var(--accent); color: var(--on-accent); padding: .1rem .55rem; border-radius: 4px; margin-right: .4rem; }

/* Numbered breakdowns: coloured numbers and lead-ins. */
ol.pi-steps > li::marker { color: var(--accent); font-weight: 700; }
ol.pi-steps > li > strong:first-child { color: var(--accent); }

/* Outcome cells in comparison tables. */
table.data td.pi-td-ok { color: var(--good); font-weight: 650; }
table.data td.pi-td-no { color: var(--bad); font-weight: 650; }
table.data td.pi-td-warn { color: var(--warn); font-weight: 650; }

/* Drill: the Picture it panel stands apart from the spoken answer. */
.radar .rq-answer.rq-picture { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--card-2); padding: .5rem 1rem .6rem; margin: .9rem 0; }
.radar .rq-answer.rq-picture > p:first-child .rq-k { background: var(--accent); color: var(--on-accent); padding: .12rem .5rem; border-radius: 4px; margin-right: .5rem; }

/* Coloured lead-ins for diagnosis lists (symptom, evidence, cause, fix). */
li.pi-l-warn > strong:first-child { color: var(--warn); }
li.pi-l-info > strong:first-child { color: var(--accent); }
li.pi-l-bad > strong:first-child { color: var(--bad); }
li.pi-l-good > strong:first-child { color: var(--good); }

/* ---------- Duo: the same job done two ways, side by side (e.g. relational | Cassandra) ----------
   <div class="duo">
     <div class="duo-side rel"><p class="duo-label">Relational · PostgreSQL</p> ...p / codeblock... </div>
     <div class="duo-side cas"><p class="duo-label">Cassandra · CQL</p> ...p / codeblock... </div>
     <p class="duo-shift"><strong>The shift:</strong> one sentence naming the change in thinking.</p>
   </div>
   Two columns when there is room, stacked on narrow screens. */
.duo { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); gap: .9rem; margin: 1.2rem 0 1.6rem; }
.duo-side { --duo-c: var(--muted); min-width: 0; border: 1px solid var(--line); border-top: 4px solid var(--duo-c); border-radius: 8px; background: var(--card); padding: .2rem .9rem .5rem; }
.duo-side.rel { --duo-c: var(--warn); }
.duo-side.cas { --duo-c: var(--accent); }
.duo-side > p.duo-label { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--duo-c); margin: .55rem 0 .4rem; }
.duo-side > p { margin: .5rem 0; }
.duo-side .codeblock { margin: .6rem 0; }
.duo-side ul, .duo-side ol { margin: .4rem 0; padding-left: 1.2rem; }
p.duo-shift { grid-column: 1 / -1; margin: 0; padding: .55rem .9rem; border-left: 4px solid var(--mark); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--mark) 22%, var(--card)); }
p.duo-shift > strong:first-child { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--warn); margin-right: .45rem; }
