/* Project page. Plain CSS, no build step. */
:root {
  --ink: #1d1d1f;
  --ink-2: #3c4043;
  --muted: #5f6368;
  --faint: #8a8f96;
  --line: #e6e6e6;
  --line-2: #eef0f2;
  --bg: #ffffff;
  --card: #f7f8fa;
  --accent: #2457c5;          /* our method / primary */
  --accent-soft: #eef3fd;
  --baseline: #c9741f;        /* baseline series */
  --mismatch: #d9822b;        /* matches the paper's "distribution of interest" orange */
  --gap: #3f8f4f;             /* matches the paper's "Gap!" green */
  --gap-fill: rgba(63, 143, 79, 0.13);
  --gap-fill-strong: rgba(63, 143, 79, 0.22);
  --area: rgba(36, 87, 197, 0.12);
  --hl: #fbdcdc;
  --maxw: 980px;
  --wide: 1140px;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 17px;
  overflow-x: hidden;
}
h1, h2, h3, .nav, .btn, .stat-num, .metric-name, .duo-title, .def-label,
.step-k, .ctl-label, .ex-bench, .footer-title {
  font-family: "Google Sans", "Noto Sans", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--card); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: 8px 14px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.nav .inner { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 22px; height: 48px; }
.nav-links { display: flex; gap: 18px; font-size: 14px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; flex: 1; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { color: var(--muted); padding: 13px 0; border-bottom: 2px solid transparent; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-links a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.wide { margin-left: calc((var(--maxw) - 40px - min(var(--wide), 100vw - 40px)) / 2); margin-right: calc((var(--maxw) - 40px - min(var(--wide), 100vw - 40px)) / 2); }
@media (max-width: 1000px) { .wide { margin-left: 0; margin-right: 0; } }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 60px 20px 18px; }
.hero h1 { font-size: 2.55rem; line-height: 1.18; margin: 0 0 22px; font-weight: 700; letter-spacing: -.01em; }
.title-break { display: none; }
@media (min-width: 760px) { .title-break { display: block; } }
.authors { font-size: 1.12rem; line-height: 1.9; margin: 0 auto 4px; }
.author-entry { display: inline-block; white-space: nowrap; margin: 0 .18em; }
.authors sup, .affils sup, .note sup { font-size: .66em; color: var(--ink-2); margin-left: 1px; }
.affils { color: var(--muted); font-size: .98rem; margin: 0 auto 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 22px; }
.note { color: var(--muted); font-size: .9rem; margin: 0 0 24px; }
.btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0 0 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #222; color: #fff; border-radius: 999px; padding: 9px 19px;
  font-size: .95rem; font-weight: 500; border: 0; cursor: pointer; line-height: 1.3;
}
.btn:hover { background: #000; text-decoration: none; }
.btn svg { width: 17px; height: 17px; fill: currentColor; flex: none; }
.btn-soon { background: #a0a3a8; cursor: default; }
.btn-soon:hover { background: #a0a3a8; }
.soon-tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; background: rgba(255,255,255,.22); border-radius: 99px; padding: 1px 7px; }

/* ---------- body copy ---------- */
.lead { font-size: 1.12rem; line-height: 1.7; color: var(--ink-2); margin: 18px 0 22px; }
.section { padding: 40px 0 10px; border-top: 1px solid var(--line); scroll-margin-top: 60px; }
.section h2 { font-size: 1.75rem; margin: 0 0 16px; letter-spacing: -.005em; line-height: 1.25; }
.section h3 { font-size: 1.24rem; margin: 34px 0 10px; scroll-margin-top: 64px; }
.section p { margin: 0 0 14px; }
.small-note { font-size: .9rem; color: var(--muted); }

/* ---------- figures ---------- */
figure { margin: 20px 0 28px; }
figure img { width: 100%; height: auto; display: block; }
figcaption { font-size: .92rem; color: var(--muted); margin-top: 12px; line-height: 1.55; }
figcaption b { color: var(--ink-2); }
.fig-src { color: var(--faint); }
.zoomable { display: block; cursor: zoom-in; border-radius: 6px; }
.teaser-figure { margin-top: 6px; }
.teaser-split { display: none; }
@media (max-width: 720px) {
  .teaser-figure .zoomable { display: none; }
  .teaser-split { display: grid; gap: 18px; }
}

/* ---------- two failure modes ---------- */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 6px 0 28px; }
.duo-card { background: var(--card); border-radius: var(--radius); padding: 16px 18px 4px; }
.duo-card p { font-size: .97rem; }
.duo-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 6px !important; display: flex; align-items: center; gap: 9px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-mismatch { background: var(--mismatch); }
.dot-gap { background: var(--gap); }
.duo-card.mismatch { background: #fdf5ec; }
.duo-card.gap { background: #eff6f0; }

/* ---------- measure view ---------- */
.def-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 30px; margin: 4px 0 10px; }
.def { border-left: 3px solid var(--line); padding: 2px 0 2px 14px; }
.def p { margin: 0 0 8px; }
.def-label { font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 2px !important; }
.def .katex-display { margin: .45em 0; text-align: left; }
.def .katex-display > .katex { text-align: left; }
.metric-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.metric-card { border: 1px solid var(--line); border-top: 3px solid var(--mismatch); border-radius: var(--radius); padding: 16px 18px 6px; min-width: 0; }
.metric-card.gap { border-top-color: var(--gap); }
.metric-name { font-weight: 700; font-size: 1.08rem; margin-bottom: 4px !important; }
.metric-card p { font-size: .96rem; }
.eq-block { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.eq-block .katex-display { margin: .6em 0; }

.theorem-cards { margin-top: 4px; }
.thm-num { display: block; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.theorem-list { margin: 0 0 11px; padding-left: 22px; }
.theorem-list li { margin-bottom: 4px; }
.thm-note { font-size: .92rem !important; color: var(--ink-2); border-top: 1px dashed var(--line); padding-top: 9px; }

/* ---------- diagnosis ---------- */
.facts { padding-left: 20px; margin: 0 0 18px; }
.facts li { margin-bottom: 8px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px 16px 10px; }
.stat p { margin: 0; }
.stat-num { font-size: 1.85rem; font-weight: 700; line-height: 1.15; color: var(--ink); }
.stat-num span { font-size: 1.05rem; color: var(--muted); font-weight: 500; }
.stat-label { font-size: .88rem; color: var(--muted); margin-top: 4px !important; line-height: 1.4; }
.stat.accent { background: var(--accent-soft); }
.stat.accent .stat-num { color: var(--accent); }

/* ---------- interactive widgets ---------- */
.explorer { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px 12px; margin: 14px 0 24px; background: #fff; }
.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 14px; }
.select-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ctl-label { font-size: .85rem; font-weight: 500; color: var(--muted); }
select {
  font: inherit; font-size: .95rem; color: var(--ink);
  padding: 7px 34px 7px 12px; border: 1px solid #cfd3d8; border-radius: 6px; background: #fff;
  -webkit-appearance: none; appearance: none; max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6368' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; cursor: pointer;
}
select:hover { border-color: #9aa0a6; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--ink-2); }
.toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggles input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.metric-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.mtile { background: var(--card); border-radius: 7px; padding: 9px 12px 8px; }
.mtile p { margin: 0; }
.mtile .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mtile .v { font-family: "Google Sans", "Noto Sans", sans-serif; font-size: 1.4rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.mtile .flag { font-size: .75rem; color: #8a4b0f; }
.mtile.high { background: #fdf3e7; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--ink-2); margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { display: inline-block; flex: none; }
.lg-line { width: 20px; height: 2px; background: var(--ink); }
.lg-dash { width: 20px; height: 0; border-top: 2px dashed #8a8f96; }
.lg-area { width: 14px; height: 12px; background: var(--area); border: 1px solid rgba(36,87,197,.35); }
.lg-gap { width: 14px; height: 12px; background: var(--gap-fill-strong); border: 1px solid rgba(63,143,79,.5); }
.lg-bar { width: 16px; height: 10px; border-radius: 2px; }
.lg-bar.base { background: var(--baseline); }
.lg-bar.bf { background: var(--accent); }
.lg-oracle { width: 3px; height: 14px; background: var(--ink); border-radius: 1px; }

.chart-box { position: relative; }
.chart-box svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(255,255,255,.97); border: 1px solid #d5d8dc; border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08); padding: 7px 10px; font-size: .82rem; line-height: 1.45;
  color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tooltip b { font-weight: 600; }
.tooltip .tt-k { color: var(--muted); }
.explorer-note { font-size: .84rem; color: var(--muted); margin: 10px 0 2px !important; line-height: 1.5; }

svg text { font-family: "Noto Sans", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
.ax line, .ax path { stroke: #9aa0a6; }
.ax text { fill: var(--muted); font-size: 11px; }
.ax-title { fill: var(--ink-2); font-size: 12px; }
.grid line { stroke: var(--line-2); }

/* ---------- method steps ---------- */
.steps { list-style: none; padding: 0; margin: 4px 0 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 10px; counter-reset: step; }
.steps li { counter-increment: step; background: var(--card); border-radius: var(--radius); padding: 12px 14px 4px; position: relative; }
.steps li p { font-size: .9rem; margin: 0 0 8px; color: var(--ink-2); line-height: 1.5; }
.step-k { display: block; font-weight: 700; font-size: .98rem; margin-bottom: 3px; }
.step-k::before { content: counter(step); display: inline-grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .74rem; margin-right: 8px; vertical-align: 1px; }

/* ---------- results ---------- */
.chart-figure { margin: 18px 0 18px; }
.takeaway { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 14px 18px 2px; border-radius: 6px; margin: 16px 0 24px; font-size: .98rem; }
.takeaway p { margin: 0 0 12px; }
.takeaway b { color: #1b3f8f; }

.examples { display: grid; gap: 16px; margin: 14px 0 12px; }
.example { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.example header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.ex-bench { font-weight: 700; }
.ex-move { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ex-pair { display: grid; grid-template-columns: 1fr 1fr; }
.ex-item { padding: 12px 16px 4px; font-size: .95rem; min-width: 0; }
.ex-item + .ex-item { border-left: 1px solid var(--line); }
.ex-item.new { background: #fbfcff; }
.ex-label { font-size: .78rem !important; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px !important; }
.ex-diff { text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.ex-target { color: var(--muted); font-weight: 400; }
mark, .hl { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 2px; }
.ex-item .katex { font-size: 1.05em; }
.ex-item p { overflow-x: auto; overflow-y: hidden; }

/* ---------- tables ---------- */
.table-details { margin: 16px 0 20px; }
.table-details > summary {
  cursor: pointer; font-weight: 600; font-size: .98rem; color: var(--ink-2); padding: 6px 0; list-style-position: inside;
}
.table-details > summary:hover { color: var(--ink); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0 6px; }
.data-table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
.data-table caption { caption-side: bottom; text-align: left; font-size: .84rem; color: var(--muted); padding-top: 9px; line-height: 1.5; }
.data-table th, .data-table td { padding: 6px 10px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; }
.data-table thead th { border-bottom: 1.5px solid #c9cdd2; font-weight: 600; color: var(--ink-2); font-size: .85rem; }
.data-table .num { text-align: right; }
.data-table td.hi { background: #fdf0e1; }
.data-table tr.domain-row td { background: var(--card); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 10px; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: #f3f6fc; }
.data-table tr.clickable:hover td.hi { background: #fae6cf; }
.data-table tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.release-table { width: auto; min-width: 360px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- bibtex ---------- */
.bibtex { position: relative; background: #f4f4f6; border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; overflow-x: auto; font-size: .86rem; line-height: 1.55; }
.bibtex pre { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.copy-btn {
  position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .8rem; color: var(--ink-2); background: #fff; border: 1px solid #d5d8dc;
  border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn svg { width: 14px; height: 14px; fill: currentColor; }
.copy-btn.copied { color: #1e7a3a; border-color: #9ccfaa; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); margin-top: 44px; padding: 28px 0 44px; text-align: center; color: var(--muted); font-size: .9rem; }
.footer p { margin: 0 0 6px; }
.footer-title { color: var(--ink-2); font-weight: 500; }
.footer-links a { margin: 0 8px; }
.footer-credit { font-size: .8rem; color: var(--faint); margin-top: 12px !important; }
.footer-credit a { color: inherit; text-decoration: underline; text-decoration-color: #c9cdd2; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(255,255,255,.97); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 18px 18px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: min(1600px, 100%); max-height: calc(100vh - 120px); width: auto; height: auto; object-fit: contain; }
.lightbox-cap { color: var(--muted); font-size: .9rem; margin: 12px 0 0; text-align: center; }
.lightbox-close { position: absolute; top: 10px; right: 14px; font-size: 30px; line-height: 1; width: 42px; height: 42px; border: 0; background: none; cursor: pointer; color: var(--ink-2); border-radius: 50%; }
.lightbox-close:hover { background: var(--card); }

/* KaTeX tweaks */
.katex { font-size: 1.06em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .def-row { grid-template-columns: 1fr; gap: 4px; }
  .metric-cards { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .hero { padding: 40px 0 12px; }
  .hero h1 { font-size: 1.85rem; }
  .authors { font-size: 1.02rem; }
  .affils { font-size: .9rem; flex-direction: column; gap: 0; }
  .section { padding-top: 32px; }
  .section h2 { font-size: 1.5rem; }
  .duo { grid-template-columns: 1fr; }
  .metric-tiles { grid-template-columns: repeat(2, 1fr); }
  .explorer { padding: 12px 12px 10px; }
  .controls { flex-direction: column; align-items: stretch; }
  .select-wrap { flex-direction: column; align-items: stretch; gap: 4px; }
  .ex-pair { grid-template-columns: 1fr; }
  .ex-item + .ex-item { border-left: 0; border-top: 1px solid var(--line); }
  .nav .inner { gap: 14px; padding: 0 14px; }
  .wrap { padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
@media print {
  .nav, .btn-row, .explorer .controls, .copy-btn, .skip-link { display: none !important; }
  .section { break-inside: avoid-page; }
}
