/* C2R# project page. One scrollable page; system fonts only, no external requests. */
:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --ink: #17191e;
  --ink-2: #3b4049;
  --muted: #676c75;
  --line: #e4e4e0;
  --soft: #f2f2ef;
  --accent: #1c6b5f;
  --accent-ink: #14544a;
  --accent-soft: #e7f0ee;
  --stage: #111214;
  --radius: 10px;
  --topbar: 56px;
  --max: 1360px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar) + 20px); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
img, video { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.container { width: min(var(--max), 100% - 64px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; background: var(--surface); padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; }
.skip-link:focus { top: 12px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 40; background: rgb(251 251 250 / 0.94); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.topbar-row { height: var(--topbar); width: min(var(--max), 100% - 64px); margin-inline: auto; display: flex; align-items: center; gap: 14px; }
.brand { font-weight: 750; font-size: 19px; letter-spacing: -0.02em; text-decoration: none; }
.paper-id { font-size: 13px; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.autoplay-switch { margin-left: auto; display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.autoplay-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 32px; height: 18px; border-radius: 9px; background: #cfd0cc; position: relative; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s; }
.autoplay-switch input:checked + .switch { background: var(--accent); }
.autoplay-switch input:checked + .switch::after { transform: translateX(14px); }
.autoplay-switch input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.topnav { display: none; gap: 4px; overflow-x: auto; scrollbar-width: none; width: min(var(--max), 100% - 32px); margin-inline: auto; padding: 0 0 8px; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { flex: none; font-size: 13px; text-decoration: none; color: var(--ink-2); padding: 5px 10px; border-radius: 999px; }
.topnav a:hover { background: var(--soft); }
.topnav a.active { background: var(--ink); color: #fff; }

/* Hero */
.hero { text-align: center; padding: 64px 0 36px; }
.hero h1 { font-size: clamp(22px, 2.05vw, 30px); line-height: 1.3; text-wrap: balance; }
.nobr { white-space: nowrap; }
.authors { margin-top: 18px; }
.author-names { font-size: 17px; color: var(--ink); }
.author-names a { text-decoration: none; white-space: nowrap; }
.author-names a:hover { color: var(--accent); }
.author-names sup, .affiliations sup, .author-note sup { font-size: 10px; color: var(--muted); margin-left: 1px; }
.author-note sup { margin: 0 2px 0 0; }
.author-names .author + .author::before { content: ", "; }
.affiliations { font-size: 14px; color: var(--muted); margin-top: 6px; }
.affiliations span + span::before { content: " · "; }
.author-note { margin-top: 6px; font-size: 14px; color: var(--muted); }
.resource-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.resource-links:empty { display: none; }
.resource-links a { font-size: 14px; text-decoration: none; padding: 7px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.resource-links a:hover { border-color: var(--ink-2); }
.resource-links .soon { font-size: 14px; padding: 7px 16px; border: 1px dashed var(--line); border-radius: 999px; color: var(--muted); cursor: default; user-select: none; }
.resource-links .soon small { font-size: 11px; margin-left: 4px; text-transform: uppercase; letter-spacing: .04em; }

@media (min-width: 960px) {
  .hero h1 { white-space: nowrap; }
}

/* Teaser */
.teaser { margin-top: 0; margin-bottom: 0; max-width: 1180px; }
.teaser-frame { border-radius: var(--radius); overflow: hidden; background: var(--stage); }
.teaser-frame video { width: 100%; aspect-ratio: 1664 / 816; object-fit: contain; }
.teaser figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; text-align: center; }

/* Layout */
.layout { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 56px; margin-top: 40px; }
.sidebar { position: sticky; top: calc(var(--topbar) + 24px); align-self: start; max-height: calc(100vh - var(--topbar) - 40px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; padding: 68px 0 16px; }
.sidebar-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.toc, .toc ol { list-style: none; margin: 0; padding: 0; }
.toc > li { margin: 1px 0; }
.toc a { display: block; text-decoration: none; font-size: 14px; color: var(--ink-2); padding: 4px 10px; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--ink); }
.toc ol a { font-size: 13px; padding-left: 22px; color: var(--muted); }
.toc ol ol a { font-size: 12.5px; padding-left: 34px; }
.toc a.active { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 600; }
.toc a.active-parent { color: var(--ink); border-left-color: var(--ink-2); }

main { min-width: 0; }
.section { padding: 64px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; }
.section > h2 { font-size: 26px; line-height: 1.25; }
.intro { color: var(--ink-2); max-width: 76ch; margin-top: 10px; }
.prose { margin-top: 16px; max-width: 76ch; }
#ablation-gallery { margin-top: 24px; }
.prose p { color: var(--ink-2); font-size: 17px; line-height: 1.75; }
.prose p + p { margin-top: 14px; }
/* Justified body text; hyphenation keeps word gaps even on narrow screens. */
.prose p, .intro, .analysis, .diagram figcaption, .prompt-block p { text-align: justify; -webkit-hyphens: auto; hyphens: auto; }
/* Abstract centered in the column; method and ablation text span the full row. */
#abstract > h2 { text-align: center; }
#abstract .prose { margin-inline: auto; }
#method .intro, #ablation .intro { max-width: none; }

/* Section heading with the example currently shown */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 26px; line-height: 1.25; }
/* Subsections (Reference image, Seedance 2.5) continue their parent section: no divider, smaller heading. */
.section.subsection { border-top: 0; padding-top: 8px; }
.section-head h3 { font-size: 21px; line-height: 1.3; }
.now { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; background: var(--accent-soft); color: var(--accent-ink); padding: 4px 12px; border-radius: 999px; }
.now:empty { display: none; }
.now-group { font-weight: 600; }
.now strong { font-weight: 700; }
.now-total { opacity: .8; }

/* Viewer controls */
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-top: 24px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 6px; font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: baseline; gap: 6px; }
.segmented button span { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 0 0 1px var(--line); }
.stepper { display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; }
.step { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); }
.step svg { width: 16px; height: 16px; }
.step:hover { border-color: var(--ink-2); }
.chips { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.chips button { min-width: 28px; height: 28px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chips button:hover { background: var(--soft); color: var(--ink); }
.chips button.current { background: var(--ink); color: #fff; font-weight: 600; }
.count { display: none; min-width: 52px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.group-note { font-size: 14px; color: var(--muted); margin-top: 12px; }
.stage { margin-top: 14px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.card .media, .card .scroll-x { border-radius: 0; }
.card .hint { padding: 0 16px; margin-top: 8px; }
.prompt-block summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; user-select: none; }
.prompt-block summary::-webkit-details-marker { display: none; }
.prompt-block summary:hover { background: var(--soft); }
.prompt-label { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.prompt-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.prompt-toggle::before { content: "Show"; }
.prompt-block[open] .prompt-toggle::before { content: "Hide"; }
.prompt-toggle::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; rotate: 45deg; translate: 0 -2px; transition: rotate .15s, translate .15s; }
.prompt-block[open] .prompt-toggle::after { rotate: 225deg; translate: 0 2px; }
.prompt-block[open] summary { padding-bottom: 6px; }
.prompt-block p { padding: 0 16px 16px; font-size: 14px; line-height: 1.7; color: var(--ink-2); }
#viewer-body .prompt-block { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; }

/* R2C training example: real image large, four coarse targets in a 2 x 2 grid */
.train-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; }
.train-cell { position: relative; margin: 0; line-height: 0; border-radius: 6px; overflow: hidden; background: var(--soft); }
.train-cell.main { grid-row: span 2; }
.train-cell button { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.train-cell img { width: 100%; height: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.tag { position: absolute; left: 6px; top: 6px; padding: 3px 7px; border-radius: 4px; background: rgb(17 18 20 / .72); color: #fff; font-size: 11.5px; line-height: 1.35; pointer-events: none; }

/* Short written analysis under a gallery */
.analysis { margin-top: 20px; color: var(--ink-2); font-size: 15.5px; line-height: 1.7; }

/* Method figures */
.diagram { margin: 28px 0 0; }
.diagram-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.diagram-head h3 { font-size: 16px; }
.diagram-head a { font-size: 13px; color: var(--accent-ink); }
.diagram-button { display: block; width: 100%; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: zoom-in; }
.diagram-button:hover { border-color: #c9c9c4; }
.diagram-button img { width: 100%; height: auto; }
.diagram figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; }

/* Media player */
.media { position: relative; aspect-ratio: var(--ar); background: var(--stage); overflow: hidden; line-height: 0; cursor: pointer; }
.media video { width: 100%; height: 100%; object-fit: contain; }
.labels { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr); pointer-events: none; }
.labels span { align-self: start; justify-self: start; margin: 6px; padding: 3px 7px; border-radius: 4px; background: rgb(17 18 20 / .72); color: #fff; font-size: 11.5px; line-height: 1.35; font-weight: 500; max-width: calc(100% - 12px); }
.labels span.ours { background: var(--accent); }
.play-state { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 44px; height: 44px; border-radius: 50%; background: rgb(255 255 255 / .92); color: var(--ink); display: grid; place-items: center; pointer-events: none; box-shadow: 0 2px 12px rgb(0 0 0 / .3); transition: opacity .15s; }
.play-state svg { width: 20px; height: 20px; margin-left: 2px; }
.media.playing .play-state { opacity: 0; }
.media.loading .play-state { opacity: .6; }
.expand { position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border: 0; border-radius: 6px; background: rgb(17 18 20 / .65); color: #fff; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.expand svg { width: 15px; height: 15px; }
.media:hover .expand, .expand:focus-visible { opacity: 1; }
@media (hover: none) { .expand { opacity: 1; } }
.video-error { position: absolute; left: 8px; right: 8px; bottom: 8px; background: #fff; color: #8a2a2a; font-size: 12px; line-height: 1.4; padding: 6px 8px; border-radius: 5px; }
.video-error[hidden] { display: none; }

.scroll-x { border-radius: var(--radius); }
.hint { display: none; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Reference rows */
.ref-row { display: grid; grid-template-columns: 1.778fr 3.467fr; gap: 2px; background: var(--stage); }
.ref-image { position: relative; margin: 0; line-height: 0; }
.ref-image button { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: var(--stage); cursor: zoom-in; }
.ref-image img { width: 100%; height: 100%; object-fit: contain; }
.ref-image .labels { grid-template-columns: 1fr; grid-template-rows: 1fr; }

/* Footer */
.footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 28px 0 40px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.footer a { color: var(--muted); }

/* Viewer dialog */
body.dialog-open { overflow: hidden; }
dialog { width: min(1600px, 96vw); max-width: none; max-height: 94vh; max-height: 94dvh; padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--ink); overflow: auto; box-shadow: 0 30px 100px rgb(0 0 0 / .45); }
dialog::backdrop { background: rgb(17 18 20 / .82); }
.viewer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.viewer-head h2 { font-size: 16px; }
.viewer-close { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); font-size: 20px; line-height: 1; }
#viewer-body { padding: 16px; }
#viewer-body .media { cursor: default; border-radius: 8px; }
#viewer-body .labels span { font-size: 13px; }
.viewer-image { max-height: calc(94vh - 110px); max-height: calc(94dvh - 110px); width: auto; margin: 0 auto; }
.viewer-scroll { overflow-x: auto; }

/* With the sidebar visible, shift the abstract left by half of the sidebar
   column plus gap (196px + 56px) so it is centered on the page axis like
   the title and teaser, and cap its width so it stays inside the column. */
@media (min-width: 1181px) {
  #abstract > h2, #abstract .prose { position: relative; left: -126px; }
  #abstract .prose { max-width: min(76ch, 100% - 252px); }
}

/* Responsive */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { display: none; }
  .topnav { display: flex; }
  html { scroll-padding-top: calc(var(--topbar) + 60px); }
}
@media (max-width: 900px) {
  .scroll-x { overflow-x: auto; }
  .wide { min-width: 720px; }
  .scroll-x + .hint { display: block; }
  .chips { display: none; }
  .count { display: block; }
}
@media (max-width: 640px) {
  .container, .topbar-row { width: calc(100% - 32px); }
  .hero { padding: 40px 0 28px; }
  .autoplay-switch span:last-child { font-size: 12px; }
  .section { padding: 48px 0; }
  .section > h2, .section-head h2 { font-size: 22px; }
  .section-head h3 { font-size: 19px; }
  .viewer-bar { gap: 10px; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; justify-content: center; padding: 6px 8px; }
  .stepper { width: 100%; justify-content: space-between; }
  .train-grid { grid-template-columns: 1fr 1fr; }
  .train-cell.main { grid-row: auto; grid-column: 1 / -1; }
  .tag { font-size: 10px; padding: 2px 5px; left: 4px; top: 4px; }
  .prose p { font-size: 16px; }
  .labels span { font-size: 10px; margin: 4px; padding: 2px 5px; }
  .ref-row { grid-template-columns: 1fr; }
  .ref-image { aspect-ratio: 16 / 9; }
  dialog { width: 100vw; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
  #viewer-body { padding: 10px; }
}
/* Touch screens: give small controls a finger-sized (about 40px) tap area. */
@media (pointer: coarse) {
  .autoplay-switch { padding-block: 10px; }
  .expand { width: 40px; height: 40px; }
  .viewer-close { width: 40px; height: 40px; }
  .footer a { display: inline-block; padding-block: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
