/* From the API Down — see STYLE.md for the design plan.
   Structure is carried by hairline rules and hanging indents. No cards, no shadows,
   no border-radius except on the two form controls. */

:root {
  --paper:   #F1F3F2;
  --surface: #F8F9F8;
  --ink:     #171A19;
  --ink-2:   #5C645F;
  --rule:    #D3D8D5;
  --accent:  #1F5C8B;
  --oxide:   #9C3D28;

  --grid:    rgba(23,26,25,.05);
  --wash:    rgba(31,92,139,.07);
  --oxide-wash: rgba(156,61,40,.06);

  --serif: "Iowan Old Style", "New York", Charter, Palatino, "Palatino Linotype", Georgia, serif;
  --mono:  ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 68ch;
  --margin-col: 13rem;
  --rail: 17.5rem;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper:   #131718;
  --surface: #1A1F20;
  --ink:     #DCE2E0;
  --ink-2:   #8E9995;
  --rule:    #2C3335;
  --accent:  #77B6E2;
  --oxide:   #D9836B;
  --grid:    rgba(220,226,224,.05);
  --wash:    rgba(119,182,226,.10);
  --oxide-wash: rgba(217,131,107,.09);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #131718;
    --surface: #1A1F20;
    --ink:     #DCE2E0;
    --ink-2:   #8E9995;
    --rule:    #2C3335;
    --accent:  #77B6E2;
    --oxide:   #D9836B;
    --grid:    rgba(220,226,224,.05);
    --wash:    rgba(119,182,226,.10);
    --oxide-wash: rgba(217,131,107,.09);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 19px; -webkit-text-size-adjust: 100%; }
@media (max-width: 700px) { html { font-size: 17.5px; } }

body {
  margin: 0;
  background-color: var(--paper);
  /* graph paper, in the gutters only — the text column paints over it */
  background-image:
    repeating-linear-gradient(0deg,  var(--grid) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 28px);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.72;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--wash); }

/* ─── links ─────────────────────────────────────────────────────────────── */

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color 120ms linear, background-color 120ms linear;
}
a:hover { border-bottom-color: var(--accent); background: var(--wash); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ─── shell ─────────────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: var(--rail) minmax(0,1fr); min-height: 100vh; }

.rail {
  border-right: 1px solid var(--rule);
  background: var(--surface);
  padding: 1.4rem 0 4rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  font-size: .78rem; line-height: 1.5;
}
.rail::-webkit-scrollbar { width: 9px; }
.rail::-webkit-scrollbar-thumb { background: var(--rule); }

.rail-head { padding: 0 1.1rem 1rem; border-bottom: 1px solid var(--rule); margin-bottom: .9rem; }
.rail-head .wordmark {
  display: block; font-size: .96rem; line-height: 1.25; font-weight: 600;
  letter-spacing: -.005em; color: var(--ink); border: 0;
}
.rail-head .wordmark:hover { background: none; }
.rail-head .sub { color: var(--ink-2); font-size: .74rem; margin-top: .2rem; }

.rail-search {
  width: calc(100% - 2.2rem); margin: 0 1.1rem .9rem; padding: .34rem .5rem;
  font: inherit; font-size: .78rem; font-family: var(--serif);
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 2px;
}
.rail-search:focus { outline: none; border-color: var(--accent); }

.rail-part { border: 0; background: none; width: 100%; text-align: left; cursor: pointer;
  font: inherit; font-size: .78rem; font-weight: 600; color: var(--ink);
  padding: .3rem 1.1rem .3rem 1.6rem; display: flex; gap: .5rem; align-items: baseline; }
.rail-part:hover { background: var(--wash); }
.rail-part .pn { color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums;
  position: absolute; margin-left: -1.15rem; }
.rail-part .pdone { margin-left: auto; color: var(--ink-2); font-weight: 400; font-size: .72rem; }
.rail-part[aria-expanded="false"] + .rail-list { display: none; }

.rail-list { list-style: none; margin: 0 0 .55rem; padding: 0; }
.rail-list a {
  display: flex; gap: .5rem; align-items: baseline;
  padding: .17rem 1.1rem .17rem 2.3rem; border: 0; color: var(--ink-2);
  position: relative;
}
.rail-list a:hover { background: var(--wash); color: var(--ink); }
.rail-list .ln { position: absolute; left: 1.1rem; font-variant-numeric: tabular-nums;
  font-size: .72rem; opacity: .8; }
.rail-list a.is-done { color: var(--ink-2); }
.rail-list a.is-done .lt { text-decoration: line-through; text-decoration-color: var(--rule); }
.rail-list a.is-stub .lt { opacity: .55; }
.rail-list a.is-stub .lt::after { content: " ·"; }
.rail-list a[aria-current="page"] {
  color: var(--ink); background: var(--wash);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ─── main + margin column ──────────────────────────────────────────────── */

.main { min-width: 0; }
.wrap {
  max-width: calc(var(--measure) + var(--margin-col) + 8rem);
  margin: 0; padding: 2.6rem 3rem 7rem 3.4rem;
  display: grid; grid-template-columns: minmax(0, var(--measure)) var(--margin-col);
  column-gap: 2.6rem; align-items: start;
}
.col { min-width: 0; grid-column: 1; }
.marginalia { grid-column: 2; }

/* the reading column is a sheet laid on the table; the margin keeps the grid */
.col { background: var(--surface); border-right: 1px solid var(--rule);
  padding: 1.6rem 2.2rem 3rem 2.8rem; margin-top: -1.6rem; }

/* ─── lesson header ─────────────────────────────────────────────────────── */

.lesson-head { margin-bottom: 2.2rem; }
.lesson-head .eyebrow {
  font-size: .8rem; color: var(--ink-2); margin: 0 0 .35rem;
  display: flex; gap: .55rem; align-items: baseline; flex-wrap: wrap;
}
.lesson-head .eyebrow b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.lesson-head h1 {
  font-size: 2.15rem; line-height: 1.16; font-weight: 600; letter-spacing: -.014em;
  margin: 0 0 1.1rem; max-width: 22ch;
}
.lesson-head h1 .num {
  color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums;
  margin-right: .5rem;
}

/* metadata as a real definition list — no middle dots, no caps eyebrows */
.meta { display: grid; grid-template-columns: max-content 1fr; gap: .18rem 1rem;
  margin: 0; font-size: .8rem; border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule); padding: .7rem 0; }
.meta dt { color: var(--ink-2); }
.meta dd { margin: 0; }
.meta dd a { font-size: .8rem; }

/* rent: three ticks, filled by level. Structural, not a pastel pill. */
.rent { display: inline-flex; gap: 2px; align-items: flex-end; vertical-align: -1px;
  margin-right: .35rem; }
.rent i { display: block; width: 3px; background: var(--rule); }
.rent i:nth-child(1) { height: 6px; }
.rent i:nth-child(2) { height: 9px; }
.rent i:nth-child(3) { height: 12px; }
.rent[data-r="1"] i:nth-child(-n+1),
.rent[data-r="2"] i:nth-child(-n+2),
.rent[data-r="3"] i:nth-child(-n+3) { background: var(--accent); }
.rent[data-r="3"] i { background: var(--accent); }

.tag { font-size: .74rem; color: var(--ink-2); border: 1px solid var(--rule);
  padding: 0 .3rem; }
.tag[data-t="core"] { color: var(--ink); border-color: var(--ink-2); }

/* ─── the spine ─────────────────────────────────────────────────────────── */

.col { position: relative; }
.spine { position: absolute; left: 1.2rem; top: 2rem; bottom: 2rem; width: 1px;
  background: var(--rule); }
.spine .fill { position: absolute; top: 0; left: 0; width: 1px; height: 0;
  background: var(--accent); transition: height 180ms ease-out; }
.spine .tick { position: absolute; left: -3px; width: 7px; height: 1px;
  background: var(--rule); border: 0; padding: 0; cursor: pointer; }
.spine .tick:hover { background: var(--accent); width: 11px; left: -5px; }
.spine .tick.on { background: var(--accent); }

/* ─── body type ─────────────────────────────────────────────────────────── */

.col > * { max-width: var(--measure); }

h2 {
  font-size: 1.55rem; line-height: 1.22; font-weight: 600; letter-spacing: -.011em;
  margin: 3rem 0 .9rem; padding-top: .4rem; position: relative;
}
h2 .hn { position: absolute; left: -1.6rem; top: .55rem; font-size: .78rem;
  color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums; }
h3 { font-size: 1.2rem; font-weight: 600; margin: 2rem 0 .5rem; line-height: 1.3; }

p { margin: 0 0 1.05rem; }
.col > p:first-of-type { margin-top: 0; }

.hook { font-size: 1.08rem; line-height: 1.62; border-left: 2px solid var(--ink);
  padding-left: 1.1rem; margin: 0 0 2.4rem; }
.hook p:last-child { margin-bottom: 0; }

ul, ol { margin: 0 0 1.05rem; padding-left: 1.4rem; }
li { margin-bottom: .35rem; }
li::marker { color: var(--ink-2); }

strong { font-weight: 600; }
em { font-style: italic; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.6rem 0; }

/* ─── code, tables, figures — these break the measure ───────────────────── */
/* Breakout is measured from the column, not from --measure. --measure is 68ch,
   which resolves ~120px wider in the serif than the real column, so an absolute
   calc overhung the sticky marginalia. 4rem = the col's right padding (2.2) plus
   the grid gap (2.6) less clearance, so these never draw under the margin notes. */

code { font-family: var(--mono); font-size: .84em; }
p code, li code, td code, dd code {
  background: var(--wash); padding: .05em .28em; border-bottom: 1px solid var(--rule);
}

pre {
  font-family: var(--mono); font-size: .76rem; line-height: 1.62;
  background: var(--paper); border: 1px solid var(--rule); border-left: 2px solid var(--accent);
  padding: .9rem 1.1rem; overflow-x: auto; margin: 1.5rem 0;
  max-width: none; width: calc(100% + 2.2rem);
}
@media (max-width: 1100px) { pre { width: 100%; } }
pre code { background: none; padding: 0; border: 0; font-size: inherit; }
/* Code must NOT wrap: these blocks carry tensor shapes and comments in aligned columns,
   and wrapping drops the continuation to column 0 where it reads as a new statement.
   So it scrolls — but macOS overlay scrollbars reserve no space, which made an over-long
   line look truncated rather than scrollable. Force a classic, always-visible bar. */
pre::-webkit-scrollbar { height: 9px; }
pre::-webkit-scrollbar-track { background: var(--wash); }
pre::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 0; }
pre:hover::-webkit-scrollbar-thumb { background: var(--ink-2); }
.code-cap { font-size: .78rem; color: var(--ink-2); margin: -1.1rem 0 1.5rem; }
.code-cap b { font-weight: 600; color: var(--ink); }

figure { margin: 2rem 0; max-width: none;
  width: calc(100% + 2.2rem); }
@media (max-width: 1100px) { figure { width: 100%; } }
figure svg { max-width: 100%; height: auto; display: block; }
figure .mermaid { display: flex; justify-content: center; }
figcaption { font-size: .78rem; color: var(--ink-2); margin-top: .6rem;
  border-top: 1px solid var(--rule); padding-top: .4rem; max-width: var(--measure); }
figcaption b { color: var(--ink); font-weight: 600; }

table { border-collapse: collapse; font-size: .84rem; margin: 1.6rem 0;
  max-width: none; width: calc(100% + 2.2rem); }
@media (max-width: 1100px) { table { width: 100%; display: block; overflow-x: auto; } }

/* `.col > *` (0,1,0) outranks the bare pre/figure/table selectors (0,0,1), so their
   `max-width: none` never took effect and the three broke out to three different
   widths — 68ch resolves differently in mono .76rem, serif .84rem and serif 1rem.
   Match the specificity so all three share one breakout, as STYLE.md section 6 intends. */
.col > pre, .col > figure, .col > table { max-width: calc(100% + 2.2rem); }
@media (max-width: 1100px) { .col > pre, .col > figure, .col > table { max-width: 100%; } }
th, td { text-align: left; padding: .38rem .8rem .38rem 0; border-bottom: 1px solid var(--rule);
  vertical-align: baseline; }
th { font-weight: 600; border-bottom-color: var(--ink-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 1.4rem; }

/* ─── callouts, differentiated by structure ─────────────────────────────── */

/* 1. wrong mental model — the only oxide thing in the body */
.wrong { margin: 2.2rem 0; border-top: 2px solid var(--oxide); padding-top: .75rem; }
.wrong > .lbl { font-size: .8rem; color: var(--oxide); font-weight: 600; margin-bottom: .5rem; }
.wrong > .belief { background: var(--oxide-wash); padding: .7rem .9rem; margin-bottom: .85rem;
  border-bottom: 1px solid var(--rule); }
.wrong > .belief::before { content: "You would reasonably assume: "; font-weight: 600;
  color: var(--oxide); }
.wrong > .belief p { margin: 0; display: inline; }
.wrong > .fix p:last-child { margin-bottom: 0; }

/* 1b. words you actually need — unavoidable jargon, named and cashed out up front.
   A ruled definition list, no fill: the term in mono accent, the plain version in
   serif, and why you cannot dodge it set smaller underneath. */
.jargon { margin: 2.2rem 0; border-top: 1px solid var(--ink-2);
  border-bottom: 1px solid var(--rule); padding: .75rem 0 .9rem; }
.jargon > .lbl { font-size: .8rem; font-weight: 600; margin-bottom: .75rem; }
.jargon dl { display: grid; grid-template-columns: minmax(6.5rem, max-content) 1fr;
  gap: .55rem 1.5rem; margin: 0; }
.jargon dt { font-family: var(--mono); font-size: .8rem; color: var(--accent);
  padding-top: .12rem; }
.jargon dd { margin: 0; font-size: .94rem; line-height: 1.55; }
.jargon dd .why { display: block; font-size: .8rem; color: var(--ink-2);
  margin-top: .1rem; }
@media (max-width: 640px) {
  .jargon dl { grid-template-columns: 1fr; gap: .15rem; }
  .jargon dt { padding-top: .5rem; }
  .jargon dd { margin-bottom: .5rem; }
}

/* 2. contested — two ruled positions, no fill */
.contested { margin: 2.2rem 0; border-top: 1px solid var(--ink-2);
  border-bottom: 1px solid var(--ink-2); padding: .75rem 0; }
.contested > .lbl { font-size: .8rem; font-weight: 600; margin-bottom: .7rem; }
.contested .sides { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.6rem; }
.contested .sides > div:first-child { border-right: 1px solid var(--rule); padding-right: 1.6rem; }
.contested .sides h4 { margin: 0 0 .35rem; font-size: .88rem; font-weight: 600; color: var(--oxide); }
.contested .sides p { font-size: .92rem; margin-bottom: .5rem; }
.contested .sides p:last-child { margin-bottom: 0; }
@media (max-width: 760px) {
  .contested .sides { grid-template-columns: 1fr; }
  .contested .sides > div:first-child { border-right: 0; padding-right: 0;
    border-bottom: 1px solid var(--rule); padding-bottom: .8rem; margin-bottom: .8rem; }
}

/* 3. connect — a note in the margin of the book */
.connect { margin: 2.2rem 0 2.2rem 1.6rem; border-left: 2px solid var(--accent);
  padding-left: 1.2rem; }
.connect > .lbl { font-size: .8rem; color: var(--accent); font-weight: 600; margin-bottom: .35rem; }
.connect p:last-child { margin-bottom: 0; }

/* 4. ship it — torn from the notebook */
.ship { margin: 2.4rem 0; border-top: 1px dashed var(--ink-2); padding-top: .85rem; }
.ship > .lbl { font-size: .8rem; font-weight: 600; margin-bottom: .5rem;
  display: flex; align-items: center; gap: .5rem; }
.ship > .lbl .est { color: var(--ink-2); font-weight: 400; margin-left: auto; font-size: .78rem; }
.ship .task { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: .7rem; }
.ship .task input { margin-top: .42rem; accent-color: var(--accent); }
.ship .task .t { font-weight: 600; }
.ship ol { font-size: .94rem; margin-bottom: .6rem; }
.ship .out { font-size: .88rem; color: var(--ink-2); border-top: 1px solid var(--rule);
  padding-top: .5rem; }
.ship .out b { color: var(--ink); font-weight: 600; }
.ship.done > .lbl, .ship.done .task .t { color: var(--ink-2); }
.ship.done .task .t { text-decoration: line-through; text-decoration-color: var(--rule); }

/* 5. explain it back — hanging numbers, no box */
.explain { margin: 2.6rem 0; border-top: 1px solid var(--rule); padding-top: 1rem; }
.explain > .lbl { font-size: .8rem; font-weight: 600; margin-bottom: .9rem; }
.explain details { border-bottom: 1px solid var(--rule); padding: .55rem 0 .55rem 2rem;
  position: relative; }
.explain details:last-of-type { border-bottom: 0; }
.explain summary { cursor: pointer; list-style: none; font-weight: 600; }
.explain summary::-webkit-details-marker { display: none; }
.explain summary::before { content: counter(qc); counter-increment: qc;
  position: absolute; left: 0; color: var(--ink-2); font-weight: 400;
  font-variant-numeric: tabular-nums; }
.explain { counter-reset: qc; }
.explain summary:hover { color: var(--accent); }
.explain details[open] summary { margin-bottom: .5rem; }
.explain .ans { font-size: .94rem; }
.explain .ans p:last-child { margin-bottom: 0; }

/* 6. go deeper — a bibliography */
.deeper { margin: 2.6rem 0; border-top: 1px solid var(--rule); padding-top: 1rem; }
.deeper > .lbl { font-size: .8rem; font-weight: 600; margin-bottom: .8rem; }
.deeper li { list-style: none; padding-left: 1.6rem; text-indent: -1.6rem;
  margin-bottom: .85rem; font-size: .94rem; }
.deeper ul { padding-left: 0; }
.deeper .src { font-size: .78rem; color: var(--ink-2); display: block;
  text-indent: 0; padding-left: 1.6rem; margin-top: .12rem; }
.deeper .req { color: var(--oxide); font-weight: 600; }
.deeper .unverified { color: var(--ink-2); font-style: italic; }

/* ─── margin notes ──────────────────────────────────────────────────────── */

.marginalia { font-size: .78rem; color: var(--ink-2); line-height: 1.5;
  position: sticky; top: 2.6rem; }
.mnote { border-top: 1px solid var(--rule); padding-top: .45rem; margin-bottom: 1.5rem; }
.mnote b { color: var(--ink); font-weight: 600; display: block; margin-bottom: .15rem; }
.mnote ul { padding-left: 1rem; margin: .3rem 0 0; }
.mnote li { margin-bottom: .18rem; }
.mnote a { font-size: inherit; }

/* threads as marks, not pills */
.threadmark { display: block; padding-left: .8rem; position: relative; margin-bottom: .2rem; }
.threadmark::before { content: ""; position: absolute; left: 0; top: .55em;
  width: 5px; height: 5px; background: var(--accent); }

/* ─── glossary tooltip ──────────────────────────────────────────────────── */

.gt { border-bottom: 1px dotted var(--ink-2); cursor: help; }
.gt-pop { position: absolute; z-index: 40; max-width: 24rem; background: var(--surface);
  border: 1px solid var(--ink-2); padding: .6rem .75rem; font-size: .82rem;
  line-height: 1.5; color: var(--ink); }
.gt-pop b { display: block; font-weight: 600; margin-bottom: .15rem; }
.gt-pop a { font-size: .78rem; }

/* ─── footer nav ────────────────────────────────────────────────────────── */

.lesson-foot { margin-top: 3.5rem; border-top: 1px solid var(--ink-2); padding-top: 1.1rem; }
.mark {
  display: inline-flex; align-items: center; gap: .55rem; cursor: pointer;
  font: inherit; font-size: .88rem; font-family: var(--serif);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--ink-2); border-radius: 2px; padding: .35rem .8rem;
}
.mark:hover { background: var(--wash); }
.mark[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
:root[data-theme="dark"] .mark[aria-pressed="true"] { color: var(--paper); }

.pn-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; margin-top: 1.6rem; }
.pn-nav a { border: 0; display: block; }
.pn-nav a:hover { background: none; }
.pn-nav .dir { font-size: .78rem; color: var(--ink-2); display: block; }
.pn-nav .tt { font-size: .96rem; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.pn-nav a:hover .tt { border-bottom-color: var(--accent); }
.pn-nav .next { text-align: right; }
.pn-nav .none { color: var(--ink-2); }
.teaser { font-size: .88rem; color: var(--ink-2); margin-top: 1.4rem;
  border-top: 1px solid var(--rule); padding-top: .6rem; }

/* notes box */
.notes { margin-top: 2.6rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.notes label { font-size: .8rem; font-weight: 600; display: block; margin-bottom: .45rem; }
.notes textarea {
  width: 100%; min-height: 7rem; resize: vertical; font: inherit; font-size: .88rem;
  font-family: var(--serif); line-height: 1.6; padding: .6rem .75rem;
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 2px;
}
.notes textarea:focus { outline: none; border-color: var(--accent); }
.notes .saved { font-size: .76rem; color: var(--ink-2); margin-top: .3rem; height: 1rem; }

/* ─── tutor block ───────────────────────────────────────────────────────── */

.tutor { margin: 2.6rem 0 0; border: 1px solid var(--rule); border-left: 2px solid var(--ink-2);
  padding: .85rem 1rem; }
.tutor .lbl { font-size: .8rem; font-weight: 600; margin-bottom: .35rem; }
.tutor p { font-size: .88rem; color: var(--ink-2); margin-bottom: .6rem; }
.tutor .cmd { display: flex; gap: .6rem; align-items: center; }
.tutor code { background: var(--paper); border: 1px solid var(--rule); padding: .25rem .5rem;
  font-size: .8rem; flex: 1; }
.copy { font: inherit; font-family: var(--serif); font-size: .8rem; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--ink-2);
  border-radius: 2px; padding: .25rem .6rem; }
.copy:hover { background: var(--wash); }

/* ─── stub state ────────────────────────────────────────────────────────── */

.stub { border-top: 2px solid var(--ink-2); padding-top: 1rem; margin-top: 2rem; }
.stub .lbl { font-weight: 600; margin-bottom: .5rem; }
.stub p { color: var(--ink-2); }
.stub .covers { font-size: .94rem; }
.stub .ask { border-top: 1px solid var(--rule); padding-top: .8rem; margin-top: 1.2rem; }

/* ─── dashboard ─────────────────────────────────────────────────────────── */

.dash-head { margin-bottom: 2.4rem; }
.dash-head h1 { font-size: 2.4rem; line-height: 1.1; font-weight: 600; margin: 0 0 .5rem;
  letter-spacing: -.018em; }
.dash-head .lede { font-size: 1.05rem; color: var(--ink-2); max-width: 54ch; margin: 0; }

.resume { border-top: 2px solid var(--accent); border-bottom: 1px solid var(--rule);
  padding: 1rem 0 1.1rem; margin: 2rem 0; }
.resume .lbl { font-size: .8rem; color: var(--ink-2); margin-bottom: .3rem; }
.resume .tt { font-size: 1.35rem; font-weight: 600; line-height: 1.25; display: block;
  letter-spacing: -.01em; }
.resume .why { font-size: .88rem; color: var(--ink-2); margin-top: .5rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 2rem 0;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stats div { padding: .8rem 1rem .8rem 0; border-right: 1px solid var(--rule); }
.stats div:last-child { border-right: 0; }
.stats .v { font-size: 1.5rem; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums; display: block; }
.stats .k { font-size: .76rem; color: var(--ink-2); }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; }
  .stats div:nth-child(2) { border-right: 0; } }

.partbar { display: flex; height: 3px; background: var(--rule); margin: .35rem 0 0; }
.partbar i { display: block; background: var(--accent); height: 3px; }

.partlist { margin: 2.6rem 0; }
.partrow { border-top: 1px solid var(--rule); padding: 1rem 0; }
.partrow:last-child { border-bottom: 1px solid var(--rule); }
.partrow .ph { display: flex; align-items: baseline; gap: .7rem; }
.partrow .pnum { font-size: .8rem; color: var(--ink-2); font-variant-numeric: tabular-nums;
  width: 2.2rem; flex: none; }
.partrow h3 { margin: 0; font-size: 1.15rem; }
.partrow .psub { color: var(--ink-2); font-size: .88rem; }
.partrow .pmeta { margin-left: auto; font-size: .78rem; color: var(--ink-2);
  font-variant-numeric: tabular-nums; display: flex; gap: 1.1rem; }
.partrow .pship { font-size: .84rem; color: var(--ink-2); margin: .5rem 0 0 2.9rem;
  padding-left: .8rem; border-left: 2px solid var(--rule); max-width: 62ch; }
.partrow .pship b { color: var(--ink); font-weight: 600; }
.partrow ol { list-style: none; padding: 0; margin: .7rem 0 0 2.9rem; }
.partrow ol li { display: flex; gap: .6rem; align-items: baseline; margin-bottom: .12rem;
  font-size: .9rem; }
.partrow ol a { border: 0; }
.partrow ol a:hover { background: none; text-decoration: underline; }
.partrow .li-n { color: var(--ink-2); font-variant-numeric: tabular-nums; width: 2.1rem;
  flex: none; font-size: .8rem; }
.partrow .li-h { margin-left: auto; color: var(--ink-2); font-size: .78rem;
  font-variant-numeric: tabular-nums; flex: none; }
.partrow .locked { color: var(--ink-2); font-size: .78rem; border: 1px solid var(--rule);
  padding: 0 .35rem; flex: none; }
.partrow .is-done .li-t { text-decoration: line-through; text-decoration-color: var(--rule);
  color: var(--ink-2); }
.partrow .is-stub .li-t { opacity: .6; }

.filters { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap;
  font-size: .82rem; margin: 1.6rem 0; border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule); padding: .6rem 0; }
.filters label { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
.filters input { accent-color: var(--accent); }
.filters .sp { margin-left: auto; color: var(--ink-2); }

.toolbtn { font: inherit; font-family: var(--serif); font-size: .8rem; cursor: pointer;
  background: none; color: var(--accent); border: 0; border-bottom: 1px solid transparent;
  padding: 0; }
.toolbtn:hover { border-bottom-color: var(--accent); }

/* search results */
.results { margin: 1.6rem 0; }
.results .r { border-top: 1px solid var(--rule); padding: .6rem 0; }
.results .r .rn { font-size: .78rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.results .r .rt { font-weight: 600; }
.results .r .rc { font-size: .84rem; color: var(--ink-2); }
.results mark { background: var(--wash); color: var(--ink); }

/* threads page */
.thread { margin: 2.8rem 0; border-top: 2px solid var(--accent); padding-top: .9rem; }
.thread h2 { margin: 0 0 .3rem; font-size: 1.4rem; }
.thread h2 .hn { display: none; }
.thread .blurb { color: var(--ink-2); font-size: .94rem; max-width: 58ch; }
.thread ol { list-style: none; padding: 0; margin: 1rem 0 0; }
.thread ol li { display: flex; gap: .7rem; align-items: baseline; padding: .22rem 0;
  border-bottom: 1px solid var(--rule); }
.thread .li-n { color: var(--ink-2); font-variant-numeric: tabular-nums; width: 2.4rem; flex: none; }
.thread .li-h { margin-left: auto; color: var(--ink-2); font-size: .8rem; flex: none; }

/* glossary page */
.gloss dl { margin: 0; }
.gloss dt { font-weight: 600; margin-top: 1.3rem; border-top: 1px solid var(--rule);
  padding-top: .5rem; }
.gloss dd { margin: .2rem 0 0; color: var(--ink); }
.gloss .owner { font-size: .78rem; color: var(--ink-2); display: block; margin-top: .15rem; }

/* ─── top bar ───────────────────────────────────────────────────────────── */

.topbar { display: flex; gap: 1rem; align-items: center; font-size: .8rem;
  border-bottom: 1px solid var(--rule); padding: .5rem 3rem .5rem 3.4rem;
  position: sticky; top: 0; background: var(--surface); z-index: 30; }
.topbar .crumb { color: var(--ink-2); }
.topbar .crumb a { font-size: inherit; }
.topbar .right { margin-left: auto; display: flex; gap: 1rem; align-items: center; }
.railtoggle { display: none; }

/* ─── responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; width: var(--rail); z-index: 50;
    transform: translateX(-100%); transition: transform 160ms ease-out; }
  body.rail-open .rail { transform: none; }
  body.rail-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.3);
    z-index: 45; }
  .railtoggle { display: inline-block; }
  .wrap { grid-template-columns: minmax(0,1fr); padding: 2rem 2rem 6rem 2.4rem; }
  .col { border-right: 0; }
  .marginalia { grid-column: 1; margin-top: 2.5rem; border-top: 1px solid var(--ink-2);
    padding-top: 1rem; position: static; max-width: var(--measure); }
  .mnote { display: inline-block; vertical-align: top; width: 15rem; margin-right: 2rem; }
  .topbar { padding: .5rem 2rem .5rem 2.4rem; }
}
@media (max-width: 700px) {
  .wrap { padding: 1.6rem 0 5rem; }
  .col { padding: 1.4rem 1.2rem 2.5rem 2rem; }
  .spine { left: .8rem; }
  .topbar { padding: .5rem 1.2rem .5rem 1.6rem; }
  h2 .hn { position: static; display: block; margin-bottom: .1rem; }
  .mnote { width: 100%; margin-right: 0; display: block; }
  .lesson-head h1 { font-size: 1.75rem; }
  .pn-nav { grid-template-columns: 1fr; gap: 1rem; }
  .pn-nav .next { text-align: left; }
}

@media print {
  .rail, .topbar, .marginalia, .notes, .tutor, .lesson-foot .mark { display: none; }
  body { background: #fff; color: #000; }
  .shell, .wrap { display: block; }
}
