/* ==========================================================================
   Counterfactual Debugging the World Model Transfer Gap — project page
   Editorial layout after pi.website (warm paper, serif display, mono labels,
   wide rounded media) + academic structure after advantage-guidance.github.io
   (TL;DR, numbered method cards, collapsible algorithm, KaTeX, BibTeX).
   ========================================================================== */

:root {
  color-scheme: light;
  /* page */
  --bg: #ffffff;
  --bg-hover: #f0f0ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #686868;
  --muted-2: #898781;
  --card: #edece4;
  --card-border: #e6e0cb;
  --divider: #dfdccc;
  --hl: #fbd45b;
  --surface: #fcfcfb;          /* chart surface (palette validated against this) */
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  /* data roles (dataviz reference slots 1-3, validated all-pairs, light) */
  --fix: #2a78d6;              /* phi / injected real transition */
  --real: #eb6834;             /* real environment */
  --wm: #1baf7a;               /* world model */
  --base: #52514e;             /* prediction-error baselines (dashed) */
  /* type */
  --serif: "Newsreader", "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* layout: one column for text, videos and figures alike */
  --prose: 50rem;
  --wide: var(--prose);
  --hero: 62.5rem;             /* the hero alone is wider than the column, its captions stay in it */
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
[id] { scroll-margin-top: 1.25rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video, canvas, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 3px; }
strong { font-weight: 650; }
sub, sup { line-height: 0; }

.page { padding: 1.5rem 1rem 3.5rem; overflow-x: clip; }
@media (min-width: 768px) { .page { padding: 3.5rem 3rem 5rem; } }

.prose { max-width: var(--prose); margin-inline: auto; }
.wide { max-width: var(--wide); margin-inline: auto; }
#hero { max-width: var(--hero); }
.prose p { margin: 0 0 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem; padding-left: 1.25rem; }
.prose li + li { margin-top: .35rem; }

/* ---------- hero ---------- */
.title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.3rem, 5vw, 3.4rem); line-height: 1.08; letter-spacing: -.02em;
  margin: 0 0 1.25rem; text-wrap: balance;
}
.title em { font-style: italic; }

.meta {
  display: grid; grid-template-columns: 1fr; gap: .15rem 1rem;
  font-family: var(--mono); font-size: .95rem; line-height: 1.6; margin-bottom: 1.5rem;
}
@media (min-width: 640px) { .meta { grid-template-columns: 8.5rem 1fr; } }
.meta dt { color: var(--muted); }
@media (max-width: 639px) { .meta dt { margin-top: .6rem; } }
.meta dd { margin: 0; }
.meta sup { font-size: .7em; }

.buttons { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 2.25rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 40px; padding: .45rem 1rem;
  font-family: var(--mono); font-size: .8rem; letter-spacing: .02em; text-decoration: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--ink); border-radius: 6px;
  box-shadow: 3px 3px 0 0 var(--ink); transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { text-decoration: none; transform: translate(1px, 1px); box-shadow: 2px 2px 0 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 0 var(--ink); }
.btn svg { width: 15px; height: 15px; }
.btn[aria-disabled="true"] { color: var(--muted); border-color: var(--muted-2); box-shadow: 3px 3px 0 0 var(--muted-2); cursor: default; }
.btn[aria-disabled="true"]:hover { transform: none; box-shadow: 3px 3px 0 0 var(--muted-2); }

/* ---------- media cards ---------- */
.media {
  background: #000; border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .08);
}
.media video, .media img { width: 100%; height: auto; }
.pixelated, .pixelated video, canvas.pixelated { image-rendering: pixelated; image-rendering: crisp-edges; }

.panel-labels {
  display: grid; color: #d9d8d0; font-family: var(--mono); font-size: .72rem; letter-spacing: .06em;
  text-transform: uppercase; padding: .75rem 1rem .55rem;
}
.panel-labels > div { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.panel-labels .lbl { display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; }
.key.real { background: var(--real); } .key.wm { background: var(--wm); } .key.fix { background: var(--fix); }
.score-chip {
  font-family: var(--mono); font-size: .78rem; color: #fff; background: rgba(255, 255, 255, .1);
  border-radius: 4px; padding: .05rem .45rem; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.score-chip.bad { background: rgba(235, 104, 52, .25); }
.score-chip.good { background: rgba(42, 120, 214, .35); }

.caption {
  font-family: var(--sans); font-size: .95rem; line-height: 1.55; color: var(--ink-2);
  margin: .9rem auto 0; max-width: var(--prose);
}
.caption strong { color: var(--ink); font-weight: 600; }

.figure { margin: 2.5rem auto 3.25rem; }
.figure.light .media { background: var(--surface); }
.media.narrow { max-width: 30rem; margin-inline: auto; }   /* a figure that would be too big at the column's width */
.figure img.paper-fig { background: #fff; border-radius: var(--radius); border: 1px solid var(--card-border); width: 100%; height: auto; }

/* ---------- sections ---------- */
section.block { padding-top: 1.5rem; }
.divider { height: 1px; background: var(--divider); border: 0; max-width: var(--prose); margin: 4rem auto; }
.kicker { font-family: var(--mono); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
h2.sec {
  font-family: var(--serif); font-weight: 400; font-size: clamp(1.9rem, 3.6vw, 2.5rem); line-height: 1.15;
  letter-spacing: -.015em; margin: 0 0 1.25rem; text-wrap: balance;
}
h3.sub { font-family: var(--sans); font-weight: 650; font-size: 1.2rem; margin: 2.5rem 0 .6rem; }
h3.sub .n { font-family: var(--mono); font-weight: 400; color: var(--muted); font-size: .85rem; margin-right: .4rem; }

/* ---------- boxes ---------- */
.tldr { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 1.4rem 1.6rem; margin: 3rem auto; }
.tldr .kicker { color: var(--ink); }
.tldr p { margin: 0; font-size: 1.12rem; }
.tldr p + p { margin-top: .75rem; }

.insight {
  position: relative; background: var(--surface); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 1.6rem 1.4rem 1.1rem; margin: 1.75rem 0; font-size: 1.05rem;
}
.tag {
  position: absolute; top: -.62rem; left: 1rem; background: var(--hl); color: #111; border-radius: 4px;
  padding: .12rem .45rem; font-family: var(--mono); font-size: .66rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.insight p:last-child { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin: 2rem 0; }
.stat { background: var(--surface); border: 1px solid var(--card-border); border-radius: 10px; padding: 1rem 1.1rem; }
.stat .v { font-family: var(--sans); font-weight: 600; font-size: 2.1rem; line-height: 1.1; letter-spacing: -.01em; }
.stat .v small { font-size: 1rem; font-weight: 500; color: var(--ink-2); }
.stat .l { font-size: .95rem; color: var(--ink-2); line-height: 1.4; margin-top: .3rem; }
.stat .src { font-family: var(--mono); font-size: .68rem; color: var(--muted); margin-top: .5rem; }

/* numbered method steps */
.steps { display: grid; gap: 1rem; margin: 1.75rem 0; }
.step { display: grid; grid-template-columns: 2rem 1fr; gap: .9rem; background: var(--surface); border: 1px solid var(--card-border); border-radius: 10px; padding: 1.1rem 1.25rem; }
.step .num {
  width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--ink); display: grid; place-items: center;
  font-family: var(--mono); font-size: .8rem; background: var(--bg);
}
.step h4 { margin: .1rem 0 .3rem; font-size: 1.05rem; font-weight: 650; }
.step p { margin: 0; font-size: 1rem; color: var(--ink-2); }

.eq { background: var(--surface); border: 1px solid var(--card-border); border-radius: 8px; padding: .4rem 1rem; margin: 1rem 0 1.25rem; overflow-x: auto; }
.eq .katex-display { margin: .6rem 0; }
.eq-note { font-family: var(--mono); font-size: .76rem; color: var(--muted); margin: -.6rem 0 1.25rem; }

/* collapsible */
details.disclosure { margin: 1.5rem 0; border-block: 1px solid var(--divider); }
details.disclosure > summary {
  list-style: none; cursor: pointer; padding: .85rem 0; font-family: var(--mono); font-size: .82rem; letter-spacing: .03em;
  display: flex; align-items: center; gap: .6rem; user-select: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "+"; display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border: 1px solid var(--ink); border-radius: 4px; font-size: .9rem; line-height: 1; }
details.disclosure[open] > summary::before { content: "\2212"; }
details.disclosure > .inner { padding: 0 0 1.25rem; }

.algo { border-block: 2px solid var(--ink); font-size: .95rem; line-height: 1.5; background: var(--surface); }
.algo .cap { padding: .5rem .8rem; border-bottom: 1px solid var(--ink); font-family: var(--mono); font-size: .8rem; }
.algo ol { margin: 0; padding: .6rem .8rem .7rem 2.6rem; }
.algo li { padding: .12rem 0; }
.algo li::marker { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.algo .cm { color: #1f63b8; font-family: var(--mono); font-size: .75rem; margin-left: .4rem; }
.algo .req { padding: .45rem .8rem 0; font-size: .9rem; color: var(--ink-2); }
.algo .kw { font-weight: 650; }

/* ---------- interactive players ---------- */
.player { max-width: var(--prose); margin-inline: auto; background: #0d0d0c; color: #e9e8e2; border-radius: var(--radius); overflow: hidden; box-shadow: 0 10px 30px -12px rgba(0,0,0,.35); }
.player .screens { display: grid; gap: 10px; padding: 0 12px 12px; align-items: end; }
.player .screens.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.player .screen { position: relative; min-width: 0; }
.player .screen canvas, .player .screen img { width: 100%; height: auto; aspect-ratio: 1 / 1; background: #000; border-radius: 4px; }
.player .screen .hdr { display: flex; justify-content: space-between; align-items: center; gap: .4rem; font-family: var(--mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: #cfcec6; padding: .7rem 0 .45rem; min-height: 2.6rem; }
.player .screen .hdr .lbl { display: inline-flex; align-items: center; gap: .4rem; min-width: 0; }
.player .screen .hdr .lbl span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .player .screens.three { gap: 6px; padding: 0 8px 8px; }
  .player .screen .hdr { font-size: .66rem; flex-direction: column; align-items: flex-start; }
}
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .7rem 14px; border-top: 1px solid #262624; font-family: var(--mono); font-size: .78rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chips .lab { color: #9b9a93; margin-right: .2rem; }
.chip {
  appearance: none; font: inherit; font-size: .76rem; cursor: pointer; border-radius: 999px; padding: .3rem .8rem; min-height: 32px;
  border: 1px solid #4a4944; background: transparent; color: #e9e8e2; display: inline-flex; align-items: center; gap: .45rem;
}
.chip:hover { background: #1f1f1d; }
.chip[aria-pressed="true"] { background: #f0efe9; color: #0b0b0b; border-color: #f0efe9; }
.chip .dash { width: 14px; border-top: 2px dashed currentColor; opacity: .8; }
.chip .bar { width: 14px; height: 3px; background: var(--fix); border-radius: 2px; }

.timeline { background: var(--surface); color: var(--ink); padding: .5rem .25rem .25rem; }
.timeline svg { width: 100%; height: auto; }
.timeline .legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-family: var(--mono); font-size: .72rem; color: var(--ink-2); padding: .2rem .9rem .6rem; }
.timeline .legend span { display: inline-flex; align-items: center; gap: .4rem; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.sw.line { width: 14px; height: 0; border-top: 2px solid; border-radius: 0; }
.sw.dash { width: 14px; height: 0; border-top: 2px dashed var(--base); border-radius: 0; }

/* svg text */
.vz text { font-family: var(--sans); font-size: 13px; }
.vz text:not([fill]) { fill: var(--ink-2); }
.vz .ax text { font-size: 12px; font-variant-numeric: tabular-nums; }
.vz .ax line, .vz .ax path { stroke: var(--axis); }
.vz .gridline { stroke: var(--grid); stroke-width: 1; }
.vz .lbl-strong { fill: var(--ink); font-weight: 600; }
.vz .mono { font-family: var(--mono); font-size: 11.5px; }

/* chart cards */
.chart-card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 1.1rem 1.2rem .9rem; }
.chart-card h4 { margin: 0 0 .15rem; font-size: 1.02rem; font-weight: 650; }
.chart-card .subt { margin: 0 0 .6rem; font-size: .9rem; color: var(--ink-2); line-height: 1.4; }
.chart-card .legend { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; font-family: var(--mono); font-size: .72rem; color: var(--ink-2); margin: .2rem 0 .4rem; }
.chart-card .legend span { display: inline-flex; align-items: center; gap: .4rem; }
.chart-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
.chart-grid > * { min-width: 0; width: 100%; }
@media (min-width: 900px) { .chart-grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }   /* paper figures side by side, each opens full size */
/* the Atari charts are drawn for half the column: stacked on narrower screens they keep about that size */
#atari-gap .viz svg, #atari-cost .viz svg { max-width: 26rem; margin-inline: auto; min-width: 0; }
.tablebtn { appearance: none; background: none; border: 0; padding: .35rem 0; min-height: 32px; font-family: var(--mono); font-size: .72rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; background: #fff; color: var(--ink); border: 1px solid rgba(11,11,11,.12);
  box-shadow: 0 6px 18px rgba(0,0,0,.12); border-radius: 6px; padding: .45rem .6rem; font-size: .82rem; line-height: 1.35; min-width: 9rem;
  opacity: 0; transition: opacity .08s;
}
.tip.on { opacity: 1; }
.tip .tv { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip .row { display: flex; align-items: center; gap: .45rem; }
.tip .row .k { width: 12px; height: 0; border-top: 2px solid; }
.tip .hd { font-family: var(--mono); font-size: .7rem; color: var(--muted); margin-bottom: .2rem; }

/* tables */
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; font-variant-numeric: tabular-nums; background: var(--surface); }
table.data th, table.data td { padding: .5rem .7rem; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { font-family: var(--mono); font-weight: 500; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--ink); }
table.data td.best { font-weight: 650; }
table.data tr.grp td { font-family: var(--mono); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); text-align: left; padding-top: .9rem; }
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--card-border); }

/* ---------- carousels / galleries ---------- */
.rail-wrap { position: relative; }
.rail {
  display: flex; gap: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; padding: .25rem .25rem 1rem; scrollbar-width: thin;
  overscroll-behavior-x: contain;
}
.rail > * { scroll-snap-align: start; flex: none; }
.rail-nav { display: flex; gap: .5rem; justify-content: flex-end; margin: 0 0 .6rem; }
.rail-nav button { appearance: none; border: 1px solid var(--ink); background: var(--surface); border-radius: 6px; width: 38px; height: 34px; cursor: pointer; display: grid; place-items: center; box-shadow: 2px 2px 0 0 var(--ink); }
.rail-nav button:hover { background: var(--bg-hover); }
.rail-nav button:disabled { opacity: .35; cursor: default; }
.rail-nav svg { width: 15px; height: 15px; }

.case { width: min(86vw, 30rem); background: var(--surface); border: 1px solid var(--card-border); border-radius: 10px; overflow: hidden; }
.case.cube { width: min(86vw, 26rem); }
.case.humanoid .vid video { image-rendering: auto; }
.table-breakout { width: min(64rem, calc(100vw - 2rem)); margin-left: 50%; transform: translateX(-50%); }   /* wider than the text column it sits in */
.table-breakout th { white-space: normal; }
.table-breakout td:first-child { white-space: normal; }
#types-table td:first-child { min-width: 10rem; }
#types-table th, #types-table td { padding-inline: .45rem; }
#types-table th:nth-child(2), #types-table td:nth-child(2) { text-align: left; white-space: normal; }
#types-table th { text-transform: none; }             /* an uppercase phi is another symbol */
.case .vid { background: #000; }
.case .vid video { width: 100%; height: auto; image-rendering: pixelated; }
.case .plabels { display: grid; background: #000; color: #bdbcb4; font-family: var(--mono); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; padding: .5rem 0 .35rem; }
.case .plabels span { display: flex; align-items: center; gap: .35rem; justify-content: center; }
.case .body { padding: .7rem .85rem .85rem; }
.case .ttl { font-family: var(--mono); font-size: .78rem; display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.case .ttl b { font-weight: 600; }
.case .desc { font-size: .92rem; color: var(--ink-2); line-height: 1.45; margin-top: .3rem; }
.case .inj { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.case .inj span { font-family: var(--mono); font-size: .7rem; background: #e7eef9; color: #17487f; border-radius: 4px; padding: .05rem .4rem; }
.case .score { font-family: var(--mono); font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* recursive demo */
.rdemo { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 1rem 1.1rem 1rem; }
.rdemo .controls-light { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; font-family: var(--mono); font-size: .78rem; margin-bottom: .6rem; }
.rdemo .ctl-l {
  appearance: none; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); border-radius: 6px; min-height: 34px; padding: .25rem .75rem;
  font: inherit; cursor: pointer; box-shadow: 2px 2px 0 0 var(--ink); display: inline-flex; align-items: center; gap: .35rem;
}
.rdemo .ctl-l:hover { background: var(--bg-hover); }
.rdemo .ctl-l:disabled { opacity: .4; cursor: default; }
.rdemo .readout { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rdemo .readout b { color: var(--ink); font-weight: 600; }
.rdemo label.sel { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink-2); }
.rdemo select { font: inherit; border: 1px solid var(--axis); border-radius: 5px; background: #fff; padding: .2rem .35rem; min-height: 34px; }

/* bibtex */
pre.bib {
  position: relative; background: var(--surface); border: 1px solid var(--card-border); border-radius: 10px; padding: 1.1rem 1.2rem;
  font-family: var(--mono); font-size: .8rem; line-height: 1.55; overflow-x: auto; margin: 0;
}
.bibwrap { position: relative; }
.copy { position: absolute; top: .6rem; right: .6rem; z-index: 1; }
.copy button { min-height: 32px; appearance: none; border: 1px solid var(--ink); background: var(--surface); border-radius: 5px; font-family: var(--mono); font-size: .72rem; padding: .25rem .6rem; cursor: pointer; box-shadow: 2px 2px 0 0 var(--ink); }

.small-note { font-family: var(--mono); font-size: .74rem; color: var(--muted); line-height: 1.55; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.inline-key { display: inline-block; width: .9em; height: .22em; border-radius: 2px; vertical-align: .22em; margin-right: .2em; }
.inline-key.real { background: var(--real); } .inline-key.wm { background: var(--wm); } .inline-key.fix { background: var(--fix); }
.inline-key.dash { height: 0; border-top: 2px dashed var(--base); background: none; border-radius: 0; }

@media print {
  .player .controls, .rail-nav, .copy { display: none; }
  body { background: #fff; }
}

.sym { font-family: var(--sans); font-style: normal; text-transform: none; }

/* ---------- small screens ---------- */
.chart-card .viz, .timeline .tl-svg, .rdemo-svg { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) {
  .panel-labels { font-size: .66rem; letter-spacing: .03em; padding: .55rem .5rem .45rem; }
  .panel-labels > div { flex-direction: column; align-items: flex-start; gap: .25rem; }
  .panel-labels .lbl { white-space: normal; line-height: 1.25; }
  .score-chip { font-size: .66rem; }
  .player .screen .hdr .lbl { max-width: 100%; }
  .player .screen .hdr .lbl span.t { white-space: normal; line-height: 1.25; overflow-wrap: anywhere; }
  .timeline .tl-svg svg { min-width: 720px; }
  .chart-card .viz svg { min-width: 460px; }
  #hybrid-diagram .viz svg { min-width: 600px; }
  pre.bib { padding-top: 2.9rem; }
  .rdemo-svg svg { min-width: 640px; }
  .controls { padding: .6rem 10px; }
  .chips .chip { font-size: .7rem; }
}

/* ---------- review fixes ---------- */
.prose p.caption, .figure > p.caption { margin-top: .9rem; }
.disclosures details + details { border-top: 0; }
a.figlink { display: block; text-decoration: none; }
a.figlink:hover img { border-color: var(--muted-2); }
.player :focus-visible { outline-color: #f0efe9; }
.vz .lbl-strong { font-weight: 600; }

/* hero toggle */
.hero-bar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; justify-content: space-between; align-items: center; margin: 0 auto .7rem; }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 7px; overflow: hidden; box-shadow: 2px 2px 0 0 var(--ink); background: var(--surface); }
.seg button { appearance: none; border: 0; background: transparent; font-family: var(--mono); font-size: .78rem; padding: .5rem .9rem; min-height: 36px; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--bg-hover); }
.hero-labels { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: .7rem 0 .55rem; }
.hero-labels > div { padding: 0 .6rem; }
.hero-labels .lbl { white-space: normal; line-height: 1.25; }
@media (max-width: 1023px) {
  .panel-labels .lbl { white-space: normal; line-height: 1.25; }
  .player .screen .hdr .lbl span.t { white-space: normal; line-height: 1.25; }
}
@media (max-width: 960px) { .hero-labels > div { flex-direction: column; align-items: flex-start; gap: .25rem; } }
@media (max-width: 780px) { .player .screen .hdr { flex-direction: column; align-items: flex-start; } }
@media (max-width: 640px) {
  .hero-labels > div { padding: 0 .3rem; }
  .hero-bar { flex-wrap: nowrap; gap: .5rem; }
  .seg button { font-size: .66rem; padding: .45rem .5rem; letter-spacing: 0; }
  .eq .katex-display { font-size: .86em; }
}

.katex { font-size: 1.06em; }

/* third panel at a phi-picked injection (same mark as the one burned into the videos) */
.player .screen canvas.inj-now { outline: 6px solid var(--hl); outline-offset: -6px; }
@media (max-width: 640px) { .player .screen canvas.inj-now { outline-width: 3px; outline-offset: -3px; } }

/* a fold whose content includes wide figures: the fold spans the page, its summary stays in the text column */
details.disclosure.wide-fold { margin: 0; border-block: 0; }
details.disclosure.wide-fold > summary { max-width: var(--prose); margin-inline: auto; border-block: 1px solid var(--divider); }

/* the humanoid case study plays a video in a player */
.player > video { width: 100%; height: auto; background: #000; }
.player > .panel-labels { padding-bottom: .5rem; }
/* a case study's chart moves the playhead from anywhere on it (on touch a tap does, and a swipe scrolls) */
.vz.scrub, .vz.scrub .tl-hit { cursor: ew-resize; }
/* the driving case: what Alpamayo said at its latest decision, under each panel */
:is(.player, .media) > .said { padding: .5rem 0 .6rem; text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: .82rem; color: #cfcec6; align-items: start; }
:is(.player, .media) > .said > div { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; line-height: 1.35; min-height: 3.3em; padding: 0 .6rem; }
@media (max-width: 640px) { :is(.player, .media) > .said { font-size: .7rem; } :is(.player, .media) > .said > div { padding: 0 .3rem; } }
:is(.player, .media) > .said > div.none { color: #7d7c76; font-style: italic; }
/* the driving panels' reasoning: green when Alpamayo stops for the red light, red when it drives on through it */
:is(.player, .media) > .said > div.safe { color: #7ee2a8; }
:is(.player, .media) > .said > div.unsafe { color: #ff8a80; }
.panel-labels[hidden] { display: none; }   /* the hero's reasoning row shows on the driving tab only */
#driving-case .es-group, #driving-case .es-group + .es-group { flex: 1 1 0; min-width: 15rem; }
#driving-case .es-img { background: #0d0d0c; }
#driving-case .es-img span { color: #e9e8e2; }
@media (max-width: 640px) { .seg-ext { display: none; } }

/* real and predicted frames, side by side, at the moments that decide and the moments that look worst */
.es-text { margin-top: 2rem; }
.errstrip { display: flex; gap: 1.25rem; max-width: var(--prose); margin: 1.25rem auto 0; overflow-x: auto; padding-bottom: .4rem; }
.es-group { flex: 2 1 0; min-width: 15rem; margin-top: 1.25rem; }   /* the heading sits under the frames, so leave room above them */
.es-group + .es-group { flex-grow: 3; min-width: 22.5rem; }
.es-head { font-family: var(--sans); font-size: .95rem; color: var(--ink-2); margin-bottom: .25rem; margin-top: .3rem;}
.es-head b { color: var(--ink); font-weight: 600; }
.es-cols { display: flex; gap: .35rem; }
.es-cols figure { flex: 1 1 0; min-width: 0; margin: 0; }
.es-img { position: relative; border-radius: 4px; overflow: hidden; margin-bottom: .35rem; background: #eceef0; }
.es-img img { width: 100%; height: auto; aspect-ratio: 1 / .78; object-fit: cover; object-position: 50% 100%; }
.es-img span { position: absolute; top: .3rem; left: .35rem; font-family: var(--mono); font-size: .66rem; color: var(--ink-2); }
.es-cols figcaption { font-family: var(--mono); font-size: .72rem; color: var(--ink-2); line-height: 1.35; }
.es-cols figcaption b { display: block; color: var(--ink); font-weight: 500; }


/* ---------- floating play bar over a player's frames (after pi07's): shown on hover, on keyboard focus, while paused, or after a touch ---------- */
.fhost { position: relative; }
.fhost > video { display: block; width: 100%; height: auto; }
.player > .fhost > video { background: #000; }
.fbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; align-items: center; gap: .65rem;
  padding: .4rem .65rem; background: rgba(13, 13, 12, .74); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: #e9e8e2; font-family: var(--mono); font-size: .72rem; font-variant-numeric: tabular-nums; letter-spacing: .02em;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.fhost:hover > .fbar, .fhost:has(:focus-visible) > .fbar, .fhost.is-paused > .fbar, .fhost.awake > .fbar { opacity: 1; pointer-events: auto; }
.screens.fhost > .fbar { left: 12px; right: 12px; bottom: 12px; border-radius: 0 0 4px 4px; }
.fbar .fb-play {
  appearance: none; flex: none; width: 28px; height: 28px; padding: 0; border: 1px solid #f0efe9; border-radius: 6px;
  background: #f0efe9; color: #0b0b0b; display: grid; place-items: center; cursor: pointer;
}
.fbar .fb-play:hover { background: #fff; }
.fbar .fb-play svg { width: 13px; height: 13px; pointer-events: none; }
.fhost > video, .fhost canvas { cursor: pointer; }
.fbar .fb-play:focus-visible, .fb-track:focus-visible { outline: 2px solid #f0efe9; outline-offset: 2px; }
.fbar .fb-now, .fbar .fb-end { flex: none; color: #cfcec6; white-space: nowrap; }
.fbar .fb-now { min-width: 6.5ch; }
.fb-track { position: relative; flex: 1; min-width: 3rem; height: 22px; cursor: pointer; touch-action: none; border-radius: 3px; }
.fb-track:focus { outline: none; }
.fb-rail, .fb-fill { position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; }
.fb-rail { left: 0; right: 0; background: rgba(255, 255, 255, .22); }
.fb-fill { left: 0; background: #f0efe9; }
.fb-marks { position: absolute; inset: 0; pointer-events: none; }
.fb-marks i { position: absolute; top: 50%; height: 8px; margin-top: -4px; min-width: 3px; background: var(--hl); border-radius: 1px; }
.fb-thumb { position: absolute; top: 50%; width: 8px; height: 16px; margin: -8px 0 0 -4px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); pointer-events: none; }
@media (max-width: 640px) {
  .fbar { gap: .45rem; padding: .3rem .45rem; font-size: .64rem; }
  .fbar .fb-end { display: none; }
  .fbar .fb-play { width: 26px; height: 26px; }
  .screens.fhost > .fbar { left: 8px; right: 8px; bottom: 8px; }
}

/* ---------- readability on the dark players: brighter, bolder, slightly larger labels (user's request, 2026-11-08) ---------- */
.panel-labels, .player .screen .hdr { color: #f5f4ef; font-size: .8rem; font-weight: 600; letter-spacing: .03em; }
.key { width: 16px; height: 4px; }
.score-chip { font-size: .82rem; font-weight: 600; background: rgba(255, 255, 255, .17); padding: .1rem .5rem; }
.score-chip.bad { background: rgba(235, 104, 52, .4); }
.score-chip.good { background: rgba(42, 120, 214, .45); }
.chips .lab { color: #f0efe9; font-weight: 600; }
.chip { font-size: .8rem; }
:is(.player, .media) > .said { color: #ecebe5; font-size: .88rem; }
:is(.player, .media) > .said > div.none { color: #a8a7a0; }
.fbar .fb-now, .fbar .fb-end { color: #f0efe9; font-weight: 600; }
@media (max-width: 640px) {
  .panel-labels, .player .screen .hdr { font-size: .7rem; letter-spacing: .03em; }
  .score-chip { font-size: .7rem; }
  :is(.player, .media) > .said { font-size: .74rem; }
}
