:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666;
  --accent: #2b5fd9;
  --accent-soft: #e8efff;
  --border: #e3e3e8;
  --card-bg: #fafafa;
  --chip-bg: #eef2f7;
  --chip-fg: #355;
  --ours-bg: #fff4e0;
  --ours-fg: #8a4b00;
  --max-w: 1152px;
  --text-w: 900px;
}

* { box-sizing: border-box; }

/* NOTE: shell-level rules (html/body, global <a>, .hero, .badge, .tldr,
   section.section) are intentionally omitted here — the Bulma/VidToMe layer
   owns the page chrome. This file only carries the FlowR2A gallery, figure,
   sampling, reward and bibtex component styles. */

/* ---- Hero band spacing (mirror VidToMe's tight rhythm) ---- */
/* Keep the teaser tucked close under the link buttons instead of a full
   hero-body gap. */
.title-hero .hero-body { padding-bottom: 1.5rem; }

/* ---- TL;DR card (reused for the abstract callout) ---- */
.tldr-card {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 18px 22px;
  font-size: 16px;
  line-height: 1.6;
  text-align: left;
}
.tldr-card strong { color: var(--accent); }

p.section-desc {
  color: var(--muted);
  max-width: var(--text-w);
  margin: 6px auto 6px;
  text-align: left;
}

/* ---- NAVSIM benchmark table figure ---- */
.navsim-fig {
  max-width: 760px;
  margin: 10px auto 0;
}
.navsim-fig img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

/* ---- Highlights list (key points before Framework) ---- */
.highlight-list {
  list-style: none;
  max-width: 860px;
  margin: 16px auto 4px;
  padding: 0;
}
.highlight-list li {
  position: relative;
  padding: 12px 0 12px 30px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.highlight-list li:last-child { border-bottom: none; }
.highlight-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 21px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}
.highlight-list li strong {
  color: var(--fg);
  font-weight: 600;
}
.highlight-list li em {
  font-style: italic;
}

.result-highlights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  max-width: 1240px;
  margin-top: 22px;
  margin-right: auto;
  margin-bottom: 30px;
  margin-left: auto;
}
.result-highlight {
  background: rgba(255,255,255,0.86);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 16px 15px;
  box-shadow: 0 12px 28px rgba(22, 34, 55, 0.06);
}
.result-highlight strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  line-height: 1.25;
  color: var(--fg);
}
.result-highlight p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.result-kicker {
  display: inline-flex;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
@media (max-width: 980px) {
  .result-highlights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 620px) {
  .result-highlights {
    grid-template-columns: 1fr;
  }
}

/* ---- Teaser video ---- */
.teaser-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 0 0;
}
.teaser-wrap video, .teaser-wrap img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #000;
}
.teaser-caption {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
}
.video-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #2b5fd9 0%, #1a3a8a 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}

/* ---- Sticky nav ---- */
nav.sticky-nav {
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  padding: 10px 24px;
}
nav.sticky-nav .inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 14px;
  justify-content: center;
}
nav.sticky-nav a {
  color: var(--fg);
  padding: 4px 10px;
  border-radius: 6px;
}
nav.sticky-nav a:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

main { display: block; }

.pdms-red   { color: #d83a3a; font-weight: 600; }
.pdms-green { color: #1ea75c; font-weight: 600; }

/* ---- Qualitative gallery (carried over from supplementary) ---- */
section.gallery {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 8px 24px 16px;
}
/* When nested inside #results, the parent <section.section> already provides
   horizontal padding — drop the gallery's own side padding to avoid doubling. */
#results > section.gallery {
  padding-left: 0;
  padding-right: 0;
  max-width: none;
}
/* Tier-2 sub-headings inside #results (e.g. Proposal quality, Qualitative comparison) */
.gallery-title.results-subhead {
  max-width: var(--text-w);
  margin: 36px auto 6px;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  color: var(--fg);
}
/* Tier-3 sub-sub-headings inside a gallery (e.g. Video comparisons, Per-frame comparisons) */
section.gallery > h3.gallery-title {
  max-width: var(--text-w);
  margin: 20px auto 8px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  color: var(--accent);
  padding-bottom: 0;
}
section.subsection {
  margin: 28px 0;
}
/* Tier-4 sub-sub-sub-headings (Forward scenes, Turning scenes) */
section.subsection > h3 {
  max-width: var(--text-w);
  margin: 24px auto 14px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}
.video-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.video-card img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  background: #000;
}
.combined-video-card video {
  width: 100%;
  height: auto;
  border-radius: 0;
  display: block;
  background: #fff;
}
.combined-video-card {
  --combined-row-h: 320;
  --combined-row-gap: 12;
  display: grid;
  grid-template-columns: minmax(126px, 0.12fr) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}
.combined-video-labels {
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 0.912%;
}
.combined-video-label {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  justify-self: stretch;
  min-height: 0;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  background: #f6f7f9;
  border-radius: 4px;
}
.combined-video-label.ours {
  background: var(--ours-bg);
  color: var(--ours-fg);
}

.frame-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 18px;
}

/* One shared column header per subsection, replacing per-table <thead> */
.compare-header {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 6px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  position: sticky;
  top: 48px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.compare-header > div { padding: 4px 0; }
.compare-header > div.ours {
  background: var(--ours-bg);
  color: var(--ours-fg);
  border-radius: 4px;
}

.frame-compare-header {
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  margin: 6px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  position: sticky;
  top: 48px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.frame-compare-header > div { padding: 4px 0; }

.compare-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 6px;
  table-layout: fixed;
}
.compare-table th, .compare-table td {
  padding: 0;
  vertical-align: middle;
  text-align: center;
}
.media-compare-table {
  table-layout: fixed;
}
.media-compare-table tr {
  display: grid;
  grid-template-columns: minmax(118px, 0.7fr) minmax(110px, 1fr) minmax(0, 5.3fr);
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.media-compare-table colgroup,
.media-compare-table thead { display: none; }
.media-compare-table th[scope="row"] {
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: #f6f7f9;
  border-radius: 4px;
}
.media-compare-table tr.ours th[scope="row"] {
  background: var(--ours-bg);
  color: var(--ours-fg);
}
.media-compare-table td {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.compare-table thead th {
  font-size: 13px;
  font-weight: 600;
  padding-bottom: 4px;
  color: var(--muted);
}
.compare-table thead th.ours {
  background: var(--ours-bg);
  color: var(--ours-fg);
  border-radius: 4px;
  padding: 4px 0;
}
.compare-table td img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  cursor: zoom-in;
  background: transparent;
}
.compare-table.media-compare-table td img,
.compare-table.media-compare-table td video {
  height: 168px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
.compare-table.media-compare-table td video {
  display: block;
  border-radius: 4px;
  background: transparent;
}
.compare-table td.ours img { outline: 2px solid var(--accent); outline-offset: 0; }
.compare-table td.ours video { outline: 2px solid var(--accent); outline-offset: 0; }
.compare-table.media-compare-table td.ours img,
.compare-table.media-compare-table td.ours video {
  object-fit: cover;
}

.frame-panel { display: none; }
.frame-panel.active { display: block; }

@media (max-width: 760px) {
  .frame-compare-header {
    display: none;
  }
  .media-compare-table,
  .media-compare-table tbody,
  .media-compare-table tr,
  .media-compare-table th,
  .media-compare-table td {
    display: block;
    width: 100%;
  }
  .media-compare-table tr {
    display: block;
  }
  .media-compare-table tr {
    margin-bottom: 14px;
  }
  .media-compare-table th[scope="row"] {
    width: 100%;
    margin-bottom: 6px;
  }
  .media-compare-table td {
    margin-bottom: 6px;
  }
  .media-compare-table td img,
  .media-compare-table td video {
    height: auto;
  }
}

/* ---- Carousel (qualitative gallery) ---- */
.carousel {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 12px;
  margin: 12px 0 20px;
}
.carousel-viewport {
  min-width: 0;
}
.carousel-track > .video-card,
.carousel-track > .frame-card,
.carousel-track > .reward-scene-card { display: none; margin: 0; }
.carousel-track > .video-card.active,
.carousel-track > .frame-card.active,
.carousel-track > .reward-scene-card.active { display: block; }
.carousel-track > .combined-video-card.active { display: grid; }
.carousel-counter {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  margin-top: 8px;
}
.carousel-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(22, 34, 55, 0.10);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
              box-shadow 0.15s ease, transform 0.1s ease;
}
.carousel-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(43, 95, 217, 0.28);
}
.carousel-btn:active { transform: scale(0.94); }
.carousel-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.carousel-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
  background: #fff;
  color: var(--fg);
  border-color: var(--border);
}

.tag {
  display: inline-block;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  display: block;
}
.lightbox .lb-caption {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  background: rgba(0,0,0,0.5);
  padding: 4px 10px;
  border-radius: 4px;
}

details.more { margin: 16px 0 0; }
details.more > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  border-radius: 6px;
  user-select: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+"; font-size: 18px; line-height: 1; }
details.more[open] > summary::before { content: "−"; }
details.more > summary:hover { background: #d8e3ff; }
details.more > .more-list { margin-top: 16px; }

/* ---- Training reward visualization ---- */
.reward-gallery {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
.reward-header {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 6px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  position: sticky;
  top: 48px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.reward-header > div {
  padding: 4px 0;
}
.reward-scene-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 18px;
}
.reward-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.reward-grid img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  background: #fff;
  cursor: zoom-in;
}
@media (max-width: 900px) {
  .reward-header,
  .reward-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .reward-header {
    display: none;
  }
}

/* ---- Framework section ---- */
.framework-fig {
  max-width: var(--text-w);
  margin: 8px auto 24px;
}
.framework-fig img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--border);
}
.framework-fig figcaption {
  margin-top: 10px;
  color: var(--fg);
  font-size: 16px;
  line-height: 1.6;
  max-width: var(--text-w);
  margin-left: auto;
  margin-right: auto;
}
.framework-fig figcaption strong { color: var(--accent); }

/* ---- Additional experiments grid ---- */
.exp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin: 8px 0;
}
.exp-grid-2col {
  grid-template-columns: 4fr 7fr;
  align-items: stretch;
}
.exp-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.exp-card.exp-full {
  max-width: 900px;
  margin: 8px auto 24px;
  /* Results figures sit on the section background — no card chrome. */
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.exp-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--accent);
}
.exp-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  background: #fff;
}
.exp-card p {
  color: var(--muted);
  font-size: 14px;
  margin: 8px 0 0;
  text-align: center;
}
@media (max-width: 800px) {
  .exp-grid { grid-template-columns: 1fr; }
}

/* ---- Interactive sampling space ---- */
.sampling-interactive {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
.sampling-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 16px;
}
@media (max-width: 700px) {
  .sampling-controls { grid-template-columns: 1fr; }
}
.slider-row label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--fg);
}
.slider-row label .val {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 600;
  color: var(--accent);
  margin-left: 6px;
}
.slider-row input[type=range] {
  width: 100%;
  accent-color: var(--accent);
}
.slider-row .ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.sampling-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}
.sampling-stage img {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}
.sampling-hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}

/* ---- BibTeX ---- */
.bibtex-wrap {
  position: relative;
  max-width: var(--text-w);
  margin: 0 auto;
  background: #0e1116;
  color: #d6deeb;
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}
.bibtex-wrap pre { margin: 0; }
.bibtex-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}
.bibtex-copy:hover { background: rgba(255,255,255,0.2); }
.bibtex-copy.copied { background: #1ea75c; border-color: #1ea75c; }

/* ================================================================
   Bulma bridge — page-level layout for the ported FlowR2A gallery.
   The shell (hero, sections, abstract, bibtex container) is Bulma;
   these rules only position the gallery blocks inside Bulma sections.
   ================================================================ */
/* Wide centered column for the media-heavy results gallery. */
.results-body {
  max-width: 1320px;
  margin: 0 auto;
}
/* Galleries inside a results-body wrapper fill the column width. */
.results-body section.gallery {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
/* Constrain the Framework figures to a comfortable reading width. */
.framework-body { max-width: var(--text-w); margin: 0 auto; }
/* Bulma's <strong>/<em> inherit fine; keep the bibtex block left-aligned. */
.bibtex-wrap { text-align: left; }
/* Bulma styles bare <pre> with a light background + padding; the bibtex code
   sits inside the dark .bibtex-wrap, so neutralise Bulma's <pre> chrome. */
.bibtex-wrap pre {
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
}
/* Sticky compare/reward headers: no sticky nav in this layout, pin to top. */
.compare-header, .frame-compare-header, .reward-header { top: 0; }

/* The first per-frame subsection ("Forward scenes") should tuck under the
   section title with the same rhythm as a title -> desc line, not a big gap. */
.results-body section.gallery#frames { padding-top: 0; }
.results-body section.gallery#frames > section.subsection:first-of-type { margin-top: 0; }
.results-body section.gallery#frames > section.subsection:first-of-type > h3 { margin-top: 6px; }

/* ---- Footer ---- */
footer.page-footer {
  max-width: var(--max-w);
  margin: 56px auto 24px;
  padding: 20px 24px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  text-align: center;
}
footer.page-footer a { color: var(--muted); }
