/* Shared tokens and page layout. Component styles live in replay.css, compare.css, charts.css,
   browser.css and use only the tokens defined here. The look follows a plain academic page:
   white background, near-black text, hairline rules, colour only where it carries meaning. */
:root {
  --page: #FFFFFF;
  --ink: #1F1B24;
  --muted: #6B6675;
  --bg: #F7F6F9;          /* inset areas: code, notes, controls */
  --card: #FFFFFF;
  --line: #E4E1E8;
  --purple: #32006E;
  --purple-mid: #7A55B5;
  --purple-tint: #F1ECF7;
  --teal: #237F7B;
  --tmax: #218C8D;
  --prompt: #CDBCEA;
  --feedback: #7A55B5;
  --gpt: #237F7B;
  --opus: #C2692A;
  --qwen: #674294;
  --stage-R: #5B7FA6;
  --stage-B: #C2692A;
  --stage-W: #7A55B5;
  --stage-T: #2E9A5A;
  --ok: #2E8A52;
  --bad: #B8433A;
  --term-bg: #1D1B22;
  --term-text: #E4E1EA;
  --term-dim: #A09AAD;
  --radius: 6px;
  --shadow: none;
  --font: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --col: 1000px;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 16px/1.65 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--purple-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); font-size: .88em; }
code { background: var(--bg); border: 1px solid var(--line); padding: 0 .3em; border-radius: 3px; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--purple-mid); outline-offset: 2px; }

/* Title block */
.hero { max-width: var(--col); margin: 0 auto; padding: 56px 20px 8px; text-align: center; }
.title { margin: 0 auto 18px; max-width: 820px; font-size: clamp(26px, 4.2vw, 34px); line-height: 1.25; font-weight: 700; letter-spacing: -.005em; }
.title .name { color: var(--purple); }
.authors { margin: 0 auto 6px; max-width: 800px; font-size: 16px; line-height: 1.7; }
.authors a, .authors a:hover { color: inherit; text-decoration: none; }
.affils { margin: 0 auto; max-width: 860px; font-size: 14.5px; color: var(--muted); }
.affils span { display: inline-block; margin: 0 6px; white-space: nowrap; }
.footnote { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.logos { display: flex; justify-content: center; align-items: center; gap: 22px; flex-wrap: wrap; margin: 18px 0 4px; }
.logos img { height: 26px; width: auto; }
.buttons { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 20px 0 8px; }
.btn { display: inline-block; padding: 7px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; }
.btn:hover { background: #000; text-decoration: none; }
.btn.is-disabled { background: #9A95A2; cursor: default; }

/* Content column */
main { max-width: var(--col); margin: 0 auto; padding: 0 20px; }
.section { padding-top: 36px; }
.section > h2 { font-size: 21px; margin: 0 0 14px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.section > h3 { font-size: 17.5px; margin: 28px 0 6px; }
.section > p, .subsection > p { margin: 0 0 12px; }
.subsection + .subsection { margin-top: 40px; }
.chart-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; margin-bottom: 30px; }
.chart-pair > .chart-root { margin-bottom: 0; }
@media (max-width: 860px) { .chart-pair { grid-template-columns: minmax(0, 1fr); gap: 0; } .chart-pair > .chart-root { margin-bottom: 30px; } }
.loading { color: var(--muted); font-style: italic; }
.app-root, .chart-root { min-height: 80px; margin-top: 14px; }
.chart-root { margin-bottom: 30px; }

.figure { margin: 24px 0; }
.figure img { display: block; width: 100%; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; line-height: 1.55; }
.video { margin: 24px 0 0; }
.video video { width: 100%; border-radius: var(--radius); background: #000; }

.steps { margin: 8px 0 14px; padding-left: 1.3em; }
.steps li { margin-bottom: 6px; }

/* Stage chips, shared by replay, compare, and the method text */
.stage {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 3px;
  border-radius: 3px; color: #fff; font: 700 11px/1 var(--mono); vertical-align: 1px;
}
.s-R { background: var(--stage-R); } .s-B { background: var(--stage-B); }
.s-W { background: var(--stage-W); } .s-T { background: var(--stage-T); }
.s-none { background: #BDB8C6; }

/* Shared controls */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; padding: 5px 12px; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--ink); color: #fff; }
.select, select.select {
  appearance: none; border: 1px solid var(--line); border-radius: var(--radius); background-color: var(--card);
  padding: 5px 30px 5px 10px; font-size: 14px; color: var(--ink); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.chip { display: inline-block; padding: 0 6px; border-radius: 3px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Data note, citation, footer */
.data-note { font-size: 13px; color: var(--muted); margin-top: 14px; }
.bibtex { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.bibtex pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.55; }
.copy { position: absolute; top: 8px; right: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 4px; padding: 2px 10px; font-size: 13px; cursor: pointer; }
.copy:hover { border-color: var(--muted); }
.footer { max-width: var(--col); margin: 48px auto 0; padding: 20px 20px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; text-align: center; }

/* Rendered Markdown (js/md.js) */
.md { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.md h3, .md h4, .md h5, .md h6, .md h7, .md h8 { margin: 1em 0 .4em; font-size: 1.05em; }
.md p { margin: 0 0 .7em; }
.md ul, .md ol { margin: 0 0 .7em; padding-left: 1.4em; }
.md blockquote { margin: 0 0 .7em; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md pre { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.md pre code { background: none; border: 0; padding: 0; }

@media (max-width: 560px) {
  body { font-size: 15px; }
  .hero { padding-top: 32px; }
  .logos { gap: 16px; }
  .logos img { height: 22px; }
  .affils span { margin: 0 4px; }
}
