:root {
  --bg:           #fafaf9;
  --bg-alt:       #f3f3f1;
  --surface:      #ffffff;
  --ink:          #111418;
  --ink-soft:     #3a3f47;
  --ink-mute:     #6b7280;
  --line:         #e5e5e3;
  --accent:       #1f6feb;
  --accent-soft:  #e8f0fe;
  --warn:         #b54708;
  --shadow-sm:    0 1px 2px rgba(17, 20, 24, 0.04),
                  0 1px 3px rgba(17, 20, 24, 0.06);
  --shadow-md:    0 4px 8px rgba(17, 20, 24, 0.05),
                  0 12px 24px rgba(17, 20, 24, 0.08);
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --maxw:         1180px;
  --maxw-narrow:  760px;

  /* Vertical gap between consecutive top-level sections. Edit this one value. */
  --section-gap:  60px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ────── Layout ────── */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}
.container.narrow {
  max-width: var(--maxw-narrow);
}

/* ────── Anonymity banner ────── */
.anon-banner {
  background: #fff7ed;
  border-bottom: 1px solid #fdba74;
  color: var(--warn);
  font-size: 0.875rem;
  text-align: center;
  padding: 10px 16px;
  letter-spacing: 0.01em;
}
.anon-banner .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--warn);
  vertical-align: middle;
}

/* ────── Hero ────── */
.hero {
  padding: 84px 0 72px;
  background:
    radial-gradient(1200px 600px at 50% -100px, #eef2ff 0%, transparent 60%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  border-bottom: 3px solid var(--line);
}
.hero .container { text-align: center; }

.eyebrow {
  display: inline-block;
  padding: 4px 12px;
  margin: 0 0 18px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

.title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 16px;
  color: var(--ink);
}

.subtitle {
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  color: var(--ink-soft);
  max-width: 680px;
  margin: 0 auto 22px;
}

.meta {
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0 0 6px;
}
.meta em { font-style: italic; color: var(--ink-soft); }
.meta-hero { margin-bottom: 28px; }

.affiliations {
  font-size: 0.9rem;
  color: var(--ink-mute);
  margin: 0 0 32px;
}

/* ────── Buttons ────── */
.hero-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  color: #ffffff;
  background: #5da9e9;
  border: 1px solid #5da9e9;
  transition: background 120ms ease, transform 120ms ease,
              box-shadow 120ms ease;
}
.btn:hover {
  background: #4a97da;
  border-color: #4a97da;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-secondary {
  color: #ffffff;
  background: #5da9e9;
  border-color: #5da9e9;
}
.btn-secondary:hover {
  background: #4a97da;
  border-color: #4a97da;
}
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* ────── Sections ────── */
.section { padding: 72px 0; }
#abstract { padding-bottom: 36px; }

/* Consecutive top-level sections all share --section-gap.
   "Inference-Time Policy Improvement" and "Policy Evaluation" are h2s inside
   #results rather than real <section>s; the "Visualization" title sits inside
   .section-header, so it is not matched by the direct-child selector below. */
#scripted-demos { padding-bottom: 0; }
#results { padding-top: var(--section-gap); }
#results > .container > h2.section-title { margin-top: var(--section-gap); }
/* margin (not padding) so it collapses with the preceding card's bottom margin,
   matching the h2 boundaries above. */
#live-demo { padding-top: 0; margin-top: var(--section-gap); }
#abstract .container.narrow {
  width: 45%;
  max-width: none;
}
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--line);
              border-bottom: 1px solid var(--line); }

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.section-desc {
  color: var(--ink-soft);
  margin: 0 0 28px;
}
.section-header { margin-bottom: 36px; }

.subsection-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 56px 0 6px;
  letter-spacing: -0.005em;
}
.subsection-title:first-of-type { margin-top: 8px; }
.subsection-desc {
  color: var(--ink-mute);
  margin: 0 0 22px;
  font-size: 0.95rem;
}

.lead {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink-soft);
}

/* ────── Method figure placeholder ────── */
.figure-placeholder { margin: 0; }
.figure-placeholder .figure-inner {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  border: 1.5px dashed #c8c8c4;
  background:
    repeating-linear-gradient(
      45deg,
      #f7f7f5 0 12px,
      #f0f0ec 12px 24px
    );
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mute);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.figure-placeholder figcaption {
  margin-top: 12px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-mute);
}
.placeholder-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ────── Video grid ────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
  margin: 0 0 8px;
}

.video-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, box-shadow 140ms ease,
              border-color 140ms ease;
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #d1d1cd;
}

.video-card-wide {
  grid-column: span 2;
}
@media (max-width: 720px) {
  .video-card-wide { grid-column: span 1; }
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, #1e2630 0%, #2a3340 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.video-frame::after {
  /* subtle grain overlay */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at 50% 50%,
      rgba(255,255,255,0.04) 0%,
      transparent 60%
    );
  pointer-events: none;
}
.video-frame .placeholder-label {
  color: rgba(255,255,255,0.85);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  z-index: 1;
}
.video-frame .play-icon {
  position: absolute;
  width: 52px;
  height: 52px;
  fill: rgba(255,255,255,0.18);
  transition: fill 160ms ease, transform 160ms ease;
}
.video-card:hover .video-frame .play-icon {
  fill: rgba(255,255,255,0.35);
  transform: scale(1.08);
}
.video-frame video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #000;
}

.video-card figcaption {
  padding: 14px 16px 16px;
  font-size: 0.93rem;
  color: var(--ink-soft);
  line-height: 1.5;
}
.video-card figcaption strong {
  color: var(--ink);
  font-weight: 600;
}

/* ────── Grouped comparison cards ────── */
.compare-card {
  background: #e8e8e5;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 18px;
  margin: 0 0 22px;
}

.compare-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.compare-header strong {
  grid-column: 2;
  justify-self: center;
  text-align: center;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}
.compare-header .replay-btn {
  grid-column: 3;
  justify-self: end;
}

.replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  transition: color 120ms ease;
}
.replay-btn:hover { color: #1452b3; }
.replay-btn svg {
  width: 0.95em;
  height: 0.95em;
  fill: currentColor;
}

.compare-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.compare-item {
  flex: 1 1 0;
  min-width: 150px;
  max-width: 280px;
  margin: 0;
  text-align: center;
}
.compare-item video {
  width: 100%;
  display: block;
  border-radius: 6px;
  background: #000;
}
.compare-item .video-frame {
  border-radius: 6px;
  aspect-ratio: 1 / 1;
}
.compare-caption {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}


.compare-tabs {
  /* Change this value to force every tab panel to the same height. */
  --compare-tab-panel-height: 360px;
  padding-top: 0;
  padding-bottom: 18px;
}

.compare-tab-list {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 3px;
  margin: -16px -19px 18px -18px;
  padding: 16px 19px 0 0;
  border-bottom: 1px solid #cfcfca;
  background: var(--bg);
  overflow: visible;
}

.compare-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 8px 16px 9px;
  border: 1px solid #d8d8d3;
  border-bottom-color: #cfcfca;
  border-radius: 8px 8px 0 0;
  background: #eeeeeb;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.compare-tab:hover {
  background: #e2e2de;
  color: var(--ink);
}

.compare-tab.is-active {
  z-index: 1;
  margin-bottom: -1px;
  border-color: #cfcfca;
  border-bottom-color: #e8e8e5;
  background: #e8e8e5;
  color: var(--ink);
}

.compare-tab-panel {
  display: none;
  height: var(--compare-tab-panel-height);
  overflow: hidden;
}

.compare-tab-panel.is-active {
  display: flex;
  flex-direction: column;
}

.compare-tab-panel-lift {
  padding: 0 38px 36px;
}

.compare-tab-panel-lift .compare-row {
  flex: 1;
  min-height: 0;
  align-items: center;
}

.compare-tab-panel-lift .compare-item {
  flex: 1 1 0;
  max-width: none;
}
.compare-tab-panel .compare-carousel,
.compare-tab-panel .compare-carousel-viewport,
.compare-tab-panel .compare-carousel-track,
.compare-tab-panel .compare-slide {
  height: 100%;
}

.compare-tab-panel .compare-carousel,
.compare-tab-panel .compare-slide {
  display: flex;
  flex-direction: column;
}

.compare-tab-panel .compare-slide .compare-row {
  flex: 1;
  align-items: center;
}

.policy-rollout-tabs {
  --policy-rollout-plot-height: 395px;
  --policy-rollout-plot-offset: 47px;
  padding-bottom: 0;
}

.policy-rollout-tabs .compare-tab-panel {
  height: auto;
  overflow-x: auto;
}

.policy-rollout-tabs .compare-tab-panel.is-active {
  display: block;
}

.policy-rollout-body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
}

.policy-rollout-figure {
  display: flex;
  align-items: flex-start;
  flex: 0 0 auto;
  max-width: 390px;
  margin: var(--policy-rollout-plot-offset) 0 0;
  line-height: 0;
}

.policy-rollout-figure img {
  width: auto;
  height: var(--policy-rollout-plot-height);
  max-width: 100%;
  display: block;
  object-fit: contain;
}

.policy-rollout-videos {
  flex: 0 1 auto;
}

.policy-rollout-videos .rollout-table {
  margin-top: 0;
}
.compare-carousel {
  overflow: hidden;
  padding-bottom: 0;
}

.compare-carousel-viewport {
  position: relative;
  width: 100%;
  padding-bottom: 13px;
  margin-bottom: 13px;
  overflow: hidden;
}

.compare-carousel-track {
  display: flex;
  align-items: stretch;
  transition: transform 240ms ease;
  will-change: transform;
}

.compare-slide {
  flex: 0 0 100%;
  min-width: 100%;
  padding: 0 38px;
}

.compare-slide:not(.is-active) {
  pointer-events: none;
}

.compare-carousel-controls {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.compare-carousel-arrow {
  position: absolute;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #d6d6d2;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
  transform: translateY(-50%);
  transition: color 120ms ease, transform 120ms ease, border-color 120ms ease;
}

.compare-carousel-arrow[data-carousel-prev] {
  left: 0;
}

.compare-carousel-arrow[data-carousel-next] {
  right: 0;
}

.compare-carousel-arrow:hover {
  color: var(--accent);
  border-color: #c7c7c2;
  transform: translateY(-50%) scale(1.06);
}

.compare-carousel-arrow svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.compare-carousel-dots {
  position: absolute;
  left: 50%;
  bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  pointer-events: auto;
  transform: translateX(-50%);
}

.compare-carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #a9aaa4;
  cursor: pointer;
  opacity: 0.7;
  transition: background 120ms ease, opacity 120ms ease, transform 120ms ease;
}

.compare-carousel-dot:hover,
.compare-carousel-dot.is-active {
  background: var(--accent);
  opacity: 1;
  transform: scale(1.35);
}

.compare-carousel-gpc-rank {
  padding-bottom: 12px;
}

.compare-carousel-gpc-rank .compare-carousel-viewport {
  padding-bottom: 24px;
  margin-bottom: 0;
}

.compare-carousel-gpc-rank .compare-carousel-dots {
  bottom: 6px;
}

@media (max-width: 640px) {
  .compare-slide,
  .compare-tab-panel-lift { padding-right: 28px; padding-left: 28px; }
  .compare-item { min-width: 130px; }
  .compare-carousel-arrow {
    width: 30px;
    height: 30px;
  }
}

/* ────── Rollout comparison table ────── */
.rollout-table {
  border-collapse: collapse;
  margin: 12px auto 0;
}
.rollout-table th,
.rollout-table td {
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}
.rollout-table thead th {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}
.rollout-table td video {
  /* ~16% of the 1180px content column, scaling down on narrower viewports */
  width: clamp(120px, 16vw, 189px);
  display: block;
  border-radius: 6px;
  background: #000;
}
.rollout-outcome {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.rollout-success { color: #1a7f37; }
.rollout-failure { color: #c0392b; }

/* ────── GPC-RANK: figure + stacked videos ────── */
.gpc-rank-row {
  display: flex;
  align-items: stretch;   /* both columns share the same height */
  gap: 18px;
  margin-top: 12px;
}
.gpc-rank-figure {
  flex: 1 1 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.gpc-rank-figure img {
  width: 60%;             /* scaled down from full column width */
  height: auto;           /* keep aspect ratio */
  max-height: 100%;
  object-fit: contain;
}
.gpc-rank-stack {
  flex: 0 0 100px;        /* fixed-ish width drives square video height (70% of 300px) */
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gpc-rank-stack video {
  width: 100%;
  display: block;
  border-radius: 6px;
  background: #000;
}
@media (max-width: 720px) {
  .gpc-rank-row { flex-direction: column; }
  .gpc-rank-stack { flex-basis: auto; }
}

/* ────── How-to section ────── */
.howto-list {
  padding-left: 22px;
  margin: 0 0 20px;
  color: var(--ink-soft);
}
.howto-list li { margin-bottom: 10px; }
.howto-list code,
.lead code,
.section-desc code,
p code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 6px;
  background: #ebebe8;
  border-radius: 4px;
  color: var(--ink);
}
.howto-list pre {
  margin: 8px 0 0;
  padding: 14px 16px;
  background: #1a1f26;
  color: #e6e7e9;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
}
.howto-list pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}
.note {
  font-size: 0.9rem;
  color: var(--ink-mute);
  border-left: 3px solid var(--line);
  padding: 4px 0 4px 14px;
  margin: 0;
}

/* ────── Footer ────── */
.footer {
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.85rem;
  color: var(--ink-mute);
  text-align: center;
}
.footer p { margin: 0; }

/* ────── Things to edit ────── */
@media (max-width: 640px) {
  .hero { padding: 64px 0 56px; }
  .section { padding: 56px 0; }
  #abstract .container.narrow { width: auto; }
  .video-grid { gap: 16px; }
}
