/* ───────────────────────── Tokens ───────────────────────── */
:root {
  --bg: #ffffff;
  --surface: #f6f6f3;
  --surface-2: #ecece7;
  --card: #ffffff;
  --ink: #15171c;
  --ink-2: #3a3e46;
  --muted: #676c76;
  --line: #e2e2dc;
  --line-strong: #cfcfc8;
  --accent: #b9410d;
  --accent-soft: #fbefe7;
  --ok: #17733a;
  --ok-bg: rgba(232, 246, 236, 0.94);
  --bad: #b3261e;
  --bad-bg: rgba(253, 236, 235, 0.94);
  --btn-bg: #15171c;
  --btn-ink: #ffffff;
  --figure-bg: #ffffff;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 6px 20px rgba(20, 20, 20, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --container: 1120px;
  --narrow: 780px;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1114;
    --surface: #16191e;
    --surface-2: #1e2228;
    --card: #1a1d23;
    --ink: #eceef1;
    --ink-2: #c8ccd3;
    --muted: #979ca6;
    --line: #2a2e36;
    --line-strong: #3a3f49;
    --accent: #f0915a;
    --accent-soft: #2b1d14;
    --ok: #5bd187;
    --ok-bg: rgba(16, 38, 24, 0.92);
    --bad: #ff8a80;
    --bad-bg: rgba(48, 20, 20, 0.92);
    --btn-bg: #eceef1;
    --btn-ink: #0f1114;
    --figure-bg: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1114;
  --surface: #16191e;
  --surface-2: #1e2228;
  --card: #1a1d23;
  --ink: #eceef1;
  --ink-2: #c8ccd3;
  --muted: #979ca6;
  --line: #2a2e36;
  --line-strong: #3a3f49;
  --accent: #f0915a;
  --accent-soft: #2b1d14;
  --ok: #5bd187;
  --ok-bg: rgba(16, 38, 24, 0.92);
  --bad: #ff8a80;
  --bad-bg: rgba(48, 20, 20, 0.92);
  --btn-bg: #eceef1;
  --btn-ink: #0f1114;
  --figure-bg: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ───────────────────────── Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3, h4 { margin: 0; color: var(--ink); }
h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.65rem, 3vw, 2.1rem); line-height: 1.2; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; }
h4 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; }
strong { font-weight: 600; color: var(--ink); }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.container.narrow { max-width: calc(var(--narrow) + 2 * var(--gutter)); }
.narrow-text { max-width: var(--narrow); }

.section { padding: 88px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { margin-bottom: 40px; }
.section-head h2 { margin-bottom: 16px; }
.section-head p { color: var(--ink-2); }
.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.cite { color: var(--muted); white-space: nowrap; }

/* ───────────────────────── Top navigation ───────────────────────── */
.topnav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
  transform: translateY(-100%);
  transition: transform 0.25s ease;
}
.topnav.is-visible { transform: none; }
@media (prefers-reduced-motion: reduce) { .topnav { transition: none; } }
.topnav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.topnav-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.02rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.topnav-links { display: flex; gap: 22px; margin-left: auto; }
.topnav-links a { font-size: 0.92rem; color: var(--muted); text-decoration: none; }
.topnav-links a:hover, .topnav-links a.is-active { color: var(--ink); }
.topnav-actions { display: flex; gap: 8px; }
.chip-link {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.chip-link:hover { border-color: var(--ink); }

/* ───────────────────────── Hero ───────────────────────── */
.hero { padding: 96px 0 56px; text-align: center; }
.venue {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 26px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.3rem, 6vw, 3.7rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 14px 0 34px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.2rem, 2.6vw, 1.55rem);
  line-height: 1.35;
  color: var(--ink-2);
}
.authors, .affiliations { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; }
.authors { gap: 6px 22px; font-size: 1.08rem; font-weight: 500; }
.authors sup, .affiliations sup, .contrib-note sup { font-size: 0.68em; margin-left: 1px; color: var(--muted); font-weight: 500; }
.affiliations { gap: 4px 18px; margin-top: 12px; font-size: 0.94rem; color: var(--ink-2); }
.contrib-note { margin: 10px 0 0; font-size: 0.86rem; color: var(--muted); }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 34px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1px solid var(--btn-bg);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn svg.fill { fill: currentColor; stroke: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); opacity: 1; }

/* ───────────────────────── Teaser ───────────────────────── */
.teaser { padding-top: 24px; }
.tldr {
  max-width: 860px;
  margin: 0 auto 36px;
  text-align: center;
  font-size: 1.13rem;
  line-height: 1.6;
  color: var(--ink-2);
}
.tldr strong { color: var(--ink); }

/* ───────────────────────── Figures ───────────────────────── */
.figure { margin: 0; }
.figure-frame {
  display: block;
  padding: 18px;
  background: var(--figure-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: zoom-in;
}
.figure-frame img { width: 100%; height: auto; }
.figure-hero .figure-frame { padding: 22px 26px; box-shadow: var(--shadow); }
.figure figcaption {
  max-width: var(--narrow);
  margin: 14px auto 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}
.figure figcaption b { color: var(--ink-2); font-weight: 600; }
.figure-small figcaption { text-align: left; margin-left: 0; }

/* Figure with switchable views (key result) */
.figure-switch { text-align: center; }
.figure-switch .tabs { margin-bottom: 18px; }
.figure-switch .fig-panel { text-align: left; }
.fig-panel[hidden] { display: none; }
.tabs-sm .tab { font-size: 0.88rem; padding: 6px 16px; }

/* ───────────────────────── Abstract ───────────────────────── */
.abstract { font-size: 1.04rem; color: var(--ink-2); text-align: justify; hyphens: auto; }
#abstract h2 { margin-bottom: 18px; }

/* ───────────────────────── Tabs & task explorer ───────────────────────── */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 28px;
  background: var(--surface-2);
  border-radius: 999px;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }

.panel-lead { max-width: var(--narrow); color: var(--ink-2); margin-bottom: 30px; }

.task-row { padding: 30px 0; border-top: 1px solid var(--line); }
.task-row:first-of-type { border-top: 0; padding-top: 0; }
.task-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.task-desc { max-width: 680px; }
.task-head h3 { margin-bottom: 4px; }
.task-head p { font-size: 0.93rem; line-height: 1.55; color: var(--muted); margin: 0; }

.example-switch { display: inline-flex; flex: none; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.example-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.example-switch button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.pairs { display: grid; gap: 20px; }
.pairs-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pairs-1 { grid-template-columns: minmax(0, 1fr); max-width: 980px; }
.pair[hidden] { display: none; }
.pair {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.pair-clips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pair-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px 2px; }
.pair-foot p { margin: 0; font-size: 0.9rem; line-height: 1.45; color: var(--ink-2); }

.replay {
  flex: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.replay::before {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.replay:hover { border-color: var(--ink); color: var(--ink); }

.clip { margin: 0; }
.media {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #0d1220;
}
.media.sq { aspect-ratio: 1 / 1; }
.media.wide { aspect-ratio: 464 / 256; }
.media.light { background: #ffffff; box-shadow: inset 0 0 0 1px var(--line); }
.media video { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.media.light video { mix-blend-mode: multiply; }

.tag {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.4;
  pointer-events: none;
}
.tag::before { content: ""; width: 12px; height: 12px; background: currentColor; }
.tag.ok { color: var(--ok); background: var(--ok-bg); }
.tag.bad { color: var(--bad); background: var(--bad-bg); }
.tag.ok::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tag.bad::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
}

.phy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.clip.phy { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.clip.phy figcaption { padding: 10px 4px 2px; font-size: 0.9rem; color: var(--ink-2); text-align: center; }

/* ───────────────────────── Method ───────────────────────── */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.step {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 26px 24px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.step-num {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
}
.step h3 { margin-bottom: 8px; }
.step p { font-size: 0.95rem; line-height: 1.6; color: var(--ink-2); }
.step .step-note { margin: auto 0 0; padding-top: 12px; font-size: 0.86rem; color: var(--muted); border-top: 1px dashed var(--line); }
.eq {
  margin: 4px 0 16px;
  padding: 12px 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  overflow-y: hidden;
  font-size: 0.95rem;
}
.eq .katex-display { margin: 0; }

.models { display: flex; flex-wrap: wrap; gap: 14px 40px; margin-top: 32px; }
.models-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.models-label { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.pill { font-size: 0.88rem; font-weight: 500; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill-muted { background: var(--surface-2); color: var(--ink-2); }

/* ───────────────────────── Results ───────────────────────── */
.finding { padding: 56px 0; border-top: 1px solid var(--line); }
.finding:first-of-type { border-top: 0; padding-top: 8px; }
.finding:last-of-type { padding-bottom: 0; }
.finding-num { margin: 0 0 8px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.finding-text h3 { font-family: var(--serif); font-size: clamp(1.35rem, 2.4vw, 1.6rem); font-weight: 600; line-height: 1.25; margin-bottom: 14px; }
.finding-text p { color: var(--ink-2); }
.finding > .finding-text { margin-bottom: 28px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: center; margin-top: 36px; }
.split-text { margin-top: 0; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.split-even { margin-top: 0; align-items: start; }

.callout {
  padding: 26px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.callout h4 { font-family: var(--serif); font-size: 1.25rem; margin-bottom: 10px; }
.callout p { font-size: 0.97rem; color: var(--ink-2); }
.callout p:last-child { margin-bottom: 0; }

.callout-wide { max-width: var(--narrow); margin: 36px auto 0; }

/* ───────────────────────── BibTeX & footer ───────────────────────── */
.bib-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.copy {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.copy:hover { border-color: var(--ink); color: var(--ink); }
.bib {
  margin: 0;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--ink);
}
.ack-title { margin-top: 64px; margin-bottom: 14px; font-size: 1.35rem; }
.ack { font-size: 0.93rem; color: var(--muted); }

.footer { padding: 36px 0 56px; border-top: 1px solid var(--line); }
.footer p { margin: 0; font-size: 0.84rem; color: var(--muted); text-align: center; }

/* ───────────────────────── Responsive ───────────────────────── */
@media (max-width: 1000px) {
  .steps { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .topnav-links { display: none; }
  .topnav-actions { margin-left: auto; }
  .split, .split-text, .split-even { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .pairs-2 { grid-template-columns: minmax(0, 1fr); }
  .phy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}

@media (max-width: 560px) {
  :root { --gutter: 16px; }
  body { font-size: 16px; }
  .section { padding: 64px 0; }
  .hero { padding: 72px 0 40px; }
  .authors { gap: 4px 16px; font-size: 1rem; }
  .figure-frame { padding: 10px; }
  .figure-hero .figure-frame { padding: 12px; }
  .abstract { text-align: left; }
  .tab { padding: 8px 14px; }
  .pair { padding: 8px; }
  .pair-foot { flex-wrap: wrap; }
  .tag { top: 6px; left: 6px; font-size: 0.7rem; padding: 2px 7px 2px 5px; }
  .tag::before { width: 10px; height: 10px; }
  .clip.phy { padding: 6px; }
  .clip.phy figcaption { font-size: 0.78rem; }
  .callout { padding: 20px; }
  .topnav-title { font-size: 0.95rem; }
}
