:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --surface: #ffffff;
  --nav-bg: rgba(255, 255, 255, 0.88);
  --hero-grad: radial-gradient(circle at 50% -20%, #eff6ff 0%, #ffffff 62%);
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --success: #059669;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --max-w: 1080px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111827;
  --bg-muted: #1e293b;
  --surface: #131c31;
  --nav-bg: rgba(11, 17, 32, 0.86);
  --hero-grad: radial-gradient(circle at 50% -20%, rgba(37, 99, 235, 0.22) 0%, #0b1120 62%);
  --border: #1e293b;
  --border-strong: #334155;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(96, 165, 250, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

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

img, video {
  max-width: 100%;
  display: block;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.nav-links {
  display: flex;
  gap: 22px;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Layout containers */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 64px 0;
}

.section-alt {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-header {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 36px;
}

.section-eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}

.section-title {
  margin: 0 0 10px;
  font-size: clamp(1.55rem, 2.6vw, 2.05rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.section-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Hero */
.hero {
  padding: 56px 0 40px;
  background: var(--hero-grad);
}

.hero-inner {
  text-align: center;
  max-width: 920px;
  margin: 0 auto;
}

.hero-title {
  margin: 0 0 20px;
  font-size: clamp(1.9rem, 3.6vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.18;
  color: var(--text);
}

.hero-title .accent {
  color: var(--accent);
}

.authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  font-size: 1.04rem;
  margin-bottom: 12px;
}

.author-item {
  white-space: nowrap;
}

.author-item a {
  color: var(--text);
  font-weight: 500;
}

.author-item a:hover {
  color: var(--accent);
}

.author-item sup {
  color: var(--accent);
  font-weight: 600;
  margin-left: 2px;
}

.affiliations {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 22px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 26px;
}

.affiliations sup {
  color: var(--accent);
  font-weight: 700;
  margin-right: 3px;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 34px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Single latency highlight banner */
.hero-highlight {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.1);
  margin-top: 4px;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-border);
  flex-shrink: 0;
}

.hero-highlight-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.hero-highlight-text {
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text);
}

.corresponding-note {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: -14px 0 24px;
}

/* Media cards */
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.featured-video-card {
  border-color: var(--accent-border);
  box-shadow: 0 10px 34px rgba(37, 99, 235, 0.09);
}

.media-card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 650;
  color: var(--text);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.topbar-dot-teal {
  background: #0d9488;
}

.topbar-meta {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.media-card video {
  width: 100%;
  background: #0b1120;
}

.media-caption {
  padding: 14px 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.media-caption strong {
  color: var(--text);
}

.mode-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mode-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

/* Abstract */
.abstract-box {
  max-width: 860px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  font-size: 1.01rem;
  color: var(--text-secondary);
  text-align: justify;
}

.abstract-box p {
  margin: 0;
}

/* Figure wrapper */
.figure-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.figure-card img {
  width: 100%;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  background: #ffffff;
}

.figure-caption {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.figure-caption strong {
  color: var(--text);
}

/* Method pillars */
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 24px;
}

.pillar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.pillar-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.pillar-card h3 {
  margin: 0 0 8px;
  font-size: 1.02rem;
  font-weight: 700;
}

.pillar-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Tabs */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.tab-btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
}

/* Real-world comparator */
.comparator-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.variant-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.variant-pill {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.variant-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.variant-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.video-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.video-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0b1120;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.video-pane.rw-clickable {
  cursor: pointer;
}

.video-pane.rw-clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.12);
}

.video-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text);
}

.pane-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
}

.pane-tag-base {
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.pane-tag-edit {
  background: var(--accent-soft);
  color: var(--accent);
}

.video-pane video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #0b1120;
}

.transport-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.transport-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.16s ease;
}

.ctrl-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.ctrl-btn.primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.ctrl-btn.primary:hover {
  filter: brightness(1.06);
  color: #ffffff;
  transform: translateY(-1px);
}

.speed-segment {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.speed-opt {
  padding: 5px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.speed-opt:hover {
  color: var(--text);
}

.speed-opt.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.variant-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.variant-desc strong {
  color: var(--text);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

table.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

table.results-table th,
table.results-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.results-table th:first-child,
table.results-table td:first-child,
table.results-table th:nth-child(2),
table.results-table td:nth-child(2) {
  text-align: left;
}

table.results-table thead th {
  background: var(--bg-subtle);
  font-weight: 700;
  color: var(--text);
  font-size: 0.82rem;
}

table.results-table tbody tr:last-child td {
  border-bottom: none;
}

table.results-table tbody tr.ours-row {
  background: var(--accent-soft);
  font-weight: 700;
}

table.results-table tbody tr.ours-row td:first-child {
  color: var(--accent);
}

.best {
  font-weight: 750;
  color: var(--text);
}

.second {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.result-panel {
  display: none;
}

.result-panel.active {
  display: block;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

/* BibTeX */
.bibtex-card {
  position: relative;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  overflow-x: auto;
  box-shadow: var(--shadow-md);
}

.bibtex-card pre {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.6;
}

.copy-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Footer */
.footer {
  padding: 36px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.86);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 92vh;
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

/* Responsive */
@media (max-width: 860px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .pillars-grid,
  .video-compare-grid,
  .two-col-grid {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: none;
  }
  .abstract-box {
    padding: 20px;
  }
}
