/* Layout: one 1120px column; the video stage is always a dark "edit suite" surface, the page around it follows the theme. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --ink: #141821;
  --muted: #5a6274;
  --line: #dde1e8;
  --accent: #2c56c9;
  --accent-ink: #ffffff;
  --hint: #d9821f;
  --stage: #0d0f13;
  --stage-ink: #e9ecf2;
  --stage-muted: #8d95a6;
  --chip: #eceff4;
  --banner: #fff3df;
  --banner-ink: #6a3d00;
  --f-display: "Schibsted Grotesk", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1116; --surface: #161a22; --ink: #e7eaf1; --muted: #9aa2b3; --line: #272c37;
    --accent: #8aa6ff; --accent-ink: #0d1020; --hint: #f2a33a; --stage: #07080b; --stage-ink: #e9ecf2;
    --stage-muted: #8d95a6; --chip: #1e232d; --banner: #2b2112; --banner-ink: #f3cf96; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1116; --surface: #161a22; --ink: #e7eaf1; --muted: #9aa2b3; --line: #272c37;
  --accent: #8aa6ff; --accent-ink: #0d1020; --hint: #f2a33a; --stage: #07080b; --stage-ink: #e9ecf2;
  --stage-muted: #8d95a6; --chip: #1e232d; --banner: #2b2112; --banner-ink: #f3cf96; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
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: 17px/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--surface);
}
.wrap {
  max-width: 1120px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--f-mono); font-size: 0.85em; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem); line-height: 1.15; letter-spacing: -0.01em; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
.eyebrow {
  font: 600 0.72rem/1 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px;
}

/* top bar */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 52px; }
.brand { font: 800 1.05rem var(--f-display); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.topbar nav { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 0.92rem; white-space: nowrap; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav { margin-left: auto; }
.lang-toggle {
  flex: none; min-width: 44px; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: 600 0.85rem var(--f-body); cursor: pointer;
}
.lang-toggle:hover { border-color: var(--muted); }
.lang-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Chinese reads better with a little more line height and no negative tracking */
:lang(zh) h1, :lang(zh) h2, :lang(zh) h3 { letter-spacing: 0; }
:lang(zh) body { line-height: 1.75; }
@media (max-width: 560px) { .topbar nav a:nth-child(n+4) { display: none; } }

.banner { background: var(--banner); color: var(--banner-ink); font-size: 0.9rem; }
.banner .wrap { padding-block: 8px; }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 40px; align-items: center; padding-block: 48px 28px; }
.hero h1 { font-size: clamp(2.6rem, 1.6rem + 4vw, 4.6rem); line-height: 0.98; letter-spacing: -0.035em; font-weight: 800; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 34em; margin: 18px 0 16px; }
.authors { margin: 0 0 20px; font-weight: 600; }
.aff { display: block; font-weight: 400; color: var(--muted); font-size: 0.95rem; }
.links { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-block: 32px 20px; } }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 0.95rem var(--f-body); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn[aria-disabled="true"] { opacity: 0.6; cursor: default; }
.btn small { font: 600 0.65rem var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; }

.facts dl { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts dl > div { padding: 16px 16px 16px 0; min-width: 0; }
.facts dl > div + div { padding-left: 16px; border-left: 1px solid var(--line); }
.facts dt { font: 600 0.7rem var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 4px 0 0; font-weight: 600; line-height: 1.35; }
@media (max-width: 760px) {
  .facts dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts dl > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts dl > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* sections */
.section { padding-block: 64px 8px; }
.section-head { max-width: 46em; margin-bottom: 24px; }
.sub { color: var(--muted); margin: 12px 0 0; }

/* tabs + gallery */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 6px 14px; font: 600 0.9rem var(--f-body); cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.cat-blurb { color: var(--muted); margin: 12px 0 18px; font-size: 0.95rem; }
.gallery { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .gallery { grid-template-columns: minmax(0, 1fr); } }
.gallery-side h3 { margin-bottom: 6px; }
.case-note { color: var(--muted); margin: 0 0 16px; font-size: 0.95rem; }
.case-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .case-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.case-btn {
  width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; display: block;
}
.case-btn img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--stage); }
.case-btn span { display: block; padding: 6px 8px; font-size: 0.82rem; line-height: 1.3; }
.case-btn[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* player */
.player { background: var(--stage); color: var(--stage-ink); border-radius: var(--r); overflow: hidden; }
.stage { position: relative; cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.stage canvas { display: block; width: 100%; height: auto; max-width: 100%; }
.divider { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ffffff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none; }
.knob {
  position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 1px 6px rgba(0,0,0,.45);
  display: grid; place-items: center; font: 600 13px var(--f-mono); color: #111;
}
.lbl {
  position: absolute; top: 10px; padding: 3px 8px; border-radius: 4px; pointer-events: none;
  background: rgba(8,9,12,.72); color: #f1f3f7; font: 600 0.72rem var(--f-mono); letter-spacing: 0.04em;
}
.lbl.l { left: 10px; } .lbl.r { right: 10px; }
.lbl.hint { box-shadow: inset 0 0 0 1px var(--hint); }
.bigplay {
  position: absolute; left: 14px; bottom: 14px; width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: rgba(8,9,12,.7); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.bigplay svg { width: 20px; height: 20px; margin-left: 3px; fill: currentColor; }
.loading .bigplay { opacity: .6; }
.controls { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.ctl {
  flex: none; width: 32px; height: 32px; border-radius: 4px; border: 0; background: transparent; color: var(--stage-ink);
  cursor: pointer; display: grid; place-items: center;
}
.ctl:hover { background: rgba(255,255,255,.08); }
.ctl svg { width: 16px; height: 16px; fill: currentColor; }
.scrub { flex: 1; min-width: 0; accent-color: var(--hint); }
.tc { flex: none; font: 500 0.75rem var(--f-mono); color: var(--stage-muted); font-variant-numeric: tabular-nums; text-align: right; line-height: 1.25; }
.tc b { color: var(--stage-ink); font-weight: 600; }
@media (max-width: 520px) { .tc .tc-frame { display: none; } .ctl.step { display: none; } }
.pairs { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 10px 12px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.pair { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.pair > span { font: 600 0.68rem var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--stage-muted); margin-right: 2px; }
.chip {
  border: 1px solid rgba(255,255,255,.16); background: transparent; color: var(--stage-ink); border-radius: 4px;
  padding: 3px 9px; font: 500 0.8rem var(--f-body); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--stage-ink); color: var(--stage); border-color: var(--stage-ink); }
.chip.is-hint[aria-pressed="true"] { background: var(--hint); border-color: var(--hint); color: #1a1105; }
.hero-player .pairs { display: none; }
.uhd-player { max-width: 1200px; margin: 0 auto; }
.uhd-player .pairs { display: none; }

/* overview */
.overview { aspect-ratio: 16 / 9; max-width: 100%; background: var(--stage); border-radius: var(--r); overflow: hidden; }
.overview.is-empty { aspect-ratio: auto; min-height: 160px; }
.overview iframe { width: 100%; height: 100%; border: 0; display: block; }
.overview-empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--stage-muted); padding: 16px; }
.overview-empty p { margin: 4px 0; }
.overview-empty .small { font-size: 0.85rem; }

/* trio */
/* "From model to delivery": three gaps and six pipeline steps */
.gaps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 820px) { .gaps { grid-template-columns: minmax(0, 1fr); } }
.gap { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 16px 18px; }
.gap strong { display: block; font: 700 1.2rem var(--f-display); color: var(--ink); margin-bottom: 4px; }
.gap span { color: var(--muted); }
.gaps-note { margin: 18px 0 22px; color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .steps { grid-template-columns: minmax(0, 1fr); } }
.step { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; min-width: 0; }
.step h3 { margin: 0; padding: 10px 14px; font-size: 1rem; background: var(--chip); color: var(--ink); }
.step-wide { grid-column: 1 / -1; }
.step-row { margin: 0; padding: 10px 14px 0; color: var(--muted); font-size: 0.95rem; }
.step-row:last-child { padding-bottom: 14px; color: var(--ink); }
.step-k { display: block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.step-k.fix { color: var(--hint); }

/* "Why a hint" comparison: three mask styles on the same title card */
.why { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 0; }
@media (max-width: 820px) { .why { grid-template-columns: minmax(0, 1fr); } }
.why-card { margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.why-card.good { border-color: var(--hint); box-shadow: 0 0 0 1px var(--hint); }
.why-img { aspect-ratio: 16 / 10; background: var(--stage); display: flex; align-items: center; justify-content: center; }
.why-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.why-card figcaption { padding: 14px 16px 16px; }
.why-card h3 { margin: 6px 0 4px; }
.why-card p { color: var(--muted); margin: 0; }
.why-tag { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--chip); color: var(--muted); }
.why-card.good .why-tag { background: var(--hint); color: #1b1206; }
.why-props { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 10px 28px; color: var(--muted); }
.why-props strong { color: var(--ink); }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
@media (max-width: 820px) { .trio { grid-template-columns: minmax(0, 1fr); } }
.trio article { min-width: 0; }
.trio p { color: var(--muted); margin: 6px 0 8px; }
.glyph { width: 100%; max-width: 260px; height: auto; display: block; margin-bottom: 14px; }
.g-frame { fill: var(--stage); }
.g-scene { fill: #3f4a5e; }
.g-sign { fill: #2d6d5a; }
.g-text { fill: #f4f4f4; font: 700 15px var(--f-body); }
.g-small { fill: #ffffff; font: 700 10px var(--f-mono); }
.g-hint { fill: color-mix(in srgb, var(--hint) 28%, transparent); stroke: var(--hint); stroke-width: 1.5; stroke-dasharray: 5 3; }
.more { font-weight: 600; font-size: 0.95rem; }

/* diagram */
.diagram-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.diagram { display: block; width: 100%; min-width: 680px; height: auto; }
.d-cap { font: 600 11px var(--f-mono); letter-spacing: .12em; fill: var(--muted); }
.d-lbl { font: 600 13px var(--f-body); fill: var(--ink); }
.d-note { font: 12px var(--f-body); fill: var(--muted); }
.d-film { fill: var(--stage); }
.d-sub { font: 700 15px var(--f-body); fill: #f4f4f4; }
.d-hint { fill: color-mix(in srgb, var(--hint) 30%, transparent); stroke: var(--hint); stroke-width: 1.5; stroke-dasharray: 6 4; }
.d-model { fill: var(--accent); }
.d-model-t { font: 700 16px var(--f-display); fill: var(--accent-ink); }
.d-line { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.d-arrowhead { fill: var(--muted); }
.d-win-n { font: 700 14px var(--f-mono); fill: #ffffff; }
.d-ctx { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.d-shot { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.d-shot-t { font: 11px var(--f-mono); fill: var(--muted); }

/* limits, bib */
.limits { margin: 0 0 16px; padding-left: 1.1em; max-width: 46em; }
.limits li { margin-bottom: 8px; }
.bib { position: relative; max-width: 100%; }
.bib pre {
  margin: 0; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 92px 16px 16px; font: 0.85rem/1.55 var(--f-mono);
}
.bib .copy { position: absolute; top: 10px; right: 10px; padding: 5px 12px; font-size: 0.85rem; }
.ack { color: var(--muted); max-width: 46em; margin-top: 20px; }
.foot { margin-top: 64px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.foot .wrap { padding-block: 24px; }

/* contact line under the BibTeX block */
.contact { margin-top: 20px; color: inherit; opacity: .8; }
.contact a { text-decoration: underline; }
.contact code { font-family: inherit; padding: 1px 6px; border-radius: 4px; background: rgba(127,127,127,.15); }
