:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --fg: #1d2129;
  --fg-muted: #5b6270;
  --border: #e3e6eb;
  --accent: #5b3fa6;        /* refiner purple from the paper figures */
  --accent-soft: #efeaf9;
  --teal: #2f8f8a;
  --gain: #005aa0;
  --btn-bg: #1d2129;
  --btn-fg: #ffffff;
  --row-ours: #f1edf9;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a; --bg-soft: #1b1e24; --fg: #e7e9ee; --fg-muted: #a0a7b4;
    --border: #2c3038; --accent: #b39ef0; --accent-soft: #272238; --teal: #6cc7c1;
    --gain: #7ab8ff; --btn-bg: #e7e9ee; --btn-fg: #14161a; --row-ours: #262036;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --bg-soft: #1b1e24; --fg: #e7e9ee; --fg-muted: #a0a7b4;
  --border: #2c3038; --accent: #b39ef0; --accent-soft: #272238; --teal: #6cc7c1;
  --gain: #7ab8ff; --btn-bg: #e7e9ee; --btn-fg: #14161a; --row-ours: #262036;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 820px; }
section { padding: 48px 0; }
section.alt { background: var(--bg-soft); }
h1, h2, h3 { font-family: "Castoro", Georgia, serif; font-weight: 400; line-height: 1.25; }
h2 { font-size: 2rem; text-align: center; margin: 0 0 24px; }
h3 { font-size: 1.35rem; margin: 32px 0 10px; }
p { margin: 0 0 14px; }
.muted { color: var(--fg-muted); }
.center { text-align: center; }

/* Hero */
.hero { padding: 64px 0 28px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 8px; }
.hero h1 .name { color: var(--accent); }
.hero .subtitle { font-size: clamp(1.1rem, 2.6vw, 1.5rem); color: var(--fg-muted); margin: 0 0 22px; font-family: "Castoro", Georgia, serif; }
.authors { font-size: 1.1rem; margin-bottom: 4px; }
.authors span { margin: 0 8px; white-space: nowrap; }
.affil { color: var(--fg-muted); margin-bottom: 28px; }
.affil span { display: inline-block; margin: 0 8px; }
.affil .corr { font-size: .85rem; margin-top: 6px; }
.venue { font-weight: 600; margin: 8px 0 22px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px;
  background: var(--btn-bg); color: var(--btn-fg); border-radius: 999px; font-size: .95rem;
}
.btn:hover { text-decoration: none; opacity: .85; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn.disabled { opacity: .45; pointer-events: none; }

/* The `hidden` attribute must win over display:grid on tab panels */
[hidden] { display: none !important; }

/* Teaser: large train-setting video on the left, two Piper views stacked on the right.
   2fr/1fr keeps the left video's height equal to the two stacked 16:9 videos. */
.teaser-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.teaser-side { display: grid; grid-template-rows: 1fr 1fr; gap: 12px; }
.teaser-main, .teaser-cell { position: relative; min-height: 0; }
.teaser-main video { height: 100%; }
.teaser-cell video { height: 100%; }
.teaser-grid video, .video-card video { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 854/480; object-fit: cover; }
.vlabel {
  position: absolute; left: 10px; top: 10px; padding: 3px 10px; border-radius: 999px;
  background: rgba(0,0,0,.62); color: #fff; font-size: .8rem; pointer-events: none;
}
.vlabel.unseen { background: rgba(91,63,166,.88); }
.caption { font-size: .95rem; color: var(--fg-muted); margin-top: 12px; text-align: center; }
.caption b { color: var(--fg); }

figure { margin: 20px 0 28px; }
figure img { width: 100%; border-radius: 8px; background: #fff; }
figcaption { font-size: .93rem; color: var(--fg-muted); margin-top: 10px; }

/* Highlights */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 28px 0 8px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px; text-align: center; box-shadow: var(--shadow); }
.stat .num { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat .lbl { font-size: .9rem; color: var(--fg-muted); margin-top: 6px; }

/* Method cards */
.components { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0 24px; }
.comp { border: 1px solid var(--border); border-radius: 12px; padding: 18px; background: var(--bg); }
.comp .idx { display: inline-block; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); text-align: center; font-weight: 700; line-height: 28px; margin-bottom: 8px; }
.comp h4 { margin: 0 0 6px; font-size: 1.05rem; }
.comp p { font-size: .93rem; color: var(--fg-muted); margin: 0; }

/* Tabs + videos */
.tabs { display: flex; justify-content: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { border: 1px solid var(--border); background: var(--bg); color: var(--fg); padding: 8px 18px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .95rem; }
.tab[aria-selected="true"] { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.video-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.video-card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: .85rem; }
.tag { padding: 2px 10px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); }
.tag.unseen { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.note { font-size: .9rem; color: var(--fg-muted); text-align: center; margin-top: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 12px 0 8px; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--bg-soft); font-weight: 600; }
tr.ours td { background: var(--row-ours); font-weight: 600; }
tr.sep td { border-top: 2px solid var(--border); }
tr:last-child td { border-bottom: none; }
td b { color: var(--accent); }
.gain { color: var(--gain); font-size: .8rem; margin-left: 4px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }

/* BibTeX */
pre { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow-x: auto; font-size: .85rem; line-height: 1.5; position: relative; }
.copy { position: absolute; top: 10px; right: 10px; font: inherit; font-size: .8rem; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer; }

footer { padding: 32px 0 48px; text-align: center; font-size: .85rem; color: var(--fg-muted); }

@media (max-width: 760px) {
  body { font-size: 16px; }
  section { padding: 36px 0; }
  .teaser-grid, .video-grid, .two-col, .components { grid-template-columns: 1fr; }
  .teaser-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr; }
  h2 { font-size: 1.6rem; }
}
