:root {
  --ink: #161616;
  --ink-soft: #666;
  --rule: #d8d8d4;
  --plus: #2b5fc7;   /* opinion +1, the initial majority */
  --minus: #e0562e;  /* opinion -1 */
  --measure: 39rem;
  --wide: 52rem;
}

html { background: #fff; }
body {
  margin: 0;
  color: var(--ink);
  font-family: Charter, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: 19px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga", "kern", "onum";
}

.masthead, main, footer { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem; }
.masthead { padding-top: 5rem; }
.kicker { font-size: 0.85rem; letter-spacing: 0.04em; color: var(--ink-soft); margin: 0 0 1.5rem; }
h1 { font-size: 2.35rem; line-height: 1.1; font-weight: normal; margin: 0 0 1rem; letter-spacing: -0.01em; }
.subtitle { font-size: 1.05rem; color: var(--ink-soft); margin: 0 0 3rem; line-height: 1.45; }

h2 { font-size: 1.25rem; font-weight: normal; margin: 3.5rem 0 1rem; line-height: 1.3; }
h2 .num { display: inline-block; min-width: 2.2rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
p { margin: 0 0 1.15rem; }
.lede { font-size: 1.15rem; }
.turn { font-size: 1.3rem; margin: 2.5rem 0; }
.close { margin-top: 2.5rem; }
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: #aaa; }
a:hover { text-decoration-color: var(--ink); }
a.cite { text-decoration-color: #c8c8c4; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }
b { font-weight: 600; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }

.katex-display { margin: 1.1rem 0 1.4rem; overflow-x: auto; overflow-y: hidden; }
.katex { font-size: 1.02em; }

.theorem { margin: 1.5rem 0 1.5rem; padding-left: 1.25rem; border-left: 1.5px solid var(--ink); }
.theorem p { margin-bottom: 0.9rem; }
.theorem p:last-child { margin-bottom: 0; }

/* figures */
figure { margin: 2.5rem auto; max-width: var(--wide); padding: 0 1.25rem; box-sizing: border-box; }
/* figures inside the text column break out to the wide measure, centered on the column */
main figure { width: min(var(--wide), 100vw); max-width: none; margin-left: calc((100% - min(var(--wide), 100vw)) / 2); margin-right: 0; }
figure.hero { margin-top: 0; margin-bottom: 3.5rem; }
figcaption { font-size: 0.86rem; line-height: 1.45; color: var(--ink-soft); margin: 0.7rem auto 0; max-width: calc(var(--measure) - 2.5rem); }
figcaption a { color: inherit; }
svg { width: 100%; height: auto; display: block; overflow: visible; }
svg text { font-family: inherit; }
svg a { cursor: pointer; text-decoration: none; }
svg a:hover text { text-decoration: underline; }
canvas#sim { width: 100%; height: auto; display: block; }
.sim-status { font-size: 0.9rem; color: var(--ink-soft); margin: 0.5rem 0 0; font-variant-numeric: tabular-nums; }
.sim-status b { font-weight: 600; color: var(--ink); }
.sim-status b.plus { color: var(--plus); }
.sim-status b.minus { color: var(--minus); }

.k-select { font-size: 0.86rem; color: var(--ink-soft); margin-bottom: 0.4rem; display: flex; gap: 0.6rem; align-items: baseline; }
.k-select button { font: inherit; font-size: 0.86rem; background: none; border: none; padding: 0; cursor: pointer; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.k-select button.on { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* ledger table for the CLT calculation */
table.ledger { border-collapse: collapse; width: 100%; margin: 0.5rem 0 1.4rem; }
table.ledger td { vertical-align: baseline; padding: 0.5rem 0; border-top: 1px solid var(--rule); }
table.ledger tr:first-child td { border-top: none; }
table.ledger td:first-child { padding-right: 1.5rem; width: 62%; }
table.ledger td:last-child { color: var(--ink-soft); font-size: 0.92rem; width: 38%; }

/* enumeration chain */
.chain { margin: 1.5rem 0 1.5rem; }
.chain .f { font-size: 1.02rem; margin-bottom: 0.3rem; }
.chain .g { color: var(--ink-soft); font-size: 0.92rem; line-height: 1.45; }
.chain .arrow { color: var(--ink-soft); font-size: 0.86rem; margin: 0.9rem 0; padding-left: 1.6rem; position: relative; }
.chain .arrow::before { content: "↓"; position: absolute; left: 0.2rem; top: -0.05rem; font-size: 1rem; color: var(--ink); }

/* lineage, timeline, closure, links, references */
ol.lineage, ol.timeline { list-style: none; padding: 0; margin: 1rem 0 1.5rem; }
ol.lineage li, ol.timeline li { display: grid; grid-template-columns: 8.5rem 1fr; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--rule); }
ol.lineage li:last-child, ol.timeline li:last-child { border-bottom: 1px solid var(--rule); }
.when { color: var(--ink-soft); font-size: 0.9rem; font-variant-numeric: tabular-nums; padding-top: 0.15rem; }
.what { font-size: 0.98rem; line-height: 1.45; }
ul.closure { padding-left: 1.2rem; margin: 0 0 1.15rem; }
ul.closure li { margin-bottom: 0.25rem; }
ul.links { list-style: none; padding: 0; margin: 0.5rem 0 2rem; }
ul.links li { padding: 0.45rem 0; border-top: 1px solid var(--rule); }
ul.links li:last-child { border-bottom: 1px solid var(--rule); }
ul.links .meta { color: var(--ink-soft); font-size: 0.88rem; margin-left: 0.6rem; }
ol.refs { padding-left: 2rem; margin: 0.5rem 0 5rem; font-size: 0.88rem; line-height: 1.45; color: var(--ink-soft); }
ol.refs li { margin-bottom: 0.5rem; }
ol.refs li:target { color: var(--ink); }
ol.refs a { color: inherit; }

@media (max-width: 640px) {
  body { font-size: 17px; }
  .masthead { padding-top: 3rem; }
  h1 { font-size: 1.8rem; }
  ol.lineage li, ol.timeline li { grid-template-columns: 1fr; gap: 0.15rem; }
  table.ledger td:first-child { white-space: normal; }
}

/* The frontier is typeset at reading size, with bars on a common exponent scale.
   Keep math in ordinary HTML: SVG foreignObject labels misplace it on iOS. */
#frontier { --label-width: 16rem; margin-top: 3rem; margin-bottom: 3rem; }
#frontier h3 { font-size: 1.35rem; line-height: 1.25; font-weight: normal; margin: 0 0 .4rem; }
.figure-deck { font-size: .95rem; color: var(--ink-soft); margin: 0 0 1.25rem; }
.frontier-scale { margin-left: calc(var(--label-width) + 1.5rem); }
.scale-direction { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: .8rem; }
.scale-ticks { position: relative; height: 1.8rem; margin-top: .35rem; border-top: 1px solid var(--rule); }
.scale-ticks span { position: absolute; left: var(--tick); transform: translateX(-50%); padding-top: .3rem; font-size: .85rem; }
.scale-ticks span:first-child { transform: none; }
.scale-ticks span:last-child { transform: translateX(-100%); }
.frontier-rows { list-style: none; padding: 0; margin: 0; }
.frontier-rows li { display: grid; grid-template-columns: var(--label-width) minmax(0,1fr); column-gap: 1.5rem; padding: .8rem 0; border-bottom: 1px solid #ededeb; }
.result-name { font-size: .93rem; line-height: 1.35; }
.result-year { display: block; font-size: .78rem; color: var(--ink-soft); margin-bottom: .15rem; font-variant-numeric: tabular-nums; }
.result-plot { min-width: 0; }
.density-track { position: relative; height: 1.2rem; border-left: 1px solid var(--rule); border-right: 1px dashed #888; }
.density-track::before, .density-track::after { content: ""; position: absolute; top: 0; height: 100%; border-left: 1px solid var(--rule); }
.density-track::before { left: 50%; }
.density-track::after { left: 66.6667%; }
.density-bar { position: absolute; left: 0; top: .3rem; width: var(--reach); height: .6rem; background: var(--ink); z-index: 1; box-sizing: border-box; }
.density-bar.hollow { border: 1px solid var(--ink); background: #fff; }
.result-note { font-size: .8rem; line-height: 1.55; color: var(--ink-soft); margin: .35rem 0 0; }
.our-result .result-name, .our-result .result-note { color: var(--plus); }
.our-result .density-bar { background: linear-gradient(to right, var(--plus) 88%, #edf2fc 100%); }
#frontier figcaption { max-width: none; margin-top: 1rem; font-size: .82rem; }
.chain { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 1.2rem 0; margin: 2rem 0; }
.chain h3 { font-size: 1rem; line-height: 1.4; font-weight: normal; margin: 0 0 .6rem; }
.chain .f .katex-display { font-size: .92em; margin: .7rem 0 1rem; }
.chain .arrow { margin: 1.3rem 0; }
.plot-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.plot-scroll svg { min-width: 600px; overflow: hidden; }
.ledger .katex { white-space: normal; }
@media (max-width: 640px) {
  #frontier { --label-width: 0rem; }
  .frontier-scale { margin-left: 0; }
  .frontier-rows li { grid-template-columns: minmax(0,1fr); row-gap: .45rem; padding: 1rem 0; }
  .result-year { display: inline; margin-right: .65rem; }
  .result-name { font-size: .95rem; }
  .result-note { font-size: .8rem; }
  .density-track { height: 1.4rem; }
  .density-bar { top: .4rem; }
  table.ledger, table.ledger tbody, table.ledger tr, table.ledger td { display: block; width: auto; }
  table.ledger tr { border-top: 1px solid var(--rule); padding: .7rem 0; }
  table.ledger tr:first-child { border-top: none; }
  table.ledger td:first-child, table.ledger td:last-child { width: auto; padding: 0; border: 0; }
  table.ledger td:last-child { margin-top: .4rem; }
  table.ledger td:first-child { overflow-x: auto; overflow-y: hidden; }
  .chain .f .katex-display { font-size: .94em; }
  .response-formula .katex-display { font-size: .95em; }
}

/* Preserve the original line-and-dot figure, with a gap and a second axis.
   LaTeX labels stay in ordinary HTML to avoid Safari foreignObject positioning. */
.phase-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.phase-diagram { position: relative; width: 100%; min-width: 680px; aspect-ratio: 800 / 380; }
.phase-diagram svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.phase-diagram path { fill: none; vector-effect: non-scaling-stroke; }
.phase-blue { color: var(--plus); }
.phase-orange { color: var(--minus); }
.phase-soft { color: var(--ink-soft); }
.phase-grid { stroke: var(--rule); stroke-width: 1; }
.phase-axis { stroke: currentColor; stroke-width: 1.4; }
.phase-handoff { stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 2 4; }
.phase-line { stroke: currentColor; stroke-width: 1.7; }
.phase-dot { fill: currentColor; }
.phase-zero { stroke: currentColor; stroke-width: 1.5; stroke-dasharray: 3 4; }
.phase-empty { fill: white; stroke: currentColor; stroke-width: 1.5; }
.phase-label { position: absolute; left: var(--x); top: var(--y); transform: translateY(-50%); white-space: nowrap; font-size: .8rem; line-height: 1.2; }
.phase-label.centered { transform: translate(-50%, -50%); }
.phase-label.right-aligned { transform: translate(-100%, -50%); }
.phase-label.phase-title { font-size: 1rem; }
#phases figcaption { max-width: none; }
