/* Mathematics Fundamentals: the look.

   A precision drafting board in a dark room — shared 1:1 with the Manim videos.
   Color is strictly semantic, never decorative:

     white   prose, headings, axes, established structure
     blue    given quantities, inputs, starting geometry (#58a6ff)
     gold    the unknown, active transformation, key insight, history (#f2b84b)
     teal    proven result, invariant, completed grouping, verified output (#3dd68c)
     coral   contradiction, trap, overflow, broken assumption (#ff645a)
*/

@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin-wght-italic.woff2") format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/source-sans-3-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Code Pro"; src: url("fonts/source-code-pro-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }

:root {
  --ground: #0b0e14;
  --screen: #06080d;
  --panel: #111622;
  --rule: #222938;
  --rule-2: #364156;

  --white: #dcdcd6;
  --white-hi: #f5f5f0;
  --white-lo: #9ea4b0;
  --white-off: #727987;

  --blue: #58a6ff;
  --blue-hi: #99cbff;
  --blue-lo: #2e66a8;

  --gold: #f2b84b;
  --gold-hi: #ffd88a;
  --gold-lo: #9e7324;

  --teal: #3dd68c;
  --teal-hi: #8cf0be;
  --teal-lo: #228254;

  --coral: #ff645a;
  --coral-hi: #ff9f98;
  --coral-lo: #a63832;

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "Source Code Pro", ui-monospace, Consolas, monospace;
  --measure: 40.375rem;
  --wide: 53.75rem;
  --gutter: 1rem;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--ground); }
body {
  margin: 0; background: var(--ground); color: var(--white);
  font-family: var(--serif); font-size: 1.09rem; line-height: 1.66; font-weight: 400;
  font-optical-sizing: auto; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-variant-numeric: lining-nums;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "running" "beside" "main" "foot";
}
@media (min-width: 46em) { body { font-size: 1.16rem; } }

::selection { background: var(--gold); color: #06080d; }
a { color: var(--white-hi); text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--blue); color: var(--white-hi); }
a:focus-visible, input:focus-visible { outline: 1px solid var(--blue); outline-offset: 3px; }
strong { font-weight: 650; color: var(--white-hi); }
em { font-style: italic; }
.planned { color: var(--white-off); }
.spoken { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.emblem { display: inline-block; width: 16px; height: 16px; fill: currentColor; flex: none; }

/* ---- KaTeX math styling -------------------------------------------------------------------- */
.katex { font-size: 1.04em; color: var(--white-hi); }
.math-display {
  margin: 1.55em 0 1.65em; padding: 0.95em 1.25em; overflow-x: auto;
  background: var(--screen); border: 1px solid var(--rule); border-left: 2px solid var(--blue-lo);
  scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent;
}
.math-display .katex-display { margin: 0; }
.math-err { color: var(--coral); font-family: var(--mono); }

/* ---- running head -------------------------------------------------------------------------- */
.running {
  grid-area: running; position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 2.6rem; padding: 0 var(--gutter); border-bottom: 1px solid var(--rule); background: var(--ground);
  font-family: var(--sans); font-size: 0.78rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase;
}
.crumbs { display: flex; align-items: center; gap: 0.8em; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a, .crumbs .here { display: inline-flex; align-items: center; gap: 0.55em; color: var(--white-lo); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: var(--white-hi); }
.crumbs .book { color: var(--white-hi); font-weight: 650; flex: none; }
.crumbs .here { color: var(--white-hi); }
.crumbs .sep { color: var(--rule-2); }
.crumbs .no { color: var(--white-off); font-variant-numeric: tabular-nums; }
.crumbs .here .no { color: var(--blue); }
.top-actions { display: flex; align-items: center; gap: 1.1rem; flex: none; }
.shorts-link { color: var(--gold); text-decoration: none; font-weight: 600; }
.shorts-link:hover { color: var(--gold-hi); text-decoration: underline; text-underline-offset: 0.25em; }
.open-contents { position: relative; cursor: pointer; color: var(--white-hi); user-select: none; flex: none; }
.open-contents input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.open-contents::after { content: " +"; color: var(--white-lo); }
.open-contents:has(input:checked)::after { content: " \2212"; }
@media (max-width: 46em) { .crumbs .here, .crumbs .chapter + .sep { display: none; } }

/* ---- sidebar contents ---------------------------------------------------------------------- */
.booknav {
  grid-area: beside; display: none; padding: 1rem var(--gutter) 1.25rem; border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: 0.89rem; line-height: 1.35;
}
body:has(#_contents-open:checked) .booknav { display: block; }
.booknav ol { margin: 0; padding: 0; list-style: none; }
.navhead { display: none; }
.booknav .part { margin: 1.5em 0 0.6em; padding-top: 1em; border-top: 1px solid var(--rule); font-size: 0.71rem; font-weight: 600; line-height: 1.5; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-off); }
.booknav a, .booknav .planned { display: grid; grid-template-columns: 1.65rem 1.5rem 1fr; align-items: center; padding: 0.27em 0; color: var(--white); text-decoration: none; }
.booknav .planned { color: var(--white-off); }
.booknav a:hover { color: var(--white-hi); }
.booknav a:hover .title { text-decoration: underline; text-decoration-color: var(--blue-lo); text-underline-offset: 0.2em; }
.booknav .emblem { color: var(--blue); }
.booknav .planned .emblem { color: var(--rule-2); }
.booknav .no { font-size: 0.86em; color: var(--white-off); font-variant-numeric: tabular-nums; }
.booknav a[aria-current] { color: var(--white-hi); font-weight: 650; }
.booknav a[aria-current] .emblem, .booknav .open > a .emblem { color: var(--gold); }
.booknav .under { margin: 0.2em 0 0.6em 0.45rem; border-left: 1px solid var(--rule-2); font-size: 0.94em; }
.booknav .under a, .booknav .under .planned { grid-template-columns: 2.7rem 1fr; padding-left: 1.15rem; }
.booknav .under a[aria-current] { box-shadow: -2px 0 0 var(--gold); }
.booknav .headings { margin: 0.1em 0 0.4em 3.85rem; font-size: 0.92em; }
.booknav .headings a { display: block; padding: 0.18em 0; color: var(--white-lo); font-weight: 400; box-shadow: none; }

@media (min-width: 62em) {
  body { grid-template-columns: 17.8rem minmax(0, 1fr); grid-template-areas: "running running" "beside main" "beside foot"; }
  .booknav, body:has(#_contents-open:checked) .booknav {
    display: block; position: sticky; top: 2.6rem; align-self: start; min-height: calc(100vh - 2.6rem); max-height: calc(100vh - 2.6rem); overflow-y: auto;
    padding: 1.7rem 1rem 4rem 1.5rem; border-bottom: 0; border-right: 1px solid var(--rule);
    scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent;
  }
  .open-contents { display: none; }
}

/* ---- column and margin --------------------------------------------------------------------- */
main { grid-area: main; min-width: 0; padding: 0 var(--gutter) 3rem; --frame: var(--wide); }
@media (min-width: 62em) { main { padding: 0 2.5rem 4rem; } }
.head, .flow, .outline, .contents, .turn, .video-card { max-width: var(--frame); margin-left: auto; margin-right: auto; }
.flow > * { margin-top: 0; margin-bottom: 1.05em; max-width: var(--measure); }
.flow > .figure.wide, .flow > .table, .flow > .tabular, .flow > .exhibit { max-width: none; clear: both; }
.flow::after { content: ""; display: block; clear: both; }
.gives { display: none; }
@media (min-width: 76em) {
  .flow > .gives {
    display: block; float: right; clear: right; width: 11.6rem; margin: 0.42em 0 0; max-width: none;
    font-family: var(--sans); font-size: 0.8rem; font-weight: 600; line-height: 1.4; letter-spacing: 0.02em; color: var(--gold);
  }
  .gives span { display: block; padding-left: 0.8rem; border-left: 1px solid var(--gold-lo); margin-bottom: 0.25rem; }
}

/* ---- heads --------------------------------------------------------------------------------- */
.head { padding: 3.1rem 0 1.8rem; margin-bottom: 2.1rem; border-bottom: 1px solid var(--rule); }
.head > * { margin-bottom: 0; }
.head > .kicker, .kicker { display: flex; align-items: center; gap: 0.8em; margin: 0 0 1.2rem; font-family: var(--sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-lo); }
.kicker a { display: inline-flex; align-items: center; gap: 0.8em; color: inherit; text-decoration: none; }
.kicker a:hover { color: var(--white-hi); }
.kicker .no { color: var(--blue); font-variant-numeric: tabular-nums; }
.kicker .emblem { color: var(--gold); }
.head > h1, h1 { margin: 0 0 0.9rem; font-size: 2.65rem; line-height: 1.08; font-weight: 600; letter-spacing: -0.012em; color: var(--white-hi); text-wrap: balance; }
.head .lede, .lede { margin: 0; max-width: 44rem; font-size: 1.22em; line-height: 1.46; color: var(--white); text-wrap: pretty; }

.title-page { padding: 5.2rem 0 2.6rem; }
.title-page > h1 { margin-bottom: 1.4rem; font-size: clamp(2.8rem, 6vw, 4.4rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.03; }

.opener { padding-top: 3.4rem; }
.opener > .kicker { margin-bottom: 2rem; }
.opener .kicker .emblem { width: 32px; height: 32px; }
.opener > .numeral { margin: 0 0 0.3rem; font-size: 5.2rem; font-weight: 300; line-height: 1; letter-spacing: -0.02em; color: var(--rule-2); font-variant-numeric: lining-nums; }
.opener > h1 { margin-bottom: 1.8rem; font-size: 3.4rem; }
.says { display: block; margin-bottom: 0.35rem; font-family: var(--sans); font-size: 0.73rem; font-style: normal; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-off); }
.opener > .story { margin: 0 0 1.45rem; max-width: 44rem; font-size: 1.65em; line-height: 1.26; font-style: italic; font-weight: 400; color: var(--white-hi); text-wrap: balance; }
.story q { quotes: "\201C" "\201D"; }
.opener > .lede .says { color: var(--teal); }
.fault > .numeral { color: var(--coral); }

/* ---- embedded video card (9:16 Short & 16:9 Film) ------------------------------------------ */
.video-card {
  margin-top: 0; margin-bottom: 2.4rem;
  border: 1px solid var(--rule-2); background: var(--screen);
}
.video-bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.65rem 1.15rem; border-bottom: 1px solid var(--rule); background: var(--panel);
  font-family: var(--sans); font-size: 0.75rem;
}
.video-bar .badge { font-weight: 650; letter-spacing: 0.11em; text-transform: uppercase; color: var(--gold); }
.video-bar .hint { color: var(--white-lo); }
.video-stage { display: flex; justify-content: center; background: #04060a; padding: 1rem; }
.video-card.short .video-stage video { width: 100%; max-width: 315px; aspect-ratio: 9 / 16; background: #000; border: 1px solid var(--rule); }
.video-card.film .video-stage { padding: 0; }
.video-card.film .video-stage video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }

/* ---- /shorts standalone gallery (grouped by chapter) --------------------------------------- */
.shorts-chapter { max-width: var(--wide); margin: 0 auto 3.2rem; padding-top: 1.5rem; border-top: 1px solid var(--rule-2); }
.shorts-chapter:first-of-type { margin-top: 0.5rem; }
.shorts-chapter-head {
  display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1.4rem;
}
.shorts-chapter-mark { color: var(--gold); display: inline-flex; flex: none; }
.shorts-chapter-mark .emblem { width: 26px; height: 26px; }
.shorts-chapter-head h2 {
  border: 0; margin: 0; padding: 0; font-size: 1.45rem; line-height: 1.2; flex: 1;
}
.shorts-chapter-head h2::before { display: none; }
.shorts-chapter-head h2 .no { font-family: var(--sans); font-size: 0.85em; font-weight: 500; color: var(--blue); margin-right: 0.25rem; }
.shorts-chapter-head h2 a { color: var(--white-hi); text-decoration: none; }
.shorts-chapter-head h2 a:hover { text-decoration: underline; text-decoration-color: var(--blue); text-underline-offset: 0.2em; }
.shorts-chapter-count {
  font-family: var(--sans); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--white-lo); padding: 0.25rem 0.65rem; border: 1px solid var(--rule-2); background: var(--panel); white-space: nowrap;
}
.shorts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr)); gap: 1.6rem;
}
.short-tile {
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--rule-2); background: var(--screen);
}
.short-meta { padding: 1.05rem 1.15rem 0.9rem; border-bottom: 1px solid var(--rule); background: var(--panel); }
.short-kicker { margin: 0 0 0.35rem; font-family: var(--sans); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.short-meta h3 { border: 0; margin: 0 0 0.35rem; padding: 0; font-size: 1.12rem; font-style: normal; line-height: 1.25; }
.short-meta h3 a { color: var(--white-hi); text-decoration: none; }
.short-meta h3 a:hover { text-decoration: underline; text-decoration-color: var(--blue); }
.short-hook { margin: 0; font-size: 0.88rem; line-height: 1.45; color: var(--white-lo); }
.short-player { padding: 0.85rem; display: flex; justify-content: center; background: #04060a; }
.short-player video { width: 100%; max-width: 310px; aspect-ratio: 9 / 16; display: block; background: #000; border: 1px solid var(--rule); }

/* ---- prose --------------------------------------------------------------------------------- */
.section { margin-top: 3.1rem; }
h2 { position: relative; clear: both; margin: 0 0 0.75em; padding-top: 1.05rem; font-size: 1.6rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.006em; color: var(--white-hi); border-top: 1px solid var(--rule); text-wrap: balance; }
h3 { margin: 1.85em 0 0.5em; font-size: 1.15rem; font-weight: 600; font-style: italic; color: var(--white-hi); }
p { text-wrap: pretty; hyphens: manual; }
ul, ol { padding-left: 1.3em; }
li { margin: 0.32em 0; }
li::marker { color: var(--blue); font-size: 0.9em; }
blockquote { margin-left: 0; padding-left: 1.2em; border-left: 1px solid var(--rule-2); color: var(--white-lo); font-style: italic; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }

/* ---- code & verified Math Lab exhibits ----------------------------------------------------- */
code { font-family: var(--mono); font-size: 0.85em; color: var(--teal); }
code.whole { white-space: nowrap; }
a code { color: inherit; }
pre {
  position: relative; margin: 1.5em 0 1.7em; padding: 0.95em 1.2em 1em; overflow-x: auto;
  background: var(--screen); border: 1px solid var(--rule); border-left: 2px solid var(--teal-lo);
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.6; color: var(--teal-hi);
}
pre code { font-size: inherit; color: inherit; }
.exhibit { margin: 1.8em 0 2em; }
.exhibit figcaption {
  display: flex; align-items: baseline; gap: 0.9em; margin: 0; padding: 0 0 0.5em; border: 0; background: none;
  font-family: var(--sans); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal);
}
.exhibit .what::before { content: ""; display: inline-block; width: 0.58em; height: 0.58em; margin-right: 0.65em; background: var(--teal); }
.exhibit .name, .exhibit .program { font-family: var(--mono); font-size: 0.95em; font-weight: 500; text-transform: none; letter-spacing: 0.02em; color: var(--white-lo); }
.exhibit figcaption a { color: inherit; text-decoration: none; }
.exhibit figcaption a:hover { text-decoration: underline; color: var(--white-hi); }
.exhibit pre { margin: 0; border-left: 2px solid var(--teal); }
.exhibit .gap { color: var(--white-off); }

/* ---- notes --------------------------------------------------------------------------------- */
.note {
  --kind: var(--white-lo); --ink: var(--white);
  position: relative; clear: both; margin: 1.9em 0 2em; padding: 0.15rem 0 0.2rem 1.35rem;
  border-left: 2px solid var(--kind); font-size: 0.95em; line-height: 1.6; color: var(--ink);
}
.note > :last-child { margin-bottom: 0; }
.note > p { margin: 0 0 0.8em; }
.note > p:first-child > strong:first-child {
  display: flex; align-items: center; gap: 0.6em; margin: 0 0 0.45rem;
  font-family: var(--sans); font-size: 0.74rem; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--kind);
}
.note[data-kind="why"] { --kind: var(--blue); }
.note[data-kind="history"] { --kind: var(--gold); --ink: color-mix(in srgb, var(--gold) 22%, var(--white-hi)); }
.note[data-kind="history"] strong { color: var(--gold); }
.note[data-kind="trap"] { --kind: var(--coral); border-left: 4px double var(--coral); }
.note[data-kind="deeper"] { --kind: var(--white-lo); border-left: 1px dashed var(--rule-2); font-size: 0.91em; color: var(--white-lo); }
.note[data-kind="try"] { --kind: var(--teal); }

/* ---- tables -------------------------------------------------------------------------------- */
.table { overflow-x: auto; margin: 1.6em 0 1.8em; }
table { width: 100%; border-collapse: collapse; font-size: 0.92em; line-height: 1.48; font-variant-numeric: tabular-nums lining-nums; border-bottom: 1px solid var(--rule-2); }
thead th {
  padding: 0.7em 0.9em 0.6em; text-align: left; vertical-align: bottom; white-space: nowrap;
  font-family: var(--sans); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-lo);
  border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2);
}
td { padding: 0.55em 0.9em; vertical-align: top; border-bottom: 1px solid var(--rule); }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; }
.tabular { margin: 1.9em 0 2.1em; }
.tabular .table { margin: 0.7em 0 0; }
td > .label { display: none; }

/* ---- figures: precision plates ------------------------------------------------------------- */
.figure { position: relative; clear: both; margin: 2.2em 0 2.4em; border: 1px solid var(--rule-2); background: var(--screen); }
.figure .art { padding: 22px 20px 20px; overflow-x: auto; }
.figure svg { display: block; width: 100%; max-width: var(--natural); min-width: calc(var(--natural) * 0.72); height: auto; margin: 0 auto; overflow: visible; }
figcaption { margin: 0; padding: 0.8em 1.3rem 0.85em; border-top: 1px solid var(--rule-2); font-size: 0.88em; line-height: 1.5; color: var(--white-lo); background: var(--ground); }
figcaption .no { margin-right: 0.7em; font-family: var(--sans); font-size: 0.84em; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--white-hi); }
.tabular figcaption { padding: 0; border-top: 0; background: none; }

/* ---- chapter outline & front-page contents ------------------------------------------------- */
.outline { margin-top: 3rem; clear: both; }
.outline h2 { font-family: var(--sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-lo); }
.outline ol { margin: 0; padding: 0; list-style: none; }
.outline li { display: grid; grid-template-columns: 3.4rem 1fr; column-gap: 0.4rem; margin: 0; padding: 0.95rem 0 1rem; border-bottom: 1px solid var(--rule); }
.outline li > a, .outline li > .planned { display: contents; text-decoration: none; color: var(--white-hi); font-weight: 600; font-size: 1.06em; }
.outline li > .planned { color: var(--white-lo); }
.outline li > a .title { justify-self: start; text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 0.2em; }
.outline li > a:hover .title { text-decoration-color: var(--blue); }
.outline .no { font-family: var(--sans); font-size: 0.84em; font-weight: 500; color: var(--blue); padding-top: 0.2em; font-variant-numeric: tabular-nums; }
.outline .planned .no { color: var(--white-off); }
.outline .about { grid-column: 2; font-size: 0.94em; line-height: 1.5; color: var(--white-lo); margin-top: 0.2rem; }

.contents { margin-top: 3.5rem; }
.contents > h2 { margin-bottom: 0; font-family: var(--sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-lo); }
.part + .part { margin-top: 3rem; }
.part-head { display: flex; align-items: baseline; gap: 1.1rem; margin: 0; padding: 0 0 0.8rem; border-bottom: 1px solid var(--rule-2); font-size: 1.5rem; font-style: normal; line-height: 1.2; }
.part-no { flex: none; font-family: var(--sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.part-title { font-weight: 600; color: var(--white-hi); }
.toc { margin: 0; padding: 0; list-style: none; }
.toc li { display: grid; grid-template-columns: 3.4rem 2.1rem minmax(0, 1fr) auto; align-items: baseline; margin: 0; padding: 1.1rem 0 1.15rem; border-bottom: 1px solid var(--rule); }
.toc .mark { grid-row: 1 / span 3; align-self: start; padding-top: 0.2rem; color: var(--rule-2); }
.toc .written .mark { color: var(--gold); }
.toc .mark .emblem { width: 32px; height: 32px; }
.toc .entry { display: contents; }
.toc .entry a, .toc .entry .planned { display: contents; color: var(--white-hi); text-decoration: none; font-weight: 600; line-height: 1.3; }
.toc .entry .no { font-family: var(--sans); font-size: 0.9em; font-weight: 500; color: var(--blue); font-variant-numeric: tabular-nums; }
.toc .entry .planned .no { color: var(--white-off); }
.toc .entry .title { justify-self: start; font-size: 1.14em; }
.toc .entry a .title { text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 0.2em; }
.toc .entry a:hover .title { text-decoration-color: var(--blue); }
.toc .count { margin: 0; grid-row: 1; grid-column: 4; justify-self: end; font-family: var(--sans); font-size: 0.74rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--white-off); white-space: nowrap; }
.toc .story { margin: 0.28rem 0 0; grid-column: 3 / -1; font-style: italic; font-size: 1.03em; line-height: 1.4; color: var(--white-hi); }
.toc .about { margin: 0.2rem 0 0; grid-column: 3 / -1; max-width: 39rem; font-size: 0.92em; line-height: 1.5; color: var(--white-lo); }

/* ---- turn of page & colophon --------------------------------------------------------------- */
.turn { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; clear: both; margin-top: 4rem; padding-top: 1.2rem; border-top: 1px solid var(--rule-2); }
.turn a, .turn > span { display: block; color: var(--white-hi); text-decoration: none; font-weight: 600; font-size: 1.06em; line-height: 1.35; }
.turn a:hover { text-decoration: underline; text-decoration-color: var(--blue); text-underline-offset: 0.2em; }
.turn .after { text-align: right; grid-column: 2; }
.turn .dir { display: block; margin-bottom: 0.3rem; font-family: var(--sans); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-off); }
.turn .no { font-family: var(--sans); font-size: 0.86em; font-weight: 500; color: var(--blue); margin-right: 0.3em; font-variant-numeric: tabular-nums; }
.colophon { grid-area: foot; padding: 2rem var(--gutter) 3rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.8rem; color: var(--white-off); }
.colophon p { max-width: var(--wide); margin: 0.3em auto; }
.colophon a { color: var(--white-lo); }
@media (min-width: 62em) { .colophon { padding-left: 2.5rem; padding-right: 2.5rem; } }

/* ---- part stationeries --------------------------------------------------------------------- */
h2::before { content: ""; position: absolute; left: 0; top: -1px; width: 2.4rem; height: 2px; background: var(--blue); }
[data-part="1"] h2::before { width: 1.6rem; height: 3px; top: -2px; background: var(--blue); }
[data-part="2"] h2::before { width: 3.2rem; height: 2px; top: -1px; background: linear-gradient(90deg, var(--gold) 0 46%, transparent 46% 54%, var(--gold) 54% 100%); }
[data-part="3"] h2 { border-top: 3px double var(--rule-2); }
[data-part="3"] h2::before { top: -3px; width: 2.4rem; height: 3px; background: var(--teal); }
[data-part="4"] h2::before { top: -1px; width: 5rem; height: 1px; background: var(--white-hi); }
.outline h2::before, .contents > h2::before { width: 2.4rem; height: 2px; top: -1px; background: var(--gold); }
.outline h2, .contents > h2 { border-top: 1px solid var(--rule); }

/* ---- semantic SVG figure grammar (1:1 parity with video/style.py) -------------------------- */
.fig { --pen: var(--blue); --pen-hi: var(--blue-hi); --pen-lo: var(--blue-lo); }
.fig .struct { --pen: var(--white); --pen-hi: var(--white-hi); --pen-lo: var(--white-off); }
.fig .given  { --pen: var(--blue);  --pen-hi: var(--blue-hi);  --pen-lo: var(--blue-lo); }
.fig .focus  { --pen: var(--gold);  --pen-hi: var(--gold-hi);  --pen-lo: var(--gold-lo); }
.fig .result { --pen: var(--teal);  --pen-hi: var(--teal-hi);  --pen-lo: var(--teal-lo); }
.fig .trap   { --pen: var(--coral); --pen-hi: var(--coral-hi); --pen-lo: var(--coral-lo); }

.fig text { font-family: var(--sans); font-size: 13.5px; font-weight: 450; fill: var(--white); }
.fig .label { font-size: 10.5px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; fill: var(--white-lo); }
.fig .val { font-family: var(--mono); font-size: 13px; fill: var(--pen); }
.fig .big { font-size: 18px; font-weight: 600; }
.fig .small { font-size: 12px; }
.fig .val.big { font-size: 18px; }
.fig .val.small { font-size: 11.5px; }
.fig text.hi { fill: var(--white-hi); font-weight: 600; }
.fig text.lo { fill: var(--white-off); }
.fig text.pen { fill: var(--pen); font-weight: 600; }
.fig .val.hi { fill: var(--pen-hi); }
.fig .val.lo { fill: var(--pen-lo); }

.fig .wire { fill: none; stroke: var(--pen); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.fig .wire.hi { stroke: var(--pen-hi); stroke-width: 2; }
.fig .wire.lo { stroke: var(--pen-lo); stroke-width: 1.1; }
.fig .wire.dash { stroke-dasharray: 4 4; }
.fig .cell { fill: none; stroke: var(--pen-lo); stroke-width: 1.15; }
.fig .cell.on { fill: color-mix(in srgb, var(--pen) 13%, transparent); stroke: var(--pen); stroke-width: 1.4; }
.fig .cell.solid { fill: var(--pen); stroke: none; }
.fig .cell.off { stroke: var(--pen-lo); stroke-dasharray: 3 3; opacity: 0.55; }
.fig .hatch { fill: none; stroke: var(--pen-lo); stroke-width: 1; opacity: 0.7; }
.fig .pip { fill: var(--pen); stroke: none; }
.fig .pip.hi { fill: var(--pen-hi); }
.fig .pip.lo { fill: var(--pen-lo); }
.fig .dim { fill: none; stroke: var(--white-off); stroke-width: 1; }
.fig .dim.dash { stroke-dasharray: 2 3; }
.fig .grid { fill: none; stroke: var(--rule); stroke-width: 1; }
.fig .head { fill: var(--white-off); stroke: none; }
.fig .head.pen { fill: var(--pen); }

@media (max-width: 46em) {
  h1 { font-size: 2rem; }
  .opener > h1 { font-size: 2.45rem; }
  .opener > .numeral { font-size: 3.9rem; }
  .figure .art { padding: 14px 12px 12px; }
  .toc li { grid-template-columns: 2.9rem 1.8rem minmax(0, 1fr) auto; }
}
