:root {
  --bg: #0b0c0e;
  --surface: #141619;
  --surface-2: #1c1f24;
  --line: #2a2e35;
  --text: #e8e9ec;
  --muted: #9aa0a8;
  --faint: #6b7280;
  --accent: #7dd3fc;
  --accent-dim: #38598a;
  --measured: #e8e9ec;
  --estimate: #f08a5d;      /* PIDU orange, as in the paper figures */
  --good: #5ccf9a;
  --bad: #f07171;
  --paper: #ffffff;
  --radius: 10px;
  --measure: 46rem;
  --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: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--surface-2); color: var(--text); padding: .5rem 1rem; z-index: 10;
}
.skip-link:focus { left: 1rem; top: 1rem; }

.wrap { width: 100%; max-width: 68rem; margin: 0 auto; padding: 0 1.5rem; }
.wrap.narrow { max-width: calc(var(--measure) + 3rem); }

section { padding: 3.5rem 0; }
section + section { border-top: 1px solid var(--line); }

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.6rem; margin: 0 0 1.5rem; letter-spacing: -0.01em; text-align: center; }
h3 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3.sub { text-align: center; font-size: 1.3rem; margin: 3rem 0 1rem; }
p { margin: 0 0 1.1rem; }
#abstract p { text-align: justify; hyphens: auto; color: #d4d6db; }

.lead { max-width: var(--measure); margin: -0.9rem auto 1.8rem; color: var(--muted); text-align: center; }
.body-text { max-width: var(--measure); margin: 0 auto 1.6rem; color: #d4d6db; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; }
sub, sup { line-height: 0; }

/* ── Hero ─────────────────────────────────────────── */
.hero { padding: 5rem 0 3.5rem; text-align: center; }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); margin: 0 0 .6rem; letter-spacing: -0.02em; }
.hero .tagline {
  font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: var(--muted);
  max-width: 40rem; margin: 0 auto 2.2rem; line-height: 1.45;
}
.venue {
  display: inline-block; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); border: 1px solid var(--line); border-radius: 999px;
  padding: .25rem .85rem; margin-bottom: 1.5rem;
}
.authors { font-size: 1.02rem; margin: 0 0 .5rem; }
.authors a { color: var(--text); }
.authors a:hover { color: var(--accent); }
.authors sup, .affiliations sup { color: var(--accent); font-size: .72em; padding-left: .1em; }
.affiliations { font-size: .92rem; color: var(--muted); margin: 0 0 2rem; }

.links { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: .5rem 1.15rem; font-size: .95rem; font-weight: 500;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.btn:hover { background: #23272e; border-color: var(--accent-dim); text-decoration: none; transform: translateY(-1px); }
.btn svg { width: 1em; height: 1em; fill: currentColor; opacity: .85; }
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; cursor: default; }
.btn[aria-disabled="true"]::after {
  content: "soon"; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--faint);
}

/* ── Figures ──────────────────────────────────────── */
figure { margin: 0 0 1.5rem; }
figure img { display: block; width: 100%; height: auto; }
figcaption { font-size: .88rem; color: var(--muted); line-height: 1.5; margin: .75rem auto 0; max-width: var(--measure); }
figcaption b { color: var(--text); font-weight: 600; }

.paper-frame {
  position: relative; background: var(--paper); border-radius: var(--radius);
  padding: clamp(.5rem, 2vw, 1.25rem); overflow: hidden;
}
.method .paper-frame { max-width: 46rem; margin: 0 auto; }

.loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); background: rgba(11, 12, 14, .35); pointer-events: none;
  opacity: 0; transition: opacity .2s ease;
}
.is-loading > .loading, .is-loading .loading { opacity: 1; }

/* ── Fit pool ─────────────────────────────────────── */
.fits { max-width: 54rem; margin: 0 auto; }
.fits-frame { aspect-ratio: 920 / 710; padding: .4rem; }
.fits-frame img { width: 100%; height: 100%; object-fit: contain; }
.fits-frame .loading { background: rgba(255, 255, 255, .6); color: #52514e; }

/* ── Controls ─────────────────────────────────────── */
.viewer-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center;
  gap: 1rem 1.75rem; margin: 0 0 1.1rem;
}
.ctl { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.ctl-grow { flex: 1 1 14rem; max-width: 22rem; }
.ctl-label {
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .85rem;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent-dim); }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.chip svg { width: .95em; height: .95em; fill: currentColor; }
.chip:focus-visible, .play:focus-visible, input[type="range"]:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.slider-row { display: flex; align-items: center; gap: .7rem; }
.slider-row output { font-family: var(--font-mono); font-size: .82rem; color: var(--text); min-width: 3.6rem; text-align: right; }
input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); height: 1.4rem; margin: 0; background: transparent; }

.play {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.play svg { width: .75rem; height: .75rem; fill: currentColor; }
.play .icon-pause, .play.is-playing .icon-play { display: none; }
.play.is-playing .icon-pause { display: block; }

/* ── Highlights ───────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
}
.stat b {
  display: block; font-family: var(--font-serif); font-size: 2rem; font-weight: 600;
  color: var(--accent); line-height: 1.1; margin-bottom: .45rem; font-variant-numeric: tabular-nums;
}
.stat span { font-size: .9rem; color: var(--muted); line-height: 1.45; display: block; }

/* ── Method ───────────────────────────────────────── */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin-top: 2rem; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.25rem; }
.step p { font-size: .93rem; color: var(--muted); margin: 0; }
.step b, .step i { color: var(--text); }
.step-n {
  display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem;
  border-radius: 50%; border: 1px solid var(--accent-dim); color: var(--accent);
  font-family: var(--font-mono); font-size: .8rem; margin-bottom: .6rem;
}

/* ── Explorer ─────────────────────────────────────── */
.section-eyebrow {
  display: block; text-align: center; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .4rem;
}
.explorer-stage {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
}
.explorer-plots { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.plot { position: relative; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot .axis line, .plot .axis path { stroke: var(--line); }
.plot .grid line { stroke: #1f2329; }
.plot text { fill: var(--faint); font-family: var(--font-sans); font-size: 11px; }
.plot .title { fill: var(--muted); font-size: 12px; font-weight: 500; }
.plot .measured { fill: none; stroke: var(--measured); stroke-width: 1.2; opacity: .85; }
.plot .estimate { fill: none; stroke: var(--estimate); stroke-width: 2; transition: d .35s ease; }
.legend { display: flex; gap: 1.2rem; font-size: .8rem; color: var(--muted); justify-content: flex-end; }
.legend i { display: inline-block; width: 1.1rem; height: 2px; vertical-align: middle; margin-right: .4rem; }

.explorer-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.mape b { display: block; font-family: var(--font-serif); font-size: 1.8rem; color: var(--text); font-variant-numeric: tabular-nums; }
.params { width: 100%; border-collapse: collapse; font-size: .8rem; font-variant-numeric: tabular-nums; }
.params th {
  text-align: right; font-weight: 500; color: var(--faint); font-size: .7rem; letter-spacing: .05em;
  text-transform: uppercase; padding: 0 0 .4rem; border-bottom: 1px solid var(--line);
}
.params th:first-child, .params td:first-child { text-align: left; }
.params td { text-align: right; padding: .28rem 0 .28rem .5rem; border-bottom: 1px solid #1f2329; font-family: var(--font-mono); font-size: .76rem; color: var(--muted); }
.params td:first-child { font-family: var(--font-sans); color: var(--text); padding-left: 0; }
.params td.err { color: var(--good); }
.params td.err.mid { color: #e8c35c; }
.params td.err.high { color: var(--bad); }

/* ── BibTeX & footer ──────────────────────────────── */
.bibtex {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; overflow-x: auto; font-family: var(--font-mono); font-size: .83rem;
  line-height: 1.6; color: var(--muted); margin: 0 auto; max-width: 52rem; text-align: left;
}
.bibtex code { white-space: pre; }
.copy-btn {
  float: right; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: .25rem .7rem; font-size: .78rem; font-family: var(--font-sans); cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent-dim); }

footer { border-top: 1px solid var(--line); padding: 2.5rem 0 3rem; font-size: .85rem; color: var(--faint); text-align: center; }
footer p { margin: 0 0 .5rem; }

/* ── Small screens ────────────────────────────────── */
@media (max-width: 820px) {
  .explorer-stage { grid-template-columns: minmax(0, 1fr); }
  .ctl-grow { max-width: none; flex-basis: 100%; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 1rem; }
  section { padding: 2.5rem 0; }
  .hero { padding: 3.5rem 0 2.5rem; }
  #abstract p { text-align: left; }
  .stat b { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .plot .estimate { transition: none; }
}

.live { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem 1rem; margin-top: 1.5rem; }
.live p { margin: 0; color: var(--muted); font-size: .92rem; }
