:root {
  --accent: #1f77b4;
  --ink: #1b1b1f;
  --muted: #6b6b76;
  --bg: #ffffff;
  --panel: #fafafb;
  --line: #e8e8ec;
  --maxw: 820px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 18px/1.7 "Source Serif 4", Georgia, "Times New Roman", serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

/* ---- header ---- */
header { padding: 66px 0 30px; text-align: center; border-bottom: 1px solid var(--line); }
.logo { width: 72px; height: 72px; display: block; margin: 0 auto 16px; }
h1 {
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3.6vw, 2.15rem);
  line-height: 1.22;
  font-weight: 650;
  letter-spacing: -0.012em;
  margin: 0 0 0.55em;
}
.authors { margin: 0.2em 0; font-size: 1.05rem; line-height: 1.5; }
.authors a { color: var(--ink); text-decoration: none; }
.authors a:hover { color: var(--accent); }
.authors sup, .venue sup { font-size: 0.7em; }
.venue { margin: 0.35em 0 1.25em; color: var(--muted); font-size: 0.92rem; line-height: 1.6; }
.venue a { color: var(--muted); }
.venue a:hover { color: var(--accent); }

.links { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.links a {
  display: inline-flex; align-items: center; gap: 0.4em;
  text-decoration: none; color: var(--accent);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.5em 1.05em; font-size: 0.93rem; font-weight: 500;
  background: var(--bg); transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.links a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.links a svg { width: 1.05em; height: 1.05em; flex: none; }

/* ---- sections ---- */
main { padding: 4px 0 36px; }
section { padding: 34px 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
h2 {
  font-size: 1.18rem; font-weight: 620; letter-spacing: -0.005em; margin: 0 0 0.7em;
}
h2::before {
  content: ""; display: inline-block; width: 9px; height: 9px;
  border-radius: 2px; background: var(--accent); margin-right: 0.55em; vertical-align: middle;
}
h3 { font-size: 1.02rem; font-weight: 600; margin: 1.5em 0 0.3em; }
p { margin: 0.6em 0; }
main p { text-align: justify; -webkit-hyphens: auto; hyphens: auto; }
a { color: var(--accent); }
.abstract { color: var(--ink); }

/* ---- media ---- */
figure { margin: 1.1em 0 0.3em; }
figure img, figure video {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
/* responsive 16:9 embed (YouTube) */
.video-frame {
  position: relative; aspect-ratio: 16 / 9;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000;
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
figcaption { font-size: 0.86rem; color: var(--muted); margin-top: 0.5em; line-height: 1.5; }
.hero figcaption { text-align: center; }

/* ---- tables ----
   display:block lets a wide results table scroll inside the column instead of
   forcing the page to scroll sideways. */
/* Centred, and allowed to break out of the text column when a wide results
   table needs more room than 820px; it scrolls only once it outgrows the
   viewport too. */
main table {
  display: block; overflow-x: auto;
  width: fit-content; max-width: calc(100vw - 44px);
  position: relative; left: 50%; transform: translateX(-50%);
  border-collapse: collapse; margin: 1.3em 0 0.4em;
  font-size: 0.78rem; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
main table th, main table td { padding: 0.42em 0.72em; text-align: center; white-space: nowrap; }
main table th:first-child, main table td:first-child { text-align: left; }
main table thead th { border-bottom: 1px solid var(--ink); font-weight: 620; }
main table tbody tr { border-bottom: 1px solid var(--line); }
main table tbody tr:last-child { border-bottom: 1px solid var(--ink); }
main table tbody tr:hover { background: var(--panel); }

/* ---- lists ---- */
main ul, main ol { padding-left: 1.35em; margin: 0.6em 0; }
main li { margin: 0.28em 0; }

/* ---- math (KaTeX) ---- */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.katex { font-size: 1.05em; }

/* ---- bibtex ---- */
pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 18px; overflow: auto;
  font: 500 13.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #2a2a30;
}
.note { color: var(--muted); font-size: 0.9rem; }

footer { padding: 30px 0 64px; text-align: center; color: var(--muted); font-size: 0.88rem; }
footer a { text-decoration: none; }

@media (max-width: 680px) { header { padding: 46px 0 24px; } }

/* ---- theme toggle ---- */
.theme-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 20;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--ink); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* smooth cross-fade when switching themes */
body { transition: background-color 0.2s ease, color 0.2s ease; }

/* ---- theming: explicit toggle (JS) + system fallback (no-JS) ---- */
:root { color-scheme: light; }
[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e9e9ee; --muted: #9a9aa6; --bg: #0f0f12; --panel: #17171b; --line: #26262c; --accent: #5aa7e0;
}
[data-theme="dark"] pre { color: #d6d6dd; }
/* figures keep a white canvas in both themes so the plots stay legible */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #e9e9ee; --muted: #9a9aa6; --bg: #0f0f12; --panel: #17171b; --line: #26262c; --accent: #5aa7e0;
  }
  :root:not([data-theme="light"]) pre { color: #d6d6dd; }
}
