[hidden] { display: none !important; }
/* Project page. Same instrument palette as the sim demo: cool light neutrals, blue for goals and controls,
   amber for the ResSafe filter, red for "no filter" and drops, green for reached. Light only, by choice. */
:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #16191f;
  --muted: #5b6372;
  --line: #dde1e8;
  --accent: #2c55c7;
  --safe: #c67a12;
  --good: #1f8a5b;
  --bad: #c2392f;
  --stage-top: #e9edf3;
  --stage-bot: #cfd6e0;
  --video-bg: #0e1013;
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --maxw: 1180px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font-body); -webkit-text-size-adjust: 100%; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.inner { max-width: var(--maxw); margin: 0 auto; }

/* top bar */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--panel); }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .inner { display: flex; align-items: center; gap: 18px; height: 52px; }
.topbar .mark { font: 700 15px var(--font-display); color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 16px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
.topbar nav a:hover { color: var(--ink); }

/* hero */
.hero { padding-block: 44px 28px; }
.hero .inner { display: grid; gap: 22px; }
.kicker { font: 500 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hero h1 { font-size: clamp(28px, 4.4vw, 50px); line-height: 1.08; font-weight: 700; max-width: 22ch; }
.byline { display: grid; gap: 6px; }
.authors { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 16px; font-weight: 500; }
.authors a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.authors a:hover { border-bottom-color: var(--accent); }
.authors sup, .affils sup { font-size: 10px; color: var(--muted); margin-left: 1px; }
.affils { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); font-size: 14px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font: 500 14px var(--font-body); text-decoration: none; }
.pill:hover { border-color: var(--accent); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.pill svg { width: 14px; height: 14px; fill: currentColor; }
.pill.dim { color: var(--muted); cursor: default; }
.pill.dim:hover { border-color: var(--line); }

/* stats strip */
.stats-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.stats-strip > div { padding: 14px 16px; border-left: 1px solid var(--line); display: grid; gap: 2px; align-content: start; }
.stats-strip > div:first-child { border-left: 0; }
.stats-strip b { font: 500 clamp(20px, 2.6vw, 28px)/1.1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stats-strip span { font-size: 13px; color: var(--muted); line-height: 1.35; }
.stats-strip .safe b { color: var(--safe); }
@media (max-width: 860px) { .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-strip > div { border-left: 0; border-top: 1px solid var(--line); }
  .stats-strip > div:nth-child(-n+2) { border-top: 0; }
  .stats-strip > div:nth-child(even) { border-left: 1px solid var(--line); } }

/* sections */
section.block { padding-block: 56px; border-top: 1px solid var(--line); }
section.block.alt { background: var(--panel); }
.block .inner { display: grid; gap: 22px; }
.sec-head { display: grid; gap: 8px; max-width: 76ch; }
.sec-head .num { font: 500 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.sec-head h2 { font-size: clamp(24px, 3vw, 34px); line-height: 1.15; font-weight: 700; }
.sec-head p, .prose p { color: var(--ink); max-width: 72ch; }
.sec-head p.lede { color: var(--muted); }
.prose { display: grid; gap: 12px; }
h3.sub { font-size: 19px; font-weight: 600; margin-top: 10px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.c-off { color: var(--bad); } .c-on { color: var(--safe); } .c-good { color: var(--good); } .c-goal { color: var(--accent); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 860px) { .grid2, .grid3, .split { grid-template-columns: minmax(0, 1fr); } }

/* figures and clips */
figure { margin: 0; display: grid; gap: 8px; min-width: 0; }
figcaption { font-size: 14px; color: var(--muted); line-height: 1.5; max-width: 80ch; }
figcaption b { color: var(--ink); font-weight: 600; }
.paperfig { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.vid { position: relative; container-type: inline-size; background: var(--video-bg); border-radius: 10px; overflow: hidden;
  aspect-ratio: var(--ar, 16 / 9); max-width: 100%; cursor: pointer; }
.vid video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.vid .ov { position: absolute; inset: 0; pointer-events: none; }
/* scrubber: a thin bar along the bottom, thicker on hover; click or drag to seek */
.vid .scrub { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; display: flex; align-items: flex-end; cursor: pointer; touch-action: none; z-index: 2; }
.vid .scrub .track { position: relative; width: 100%; height: 3px; background: rgba(255, 255, 255, .18); transition: height .12s; }
.vid .scrub .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, #fff 80%, transparent); }
.vid:hover .scrub .track, .vid.scrubbing .scrub .track, .vid:focus-visible .scrub .track { height: 7px; }
.vid.scrubbing .scrub .bar { background: #fff; }
@media (hover: none) { .vid .scrub { height: 26px; } .vid .scrub .track { height: 5px; } }
.vid .state { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: rgba(14, 16, 19, .62); color: #fff; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .2s; }
.vid.paused .state, .vid.idle .state { opacity: 1; }
.vid .state svg { width: 22px; height: 22px; fill: currentColor; }
.vid .tools { position: absolute; right: 8px; bottom: 14px; z-index: 3; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; }
.vid:hover .tools, .vid:focus-within .tools { opacity: 1; }
@media (hover: none) { .vid .tools { opacity: 1; } }
.vid .tools button { border: 0; border-radius: 6px; background: rgba(14, 16, 19, .7); color: #fff; font: 500 12px var(--font-body); padding: 5px 8px; cursor: pointer; }
.vid:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* overlays drawn from the edit's overlay JSON; positions and sizes in 1920-wide frame units */
.ov > * { position: absolute; white-space: nowrap; font-family: var(--font-body); font-weight: 600; line-height: 1.15;
  font-size: max(5.5px, calc(var(--s) * 100cqw / 1920)); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .55); }
/* labels scale with the frame like burned-in text (full screen makes them big again); speed badges stay legible */
.ov > .o-badge { font-size: max(9px, calc(var(--s) * 100cqw / 1920)); }
.ov .o-badge { background: rgba(14, 16, 19, .72); border-radius: .35em; padding: .2em .5em; font-family: var(--font-mono); font-weight: 500; text-shadow: none; }
.ov .o-badge.fast { background: #b4580f; }
.ov .o-badge.slow { background: #2c55c7; }
.ov .o-label.off, .ov .o-drop { color: #ff8a80; }
.ov .o-label.on { color: #ffc266; }
.ov .o-done { color: #7be0a8; }
.ov .o-label.white { color: var(--ink); text-shadow: none; }
.ov .o-header, .ov .o-counter, .ov .o-event, .ov .o-flash { background: rgba(14, 16, 19, .55); padding: .15em .45em; border-radius: .3em; text-shadow: none; }
.ov .o-caption { left: 50%; bottom: 4%; translate: -50% 0; background: rgba(14, 16, 19, .6); padding: .25em .6em; border-radius: .3em; text-shadow: none; }
.vid.white .ov .o-label, .vid.white .ov .o-header_state, .vid.white .ov .o-header_depth { color: var(--ink); text-shadow: none; }

/* tab pickers */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 6px 11px;
  font: 500 13.5px var(--font-body); cursor: pointer; }
.tabs button:hover { border-color: var(--accent); }
.tabs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.picker { display: grid; gap: 10px; }
.picker .row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; align-items: center; }
.picker .row > span { font: 500 11px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
@media (max-width: 560px) { .picker .row { grid-template-columns: minmax(0, 1fr); gap: 4px; } }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font: 600 12px var(--font-body); color: var(--muted); vertical-align: bottom; }
td:first-child, th:first-child, td.l, th.l { text-align: left; }
td.mono, td { font-family: var(--font-mono); font-size: 13.5px; }
td.l { font-family: var(--font-body); font-size: 14px; }
tr.on td { background: color-mix(in srgb, var(--safe) 6%, var(--panel)); }
tr.grp td { border-top: 2px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
td b { color: var(--ink); font-weight: 600; }
.tag-on { color: var(--safe); font-weight: 600; } .tag-off { color: var(--muted); }

/* abstract */
.abstract { max-width: 80ch; }
.abstract .num { font: 500 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.abstract p { color: var(--muted); }
.abstract b { color: var(--ink); font-weight: 600; }

/* collapsed extras (the results table) */
details.more { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
details.more > summary { cursor: pointer; padding: 10px 14px; font: 500 14px var(--font-body); list-style: none; display: flex; gap: 8px; align-items: center; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; color: var(--muted); transition: rotate .15s; }
details.more[open] > summary::before { rotate: 90deg; }
details.more[open] { display: grid; gap: 10px; padding-bottom: 12px; }
details.more > :not(summary) { margin-inline: 12px; }
details.more .table-wrap { border: 0; }

/* trial players: one chip per trial, colored by outcome */
.tplayer { display: grid; gap: 10px; align-content: start; min-width: 0; }
.tplayer h4 { margin: 0; font: 600 15px var(--font-display); }
.tplayer .trow { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.tplayer .chips { gap: 4px; }
.tplayer .chips button { min-width: 0; width: 2.1em; padding: 4px 0; font-size: 12.5px; }
.trials { display: grid; gap: 12px; }
.trows { display: grid; gap: 8px; justify-items: start; }
.trow { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px; align-items: center; width: 100%; }
.trow > span { font-size: 13.5px; color: var(--muted); }
.trow > span b { color: var(--ink); font: 500 14px var(--font-mono); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.trows button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 7px; cursor: pointer;
  font: 500 13px var(--font-mono); min-width: 34px; padding: 5px 7px; position: relative; }
.trows button.all { font-family: var(--font-body); padding: 6px 12px; }
.chips button::after { content: ""; position: absolute; left: 50%; bottom: 3px; translate: -50% 0; width: 14px; height: 2px; border-radius: 1px; }
.chips button.ok::after { background: var(--good); }
.chips button.part::after { background: var(--safe); }
.chips button.bad::after { background: var(--bad); }
.trows button:hover { border-color: var(--accent); }
.trows button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.trows button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 560px) { .trow { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
figure > h3.sub { margin-top: 0; }

/* sim demo section */
.simdemo { display: grid; gap: 14px; }

pre.bib { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; font: 13px/1.5 var(--font-mono); overflow-x: auto; margin: 0; }
footer { padding-block: 36px 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
footer .inner { display: grid; gap: 6px; }
.note-sm { font-size: 13.5px; color: var(--muted); }
