:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --text: #1c2026;
  --muted: #5d6673;
  --line: #e2e5ea;
  --accent: #2f6fd0;
  --ours: #1f9d63;
  --ours-soft: #e6f6ee;
  --base: #d2473f;
  --base-soft: #fdecea;
  --neutral: #6b7280;
  --radius: 10px;
  --width: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131a;
    --bg-soft: #171c25;
    --text: #e8ebf0;
    --muted: #9aa4b2;
    --line: #272e3a;
    --accent: #7fb0ff;
    --ours: #3ecf8e;
    --ours-soft: #12301f;
    --base: #ff7b72;
    --base-soft: #3a1917;
    --neutral: #9aa4b2;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { display: block; max-width: 100%; }

.wrap {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0 20px;
}

.narrow { max-width: 820px; margin-left: auto; margin-right: auto; }

/* ---------- header ---------- */

header.hero {
  padding: 64px 0 28px;
  text-align: center;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero .subtitle {
  margin: 10px 0 0;
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}

.authors {
  margin: 26px 0 4px;
  font-size: 1.15rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 32px;
}

.affiliation { margin: 0; color: var(--muted); }

.buttons {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.95rem;
  font-weight: 600;
}

.btn:hover { text-decoration: none; opacity: 0.85; }

.btn.disabled {
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  pointer-events: none;
}

.btn small { font-weight: 400; }

/* ---------- sections ---------- */

section { padding: 44px 0; }
section.alt { background: var(--bg-soft); }

h2 {
  margin: 0 0 14px;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  text-align: center;
}

h3 { margin: 34px 0 6px; font-size: 1.2rem; }

.lead {
  margin: 0 auto 26px;
  max-width: 820px;
  color: var(--muted);
  text-align: center;
}

.abstract p { margin: 0; text-align: justify; hyphens: auto; }

.main-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}

/* ---------- video panels ---------- */

.panel { margin: 0; min-width: 0; }

.panel video,
.panel img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.panel figcaption {
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
}

.tag {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--neutral);
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.tag.ours { color: var(--ours); background: var(--ours-soft); border-color: transparent; }
.tag.base { color: var(--base); background: var(--base-soft); border-color: transparent; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }

.prompt {
  margin: 0 auto 18px;
  max-width: 760px;
  text-align: center;
  font-style: italic;
  color: var(--muted);
}

.prompt b { font-style: normal; font-weight: 600; color: var(--text); }

/* comparison rows: input + prompt | baseline | ours */

.compare {
  display: grid;
  grid-template-columns: 0.55fr 1fr 1fr;
  gap: 16px;
  align-items: start;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.compare:first-of-type { border-top: 0; }

.compare .input img { aspect-ratio: 16 / 9; }

.compare .input p {
  margin: 8px 0 0;
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.4;
}

.compare .input .label,
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- method ---------- */

.diagram {
  width: 100%;
  margin: 8px 0 24px;
}

.diagram.dark { display: none; }

@media (prefers-color-scheme: dark) {
  .diagram.light { display: none; }
  .diagram.dark { display: block; }
}

.steps { counter-reset: step; }

.step {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.step h3 { margin: 0 0 6px; font-size: 1.05rem; }
.step p { margin: 0; font-size: 0.93rem; color: var(--muted); }

.step h3::before {
  counter-increment: step;
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8em;
}

/* ---------- tables ---------- */

.tables {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

caption {
  caption-side: top;
  padding-bottom: 8px;
  font-weight: 700;
  font-size: 1rem;
  text-align: left;
}

th, td { padding: 6px 5px; text-align: center; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }

thead th {
  border-top: 2px solid var(--text);
  border-bottom: 1px solid var(--text);
  font-weight: 600;
}

tbody tr:last-child td { border-bottom: 2px solid var(--text); }

tr.group td {
  padding-top: 10px;
  font-style: italic;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

tr.ours td { background: var(--ours-soft); font-weight: 600; }

td b { font-weight: 800; }
td u { text-underline-offset: 3px; }

.table-note {
  margin: 10px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- misc ---------- */

.bench-img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.bibtex { position: relative; }

.bibtex pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font: 0.85rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

section.alt .bibtex pre { background: var(--bg); }

.copy {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

footer {
  padding: 28px 0 40px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .tables { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: repeat(2, 1fr); }
  .grid.three.steps { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  section { padding: 34px 0; }
  .grid.three:not(.gallery) { grid-template-columns: 1fr; }
  .grid.three.gallery { grid-template-columns: repeat(2, 1fr); }
  .grid { gap: 10px; }
  .compare { grid-template-columns: 1fr 1fr; gap: 10px; }
  .compare .input {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    align-items: center;
  }
  .compare .input .label { display: none; }
  .compare .input p { margin: 0; }
  .abstract p { text-align: left; }
}


/* ---------- scene picker (comparison) ---------- */

.picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  margin: 0 0 18px;
}

.picker button,
.bench-grid button {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  overflow: hidden;
  outline: 3px solid transparent;
  outline-offset: 1px;
  opacity: 0.6;
  transition: opacity 0.15s, outline-color 0.15s;
}

.picker button img,
.bench-grid button img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.bench-grid button { opacity: 0.85; }

.picker button:hover,
.bench-grid button:hover { opacity: 1; }

.picker button[aria-selected="true"],
.bench-grid button[aria-pressed="true"] {
  opacity: 1;
  outline-color: var(--accent);
}

.panel .missing {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.85rem;
}

section.alt .panel .missing { background: var(--bg); }

.panel-head { margin-bottom: 6px; }
.panel-head .tag { margin-right: 0; }

.tag.sim { color: var(--accent); background: var(--bg); border-color: var(--line); }
section:not(.alt) .tag.sim { background: var(--bg-soft); }

/* ---------- simulation vs InterPlay pairs ---------- */

.pairs { column-gap: 28px; row-gap: 30px; }

/* before/after slider: the simulation sits on top and is clipped at the divider */
.slider {
  --pos: 50%;
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-soft);
  cursor: ew-resize;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.slider video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.slider .slider-top { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }

.slider-label {
  position: absolute;
  top: 10px;
  z-index: 2;
  margin: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.slider-label.left { left: 10px; }
.slider-label.right { right: 10px; }
.slider-label.hidden { opacity: 0; }

.slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  z-index: 3;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
  outline: none;
}

/* round grip with arrows on the line; it stays fully inside the frame at the edges */
.slider::after {
  content: "\2039\00a0\203A";
  position: absolute;
  top: 50%;
  left: clamp(17px, var(--pos), calc(100% - 17px));
  z-index: 4;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  color: #1c2026;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.slider:has(.slider-handle:focus-visible)::after { outline: 3px solid var(--accent); outline-offset: 2px; }

.pair-caption {
  margin: 10px 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.pair-prompt {
  display: block;
  margin-bottom: 2px;
  font-style: italic;
  color: var(--text);
}

@media (max-width: 860px) {
  .grid.two.pairs { grid-template-columns: 1fr; }
}

/* ---------- InterBench browser ---------- */

.bench {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.bench-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.bench-grid .count {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.6;
}

.bench-detail {
  position: sticky;
  top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.bench-detail img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-soft);
}

.bench-meta {
  margin: 12px 0 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.bench-detail ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: p;
}

.bench-detail li {
  counter-increment: p;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  line-height: 1.45;
}

.bench-detail li:first-child { border-top: 0; }

.bench-detail li::before {
  content: "Prompt " counter(p);
  display: block;
  margin-bottom: 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 860px) {
  .picker { grid-template-columns: repeat(4, 1fr); }
  .bench { grid-template-columns: 1fr; }
  .bench-detail { position: static; order: -1; }
}

@media (max-width: 640px) {
  .bench-grid { grid-template-columns: repeat(3, 1fr); }
}
