/* Lightbox palette: blue = generated (CADRE), ochre = real video, slate = other autoencoders. */
:root {
  --box: #e6e9ec;
  --box-2: #dde1e5;
  --sheet: #f3f5f7;
  --ink: #14181e;
  --ink-2: #48505b;
  --ink-3: #6f7782;
  --rule: #c5cbd2;
  --gen: #2338c4;
  --gen-2: #dfe3fb;
  --real: #b4741a;
  --real-2: #f1e3cc;
  --base: #7d8590;
  --bad: #b03a2e;
  --f: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --rail: 168px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --box: #1c2027; --box-2: #232830; --sheet: #262b34; --ink: #e7e9ec; --ink-2: #b3b9c2; --ink-3: #8a929c; --rule: #373d47;
    --gen: #8196ff; --gen-2: #252d52; --real: #e0a64a; --real-2: #3a2d17; --base: #8d95a0; --bad: #ec7a6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --box: #1c2027; --box-2: #232830; --sheet: #262b34; --ink: #e7e9ec; --ink-2: #b3b9c2; --ink-3: #8a929c; --rule: #373d47;
  --gen: #8196ff; --gen-2: #252d52; --real: #e0a64a; --real-2: #3a2d17; --base: #8d95a0; --bad: #ec7a6b; color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; background: var(--box); color: var(--ink); font: 400 17px/1.62 var(--f); font-variation-settings: "wdth" 100;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
b { font-weight: 650; }
i { font-style: italic; }
:is(button, a, input, [tabindex]):focus-visible { outline: 2px solid var(--gen); outline-offset: 3px; }

/* ---------- rail ---------- */
.rail { position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail); padding: 30px 18px 24px 26px; display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--rule); z-index: 20; background: var(--box); }
.rail a { color: var(--ink-3); text-decoration: none; font-size: 14px; line-height: 1.25; padding: 6px 0; font-stretch: 82%;
  font-variation-settings: "wdth" 82; display: grid; grid-template-columns: 34px 1fr; transition: color .15s; }
.rail a span { color: var(--ink-3); font-variation-settings: "wdth" 70; font-size: 12.5px; padding-top: 1px; }
.rail a:hover { color: var(--ink); }
.rail a.on { color: var(--ink); }
.rail a.on span { color: var(--gen); font-weight: 650; }
.rail .rail-home { display: block; font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; margin-bottom: 26px;
  font-variation-settings: "wdth" 125; }

main, .hero, .foot { margin-left: var(--rail); }
.hero, .sec, .foot { padding-left: clamp(24px, 4vw, 64px); padding-right: clamp(24px, 4vw, 64px); max-width: calc(1320px); }

/* ---------- hero ---------- */
.hero { padding-top: 56px; padding-bottom: 40px; }
.hero h1 { margin: 0; font-size: clamp(40px, 5.6vw, 88px); line-height: .96; font-weight: 780; letter-spacing: -.02em;
  font-variation-settings: "wdth" 125; max-width: 15.5ch; text-wrap: balance; }
.byline { margin: 18px 0 34px; color: var(--ink-3); font-variation-settings: "wdth" 85; font-size: 15px; }
.hero-lede { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 44px; margin-top: 30px; max-width: 1100px; }
.hero-lede p { margin: 0; color: var(--ink-2); max-width: 62ch; }
.key { font-weight: 650; }
.key.gen { color: var(--gen); } .key.real { color: var(--real); }

.hero-reel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; }
.hero-reel .frame { border-top-color: var(--gen); }
.hero-claim { margin: 22px 0 0; max-width: 78ch; font-size: clamp(17px, 1.5vw, 20px); line-height: 1.5; color: var(--ink-2); font-variation-settings: "wdth" 95; }
.hero-claim b { color: var(--ink); }
.hero-hint { margin: 14px 0 0; font-size: 14.5px; color: var(--ink-3); font-variation-settings: "wdth" 88; }
.corner.l2.real { background: var(--real); }

/* ---------- sections ---------- */
.sec { padding-top: 96px; padding-bottom: 8px; }
.sec-head { display: grid; grid-template-columns: 76px minmax(0, 660px) minmax(220px, 300px); gap: 0 36px; align-items: start; margin-bottom: 30px; }
.sec-no { font-size: 15px; font-weight: 650; color: var(--gen); font-variation-settings: "wdth" 75; padding-top: 9px; border-top: 2px solid var(--gen); }
.sec-body h2 { margin: 0 0 14px; font-size: clamp(27px, 3vw, 42px); line-height: 1.04; font-weight: 740; letter-spacing: -.015em;
  font-variation-settings: "wdth" 118; text-wrap: balance; }
.sec-body p { margin: 0; color: var(--ink-2); max-width: 66ch; }
.margin-note { margin-top: 6px; padding-left: 16px; border-left: 2px solid var(--gen); font-size: 15px; line-height: 1.55; color: var(--ink-2);
  font-variation-settings: "wdth" 90; }
.margin-note b { color: var(--ink); display: block; margin-bottom: 4px; }
.note { color: var(--ink-3); font-size: 14px; margin: 14px 0 0; max-width: 90ch; font-variation-settings: "wdth" 90; }

/* ---------- tabs and switches ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0 0 18px; }
.tabs button { appearance: none; background: none; border: 0; padding: 4px 0 5px; cursor: pointer; color: var(--ink-3); font: 500 15.5px var(--f);
  font-variation-settings: "wdth" 85; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--gen); }
.tabs button .sub { color: var(--ink-3); margin-left: 6px; font-weight: 400; }
.tabs.big button { font-size: clamp(18px, 1.8vw, 23px); font-weight: 650; font-variation-settings: "wdth" 110; padding-bottom: 6px; border-bottom-width: 3px; }
.controls { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 44px; margin-bottom: 18px; }
.controls .tabs { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 15.5px; font-variation-settings: "wdth" 85; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 32px; height: 16px; border: 1.5px solid var(--ink-2); position: relative; transition: background .15s, border-color .15s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 9px; height: 9px; background: var(--ink-2); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--gen); border-color: var(--gen); }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--gen); outline-offset: 3px; }

/* ---------- video plates ---------- */
.grid { display: grid; gap: 22px 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { position: relative; min-width: 0; }
/* sources are 512x288: keep single large panels near native size (<= 1.4x), two-up grids <= ~1.15x */
.tile.big { max-width: 704px; }
.hero-reel, #env-player .g2, .cf-wrap { max-width: 1180px; }
.frame { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; border-top: 3px solid var(--base); cursor: pointer; }
.tile.ours .frame { border-top-color: var(--gen); }
.tile.real .frame { border-top-color: var(--real); }
.frame video.alt { opacity: 0; }
.frame.show-alt video.alt { opacity: 1; }
.frame video, .frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.missing .frame { display: grid; place-items: center; background: var(--box-2); color: var(--ink-3); font-size: 14px; font-variation-settings: "wdth" 85; cursor: default; border-top-color: var(--rule); }
.cap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding-top: 7px; font-variation-settings: "wdth" 80; font-size: 14.5px; line-height: 1.3; }
.cap .name { font-weight: 650; margin-right: auto; color: var(--ink); }
.tile.ours .cap .name { color: var(--gen); }
.tile.real .cap .name { color: var(--real); }
.cap small { flex-basis: 100%; color: var(--ink-3); font-size: 13.5px; }
.badge { color: var(--ink-2); font-size: 13.5px; font-variation-settings: "wdth" 75; white-space: nowrap; }
.badge.best { color: var(--gen); font-weight: 650; box-shadow: inset 0 -2px 0 var(--gen); }
.badge.worst { color: var(--bad); }
.phase { position: absolute; left: 0; bottom: 0; font-size: 12.5px; font-weight: 600; font-variation-settings: "wdth" 72; color: #fff; padding: 2px 7px 3px;
  background: var(--real); pointer-events: none; z-index: 3; }
.phase.gen { background: var(--gen); }
.corner { position: absolute; top: 0; font-size: 12.5px; font-weight: 600; font-variation-settings: "wdth" 72; color: #fff; padding: 2px 7px 3px; z-index: 3; pointer-events: none; }
.corner.l2 { left: 0; background: var(--base); }
.corner.r2 { right: 0; background: var(--gen); }

/* wipe comparison */
.wipe { cursor: ew-resize; touch-action: pan-y; }
.wipe .over { clip-path: inset(0 0 0 var(--x, 50%)); }
.wipe .handle { position: absolute; top: 0; bottom: 0; left: var(--x, 50%); border-left: 2px solid #fff; z-index: 4; pointer-events: none; }
.wipe .handle::after { content: ""; position: absolute; top: 50%; left: -8px; width: 14px; height: 44px; margin-top: -22px; background: #fff; }
.wipe .phase { left: auto; right: 0; bottom: 0; }

/* frame-strip transport: one tick per frame */
.transport { display: flex; align-items: center; gap: 14px; margin: 16px 0 0; }
.pp { appearance: none; flex: none; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; background: none; color: var(--ink);
  border: 1.5px solid var(--ink); }
.pp svg { width: 12px; height: 12px; fill: currentColor; pointer-events: none; }
.scrub { position: relative; flex: 1; height: 34px; cursor: pointer; touch-action: none; }
.scrub .ticks { position: absolute; left: 0; right: 0; top: 8px; height: 18px;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(var(--tick) - 1px), transparent calc(var(--tick) - 1px) var(--tick));
          mask: repeating-linear-gradient(90deg, #000 0 calc(var(--tick) - 1px), transparent calc(var(--tick) - 1px) var(--tick)); }
.scrub .ticks i { position: absolute; top: 0; bottom: 0; }
.scrub .t-ctx { left: 0; background: var(--real-2); }
.scrub .t-gen { right: 0; background: var(--gen-2); }
.scrub .t-fill-c { left: 0; background: var(--real); width: 0; }
.scrub .t-fill-g { background: var(--gen); width: 0; }
.scrub .head { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: var(--ink); left: 0; }
.tlabel { flex: none; min-width: 130px; text-align: right; font-size: 14px; color: var(--ink-2); font-variation-settings: "wdth" 75; }

/* environment strip */
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 18px; max-width: 760px; }
.thumb { position: relative; appearance: none; padding: 0; border: 0; cursor: pointer; background: #000; aspect-ratio: 16 / 9; outline-offset: 3px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .62; transition: opacity .15s; }
.thumb:hover img, .thumb[aria-pressed="true"] img { opacity: 1; }
.thumb[aria-pressed="true"] { outline: 2px solid var(--gen); }
.thumb span { position: absolute; left: 0; bottom: 0; font-size: 12px; font-weight: 600; font-variation-settings: "wdth" 72; color: #fff; background: rgba(0, 0, 0, .6); padding: 1px 6px 2px; }
.thumb[aria-pressed="true"] span { background: var(--gen); }

/* clip library: one synced grid per environment */
.lib-group + .lib-group { margin-top: 56px; }
.lib-env { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 14px; font-size: clamp(18px, 1.8vw, 23px); font-weight: 650;
  font-variation-settings: "wdth" 110; }
.lib-env span { font-size: 14.5px; font-weight: 400; color: var(--ink-3); font-variation-settings: "wdth" 80; }
.lib-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: 1180px; }
.lib-grid.has-featured { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.lib-grid .featured { grid-column: span 3; grid-row: span 3; }
.lib-grid .featured .frame { aspect-ratio: auto; height: 100%; }

/* chunk demo */
.plate { background: var(--sheet); padding: 24px 26px 20px; }
.chunk-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 40px; margin-bottom: 20px; }
.chunk-head .tabs { margin: 0; }
.chunk-head .tabs button { font-size: 20px; font-weight: 650; font-variation-settings: "wdth" 100; }
.lat { display: flex; gap: 34px; margin: 0; flex-wrap: wrap; }
.lat div { display: flex; flex-direction: column; }
.lat dt { font-size: 13.5px; color: var(--ink-3); font-variation-settings: "wdth" 80; }
.lat dd { margin: 0; font-size: 22px; font-weight: 600; font-variation-settings: "wdth" 90; line-height: 1.2; }
.lat .tot dd { font-size: 34px; font-weight: 780; color: var(--gen); font-variation-settings: "wdth" 115; }
.chunk-rows { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 14px; align-items: center; }
.row-lab { font-size: 14px; color: var(--ink-3); font-variation-settings: "wdth" 80; }
.lane { height: 30px; display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; }
.lane .c { background: var(--box-2); transition: background .15s; }
.lane .c.act.on { background: var(--real); }
.lane .c.act.now { background: var(--ink); }
.lane .blk { border: 1.5px dashed var(--rule); display: grid; place-items: center; font-size: 12.5px; color: var(--ink-3); font-variation-settings: "wdth" 72; transition: background .2s, border-color .2s, color .2s; }
.lane .blk.wait { border-color: var(--real); color: var(--real); }
.lane .blk.done { border: 1.5px solid var(--gen); background: var(--gen-2); color: var(--gen); }
.lane .c.dec.on { background: var(--gen); }
.lat-bar { height: 8px; margin: 20px 0 0 124px; display: flex; background: var(--box-2); }
.lat-bar i { display: block; height: 100%; transition: width .45s cubic-bezier(.2, .7, .2, 1); }
.lat-bar i.w { background: var(--real); } .lat-bar i.g { background: var(--gen); }

/* counterfactual */
.cf-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); align-items: center; }
.cf-branches { display: grid; gap: 12px; }
.cf-branches .tile { display: grid; grid-template-columns: 52% minmax(0, 1fr); gap: 14px; align-items: center; }
.cf-branches .tile .cap { padding: 0; flex-direction: column; align-items: flex-start; }
.cf-svg { width: 100%; height: 100%; overflow: visible; }
.cf-svg path { fill: none; stroke: var(--rule); stroke-width: 2; transition: stroke .35s; }
.cf-svg.live path { stroke: var(--gen); }

/* tau chart */
.chart { margin-top: 24px; background: var(--sheet); padding: 16px 18px 12px; }
.chart .ch-t { font-size: 14px; color: var(--ink-2); font-variation-settings: "wdth" 85; margin-bottom: 6px; }
.chart canvas { width: 100%; height: 200px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; color: var(--ink-2); margin-top: 8px; font-variation-settings: "wdth" 82; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 16px; height: 3px; display: inline-block; }

.foot { padding-top: 90px; padding-bottom: 70px; }
.foot p { margin: 0; padding-top: 16px; border-top: 1px solid var(--rule); color: var(--ink-3); font-size: 14.5px; max-width: 90ch; font-variation-settings: "wdth" 88; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  :root { --rail: 0px; }
  .rail { position: sticky; top: 0; bottom: auto; width: auto; height: auto; flex-direction: row; align-items: center; gap: 0 18px; overflow-x: auto;
    padding: 10px 24px; border-right: 0; border-bottom: 1px solid var(--rule); scrollbar-width: none; }
  .rail::-webkit-scrollbar { display: none; }
  .rail a { display: flex; gap: 5px; flex: none; padding: 4px 0; }
  .rail .rail-home { margin: 0 8px 0 0; font-size: 18px; }
  .sec-head { grid-template-columns: 64px minmax(0, 1fr); }
  .margin-note { grid-column: 2; margin-top: 20px; max-width: 66ch; }
}
@media (max-width: 900px) {
  .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-lede { grid-template-columns: 1fr; }
  .cf-wrap { grid-template-columns: 1fr; gap: 16px; }
  .cf-svg { display: none; }
  .lib-grid, .lib-grid.has-featured { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lib-grid .featured { grid-column: span 2; grid-row: auto; }
  .lib-grid .featured .frame { aspect-ratio: 16 / 9; height: auto; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero, .sec, .foot { padding-left: 16px; padding-right: 16px; }
  .hero { padding-top: 32px; }
  .sec { padding-top: 64px; }
  .sec-head { grid-template-columns: 1fr; }
  .sec-no { width: max-content; margin-bottom: 12px; }
  .margin-note { grid-column: 1; }
  .g2, .hero-reel { grid-template-columns: 1fr; }
  .grid { gap: 16px 8px; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chunk-rows { grid-template-columns: 1fr; gap: 4px; }
  .lat-bar { margin-left: 0; }
  .plate { padding: 18px 16px; }
  .tlabel { min-width: 0; font-size: 12.5px; }
  .cf-branches .tile { grid-template-columns: 1fr; gap: 0; }
  .cf-branches .tile .cap { padding-top: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
