/* Backtesting from Scratch, v4 (9 Nov 2026): "the workbook".
   One idea: a printed workbook that you can also work in. Two voices: a sans for doing (steps, questions, controls)
   and a serif for reading (titles, formulas, the lesson notes). One accent, terracotta, for what you touch and what
   you chose. Green only for a correct answer; a wrong answer is neutral ink with a cross, so right and wrong differ by
   a mark and a word, never by colour alone. The lesson code (A3) is the spine of every page.
   v3's class names, ids, data attributes and dock behaviour are unchanged: 22 lessons and their replay scripts rely on
   them. Fonts: SIL OFL 1.1 (licences in fonts/).
   v5 (11 Nov 2026), "plain notes" (docs/DESIGN-AI-FEEL-RESEARCH-2026-11-11.md): white and neutral greys, one sans for
   the page, serif only in formulas, black for everything you touch; terracotta stays inside figures only, where captions
   name it. The outline is a drawer at every width. Overrides are in the v5 section at the end. */
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/HankenGrotesk-latin-var.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/SourceSerif4-latin-var.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/SourceSerif4-latin-var-italic.woff2") format("woff2"); font-weight: 400 700; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/JetBrainsMono-latin-var.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }

:root {
  /* surfaces and lines */
  --room: #F6F6F5; --card: #FFFFFF; --tint: #F5F5F4; --tint-2: #EBEBEA; --line: #E5E5E3; --line-2: #CFCFCC;
  /* ink: -3 is the lightest that still passes AA (4.5:1) on card, tint and room; -4 is for marks and disabled only */
  --ink: #161616; --ink-2: #444444; --ink-3: #6B6B6B; --ink-4: #ADADAD;
  /* accent: --accent for marks and fills in figures (3.6:1), -text for words (5.7:1), -solid under white text (5.1:1) */
  --accent: #D4633D; --accent-deep: #A9492A; --accent-text: #A9492A; --accent-solid: #B4502F; --accent-wash: #FBE9E1;
  --good: #25784A; --good-wash: #E4F3E9; --miss: #5A554D; --miss-wash: #EFEDE7;
  --focus: #161616;
  /* v5 (11 Nov 2026), plain notes: the page's own chrome is black and grey; terracotta is kept for figures only */
  --link: var(--ink); --solid: #161616; --solid-ink: #FFFFFF;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --card-w: 44rem; --read-w: 35rem; --side-w: 288px; --head-h: 60px; --lbar-h: 52px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 12px 32px -12px rgba(28, 27, 25, 0.12);
  --ease: cubic-bezier(.2, .8, .2, 1);
  /* marks: used as masks, so they take the colour of the element */
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.6l3.1 3.1L13 4.6' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3.5l4.5 4.5L6 12.5' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  /* v1 names still used by figure code: aliases, so a figure never draws with an empty colour */
  --rule: var(--line); --rule-2: var(--line-2); --sheet: var(--card); --sheet-2: var(--tint-2);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --room: #141414; --card: #1E1E1E; --tint: #262626; --tint-2: #303030; --line: #353535; --line-2: #474747;
    --ink: #F0F0EE; --ink-2: #CCCCCA; --ink-3: #A0A09D; --ink-4: #6A6A68;
    --accent: #E8805B; --accent-deep: #F29C7C; --accent-text: #F29C7C; --accent-solid: #B4502F; --accent-wash: #3A2720;
    --good: #6CC58B; --good-wash: #1C3325; --miss: #B9B4AA; --miss-wash: #33312D;
    --focus: #F0F0EE;
    --solid: #F0F0EE; --solid-ink: #161616;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* lessons hide controls with the hidden attribute; no display rule below may bring them back */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--head-h) + var(--lbar-h) + 1rem); }
body { margin: 0; background: var(--card); color: var(--ink); font: 400 1.125rem/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: from-font; }
strong, b { font-weight: 650; }
.num, .v, .big { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- site header: the course's wordmark, Courses, About, and the publisher ---- */
.site-head { position: sticky; top: 0; z-index: 50; height: var(--head-h); background: var(--card); border-bottom: 1px solid var(--line); }
.site-head-inner { height: 100%; max-width: 75rem; margin: 0 auto; padding: 0 1.5rem; display: flex; align-items: center; gap: 1.75rem; font: 600 0.92rem var(--sans); }
.has-outline .site-head-inner { max-width: none; }
/* the wordmark is set, not drawn: the title in the sans, nothing accented */
.brand { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; color: var(--ink); white-space: nowrap; font: 650 1.1rem/1 var(--sans); letter-spacing: -0.01em; }
.brand .wm { display: inline-flex; align-items: baseline; }
.brand .by { display: none; }
.site-links { display: flex; align-items: center; gap: 0.25rem; flex: 1; }
.site-links > a { color: var(--ink-2); text-decoration: none; min-height: 40px; padding: 0 0.75rem; border-radius: 8px; font: 600 0.92rem var(--sans); background: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; }
.site-links > a:hover { background: var(--tint); color: var(--ink); }
/* the publisher's imprint: QuantWright's own mark and name, quiet, at the far end */
.qw { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 40px; color: var(--ink-2); text-decoration: none; font: 600 0.9rem var(--sans); padding: 0 0.6rem; border-radius: 8px; white-space: nowrap; }
.qw:hover { background: var(--tint); color: var(--ink); }
.qw .mark { width: 20px; height: 20px; flex: none; color: var(--ink); }
.qw .ext { width: 9px; height: 9px; color: var(--ink-3); }

/* ---- lesson bar: where you are (course / code and title), one segment per step, count, previous and next lesson ---- */
.lesson-bar { position: sticky; top: var(--head-h); z-index: 40; height: var(--lbar-h); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.lesson-bar-inner { position: relative; height: 100%; padding: 0 1.5rem; display: flex; align-items: center; gap: 1.25rem; }
.lb-title { display: flex; align-items: baseline; gap: 0.55rem; min-width: 0; white-space: nowrap; font: 600 0.92rem var(--sans); }
.lb-c { color: var(--ink-3); text-decoration: none; }
.lb-c:hover { color: var(--ink); text-decoration: underline; }
.lb-sep { color: var(--ink-4); }
.lb-k { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.lb-t { font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.segs { flex: 1; display: flex; gap: 4px; max-width: 30rem; margin-left: auto; }
.segs i { flex: 1; height: 6px; border-radius: 3px; background: var(--tint-2); transition: background .3s; }
.segs i.done { background: var(--ink); }
.segs i.here { background: var(--ink); }
.lesson-bar .count { font: 600 0.85rem var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-3); white-space: nowrap; }
.all .lesson-bar .count { visibility: hidden; }
.lb-nav { display: flex; gap: 0.3rem; }
.lb-nav a, .lb-nav span { display: inline-flex; align-items: center; gap: 0.3rem; height: 32px; padding: 0 0.6rem; border-radius: 8px; font: 650 0.82rem var(--sans); font-variant-numeric: tabular-nums; text-decoration: none; color: var(--ink-2); box-shadow: 0 0 0 1px var(--line-2) inset; white-space: nowrap; }
.lb-nav a:hover { background: var(--tint); color: var(--ink); }
.lb-nav span { color: var(--ink-4); box-shadow: 0 0 0 1px var(--line) inset; }
.lb-nav .ar { width: 10px; height: 10px; background: currentColor; -webkit-mask: var(--i-chev) center / contain no-repeat; mask: var(--i-chev) center / contain no-repeat; }
.lb-nav .lb-prev .ar { transform: scaleX(-1); }
/* the Sections button lives in the dock, where a thumb reaches it; it shows when the outline is a drawer */
.sections-btn { display: none; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; color: var(--ink); background: var(--card); border: 0; border-radius: 10px; box-shadow: 0 0 0 1.5px var(--line-2) inset; cursor: pointer; }
.sections-btn svg { width: 18px; height: 14px; }

/* ---- section outline: left column on wide screens, a drawer on narrow ones ---- */
.outline { position: fixed; z-index: 30; top: calc(var(--head-h) + var(--lbar-h)); bottom: 0; left: 0; width: var(--side-w); background: var(--room); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
.ol-inner { padding: 1.2rem 1.1rem 2rem; }
.ol-back { display: inline-flex; align-items: center; min-height: 36px; font: 600 0.85rem var(--sans); color: var(--ink-3); text-decoration: none; margin: 0 0 0.6rem 0.4rem; }
.ol-back:hover { color: var(--ink); }
.ol-k { margin: 0 0 0.25rem 0.4rem; font: 650 0.82rem var(--sans); color: var(--accent-text); }
.ol-title { margin: 0 0 0.25rem 0.4rem; font: 600 1.35rem/1.2 var(--serif); color: var(--ink); letter-spacing: -0.01em; }
.ol-meta { margin: 0 0 1.1rem 0.4rem; font: 500 0.85rem var(--sans); color: var(--ink-3); }
.ol-h { margin: 1.2rem 0 0.35rem 0.4rem; font: 700 0.72rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.outline ol { list-style: none; margin: 0; padding: 0; }
.outline ol button, .outline ol a { width: 100%; display: grid; grid-template-columns: 1.1rem 1fr; gap: 0.6rem; align-items: start; text-align: left; min-height: 36px; padding: 0.5rem 0.5rem; border: 0; border-radius: 8px; background: none; font: 500 0.9rem/1.35 var(--sans); color: var(--ink-2); text-decoration: none; cursor: pointer; }
.outline ol button:hover:not(:disabled), .outline ol a:hover { background: var(--tint-2); color: var(--ink); }
.outline .dot { width: 0.8rem; height: 0.8rem; margin-top: 0.22rem; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--line-2) inset; background: var(--card); position: relative; }
.outline button.done .dot { background: var(--solid); box-shadow: none; }
.outline button.done .dot::after { content: ""; position: absolute; inset: 1px; background: #fff; -webkit-mask: var(--i-check) center / contain no-repeat; mask: var(--i-check) center / contain no-repeat; }
.outline button.here { background: var(--card); color: var(--ink); font-weight: 650; box-shadow: 0 0 0 1px var(--line-2) inset; }
.outline button.here .dot { box-shadow: 0 0 0 2px var(--ink) inset; background: var(--card); }
.outline button.here .dot::after { content: ""; position: absolute; inset: 0.22rem; border-radius: 50%; background: var(--ink); -webkit-mask: none; mask: none; }
.outline button.locked { color: color-mix(in srgb, var(--ink-3) 72%, var(--room)); cursor: default; }
.outline button.locked .dot { box-shadow: 0 0 0 1.5px var(--line) inset; background: transparent; }
/* after-the-lesson links (the lesson notes first): a small page mark instead of a step dot */
.ol-more .dot { border-radius: 2px; width: 0.7rem; height: 0.85rem; margin-left: 0.05rem; background: transparent; box-shadow: 0 0 0 1.5px var(--ink-3) inset; }
.ol-all { display: inline-flex; align-items: center; min-height: 44px; margin: 0.8rem 0 0 0.4rem; padding: 0; border: 0; background: none; font: 600 0.85rem var(--sans); color: var(--ink-3); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 0.25em; cursor: pointer; }
.ol-all:hover { color: var(--ink); }
.all .ol-all { display: none; }
.ol-lessons { display: grid; gap: 0.2rem; margin: 1rem 0 0; padding: 0.9rem 0 0; border-top: 1px solid var(--line-2); }
.ol-lessons > a, .ol-lessons > span { display: grid; grid-template-columns: 1.6rem 1fr; gap: 0.6rem; align-items: baseline; min-height: 36px; padding: 0.45rem 0.5rem; border-radius: 8px; font: 500 0.88rem/1.35 var(--sans); color: var(--ink-2); text-decoration: none; }
.ol-lessons a:hover { background: var(--tint-2); color: var(--ink); }
.ol-lessons > span { color: color-mix(in srgb, var(--ink-3) 72%, var(--room)); }
.ol-lessons b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.ol-lessons small { display: block; font: 700 0.68rem var(--sans); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); }
.scrim { display: none; }
.page { min-height: calc(100vh - var(--head-h) - var(--lbar-h)); }
.has-outline .page { margin-left: var(--side-w); }
.has-outline .dock { left: var(--side-w); }

/* ---- the step ---- */
main { padding: 0 1.5rem 9rem; }
.step { max-width: var(--card-w); margin: 0 auto; padding: 3rem 0 2rem; }
.all .step + .step { border-top: 1px solid var(--line); }
.js:not(.all) .step:not(.current) { display: none; }
.js .step.current { animation: in .4s var(--ease) both; }
@keyframes in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.step .no { font: 700 0.75rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.7rem; }
.step .no.practice { color: var(--ink-2); }
.step h2 { font: 600 2rem/1.18 var(--serif); letter-spacing: -0.015em; color: var(--ink); margin: 0 0 1rem; text-wrap: balance; }
.step p { margin: 0 0 0.9rem; color: var(--ink-2); }
.step p strong { color: var(--ink); }
.step > figure, .step .figwrap { margin: 1.5rem 0 0.8rem; }

/* the cover */
.cover { padding-top: 3.2rem; }
.cover .kicker { font: 500 0.95rem var(--sans); color: var(--ink-3); margin: 0 0 1rem; }
.cover h1 { font: 600 clamp(2.5rem, 6vw, 3.7rem)/1.05 var(--serif); letter-spacing: -0.025em; margin: 0 0 1rem; color: var(--ink); text-wrap: balance; }
.cover .dek { font-size: 1.3rem; line-height: 1.5; color: var(--ink-2); max-width: 34rem; margin: 0 0 1.5rem; }
.cover .meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0; margin: 0 0 0.4rem; padding: 1rem 0 0; list-style: none; border-top: 1px solid var(--line); }
.cover .meta li { font: 500 0.9rem var(--sans); color: var(--ink-3); }
.cover .meta li + li::before { content: "·"; margin: 0 0.6rem; color: var(--ink-4); }
.cover .art { display: block; margin: 2rem 0 0.9rem; width: 100%; max-width: none; height: auto; max-height: 13rem; padding: 1.2rem 1.6rem; background: var(--tint); border: 1px solid var(--line); border-radius: 14px; }
/* the two quiet ways past the steps: show them all at once, or go straight to the lesson notes */
.showall { display: none; vertical-align: top; align-items: center; gap: 0.5rem; width: fit-content; min-height: 44px; padding: 0; margin: 0; border: 0; background: none; cursor: pointer; text-align: left; font: 600 0.95rem/1.3 var(--sans); color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-decoration-thickness: 1px; text-underline-offset: 0.28em; }
.js .showall { display: inline-flex; margin-right: 1.75rem; }
.showall::after { content: ""; flex: none; width: 0.7rem; height: 0.7rem; background: var(--ink-3); -webkit-mask: var(--i-chev) center / contain no-repeat; mask: var(--i-chev) center / contain no-repeat; transition: transform .15s; }
.showall:hover { color: var(--ink); text-decoration-color: currentColor; }
.showall:hover::after { transform: translateX(2px); background: var(--ink); }

/* after-text: appears once the step's task is done */
.js .after { display: none; }
.js .after.show, .all .after { display: block; animation: in .4s var(--ease) both; }
/* the verdict under a question: a mark, a word, then the reason */
.say, .step .say { position: relative; margin: 1.1rem 0 0.4rem; padding: 0.95rem 1.15rem; border-radius: 10px; background: var(--tint); box-shadow: 0 0 0 1px var(--line) inset; color: var(--ink); font-size: 1.05rem; animation: in .35s var(--ease) both; }
.say.good, .say.miss, .step .say.good, .step .say.miss { padding-left: 3.1rem; }
.say.good::before, .say.miss::before { content: ""; position: absolute; left: 1.05rem; top: 0.95rem; width: 1.45rem; height: 1.45rem; border-radius: 50%; }
.say.good::after, .say.miss::after { content: ""; position: absolute; left: 1.05rem; top: 0.95rem; width: 1.45rem; height: 1.45rem; background: var(--card); -webkit-mask: var(--i-check) center / 62% no-repeat; mask: var(--i-check) center / 62% no-repeat; }
.say.good { background: var(--good-wash); box-shadow: 0 0 0 1px color-mix(in srgb, var(--good) 28%, transparent) inset; }
.say.good::before { background: var(--good); }
.say.miss { background: var(--miss-wash); box-shadow: 0 0 0 1px var(--line-2) inset; }
.say.miss::before { background: var(--miss); }
.say.miss::after { -webkit-mask-image: var(--i-cross); mask-image: var(--i-cross); -webkit-mask-size: 58%; mask-size: 58%; }
.say b { font-weight: 700; }
.say .verdict { display: block; font: 700 1rem/1.45rem var(--sans); margin-bottom: 0.2rem; color: var(--ink); }
.say.good .verdict { color: var(--good); }

/* ---- bottom bar: Sections (narrow screens) · Back · hint or verdict · Check / Continue ---- */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); transition: background .25s; display: none; }
.js:not(.all) .dock { display: block; }
.dock.good { background: var(--good-wash); border-top-color: color-mix(in srgb, var(--good) 28%, transparent); }
.dock.miss { background: var(--miss-wash); border-top-color: var(--line-2); }
.dock-inner { max-width: calc(var(--card-w) + 3rem); margin: 0 auto; padding: 0.9rem 1.5rem calc(0.9rem + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 0.75rem; }
.dock .status { flex: 1; display: flex; align-items: center; gap: 0.5rem; font: 600 0.95rem/1.3 var(--sans); color: var(--ink-3); min-width: 0; padding-left: 0.25rem; }
.dock.good .status, .dock.miss .status { font-weight: 700; color: var(--ink); }
.dock.good .status { color: var(--good); }
.dock.good .status::before, .dock.miss .status::before { content: ""; flex: none; width: 1.1rem; height: 1.1rem; background: currentColor; -webkit-mask: var(--i-check) center / contain no-repeat; mask: var(--i-check) center / contain no-repeat; }
.dock.miss .status::before { -webkit-mask-image: var(--i-cross); mask-image: var(--i-cross); }
.btn {
  font: 700 1rem var(--sans); border: 0; border-radius: 10px; cursor: pointer; min-height: 48px; padding: 0 1.7rem;
  background: var(--ink); color: var(--card); transition: transform .08s, opacity .2s, background .2s; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 88%, var(--card)); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { background: var(--tint-2); color: var(--ink-3); cursor: default; }
.dock.good .btn:not(.ghost) { background: var(--good); color: var(--card); }
.btn.ghost { background: transparent; color: var(--ink-2); box-shadow: 0 0 0 1.5px var(--line-2) inset; padding: 0 1.2rem; }
.btn.ghost:hover:not(:disabled) { background: var(--tint); color: var(--ink); }
.btn.ghost:disabled { background: transparent; opacity: 0.4; }
.dock .btn.ghost:disabled { visibility: hidden; }
.btn.small { font-size: 0.92rem; min-height: 44px; padding: 0 1.15rem; }
.btn.accent { background: var(--solid); color: var(--solid-ink); }
.btn.accent:hover:not(:disabled) { background: var(--ink-2); }
.btn.soft { background: var(--tint); color: var(--ink); box-shadow: 0 0 0 1.5px var(--line) inset; }
.btn.soft:hover:not(:disabled) { background: var(--tint-2); }

/* ---- questions ---- */
.choices { display: grid; gap: 0.6rem; margin: 1.2rem 0 0.3rem; }
.choice {
  display: flex; gap: 0.9rem; align-items: center; text-align: left; width: 100%; min-height: 56px;
  font: 600 1.05rem/1.35 var(--sans); color: var(--ink); background: var(--card); cursor: pointer;
  border: 0; border-radius: 10px; padding: 0.8rem 1.1rem; box-shadow: 0 0 0 1.5px var(--line-2) inset;
  transition: box-shadow .15s, background .2s, transform .08s;
}
.choice .letter { position: relative; flex: none; width: 1.8rem; height: 1.8rem; border-radius: 6px; display: grid; place-items: center; font: 700 0.82rem var(--sans); color: var(--ink-2); background: var(--tint-2); transition: background .15s, color .15s; }
.choice:hover:not([disabled]) { box-shadow: 0 0 0 1.5px var(--ink-3) inset; background: var(--tint); }
.choice:active:not([disabled]) { transform: scale(.995); }
/* yours, before Check: the accent */
.choice.sel { background: var(--tint); box-shadow: 0 0 0 2px var(--solid) inset; }
.choice.sel .letter { background: var(--solid); color: var(--solid-ink); }
.choice[disabled] { cursor: default; color: var(--ink-2); }
/* after Check: the letter gives way to a mark, so right and wrong never differ by colour alone */
.choice.right { color: var(--ink); background: var(--good-wash); box-shadow: 0 0 0 2px var(--good) inset; }
.choice.wrong { color: var(--ink); background: var(--miss-wash); box-shadow: 0 0 0 2px var(--miss) inset; animation: nudge .3s; }
.choice.right .letter, .choice.wrong .letter { color: transparent; }
.choice.right .letter { background: var(--good); }
.choice.wrong .letter { background: var(--miss); }
.choice.right .letter::after, .choice.wrong .letter::after { content: ""; position: absolute; inset: 0; background: var(--card); -webkit-mask: var(--i-check) center / 62% no-repeat; mask: var(--i-check) center / 62% no-repeat; }
.choice.wrong .letter::after { -webkit-mask-image: var(--i-cross); mask-image: var(--i-cross); -webkit-mask-size: 56%; mask-size: 56%; }
.choice.right .letter::after { animation: mark .3s var(--ease) both; }
.choice.mine { color: var(--ink); background: var(--tint); box-shadow: 0 0 0 2px var(--solid) inset; }
.choice.mine .letter { background: var(--solid); color: var(--solid-ink); }
@keyframes nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes mark { from { transform: scale(.4); opacity: 0; } }
.js .why { display: none; }
.numeric { display: flex; align-items: center; gap: 0.6rem; margin: 1.2rem 0 0.3rem; font: 600 1.05rem var(--sans); color: var(--ink-2); }
.numeric input { width: 7.5rem; min-height: 52px; font: 700 1.4rem var(--sans); font-variant-numeric: tabular-nums; text-align: center; color: var(--ink); background: var(--card); border: 0; border-radius: 10px; padding: 0.5rem; box-shadow: 0 0 0 1.5px var(--line-2) inset; outline: none; }
.numeric input:hover:not(:disabled) { box-shadow: 0 0 0 1.5px var(--ink-3) inset; }
.numeric input:focus { box-shadow: 0 0 0 2px var(--solid) inset, 0 0 0 4px var(--tint-2); }
.numeric.right input { box-shadow: 0 0 0 2px var(--good) inset; background: var(--good-wash); }
.numeric.wrong input { box-shadow: 0 0 0 2px var(--miss) inset; background: var(--miss-wash); }
.hint-box { font-size: 0.98rem; color: var(--ink-3); margin-top: 0.6rem; }
.scenario { background: var(--tint); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem; margin: 0.4rem 0 1rem; color: var(--ink); }
.scenario .who { font: 700 0.75rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); display: block; margin-bottom: 0.3rem; }

/* ---- theory cards and the Key ideas sheet ----
   A theory card states the general rule: words, then the formula with every symbol named, a worked example on the
   lesson's own numbers, what it assumes and where it breaks, then a question that uses it on new numbers.
   The same three boxes are reused, unchanged, inside the lesson notes. */
.step .no.theory { color: var(--ink); display: inline-flex; align-items: center; gap: 0.45rem; }
.step .no.theory::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 2px; background: var(--ink); }
.formula { margin: 1.3rem 0; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; break-inside: avoid; }
.formula .eq { padding: 1.25rem 1.25rem; font: 500 1.4rem/1.4 var(--serif); color: var(--ink); text-align: center; background: var(--card); overflow-x: auto; white-space: nowrap; }
.formula .eq i, .keyideas .eq i { font-style: italic; }
.formula .eq sub, .formula .eq sup { font-size: 0.65em; }
.formula dl { margin: 0; padding: 0.85rem 1.25rem 0.95rem; background: var(--tint); border-top: 1px solid var(--line); display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; font: 400 0.98rem/1.5 var(--sans); }
.formula dt { font: italic 500 1.08rem/1.4 var(--serif); color: var(--ink); }
.formula dd { margin: 0; color: var(--ink-2); }
/* a worked example is set like one in a textbook: a ruled block, not another box */
.worked { margin: 1.2rem 0; padding: 0.1rem 0 0.1rem 1.15rem; border-left: 3px solid var(--ink); color: var(--ink-2); font: 400 1.02rem/1.55 var(--sans); break-inside: avoid; }
.holds { margin: 1.2rem 0; padding: 0.95rem 1.15rem; border-radius: 10px; background: var(--tint); border: 1px solid var(--line); color: var(--ink-2); font: 400 1.02rem/1.55 var(--sans); break-inside: avoid; }
.worked .who, .holds .who { display: block; font: 700 0.72rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); margin-bottom: 0.35rem; }
.holds .who { color: var(--ink-3); }
.holds * + .who { margin-top: 0.8rem; padding-top: 0.75rem; border-top: 1px solid var(--line-2); }
.worked p, .holds p { margin: 0 0 0.5rem; }
.worked p:last-child, .holds p:last-child { margin-bottom: 0; }
.holds ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.holds li { margin: 0.2rem 0; }
.keyideas { text-align: left; margin: 1.8rem 0 0.4rem; border: 1px solid var(--line-2); border-top: 3px solid var(--ink); border-radius: 2px 2px 12px 12px; padding: 1.1rem 1.25rem 0.7rem; break-inside: avoid; }
.keyideas h3 { font: 700 0.75rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); margin: 0 0 0.5rem; }
.keyideas h3 + * { margin-top: 0; }
.keyideas dl { margin: 0 0 0.9rem; display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; font-size: 0.98rem; }
.keyideas dt, .keyideas dd { padding: 0.45rem 0; border-top: 1px solid var(--line); }
.keyideas dt { font-weight: 650; color: var(--ink); padding-right: 1.25rem; }
.keyideas dd { margin: 0; color: var(--ink-2); }
.keyideas p { font-size: 0.98rem; color: var(--ink-2); margin: 0 0 0.7rem; }
.keyideas .eq { font: 500 1.12rem/1.5 var(--serif); color: var(--ink); margin: 0 0 0.5rem; }
.outline .tag { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.4rem; border-radius: 4px; font: 700 0.62rem/1.5 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); background: var(--tint-2); vertical-align: 0.1em; }
@media (max-width: 560px) {
  .formula .eq { font-size: 1.15rem; padding: 0.9rem 0.8rem; }
  .formula dl, .keyideas dl { grid-template-columns: 1fr; gap: 0; }
  .formula dd { margin-bottom: 0.45rem; }
  .keyideas dt { padding-bottom: 0; }
  .keyideas dd { border-top: 0; padding-top: 0.05rem; }
}

/* ---- figures: a tinted plate, a title and a caption above, thin ink axes, knobs you drag ----
   Figure code reads its colours from the tokens above (accent against ink and greys: told apart by lightness, so
   they survive colour-blindness and a black-and-white print). SVG label sizes and the plate's padding are unchanged
   from v3, so every figure keeps the fit it was tested with. */
figure.fig { margin: 0; background: var(--tint); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.3rem 1rem; break-inside: avoid; }
.fig-title { font: 700 0.95rem/1.35 var(--sans); color: var(--ink); margin: 0 0 0.2rem; }
.fig-sub { font: 500 0.875rem/1.45 var(--sans); color: var(--ink-3); margin: 0 0 0.8rem; max-width: 38rem; }
.fig svg, .fig canvas { display: block; width: 100%; height: auto; touch-action: pan-y; }
.fig text { font: 500 12px var(--sans); fill: var(--ink-3); }
.fig text.lab { fill: var(--ink-2); font-weight: 650; }
.fig text.acc { fill: var(--accent-text); font-weight: 700; }
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin: 0.9rem 0 0.2rem; font: 600 0.95rem var(--sans); color: var(--ink-2); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: min(100%, 22rem); height: 44px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(var(--ink), var(--ink)) 0 / var(--fill, 0%) 100% no-repeat, var(--line-2); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line-2); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--ink); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line-2), 0 2px 6px rgba(0, 0, 0, .2); transition: transform .12s; }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line-2), 0 2px 6px rgba(0, 0, 0, .2); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--card), 0 0 0 4.5px var(--focus); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px var(--card), 0 0 0 4.5px var(--focus); }
input[type="range"]:disabled { opacity: 0.5; }
.seg { display: inline-flex; border-radius: 10px; background: var(--card); box-shadow: 0 0 0 1.5px var(--line-2) inset; padding: 3px; }
.seg button { font: 650 0.9rem var(--sans); font-variant-numeric: tabular-nums; min-height: 38px; min-width: 44px; padding: 0 0.8rem; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); cursor: pointer; }
.seg button:hover { color: var(--ink); background: var(--tint); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.ledger { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; margin: 0.9rem 0 0; padding-top: 0.75rem; border-top: 1px solid var(--line-2); font: 500 0.84rem var(--sans); color: var(--ink-3); }
.ledger .v { display: block; font: 700 1.15rem/1.3 var(--sans); color: var(--ink); }
.ledger .v.accent { color: var(--accent-text); }
.big { display: block; margin-top: 0.3rem; font: 700 clamp(2.2rem, 8vw, 3.2rem)/1 var(--sans); color: var(--accent-text); letter-spacing: -0.02em; }

/* the coin */
.coinbox { display: grid; grid-template-columns: auto 1fr; gap: 1.6rem; align-items: center; }
.coin-stage { width: 8.5rem; height: 9.5rem; perspective: 600px; display: grid; place-items: center; }
.coin { width: 7rem; height: 7rem; position: relative; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.25, .9, .3, 1); }
.coin.toss { animation: toss .9s cubic-bezier(.3, .7, .3, 1); }
@keyframes toss { 40% { translate: 0 -34px; } 100% { translate: 0 0; } }
.face { position: absolute; inset: 0; border-radius: 50%; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-content: center; text-align: center; font: 700 1.55rem/1 var(--sans); }
.face::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 2px solid currentColor; opacity: 0.25; }
.face small { display: block; font: 700 0.6rem var(--sans); letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; margin-top: 0.35rem; }
.face.heads { background: #C85A36; color: #FFF5F0; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12), 0 10px 22px -10px rgba(120, 40, 10, .6); }
.face.tails { background: #2B2A27; color: #EDEAE3; transform: rotateY(180deg); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .25), 0 10px 22px -10px rgba(0, 0, 0, .6); }
.coin-side .tally { font: 600 0.95rem var(--sans); color: var(--ink-3); margin: 0.7rem 0 0.2rem; }
.coin-side .tally b { color: var(--ink); font-size: 1.2rem; }
.flips { display: flex; flex-wrap: wrap; gap: 5px; min-height: 1.5rem; margin-top: 0.5rem; }
.flips span { width: 1.5rem; height: 1.5rem; border-radius: 50%; font: 700 0.6rem/1.5rem var(--sans); text-align: center; color: #fff; animation: pop .3s cubic-bezier(.3, 1.4, .5, 1); }
.flips span.w { background: var(--accent-solid); }
.flips span.l { background: var(--ink-2); color: var(--card); }
@keyframes pop { from { transform: scale(0); } }

/* tiles you pick */
.picks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; margin: 0.2rem 0 0.9rem; }
.pick { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.5rem; border: 0; border-radius: 10px; background: var(--card); color: var(--ink-2); font: 650 0.74rem/1.25 var(--sans); cursor: pointer; text-align: left; box-shadow: 0 0 0 1.5px var(--line-2) inset; transition: transform .08s; }
.pick:hover { box-shadow: 0 0 0 1.5px var(--ink-3) inset; }
.pick:active { transform: scale(.97); }
.pick[aria-pressed="true"] { background: var(--tint); color: var(--ink); box-shadow: 0 0 0 2px var(--solid) inset; }
.pick svg { width: 100%; height: auto; }

/* habits turned over one at a time */
.rules { counter-reset: r; display: grid; gap: 0.7rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.rules li { counter-increment: r; background: var(--tint); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem 0.95rem 3.6rem; position: relative; }
.rules li::before { content: counter(r); position: absolute; left: 1.1rem; top: 1rem; width: 1.8rem; height: 1.8rem; border-radius: 6px; background: var(--ink); color: var(--card); font: 700 0.92rem/1.8rem var(--sans); text-align: center; }
.rules li strong { display: block; font: 700 1.05rem/1.35 var(--sans); margin-bottom: 0.25rem; color: var(--ink); }
.rules li p { margin: 0; font-size: 1.02rem; }
.js:not(.all) .rules li.hidden { display: none; }
.rules li.in { animation: in .4s var(--ease) both; }

/* ---- the end of the lesson: a quiet tick, the summary, the Key ideas sheet, then the next lesson ---- */
.finish { text-align: left; padding-top: 0.4rem; }
.finish .stamp { position: relative; display: block; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--good); color: transparent; font-size: 0; margin-bottom: 1.1rem; }
.finish .stamp::after { content: ""; position: absolute; inset: 0; background: var(--card); -webkit-mask: var(--i-check) center / 58% no-repeat; mask: var(--i-check) center / 58% no-repeat; }
.step.current .finish .stamp { animation: pop .45s cubic-bezier(.3, 1.4, .5, 1); }
.step.current .finish .stamp::after { animation: mark .35s .2s var(--ease) both; }
.finish > h2 { margin-bottom: 0.8rem; }
.finish > p { max-width: 38rem; }
.panel { background: var(--tint); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.25rem; margin: 1rem 0; font-size: 1.02rem; color: var(--ink-2); }
.panel h3 { font: 700 1rem var(--sans); color: var(--ink); margin: 0 0 0.45rem; }
.panel p:last-child { margin-bottom: 0; }
.panel.about { background: var(--card); border-color: var(--line-2); }
.panel.about h3 { color: var(--ink); }
details.precise { margin: 0.9rem 0; font: 400 0.97rem/1.55 var(--sans); color: var(--ink-2); }
details.precise summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; font: 700 0.75rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); list-style: none; }
details.precise summary::-webkit-details-marker { display: none; }
details.precise summary::before { content: "+"; width: 1rem; color: var(--ink); font-size: 0.95rem; }
details.precise[open] summary::before { content: "−"; }
details.precise[open] { padding: 0 0 0.4rem 0.9rem; border-left: 2px solid var(--line-2); }
details.code summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--ink); font: 600 0.95rem var(--sans); }
pre { overflow-x: auto; background: var(--tint); border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem; font: 0.78rem/1.55 var(--mono); color: var(--ink-2); }

/* ---- after the lesson: the reading pages (lesson notes first), set like a textbook page ----
   Running text is the serif at a 35rem measure (about 66 characters); boxes and figures keep the full column.
   The notes are plain children of .extras after <h2 id="notes">: h3 heads, paragraphs, the theory boxes, lists,
   and Check-yourself answers in closed <details>. */
.extras { max-width: var(--card-w); margin: 0 auto; padding: 0.5rem 1.5rem 0; border-top: 1px solid var(--line); box-sizing: content-box; }
.js:not(.all):not(.finished):not(.reading) .extras { display: none; }
.extras > h2 { max-width: var(--read-w); font: 600 1.9rem/1.18 var(--serif); color: var(--ink); margin: 3.2rem 0 1rem; letter-spacing: -0.015em; text-wrap: balance; scroll-margin-top: calc(var(--head-h) + var(--lbar-h) + 1.5rem); }
.extras > h2:not(:first-child) { padding-top: 2.2rem; border-top: 1px solid var(--line); }
.extras > h2#notes { margin-top: 2.6rem; }
.extras > h3 { max-width: var(--read-w); font: 600 1.28rem/1.25 var(--serif); color: var(--ink); margin: 2.1rem 0 0.5rem; letter-spacing: -0.005em; }
.extras > p, .extras > ul, .extras > ol { max-width: var(--read-w); font: 400 1.1875rem/1.62 var(--serif); color: var(--ink); margin: 0 0 1rem; }
.extras > p strong, .extras > ul strong, .extras > ol strong { font-weight: 650; }
.extras > p i, .extras > p em, .extras li em, .extras li i { font-style: italic; }
.extras > ul, .extras > ol { padding-left: 1.3rem; }
.extras > ul > li, .extras > ol > li { margin: 0 0 0.55rem; padding-left: 0.2rem; }
.extras > ul > li::marker { color: var(--ink-3); }
.extras > ol > li::marker { font: 650 0.9em var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.extras > p.meta-line { font: 500 0.9rem/1.5 var(--sans); color: var(--ink-3); }
.extras > figure.fig { margin: 1.5rem 0; }
/* Check yourself: the answer stays closed until asked for */
.extras details:not(.precise):not(.code) { margin: 0.2rem 0 0; font: 400 1.02rem/1.55 var(--sans); color: var(--ink-2); }
.extras details:not(.precise):not(.code) > summary { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 44px; cursor: pointer; list-style: none; font: 650 0.92rem var(--sans); color: var(--ink); }
.extras details:not(.precise):not(.code) > summary::-webkit-details-marker { display: none; }
.extras details:not(.precise):not(.code) > summary::before { content: ""; width: 0.75rem; height: 0.75rem; background: currentColor; -webkit-mask: var(--i-chev) center / contain no-repeat; mask: var(--i-chev) center / contain no-repeat; transition: transform .15s; }
.extras details[open]:not(.precise):not(.code) > summary::before { transform: rotate(90deg); }
.extras details[open]:not(.precise):not(.code) { margin-bottom: 0.6rem; padding: 0 0 0.5rem 1rem; border-left: 2px solid var(--line-2); }
.extras details:not(.precise):not(.code) > p { margin: 0 0 0.5rem; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 1.8rem 0 0.4rem; }
.pager a, .pager .soon { display: block; min-height: 4.4rem; border-radius: 10px; padding: 0.85rem 1.05rem; text-decoration: none; background: var(--card); box-shadow: 0 0 0 1.5px var(--line-2) inset; }
.pager a:hover { background: var(--tint); box-shadow: 0 0 0 1.5px var(--ink-3) inset; }
.pager .soon { box-shadow: 0 0 0 1px var(--line) inset; color: var(--ink-3); }
.pager .soon .t { color: var(--ink-3); font: 600 1rem var(--sans); }
.pager .dir { font: 700 0.75rem var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.pager .t { font: 650 1rem/1.3 var(--sans); color: var(--ink); }
/* the next lesson is the one solid thing on the end screen */
.pager a.next { background: var(--ink); box-shadow: none; text-align: right; }
.pager a.next .dir { color: color-mix(in srgb, var(--card) 70%, var(--ink)); }
.pager a.next .t { color: var(--card); }
.pager a.next:hover { background: color-mix(in srgb, var(--ink) 88%, var(--card)); }
.pager > :last-child { text-align: right; }
footer.site { max-width: var(--card-w); margin: 3rem auto 0; padding: 1.5rem 1.5rem 3rem; border-top: 1px solid var(--line); font: 500 0.85rem/1.55 var(--sans); color: var(--ink-3); box-sizing: content-box; }
footer.site p { margin: 0 0 0.5rem; max-width: 38rem; }

/* narrower than the outline needs: it becomes a drawer, opened from the dock */
@media (max-width: 1080px) {
  .has-outline .page, .has-outline .dock { margin-left: 0; left: 0; }
  .sections-btn { display: inline-flex; }
  .outline { top: 0; z-index: 60; width: min(340px, 88vw); transform: translateX(-100%); visibility: hidden; transition: transform .25s var(--ease), visibility 0s .25s; box-shadow: none; }
  .outline-open .outline { transform: none; visibility: visible; transition: transform .25s var(--ease); box-shadow: 0 0 60px rgba(0, 0, 0, .25); }
  .outline-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(28, 27, 25, .35); }
  .outline ol button, .outline ol a, .ol-lessons > a, .ol-lessons > span, .ol-back { min-height: 44px; align-items: center; }
  .outline .dot { margin-top: 0; }
  .lb-c, .lb-sep, .lb-nav { display: none; }
  .lb-title { flex: 1; }
  /* progress becomes the bar's bottom edge */
  .segs { position: absolute; left: 0; right: 0; bottom: -1px; max-width: none; margin: 0; gap: 2px; }
  .segs i { height: 3px; border-radius: 0; }
  /* show-all mode has no dock: Sections floats alone in the thumb corner */
  .js.all.has-outline .dock { display: block; background: none; border: 0; backdrop-filter: none; pointer-events: none; }
  .all .dock .btn, .all .dock .status { display: none; }
  .all .dock .sections-btn { pointer-events: auto; box-shadow: 0 0 0 1.5px var(--line-2) inset, 0 6px 20px -6px rgba(28, 27, 25, .35); }
}
@media (max-width: 720px) {
  .hide-sm, .site-links > a.hide-sm { display: none; }
  .site-head-inner { gap: 0.8rem; padding: 0 1rem; }
  .site-links { gap: 0; justify-content: flex-end; }
  .site-links > a { min-height: 44px; }
  .qw { display: none; }
  /* the far-end imprint has no room on a phone, so the publisher line sits under the wordmark instead */
  .brand { flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; }
  .brand .by { display: block; font: 600 0.68rem/1 var(--sans); letter-spacing: 0.02em; color: var(--ink-3); }
  .lesson-bar-inner { padding: 0 1rem; gap: 0.8rem; }
}
@media (max-width: 560px) {
  :root { --head-h: 56px; --lbar-h: 44px; }
  body { font-size: 1.0625rem; }
  main { padding: 0 1rem 10rem; }
  .brand { font-size: 1.14rem; }
  .step { padding: 2rem 0 1.5rem; }
  .cover { padding-top: 2.2rem; }
  .cover .dek { font-size: 1.18rem; }
  .step h2 { font-size: 1.6rem; }
  .step > figure, .step .figwrap { margin: 1.2rem -0.4rem 0.6rem; }
  figure.fig { padding: 0.9rem 0.7rem 0.75rem; border-radius: 14px; }
  .fig text { font-size: 16px; }
  .seg button { min-height: 44px; }
  .coinbox { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .coin-side .flips { justify-content: center; }
  .picks { grid-template-columns: repeat(2, 1fr); }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { order: -1; text-align: left; }
  .pager > :last-child { text-align: left; }
  /* the hint or verdict gets its own line above the buttons, so it never fights them for room */
  .dock-inner { flex-wrap: wrap; gap: 0.6rem; padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom)); }
  .dock .status { order: -1; flex: 0 0 100%; font-size: 0.92rem; padding-left: 0.1rem; }
  .dock .status:empty { display: none; }
  .dock [data-dock="main"] { margin-left: auto; min-width: 8.5rem; }
  .extras { padding: 0.5rem 1rem 0; }
  .extras > h2 { font-size: 1.6rem; margin-top: 2.6rem; }
  .extras > p, .extras > ul, .extras > ol { font-size: 1.125rem; line-height: 1.6; }
  .worked { padding-left: 0.9rem; }
  footer.site { padding: 1.5rem 1rem 3rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- v5, plain notes (11 Nov 2026): headings in the sans, no tracked capitals, figures without boxes ---- */
.ol-title, .step h2, .cover h1, .extras > h2, .extras > h3 { font-family: var(--sans); font-weight: 650; letter-spacing: -0.02em; }
.cover h1 { letter-spacing: -0.03em; }
.extras > p, .extras > ul, .extras > ol { font-family: var(--sans); }
.ol-h, .ol-lessons small, .step .no, .scenario .who, .worked .who, .holds .who, .keyideas h3, .face small, details.precise summary, .pager .dir { text-transform: none; letter-spacing: 0; }
.step .no, .scenario .who, .worked .who, .holds .who, details.precise summary, .pager .dir { font-weight: 600; font-size: 0.9rem; }
.keyideas h3 { font-size: 1rem; font-weight: 650; }
.ol-h { font: 600 0.85rem var(--sans); color: var(--ink-3); }
.outline .tag { margin-left: 0.35rem; padding: 0; background: none; box-shadow: none; text-transform: none; letter-spacing: 0; font: 500 0.82rem var(--sans); color: var(--ink-3); }
.outline .tag::before { content: "· "; }
figure.fig { background: none; border: 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 1rem 0 0.9rem; }
.cover .art { background: none; border: 0; border-radius: 0; padding: 0.5rem 0; }
.btn { border-radius: 6px; }
.scenario, .panel, .keyideas, .pager a, .pager .soon, .choice, .sections-btn { border-radius: 6px; }

/* the lesson bar: back to the course, the lesson's code, one thin bar, "Step 2 of 15". Title and neighbours live in the outline */
.lb-sep, .lb-t, .lb-nav { display: none; }
.lb-c::before { content: "‹ "; }
.lesson-bar-inner { max-width: 75rem; margin: 0 auto; }
/* the cover's course line repeats the lesson bar on screen; print keeps it */
@media screen { .cover .kicker { display: none; } }
.segs { gap: 0; max-width: 32rem; }
.segs i { height: 4px; border-radius: 0; }
.segs i:first-child { border-radius: 2px 0 0 2px; } .segs i:last-child { border-radius: 0 2px 2px 0; }

/* the outline is a drawer at every width, opened from the dock, so the lesson has the whole page */
.ol-k { display: none; }
.has-outline .page, .has-outline .dock { margin-left: 0; left: 0; }
.has-outline .site-head-inner { max-width: 75rem; }
.sections-btn { display: inline-flex; }
.outline { top: 0; z-index: 60; width: min(340px, 88vw); transform: translateX(-100%); visibility: hidden; transition: transform .25s var(--ease), visibility 0s .25s; box-shadow: none; }
.outline-open .outline { transform: none; visibility: visible; transition: transform .25s var(--ease); box-shadow: 0 0 60px rgba(0, 0, 0, .25); }
.outline-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(20, 20, 20, .35); }
.js.all.has-outline .dock { display: block; background: none; border: 0; backdrop-filter: none; pointer-events: none; }
.all .dock .btn, .all .dock .status { display: none; }
.all .dock .sections-btn { pointer-events: auto; box-shadow: 0 0 0 1.5px var(--line-2) inset, 0 6px 20px -6px rgba(20, 20, 20, .35); }
@media (max-width: 1080px) { .lb-c { display: inline; } }
/* the cover's facts (minutes, steps, simulated data): a plain row, no dots between */
.cover .meta { gap: 0.3rem 1.4rem; }
.cover .meta li + li::before { content: none; }
@media (max-width: 560px) {
  figure.fig { padding: 0.8rem 0 0.75rem; border-radius: 0; }
  .lb-c { overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
}

/* ---- v5 catalogue pages: the home page (the courses) and a course page (its lessons), each with progress ---- */
.cat { max-width: 66rem; margin: 0 auto; padding: 0 2rem 4rem; }
.cat h1 { font: 650 clamp(2.2rem, 5vw, 2.9rem)/1.1 var(--sans); letter-spacing: -0.03em; margin: 0 0 0.9rem; }
.cat h2 { font: 650 1.5rem/1.2 var(--sans); letter-spacing: -0.015em; margin: 0 0 0.3rem; }
.cat .lead { font-size: 1.2rem; line-height: 1.55; color: var(--ink-2); margin: 0 0 0.8rem; max-width: 34em; }
.cat .small { font: 400 0.92rem/1.5 var(--sans); color: var(--ink-3); margin: 0; }
.cat .btn { min-height: 42px; padding: 0 1.1rem; font: 650 0.95rem var(--sans); white-space: nowrap; }
.cat .pbar { height: 6px; border-radius: 3px; background: var(--tint-2); overflow: hidden; }
.cat .pbar i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.cat .frac { font: 600 0.88rem var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }

.cat .hero { display: grid; grid-template-columns: 1fr 25rem; gap: 3.5rem; align-items: end; padding: 3.5rem 0 2.5rem; border-bottom: 1px solid var(--line); }
.cat .hero figure { margin: 0; }
.cat .hero svg { display: block; width: 100%; height: auto; }
.cat .hero figcaption { font: 400 0.82rem/1.45 var(--sans); color: var(--ink-3); margin-top: 0.5rem; }
.cat .courses-sec { padding-top: 2.5rem; scroll-margin-top: var(--head-h); }
.cat .courses { list-style: none; margin: 1.4rem 0 0; padding: 0; border-top: 1px solid var(--line-2); }
.cat .courses > li { display: grid; grid-template-columns: 2.5rem 1fr 15rem 9.5rem; gap: 1.5rem; align-items: center; padding: 1.4rem 0; border-bottom: 1px solid var(--line); }
.cat .courses .no { align-self: start; padding-top: 0.15rem; font: 650 0.95rem var(--sans); color: var(--ink-3); }
.cat .courses .nm { font: 650 1.2rem/1.3 var(--sans); color: var(--ink); text-decoration: none; }
.cat .courses .nm:hover { text-decoration: underline; text-underline-offset: 0.18em; }
.cat .courses .bl { display: block; margin-top: 0.2rem; font: 400 0.96rem/1.45 var(--sans); color: var(--ink-2); }
.cat .courses .pg { display: grid; gap: 0.45rem; }
.cat .courses .act { justify-self: end; }
.cat .later { font: 400 0.95rem/1.5 var(--sans); color: var(--ink-3); margin: 1.1rem 0 0; }
.cat .about { display: grid; grid-template-columns: 1fr 1fr; gap: 3.5rem; padding: 2.5rem 0 1rem; margin-top: 2.5rem; border-top: 1px solid var(--line); font-size: 0.98rem; color: var(--ink-2); scroll-margin-top: var(--head-h); }
.cat .about p { margin: 0 0 0.7rem; }
.cat .linkbtn { padding: 0; border: 0; background: none; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; }

.cat .crumb { font: 500 0.92rem var(--sans); color: var(--ink-3); margin: 0; padding: 1.8rem 0 1.1rem; }
.cat .crumb a { color: var(--ink-3); text-decoration: none; }
.cat .crumb a:hover { color: var(--ink); text-decoration: underline; }
.cat .chead { display: grid; grid-template-columns: 1fr 19rem; gap: 3.5rem; align-items: end; padding-bottom: 1.8rem; border-bottom: 1px solid var(--line-2); }
.cat .chead .side { display: grid; gap: 0.6rem; justify-items: start; }
.cat .chead .side .pbar { width: 100%; height: 8px; border-radius: 4px; }
.cat .chead .side .btn { margin-top: 0.3rem; white-space: normal; text-align: left; }
.cat .chead .refs { display: flex; gap: 1.2rem; margin: 0.6rem 0 0; font: 500 0.95rem var(--sans); }
.cat .lessons { list-style: none; margin: 0; padding: 0; }
.cat .lessons a { display: grid; grid-template-columns: 3.2rem 1fr 4.5rem 1.4rem; gap: 1rem; align-items: baseline; padding: 0.95rem 0.5rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.cat .lessons a:hover { background: var(--tint); }
.cat .lessons .n { font: 600 0.92rem var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.cat .lessons .t { font: 650 1.05rem/1.35 var(--sans); }
.cat .lessons .d { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin-top: 0.2rem; font: 400 0.94rem/1.45 var(--sans); color: var(--ink-2); }
.cat .lessons .m { font: 400 0.88rem var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-3); text-align: right; }
.cat .lessons .k { position: relative; align-self: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--line-2) inset; }
.cat .lessons .done .k { background: var(--solid); box-shadow: none; }
.cat .lessons .done .k::after { content: ""; position: absolute; inset: 2px; background: var(--solid-ink); -webkit-mask: var(--i-check) center / contain no-repeat; mask: var(--i-check) center / contain no-repeat; }
.cat .lessons .done .t { color: var(--ink-2); }
.cat .lessons .next a { background: var(--tint); }
.cat .lessons .next .up { margin-left: 0.5rem; font: 600 0.8rem var(--sans); color: var(--ink-3); white-space: nowrap; }
.cat .cfoot { font: 400 0.92rem/1.5 var(--sans); color: var(--ink-3); margin: 1.3rem 0 0; }

@media (max-width: 860px) {
  .cat { padding: 0 1rem 3rem; }
  .cat .hero, .cat .chead, .cat .about { grid-template-columns: 1fr; gap: 1.4rem; }
  .cat .hero { padding-top: 2rem; }
  .cat .hero figure { order: 2; }
  .cat .courses > li { grid-template-columns: 1.6rem 1fr; gap: 0.5rem 0.8rem; }
  .cat .courses .pg, .cat .courses .act { grid-column: 2; justify-self: stretch; }
  .cat .courses .act { justify-self: start; margin-top: 0.3rem; }
  .cat .lessons a { grid-template-columns: 2.6rem 1fr 1.4rem; gap: 0.7rem; padding: 0.9rem 0.25rem; }
  .cat .lessons .m { display: none; }
}
/* on a phone the courses come first: the coin-flip figure is left out */
@media (max-width: 640px) { .cat .hero figure { display: none; } }

/* ---- print: the lesson's title, its Key ideas and its notes on one or two sheets ----
   Without the header, lesson bar, outline, dock or steps not yet opened. In show-all mode every step prints too. */
@media print {
  :root {
    --room: #fff; --card: #fff; --tint: #fff; --tint-2: #f0f0f0; --line: #cfcfcf; --line-2: #b5b5b5;
    --ink: #000; --ink-2: #1a1a1a; --ink-3: #444; --ink-4: #999; --accent-text: #000; --accent-deep: #000; --good: #000; --miss: #000;
    color-scheme: light;
  }
  @page { margin: 16mm 17mm; }
  html { font-size: 10.5pt; }
  body { background: #fff; }
  .site-head, .lesson-bar, .outline, .scrim, .dock, .pager, .showall, .panel, details.code, .meta-line, .cover .art, .cover .meta, .finish .stamp { display: none !important; }
  .has-outline .page { margin-left: 0; min-height: 0; }
  main { padding: 0; }
  .step, .extras, footer.site { max-width: none; padding: 0; margin: 0; border: 0; animation: none !important; }
  .cover h1 { font-size: 24pt; margin-bottom: 4pt; }
  .cover .dek { font-size: 12pt; max-width: none; margin-bottom: 10pt; }
  .cover .kicker { margin-bottom: 4pt; }
  .js:not(.all) .step:not(.cover):not(:has(.keyideas)) { display: none !important; }
  .js:not(.all) .step.cover, .js:not(.all) .step:has(.keyideas) { display: block !important; }
  .js:not(.all) .finish > :not(.keyideas) { display: none; }
  .keyideas { margin: 0 0 12pt; border-radius: 0; }
  .js .extras { display: block !important; }
  .extras > h2 { font-size: 16pt; margin: 14pt 0 6pt; padding: 0; border: 0; break-after: avoid; }
  .extras > h3 { font-size: 12pt; margin: 12pt 0 3pt; break-after: avoid; }
  .extras > p, .extras > ul, .extras > ol { max-width: none; font-size: 10.5pt; line-height: 1.45; margin-bottom: 6pt; orphans: 3; widows: 3; }
  .extras > #notes ~ h2, .extras > #notes ~ h2 ~ * { display: none !important; }
  .formula, .worked, .holds { margin: 8pt 0; }
  .formula .eq { font-size: 13pt; padding: 8pt; }
  .extras details > summary { min-height: 0 !important; }
  a { color: inherit; text-decoration: none; }
  footer.site { margin-top: 14pt; padding-top: 6pt; border-top: 1px solid var(--line); font-size: 8pt; }
}
