:root {
  --bg: #f8f9fc;
  --card: #ffffff;
  --line: rgba(15, 23, 42, 0.09);
  --text: #0f172a;
  --muted: #475569;
  --faint: #8a94a6;
  --ppg: #e0573e;
  --ecg: #15896a;
  --flow: #6d4fb0;
  --blue: #2f6db0;
  --paper-ppg: #1f77b4;
  --paper-ecg: #111111;
  --paper-base: #4a5c7d;
  --paper-ours: #d62728;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.06);
  --container: 1120px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ecg); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: min(var(--container), 100% - 32px);
  margin-inline: auto;
}

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.015em; }
h2 { font-size: clamp(26px, 3.2vw, 36px); font-weight: 700; }
h3 { font-size: 18px; font-weight: 650; }
p { margin: 0; }

sup { font-size: 0.68em; line-height: 0; vertical-align: 0.5em; color: var(--muted); }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(248, 249, 252, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 800; letter-spacing: 0.02em; font-size: 17px;
}
.wordmark:hover { text-decoration: none; }
.wordmark-pulse {
  width: 10px; height: 10px; border-radius: 50%; background: var(--ecg);
  box-shadow: 0 0 0 0 rgba(21, 137, 106, 0.5);
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(21, 137, 106, 0.45); }
  100% { box-shadow: 0 0 0 10px rgba(21, 137, 106, 0); }
}
.nav-links { display: flex; gap: 22px; margin-left: 8px; }
.nav-links a { color: var(--muted); font-weight: 500; font-size: 14px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav .btn-small { margin-left: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px; line-height: 1;
  border: 1px solid var(--line); color: var(--text);
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.btn:hover { text-decoration: none; background: #f1f3f8; border-color: rgba(15, 23, 42, 0.16); transform: translateY(-1px); }
.btn-primary { background: var(--ecg); border-color: var(--ecg); color: #ffffff; }
.btn-primary:hover { background: #11745a; border-color: #11745a; }
.btn-small { padding: 8px 14px; font-size: 13px; }
.btn.is-disabled { opacity: 0.6; cursor: not-allowed; }
.btn.is-disabled:hover { transform: none; background: #ffffff; border-color: var(--line); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding: 72px 0 40px;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(224, 87, 62, 0.13), transparent 60%),
    radial-gradient(900px 480px at 88% 0%, rgba(21, 137, 106, 0.13), transparent 60%),
    radial-gradient(700px 400px at 50% 65%, rgba(109, 79, 176, 0.09), transparent 60%);
}
.hero-text { max-width: 880px; }
.badge {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ecg); background: rgba(21, 137, 106, 0.10); border: 1px solid rgba(21, 137, 106, 0.28);
}
.title {
  margin-top: 18px;
  font-size: clamp(56px, 9vw, 104px);
  font-weight: 800; letter-spacing: -0.04em; line-height: 0.95;
  background: linear-gradient(92deg, var(--ppg) 0%, var(--flow) 50%, var(--ecg) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline {
  margin-top: 14px;
  font-size: clamp(18px, 2.4vw, 26px); font-weight: 500; line-height: 1.3;
  color: #1e293b; letter-spacing: -0.01em; max-width: 820px;
}
.authors { margin-top: 22px; font-size: 15px; color: #334155; max-width: 900px; }
.affils { margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }

.hero-demo { margin-top: 44px; }
.hero-canvas {
  display: block; width: 100%; height: 330px;
  border-radius: var(--radius);
}
.demo-caption { margin-top: 10px; font-size: 13px; color: var(--faint); max-width: 820px; }
@media (max-width: 720px) {
  .hero { padding-top: 48px; }
  .hero-canvas { height: 520px; }
}

/* ---------- sections ---------- */
.section { padding: 84px 0; }
.section-tight { padding: 28px 0 8px; }
.section-head { max-width: 780px; margin-bottom: 36px; }
.eyebrow {
  display: block; margin-bottom: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--flow);
}
.lead { margin-top: 14px; color: var(--muted); font-size: 17px; }

.why-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 28px 0;
}
.why-item { padding: 0 8px; }
.why-k { display: block; font-family: var(--mono); font-size: 13px; color: var(--ecg); margin-bottom: 8px; letter-spacing: 0.04em; }
.why-item p { color: var(--muted); font-size: 15px; }
@media (max-width: 720px) { .why-grid { grid-template-columns: 1fr; gap: 20px; } }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.paper-card {
  background: #ffffff; color: #1e293b;
  border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.figure-card { margin: 0; }
.figure-card img { display: block; width: 100%; height: auto; border-radius: 8px; }

.method-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px;
}
.method-grid .card p { margin-top: 10px; color: var(--muted); font-size: 15px; }
.method-grid .card h3 { margin-top: 12px; }
@media (max-width: 900px) { .method-grid { grid-template-columns: 1fr; } }

.tag {
  display: inline-block; padding: 3px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
}
.tag-blue { color: var(--blue); background: #e8f0f8; }
.tag-green { color: var(--ecg); background: #e6f4ee; }
.tag-purple { color: var(--flow); background: #efe9f7; }

.sim-card { margin-top: 20px; padding: 24px 24px 18px; }
.sim-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 14px; }
.sim-head .eyebrow { margin-bottom: 6px; }
.sim-note { color: var(--muted); font-size: 14px; max-width: 460px; text-align: right; }
.sim-canvas { display: block; width: 100%; height: 250px; border-radius: 12px; }
@media (max-width: 720px) {
  .sim-head { flex-direction: column; align-items: flex-start; }
  .sim-note { text-align: left; }
  .sim-canvas { height: 350px; }
}

/* ---------- case studies ---------- */
.method-bar {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: #ffffff; border: 1px solid var(--line); border-radius: 999px; margin-bottom: 22px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.method-bar button {
  appearance: none; border: 0; cursor: pointer;
  padding: 9px 16px; border-radius: 999px;
  background: transparent; color: var(--muted);
  font: 600 14px var(--font);
  transition: background 160ms ease, color 160ms ease;
}
.method-bar button:hover { color: var(--text); }
.method-bar button.is-active { background: #eef1f6; color: var(--text); }
.method-bar button.is-ours.is-active { background: var(--paper-ours); color: #fff; }
.method-bar button:focus-visible { outline: 2px solid var(--ecg); outline-offset: 2px; }

.cases-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1000px) { .cases-grid { grid-template-columns: 1fr; } }
.case-card { padding: 16px 16px 14px; }
.case-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.case-head h3 { font-size: 17px; color: #0f172a; }
.case-meta { font-size: 13px; color: #64748b; font-weight: 500; }
.case-canvas { display: block; width: 100%; height: 236px; border-radius: 8px; }
.case-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.legend { font-size: 12px; color: #475569; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-left: 6px; }
.sw:first-child { margin-left: 0; }
.sw-ppg { background: var(--paper-ppg); }
.sw-ecg { background: var(--paper-ecg); }
.sw-gen { background: var(--paper-ours); }
.case-card.is-baseline .sw-gen { background: var(--paper-base); }
.chip {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgba(214, 39, 40, 0.10); color: var(--paper-ours); white-space: nowrap;
}
.chip em { font-style: italic; }
.case-card.is-baseline .chip { background: rgba(74, 92, 125, 0.12); color: var(--paper-base); }

.footnote { margin-top: 22px; font-size: 13.5px; color: var(--muted); max-width: 900px; }

/* ---------- results ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 1000px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.stat-k { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat-v { font-family: var(--mono); font-size: 30px; font-weight: 500; color: var(--ecg); letter-spacing: -0.02em; line-height: 1.1; }
.stat-v small { font-size: 13px; color: var(--muted); margin-left: 2px; font-family: var(--font); }
.stat-s { font-size: 12.5px; color: var(--faint); }

.table-wrap { margin-top: 24px; overflow-x: auto; -webkit-overflow-scrolling: touch; background: #ffffff; border: 1px solid var(--line); border-radius: 14px; }
.results-table {
  width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px;
  font-variant-numeric: tabular-nums;
}
.results-table th, .results-table td { padding: 11px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.results-table tbody tr:last-child td { border-bottom: 0; }
.results-table th { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); background: #f3f5f9; }
.results-table th:first-child, .results-table td:first-child { text-align: left; font-weight: 600; position: sticky; left: 0; background: #ffffff; }
.results-table th:first-child { background: #f3f5f9; }
.results-table td { color: #1e293b; font-family: var(--mono); font-size: 13.5px; }
.results-table td:first-child { font-family: var(--font); color: var(--text); }
.results-table tr.is-ours td { background: #e9f5f0; color: var(--text); font-weight: 600; }
.results-table tr.is-ours td:first-child { color: var(--ecg); background: #e9f5f0; }
.results-table tr.is-ablation td { color: var(--muted); }
.results-table tr.is-ablation td:first-child { color: var(--muted); font-weight: 500; }
.table-note { margin: 0; padding: 14px 14px 16px; font-size: 13.5px; color: var(--muted); max-width: 900px; background: #ffffff; position: sticky; left: 0; }

/* ---------- bibtex ---------- */
.bib-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: start; }
.bib-grid > * { min-width: 0; }
@media (max-width: 900px) { .bib-grid { grid-template-columns: 1fr; gap: 32px; } }
.bib-box { position: relative; margin-top: 18px; }
.bib-box pre {
  margin: 0; padding: 20px 64px 18px 20px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: #ffffff; border: 1px solid var(--line); border-radius: 14px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: #334155;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  appearance: none; border: 1px solid var(--line); border-radius: 8px;
  background: #f3f5f9; color: var(--text);
  font: 600 12px var(--font); padding: 6px 10px; cursor: pointer;
}
.copy-btn:hover { background: #e9edf3; }
.copy-btn.is-done { color: var(--ecg); border-color: rgba(21, 137, 106, 0.4); }
#bibtex .btn { margin-top: 18px; }
#bibtex .lead { font-size: 16px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 26px 0 40px; color: var(--faint); font-size: 13px; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 600ms ease var(--delay, 0ms), transform 600ms ease var(--delay, 0ms); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .wordmark-pulse { animation: none; }
  .btn, .method-bar button { transition: none; }
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .nav-links { display: none; }
  .section { padding: 60px 0; }
  .authors { font-size: 14px; }
  .affils { font-size: 12px; }
}
