/* Layout: a lab-notebook results explorer. Summary first (overview), then the per-task heatmap, then per-game evidence.
   Neutrals lean slightly cool toward the RSIGame blue; Play2Code is orange; Base is a recessive gray. */
:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #15181c;
  --ink-2: #4a5059;
  --ink-3: #7b828c;
  --rule: #e1e4e8;
  --accent: #2a78d6;           /* RSIGame */
  --p2c: #eb6834;              /* Play2Code */
  --base: #9aa1aa;             /* Base model */
  --mid: #f0efec;              /* diverging midpoint */
  --neg: #e34948;              /* diverging negative arm */
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --f-display: "Fraunces", Georgia, "Times New Roman", serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121416; --panel: #1a1d20; --ink: #eef0f2; --ink-2: #b9bfc7; --ink-3: #868d96; --rule: #2b3036;
    --accent: #3987e5; --p2c: #d95926; --base: #6d747d; --mid: #383835; --neg: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121416; --panel: #1a1d20; --ink: #eef0f2; --ink-2: #b9bfc7; --ink-3: #868d96; --rule: #2b3036;
  --accent: #3987e5; --p2c: #d95926; --base: #6d747d; --mid: #383835; --neg: #e66767;
  --shadow: none;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--f-body); margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.wrap { max-width: 1440px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.num, td.n, .score { font-variant-numeric: tabular-nums; }

/* top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.top-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-block: 12px; }
.brand { font: 600 20px/1.1 var(--f-display); color: var(--ink); letter-spacing: -.01em; }
.brand span { font: 500 13px var(--f-body); color: var(--ink-3); margin-left: 6px; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 6px; font-weight: 500; font-size: 14px; }
.nav a.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); border: 1px solid var(--rule); }
.nav a:hover { text-decoration: none; color: var(--ink); }

main { display: grid; gap: 28px; padding-block: 28px 40px; }
h1 { font: 600 clamp(26px, 3.2vw, 36px)/1.15 var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -.015em; }
h2 { font: 600 20px/1.25 var(--f-display); margin: 0; text-wrap: balance; }
h3 { font-size: 15px; margin: 0; font-weight: 600; }
.lede { color: var(--ink-2); max-width: 72ch; margin: 6px 0 0; }
.eyebrow { font: 500 11.5px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.section { display: grid; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 18px; box-shadow: var(--shadow); }
.loading, .empty { color: var(--ink-3); }

/* legend chips for settings */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); align-items: center; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw.base { background: var(--base); } .sw.p2c { background: var(--p2c); } .sw.rsigame { background: var(--accent); }

/* overview table */
.scroll { overflow-x: auto; }
table.sum { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 14px; }
table.sum th, table.sum td { padding: 10px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
table.sum th { font-weight: 500; color: var(--ink-3); font-size: 12.5px; }
table.sum td.n { text-align: right; white-space: nowrap; }
table.sum tr:last-child td { border-bottom: 0; }
.sd { color: var(--ink-3); font-size: 12px; margin-left: 3px; }
.runs { color: var(--ink-3); font-size: 11.5px; font-family: var(--f-mono); }
.delta { font-weight: 600; }
.delta.up { color: var(--accent); } .delta.down { color: var(--neg); }
.bars { display: grid; gap: 3px; min-width: 180px; }
.bar { height: 7px; border-radius: 0 4px 4px 0; }
.bar.base { background: var(--base); } .bar.p2c { background: var(--p2c); } .bar.rsigame { background: var(--accent); }
.bar-track { background: color-mix(in srgb, var(--rule) 60%, transparent); border-radius: 0 4px 4px 0; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; color: var(--ink-2); font: 500 13px var(--f-body); padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.ctl-label { font-size: 12.5px; color: var(--ink-3); margin-right: 6px; }
select, input[type="search"] { font: 14px var(--f-body); color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 7px 10px; }

/* heatmap */
.hm-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--panel); }
table.hm { border-collapse: separate; border-spacing: 2px; font-size: 12px; min-width: 980px; padding: 6px; }
table.hm th { font-weight: 500; color: var(--ink-3); padding: 4px 3px; white-space: nowrap; }
table.hm th.model { color: var(--ink); font-size: 12.5px; text-align: center; border-bottom: 2px solid var(--rule); }
table.hm th.task { text-align: left; color: var(--ink-2); font-weight: 500; position: sticky; left: 0; background: var(--panel); z-index: 1; padding-right: 10px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.hm th.task a { color: inherit; }
table.hm td { width: 44px; min-width: 40px; height: 26px; text-align: center; border-radius: 4px; cursor: pointer; font-variant-numeric: tabular-nums; position: relative; }
table.hm td.na { background: repeating-linear-gradient(45deg, transparent 0 4px, color-mix(in srgb, var(--rule) 70%, transparent) 4px 5px); cursor: default; color: var(--ink-3); }
table.hm td.gap { width: 8px; min-width: 8px; background: none; cursor: default; }
table.hm tr.mean td, table.hm tr.mean th { font-weight: 600; border-top: 2px solid var(--rule); }
.scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.scale .ramp { width: 200px; height: 10px; border-radius: 3px; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--panel); color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 24px rgba(0,0,0,.14); max-width: 280px; }
.tip b { font-weight: 600; } .tip .k { color: var(--ink-3); }

/* task grid (games index) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; display: grid; grid-template-rows: auto 1fr; color: inherit; box-shadow: var(--shadow); }
.card:hover { text-decoration: none; border-color: var(--accent); }
.card .thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule); aspect-ratio: 3 / 0.62; }
.card .thumbs img, .card .thumbs div { width: 100%; height: 100%; object-fit: cover; display: block; background: #0b0d10; }
.card .body { padding: 12px 14px; display: grid; gap: 6px; align-content: start; }
.card .t { font-weight: 600; }
.card .genre { font: 500 11px var(--f-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--rule); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip.base { border-color: var(--base); } .chip.p2c { border-color: var(--p2c); } .chip.rsigame { border-color: var(--accent); color: var(--ink); font-weight: 600; }

/* task detail */
.crumb { font-size: 13px; color: var(--ink-3); }
.task-head { display: grid; gap: 8px; }
.model-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.model-tabs button { border: 1px solid var(--rule); background: var(--panel); color: var(--ink-2); border-radius: 999px; padding: 6px 12px; font: 500 13px var(--f-body); cursor: pointer; }
.model-tabs button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.compare { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 980px) { .compare { grid-template-columns: 1fr; } }
.col { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; display: grid; grid-template-rows: auto auto auto 1fr; box-shadow: var(--shadow); }
.col.base { border-top: 3px solid var(--base); } .col.p2c { border-top: 3px solid var(--p2c); } .col.rsigame { border-top: 3px solid var(--accent); }
.col-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px 8px; }
.col-h .score { font: 600 26px/1 var(--f-display); }
.col-h .score small { font: 500 12px var(--f-body); color: var(--ink-3); margin-left: 4px; }
.player { background: #0b0d10; aspect-ratio: 16 / 9; position: relative; }
.player video, .player img { width: 100%; height: 100%; object-fit: contain; display: block; }
.player .none { position: absolute; inset: 0; display: grid; place-items: center; color: #8a9099; font-size: 13px; text-align: center; padding: 16px; }
.demo-row { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.demo-row button { flex: 0 0 auto; width: 84px; border: 2px solid transparent; padding: 0; background: none; cursor: pointer; border-radius: 5px; overflow: hidden; display: grid; gap: 2px; text-align: left; }
.demo-row button img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #0b0d10; }
.demo-row button span { font: 10.5px var(--f-mono); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px 2px; }
.demo-row button[aria-pressed="true"] { border-color: var(--accent); }
.dims { display: grid; gap: 6px; padding: 12px 14px 14px; align-content: start; }
.dim { display: grid; grid-template-columns: 84px 1fr 40px; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.dim .tr { height: 6px; background: color-mix(in srgb, var(--rule) 70%, transparent); border-radius: 0 3px 3px 0; overflow: hidden; }
.dim .fl { height: 100%; border-radius: 0 3px 3px 0; }
.col.base .fl { background: var(--base); } .col.p2c .fl { background: var(--p2c); } .col.rsigame .fl { background: var(--accent); }
.dim b { text-align: right; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.run-pick { display: flex; gap: 6px; align-items: center; }

/* requirement matrix */
table.req { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 680px; }
table.req th, table.req td { padding: 7px 10px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
table.req th { font-weight: 500; color: var(--ink-3); font-size: 12px; }
table.req td.v { width: 92px; text-align: center; white-space: nowrap; }
.pill { display: inline-block; min-width: 44px; padding: 2px 6px; border-radius: 999px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.s0 { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.pill.s5 { background: color-mix(in srgb, #eda100 22%, transparent); color: #a86f00; }
.pill.s1 { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.rid { font: 500 12px var(--f-mono); color: var(--ink-3); width: 44px; }
.foot { color: var(--ink-3); font-size: 12.5px; padding-block: 8px 40px; border-top: 1px solid var(--rule); }
.foot p { max-width: 100ch; margin: 14px 0 0; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* games page pickers: generators as a row of buttons, runs + legend + search on the second row */
.pick-rows { display: grid; gap: 12px; }
.pick-rows .model-tabs button { font-size: 14px; padding: 8px 16px; }
.row2 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.row2 .search { margin-left: auto; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.gain { font: 600 13px var(--f-body); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.gain.up { color: var(--accent); } .gain.down { color: var(--neg); }
table.hm th { font-size: 11px; }
.card .thumbs .ph { display: grid; place-items: center; color: #6f7680; font-size: 11px; text-align: center; }
.spr { width: 100%; aspect-ratio: 16 / 9; background-color: #0b0d10; background-repeat: no-repeat; display: block; }
.card .thumbs .spr { height: 100%; aspect-ratio: auto; }
