:root {
  --ink: #1d1f2b;
  --muted: #5d6072;
  --soft: #faf7f2;          /* warm ivory page */
  --paper: #ffffff;
  --tint: #f4f1fb;          /* faint indigo wash */
  --line: #ebe5da;
  --line-strong: #d6cdbf;
  --accent: #4b4fc4;        /* indigo */
  --accent-soft: #e8e8fb;
  --accent-2: #d9674a;      /* prismatic / rack (matches animations) */
  --green: #2f8f6b;         /* "best" markers */
  --shadow: 0 20px 50px rgba(29, 31, 43, 0.09);
  --radius: 12px;
  --maxw: 1120px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 70px; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 50% -140px, rgba(75, 79, 196, 0.13), transparent 70%),
    radial-gradient(700px 380px at 88% 60px, rgba(217, 103, 74, 0.08), transparent 70%),
    var(--soft);
  background-repeat: no-repeat;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16.5px;
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: "Space Grotesk", Inter, sans-serif; letter-spacing: -0.01em; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(250, 247, 242, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(214, 205, 191, 0.7);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 22px;
  display: flex; align-items: center; gap: 24px;
}
.brand {
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 18px;
  color: var(--ink); display: inline-flex; align-items: center; gap: 10px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--paper);
  border: 1px solid var(--line-strong); display: grid; place-items: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.topbar nav { display: flex; gap: 20px; margin-left: 8px; }
.topbar nav a { color: var(--muted); font-size: 15px; font-weight: 500; }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.venue-pill {
  margin-left: auto; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 14px;
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper);
  white-space: nowrap;
}

/* ------------------------------------------------------------ hero */
.hero { padding: 64px 0 28px; text-align: center; }
.hero h1 {
  font-size: clamp(30px, 4.6vw, 50px); line-height: 1.12; margin: 0 auto 18px; max-width: 900px;
  font-weight: 700;
}
.hero h1 .name { color: var(--accent); }
.authors { font-size: 18px; margin: 0 0 4px; }
.authors a { color: var(--ink); border-bottom: 1px solid var(--line-strong); }
.authors a:hover { text-decoration: none; border-color: var(--ink); }
.affil { color: var(--muted); font-size: 15px; margin: 0 0 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 28px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; border: 1px solid var(--ink);
}
.btn:hover { text-decoration: none; background: #34374a; }
.btn.disabled { background: var(--paper); color: var(--muted); border-color: var(--line-strong); cursor: default; }
.tldr {
  max-width: 780px; margin: 0 auto 30px; font-size: 18.5px; color: var(--ink); line-height: 1.6;
}
.tldr strong { color: var(--accent); }

.video-frame {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.video-frame video, .video-frame img { width: 100%; height: auto; }
.caption { color: var(--muted); font-size: 14.5px; margin: 12px auto 0; max-width: 860px; text-align: center; }
.caption strong { color: var(--ink); }

.callout-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 28px;
}
.callout {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; text-align: left;
}
.callout strong {
  display: block; font-family: "Space Grotesk", sans-serif; font-size: 30px; line-height: 1.1;
  color: var(--ink); margin-bottom: 4px;
}
.callout span { color: var(--muted); font-size: 14px; line-height: 1.45; display: block; }

/* ------------------------------------------------------------ sections */
.section { padding: 64px 0; }
.section + .section { border-top: 1px solid var(--line); }
.eyebrow {
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 6px;
}
.section-header { display: grid; grid-template-columns: 1fr 1.15fr; gap: 40px; align-items: end; margin-bottom: 34px; }
.section-header h2 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.15; margin: 0; }
.section-copy { margin: 0; color: var(--muted); }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 30px;
}
.abstract p { margin: 0 0 12px; text-align: justify; hyphens: auto; }
.abstract p:last-child { margin-bottom: 0; }

/* problem setup */
.lede { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; align-items: center; margin: 44px 0 20px; }
.lede h3 { font-size: 22px; margin: 0 0 8px; }
.lede p { margin: 0 0 12px; }
.slot-demo { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.slot-demo .row-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.slot-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; }
.slot-chip {
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 6px; text-align: center;
  background: var(--tint); font-size: 13px; line-height: 1.35;
}
.slot-chip .sym { display: block; font-size: 19px; margin-bottom: 2px; }
.slot-chip small { color: var(--muted); }
.slot-list { display: grid; gap: 6px; }
.slot-line {
  display: grid; grid-template-columns: 34px 1fr 90px; gap: 10px; align-items: center;
  font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
}
.slot-line.off { opacity: 0.38; border-style: dashed; }
.slot-line .conf { height: 7px; border-radius: 4px; background: var(--line); position: relative; overflow: hidden; }
.slot-line .conf i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.slot-line.off .conf i { background: #c0282d; }
.slot-line .tag { font-weight: 600; font-size: 13px; text-align: right; }
.tag.rev { color: var(--accent); }
.tag.pri { color: var(--accent-2); }

/* stage cards */
.stage-list { display: grid; gap: 26px; margin-top: 30px; }
.stage-card {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 0; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.stage-card:nth-child(even) { grid-template-columns: 1fr 1.35fr; }
.stage-card:nth-child(even) .stage-video { order: 2; border-left: 1px solid var(--line); border-right: 0; }
.stage-video { background: #fff; border-right: 1px solid var(--line); display: flex; align-items: center; }
.stage-video video { width: 100%; height: auto; }
.stage-body { padding: 24px 28px; align-self: center; }
.stage-kicker {
  display: flex; align-items: center; gap: 10px; font-family: "Space Grotesk", sans-serif;
  font-weight: 700; font-size: 19px; line-height: 1.3; margin-bottom: 10px;
}
.stage-kicker span {
  flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 14px;
}
.stage-body p { margin: 0 0 10px; font-size: 15.5px; }
.stage-body p:last-child { margin-bottom: 0; }
.pill {
  display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--muted); margin-right: 4px;
}

details.figure { margin-top: 30px; }
details.figure summary {
  cursor: pointer; font-weight: 600; color: var(--muted); list-style: none; display: inline-flex;
  align-items: center; gap: 8px;
}
details.figure summary::-webkit-details-marker { display: none; }
details.figure summary::before { content: "▸"; transition: transform .2s; }
details.figure[open] summary::before { transform: rotate(90deg); }
details.figure .video-frame { margin-top: 14px; padding: 14px; }

/* ------------------------------------------------------------ results */
.results-grid { display: grid; grid-template-columns: 1fr; gap: 26px; }
.table-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.table-card h3 { margin: 0 0 4px; font-size: 20px; }
.table-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.table-scroll { overflow-x: auto; }
table.res { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
table.res th, table.res td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.res th:first-child, table.res td:first-child { text-align: left; }
table.res thead th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
table.res tbody tr:hover { background: #fbf9f5; }
table.cap td, table.cap th { text-align: center; }
.yes { color: var(--green); font-weight: 700; }
.no { color: #b9c0c4; }
table.res tr.ours td { background: var(--accent-soft); font-weight: 600; }


/* ------------------------------------------------------------ bibtex + footer */
pre.bib {
  background: #1d1f2b; color: #e6e6f2; padding: 20px 22px; border-radius: var(--radius); overflow-x: auto;
  font-size: 13.5px; line-height: 1.55; position: relative; margin: 0;
}
.copy-btn {
  position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; font-family: Inter, sans-serif;
}
footer { padding: 36px 0 50px; color: var(--muted); font-size: 14px; text-align: center; border-top: 1px solid var(--line); }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .section-header, .lede { grid-template-columns: 1fr; gap: 16px; }
  .stage-card, .stage-card:nth-child(even) { grid-template-columns: 1fr; }
  .stage-card:nth-child(even) .stage-video { order: 0; border-left: 0; }
  .stage-video { border-right: 0; border-bottom: 1px solid var(--line); }
  .callout-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar nav { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 15.5px; }
  .container { padding: 0 16px; }
  .hero { padding-top: 40px; }
  .card { padding: 20px; }
  .stage-body { padding: 20px; }
  .slot-row { grid-template-columns: repeat(3, 1fr); }
  .callout strong { font-size: 25px; }
}

/* let grid children shrink below their content width (long formulas, tables) */
.section-header > *, .lede > *, .stage-card > *, .results-grid > *, .callout-grid > * { min-width: 0; }
.katex { white-space: normal; }

/* theme accents */
.btn { background: var(--ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.eyebrow { color: var(--accent); }
.callout strong { color: var(--accent); }
.video-frame { border-color: var(--line); }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------------------ result charts */
.chart-card { position: relative; }
.dp-legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 14px; margin: 4px 0 6px; }
.dp-legend span { display: inline-flex; align-items: center; gap: 7px; }
.dp-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dp-legend span:first-child { font-weight: 600; }
.dp-panels { display: flex; flex-direction: column; gap: 22px; margin-top: 8px; }
.dp-panels.wide { flex-direction: row; gap: 18px; }
.dp-panels svg { display: block; overflow: visible; font-family: Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.dp-panels svg rect[tabindex]:focus { outline: none; stroke: var(--accent); stroke-width: 1.5; }
.dp-tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--paper); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(29,31,43,.12); padding: 8px 11px; font-size: 13px; min-width: 190px;
}
.dp-tip-h { font-weight: 600; margin-bottom: 4px; }
.dp-tip-row { display: grid; grid-template-columns: 14px auto 1fr; gap: 8px; align-items: center; line-height: 1.6; }
.dp-tip-row i { width: 12px; height: 2px; border-radius: 1px; }
.dp-tip-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.dp-tip-row span { color: var(--muted); }
details.dp-table { margin-top: 14px; }
details.dp-table summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
details.dp-table .table-scroll { margin-top: 10px; }
details.dp-table td:nth-child(n+3), details.dp-table th:nth-child(n+3) { text-align: right; }
