:root {
  --ink: #17181b;
  --muted: #6b7280;
  --faint: #9aa1a9;
  --accent: #475569;        /* slate — subdued UI accent (near-monochrome) */
  --accent-dark: #2f3b4c;
  --accent-soft: #eef1f5;
  --accent-border: #d9dee5;
  --green: #1f9d55;         /* semantic: green-list tokens */
  --red: #d6336c;           /* semantic: red tokens */
  --line: #e7e9ec;
  --line-soft: #f0f2f4;
  --bg-soft: #f7f8f9;
  --maxw: 920px;
  --content: 800px;     /* unified content width across sections */
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

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

/* ---------- Top nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topnav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  height: 52px; display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 800; letter-spacing: 0.02em; color: var(--ink); font-size: 1.02rem; }
.brand:hover { color: var(--accent); }
.navlinks { display: flex; gap: 1.4rem; }
.navlinks a { color: var(--muted); font-size: 0.88rem; font-weight: 500; }
.navlinks a:hover { color: var(--accent); }
@media (max-width: 640px) { .navlinks { display: none; } }

/* ---------- Hero ---------- */
.hero { padding: 3.2rem 0 2.2rem; text-align: center; }
.hero .eyebrow {
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.8rem;
}
.hero h1 {
  font-size: 2.35rem; font-weight: 800; letter-spacing: -0.025em;
  line-height: 1.15; color: var(--ink); margin: 0 auto; max-width: 780px;
}
.hero h1 .hl { color: var(--accent); }
.authors { margin-top: 1.2rem; font-size: 1rem; color: #2b3138; }
.authors a { color: #2b7a9e; font-weight: 600; }
.authors a:hover { color: #1f5e78; text-decoration: underline; }
.authors .sep { color: var(--faint); }
.affil { margin-top: 0.5rem; font-size: 0.9rem; color: var(--muted); }
.venue {
  margin-top: 0.95rem;
  font-size: 1rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent);
}

/* link buttons */
.links { margin-top: 1.5rem; display: flex; gap: 0.55rem; justify-content: center; flex-wrap: wrap; }
.links a {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.95rem; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 0.88rem; font-weight: 600;
  transition: transform .12s ease, background .12s ease;
}
.links a:hover { background: var(--accent); color: #fff; transform: translateY(-1px); }
.links a i { font-size: 0.95rem; }

/* ---------- Sections ---------- */
section.block { padding: 0.5rem 0 1.7rem; scroll-margin-top: 64px; }
section.block.tint { background: var(--bg-soft); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }

.eyebrow-c {
  text-align: center; font-size: 1.12rem; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.55rem;
}
.section-title {
  text-align: center; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.025em;
  color: var(--ink); margin: 0 0 1.2rem; line-height: 1.2;
}
.section-title .accent { color: var(--red); }
.lead { max-width: var(--content); margin: 0 auto 1.2rem; font-size: 1.02rem; line-height: 1.7; color: #2b3138; }
.lead.center { text-align: center; }

/* ---------- TL;DR (no box) ---------- */
.tldr { max-width: 800px; margin: 0 auto; }
.tldr-tag {
  display: block; text-align: center; color: var(--ink);
  font-size: 1.95rem; font-weight: 800; letter-spacing: -0.01em;
  margin-bottom: 0.9rem;
}
.tldr-lead { font-size: 1.1rem; line-height: 1.6; color: #1f262c; margin-bottom: 0.7rem; }
.tldr-lead b { color: var(--ink); }
.tldr-list { margin: 0; padding-left: 1.3rem; }
.tldr-list li { margin-bottom: 0.45rem; line-height: 1.6; font-size: 1.05rem; color: #2b3138; }
.tldr-list li:last-child { margin-bottom: 0; }
.tldr-list li::marker { color: var(--accent); }
.tk-g { color: var(--green); font-weight: 700; }
.tk-r { color: var(--red); font-weight: 700; }

/* ---------- Figures ---------- */
figure.fig { margin: 0 auto; text-align: center; }
figure.fig img { max-width: 100%; height: auto; display: block; margin: 0 auto; border-radius: 8px; }
figure.fig.framed img { border: 1px solid var(--line); padding: 8px; background: #fff; }
figure.fig figcaption {
  margin-top: 0.85rem; font-size: 0.86rem; line-height: 1.55; color: var(--muted);
  max-width: var(--content); margin-left: auto; margin-right: auto; text-align: left;
}
figure.fig figcaption b { color: #3a424b; }
.fig-teaser { max-width: var(--content); }        /* matches the Method step boxes */
.fig-mid { max-width: var(--content); }

/* ---------- Stats strip ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  max-width: 820px; margin: 0 auto; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.stat { padding: 1.1rem 0.9rem; text-align: center; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat .num { font-size: 1.5rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat .num.red { color: var(--red); }
.stat .lab { margin-top: 0.4rem; font-size: 0.78rem; line-height: 1.35; color: var(--muted); }
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: none; }
  .stat:nth-child(1), .stat:nth-child(2) { border-bottom: 1px solid var(--line); }
}

/* ---------- Theorem card ---------- */
.theorem {
  max-width: var(--content); margin: 1.5rem auto; background: #fff; text-align: center;
  border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.6rem 1.4rem;
  box-shadow: 0 6px 24px rgba(20,30,40,.05);
}
.theorem .thm-label { font-size: 0.95rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.7rem; }
.theorem .thm-cond { font-size: 1rem; color: var(--ink); line-height: 1.55; margin: 0.55rem 0 0; }
.theorem .thm-eq {
  margin: 0.6rem auto; padding: 0.75rem 1rem; font-size: 1.06rem; color: var(--ink);
  background: var(--accent-soft); border-radius: 10px; overflow-x: auto;
}
.theorem .thm-eq mjx-container { margin: 0 !important; }
.theorem .thm-where { font-size: 0.82rem; color: var(--muted); margin: 0.1rem 0 0.6rem; line-height: 1.5; }
.theorem .thm-note { font-size: 0.92rem; color: #2b3138; margin: 0; line-height: 1.55; }
.theorem .thm-note b { color: var(--ink); }

/* ---------- Method steps ---------- */
.steps { max-width: var(--content); margin: 1.2rem auto 0; display: grid; gap: 0.9rem; }
.step {
  display: flex; gap: 0.95rem; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.15rem;
}
.step .badge {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
}
.step .body { flex: 1; min-width: 0; }
.step .body h4 { font-weight: 700; font-size: 0.98rem; margin: 0 0 0.25rem; color: var(--ink); }
.step .body p { font-size: 0.92rem; color: #3a424b; line-height: 1.58; margin: 0; }
.step .body .seq {
  display: flex; justify-content: center; align-items: center;
  width: 100%; box-sizing: border-box;
  margin: 0.55rem 0 0.1rem; padding: 0.5rem 0.8rem; overflow-x: auto;
  background: var(--accent-soft); border-radius: 8px; font-size: 0.98rem; color: var(--ink);
}
.step .body .seq mjx-container { margin: 0 !important; }

/* ---------- Results table ---------- */
.table-wrap { overflow-x: auto; max-width: var(--content); margin: 0 auto; border-radius: 10px; }
table.results { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 0.88rem; }
table.results th, table.results td { padding: 0.5rem 0.5rem; text-align: center; white-space: nowrap; }
table.results th:first-child, table.results td.method { width: 28%; }
table.results thead th { background: var(--ink); color: #fff; font-weight: 600; }
table.results tbody td { border-bottom: 1px solid var(--line-soft); color: #6a727c; }   /* baselines muted */
table.results td.method { font-weight: 500; color: #3a424b; }
table.results tr.group-sep td { border-top: 1.5px solid #d4d8dd; }
/* emphasize our method */
table.results tr.ours { background: #e6ebf3; }
table.results tr.ours td { color: var(--ink); font-weight: 700; }
table.results tr.ours td:first-child { border-left: 3px solid var(--accent); }
table.results tr.ours td:last-child { border-right: 3px solid var(--accent); }
table.results tr.ours.group-sep td { border-top: 2px solid var(--accent); }
table.results tr.ours:last-child td { border-bottom: 2px solid var(--accent); }
table.results td.best { color: var(--ink); font-weight: 800; }

/* ---------- Qualitative ---------- */
.legend { text-align: center; font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.legend .sw { font-weight: 800; margin-right: 0.2rem; }
.legend .sw.g { color: var(--green); }
.legend .sw.r { color: var(--red); }

.qbox { max-width: var(--content); margin: 0 auto 1.1rem; border-radius: 12px; overflow: hidden; background: #fbfcfc; }
.qbox .qhead { font-weight: 700; font-size: 0.86rem; padding: 0.55rem 1.05rem; color: var(--ink); }
.qbox.wmbox { border: 1px solid #f0c3d3; }
.qbox.wmbox .qhead { background: #fbe4ec; }
.qbox.atbox { border: 1px solid #b8e0c8; }
.qbox.atbox .qhead { background: #e2f3e9; }
.qbox .qbody { padding: 0.85rem 1.05rem 0.95rem; font-size: 0.9rem; line-height: 1.72; }
.qbox .qbody .wm { color: var(--red); }
.qbox .qbody .rg { color: var(--green); }

/* ---------- two-column ---------- */
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; max-width: var(--content); margin: 0 auto; }
@media (max-width: 720px) { .cols2 { grid-template-columns: 1fr; } }

/* ---------- BibTeX ---------- */
.bibtex-wrap { position: relative; max-width: var(--content); margin: 0 auto; }
.copy-btn {
  position: absolute; top: 0.6rem; right: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--ink); color: #fff; border: none; cursor: pointer;
  font-size: 0.78rem; font-weight: 600; padding: 0.35rem 0.7rem; border-radius: 7px;
  transition: background .12s ease;
}
.copy-btn:hover { background: var(--accent); }
.copy-btn.copied { background: var(--green); }
.copy-btn i { font-size: 0.8rem; }
pre.bibtex {
  margin: 0; background: #fff; color: #2b3138;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 1.05rem 1.25rem; overflow-x: auto;
  font-size: 0.84rem; line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------- Footer ---------- */
footer.foot { padding: 2rem 0 2.6rem; border-top: 1px solid var(--line); }
footer.foot .wrap { text-align: center; color: var(--muted); font-size: 0.85rem; line-height: 1.6; }

@media (max-width: 600px) {
  .hero h1 { font-size: 1.6rem; }
  .section-title { font-size: 1.3rem; }
}
