:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --text: #16181d;
  --muted: #5b6270;
  --border: #e3e6eb;
  --accent: #3b5bdb;
  --btn-bg: #16181d;
  --btn-text: #ffffff;
  --code-bg: #f3f4f6;
  --radius: 12px;
  --wrap: 920px;
}

/* Dark theme only when chosen with the toggle (stored per visitor). */
:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --text: #e8eaee;
  --muted: #9aa1ad;
  --border: #262a33;
  --accent: #8ea2ff;
  --btn-bg: #e8eaee;
  --btn-text: #0f1115;
  --code-bg: #171a21;
  color-scheme: dark;
}
:root[data-theme="dark"] figure img { padding: 10px; }

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

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

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

/* Header */
.hero {
  text-align: center;
  padding: 72px 0 40px;
}
.venue {
  display: inline-block;
  margin: 0 0 18px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.hero h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 10px 0 28px;
  font-size: clamp(18px, 2.6vw, 24px);
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}
.authors {
  margin: 0;
  font-size: 18px;
}
.authors a, .authors span { white-space: nowrap; }
.affil {
  margin: 4px 0 28px;
  color: var(--muted);
  font-size: 16px;
}
.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 15px;
  font-weight: 500;
}
.btn:hover { text-decoration: none; opacity: 0.85; }
.btn svg { width: 17px; height: 17px; fill: currentColor; }

/* Sections */
main section { padding: 28px 20px; }
main section + section { border-top: 1px solid var(--border); }
main section.wrap { padding-left: 20px; padding-right: 20px; }

h2 {
  margin: 12px 0 16px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h3 { font-size: 17px; font-weight: 600; margin: 0 0 8px; }
h3.sub { font-size: 20px; margin: 36px 0 14px; }

p { margin: 0 0 14px; }
p, figcaption, li { overflow-wrap: anywhere; }
#abstract p { text-align: justify; hyphens: auto; }

figure { margin: 0; }
figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: #fff;
}
figure.wide { margin: 8px 0 12px; }
figcaption {
  margin-top: 12px;
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* Videos */
.video-box {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.video-box video { display: block; width: 100%; height: auto; }
.teaser .video-box { aspect-ratio: 1920 / 1000; }
.teaser .video-box video { height: 100%; object-fit: contain; background: #000; }
.teaser { padding-top: 8px !important; }

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  min-height: 200px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 16px;
}
.placeholder svg { width: 34px; height: 34px; fill: currentColor; opacity: 0.6; }
.placeholder code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.ex .video-box { aspect-ratio: 16 / 9; }
.ex .video-box video { height: 100%; object-fit: contain; background: #000; }

/* Equations */
.eq-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 28px;
}
.eq-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 0;
}
.eq-card h3 a { color: inherit; }
.eq-card h3 a:hover { color: var(--accent); }
.eq {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
}
.eq.rendered { font-family: inherit; font-size: inherit; }
.eq .katex-display { margin: 0.4em 0; }

/* Examples */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.chip {
  font: inherit;
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.chip:hover { border-color: var(--muted); }
.chip.active { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }

.examples {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px 22px;
  align-items: start;
}
.ex[hidden] { display: none; }
.ex .tag {
  margin: 12px 0 2px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.ex h4 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.ex .desc {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ex.open .desc { -webkit-line-clamp: unset; display: block; }
.more {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* BibTeX */
.code-block {
  background: var(--code-bg);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.code-block pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13.5px;
  line-height: 1.6;
}
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px 8px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.copy {
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
footer p { margin: 0; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  main section.wrap { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 48px 0 28px; }
  .eq-grid { grid-template-columns: 1fr; }
  .examples { grid-template-columns: 1fr; }
  #abstract p { text-align: left; }
}
