/* ==========================================================================
   ECAD — Matching aniaggarwal.com design system
   Satoshi + Geist + JetBrains Mono, Electric Blue accent, CV detection motifs
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Typography */
  --font-heading: 'Satoshi', system-ui, sans-serif;
  --font-body: 'Geist', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Geist Mono', monospace;

  /* Fluid type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.76rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.88rem + 0.3vw, 1rem);
  --text-lg: clamp(1.0625rem, 0.98rem + 0.4vw, 1.15rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.5vw, 1.4rem);
  --text-2xl: clamp(1.5rem, 1.25rem + 0.85vw, 1.9rem);
  --text-3xl: clamp(1.8rem, 1.45rem + 1.2vw, 2.4rem);

  /* Zinc neutral palette */
  --bg: #fafafa;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --surface: #ffffff;
  --surface-elevated: #ffffff;

  /* Electric Blue accent */
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-dim: rgba(37, 99, 235, 0.06);

  /* Detection / annotation */
  --annotation-color: rgba(37, 99, 235, 0.15);
  --keypoint-color: rgba(37, 99, 235, 0.3);

  /* Semantic */
  --success: #22c55e;
  --success-light: #f0fdf4;

  /* Shadows */
  --shadow: rgba(24, 24, 27, 0.06);
  --shadow-accent: rgba(37, 99, 235, 0.08);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;
  --space-4xl: 4rem;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-3xl); font-weight: 900; letter-spacing: -0.04em; }
h2 { font-size: var(--text-2xl); font-weight: 900; letter-spacing: -0.03em; }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { margin-bottom: var(--space-md); color: var(--muted); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover { color: var(--text); }

strong { color: var(--text); font-weight: 600; }

img { max-width: 100%; height: auto; display: block; border-radius: 8px; }

::selection {
  background: var(--accent-light);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
main.container-fluid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2.5rem;
}

section {
  margin-bottom: var(--space-3xl);
}

/* Section headings — monospace label above */
section h2 {
  position: relative;
  margin-bottom: var(--space-xl);
}

section h2::before {
  content: attr(data-label);
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-xs);
}

/* --------------------------------------------------------------------------
   ICLR Venue Badge — flat monospace
   -------------------------------------------------------------------------- */
.iclr-badge {
  text-align: center;
  padding: var(--space-lg) var(--space-xl) var(--space-xs);
}

.iclr-badge span {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent);
  color: #ffffff;
  padding: 0.3rem 0.85rem;
  border-radius: 2px;
}

.iclr-badge span strong {
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: var(--space-2xl) 0 var(--space-xl);
  max-width: 900px;
  margin: 0 auto;
}

.hero h1 {
  line-height: 1.05;
  margin-bottom: var(--space-lg);
  color: var(--text);
}

.hero .authors {
  font-size: var(--text-lg);
  margin-bottom: var(--space-xs);
  color: var(--muted);
}

.hero .authors a {
  color: var(--text);
  font-weight: 500;
  transition: color 0.2s ease;
}
.hero .authors a:hover { color: var(--accent); }

.hero .affiliation {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-lg);
}

.hero .links {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.hero .links a[role="button"] {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.42rem 0.95rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  background: transparent;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.hero .links a[role="button"]:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--surface);
  transform: translateY(-1px);
}

/* Primary button variant (first link) */
.hero .links a[role="button"]:first-child {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.hero .links a[role="button"]:first-child:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Teaser
   -------------------------------------------------------------------------- */
.teaser {
  max-width: 1100px;
  margin: 0 auto var(--space-4xl);
}

.teaser picture,
.teaser img {
  width: 100%;
  border-radius: 8px;
}

.teaser .caption {
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  margin-top: var(--space-xl);
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

.teaser .caption strong {
  color: var(--accent);
  font-weight: 600;
}

/* ECAD acronym — inline accent background */
.ecad-acronym {
  display: inline;
  background: var(--accent);
  color: #ffffff;
  padding: 0.1em 0.4em;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.ecad-acronym strong {
  color: #ffffff;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Grids
   -------------------------------------------------------------------------- */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
  margin-bottom: var(--space-2xl);
}

@media (max-width: 900px) {
  .grid-2col { grid-template-columns: 1fr; }
}

.grid-2col.figures { gap: var(--space-xl); }

.grid-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
  align-items: start;
}

.grid-3col.figures figure {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.grid-3col.figures figure img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--surface);
}

.grid-3col.figures figcaption {
  font-size: var(--text-xs);
  margin-top: var(--space-sm);
}

@media (max-width: 900px) {
  .grid-3col { grid-template-columns: 1fr; }
  .grid-3col.figures figure img { aspect-ratio: auto; max-height: 400px; }
}

/* --------------------------------------------------------------------------
   Abstract
   -------------------------------------------------------------------------- */
.abstract-section {
  max-width: 800px;
  margin: 0 auto var(--space-3xl);
}

.abstract-section p {
  line-height: 1.75;
  font-size: var(--text-base);
}

/* --------------------------------------------------------------------------
   Interactive Pareto Frontier Explorer
   -------------------------------------------------------------------------- */
.interactive-section {
  max-width: 100%;
  margin: 0 auto var(--space-4xl);
}

.interactive-section > p:first-of-type {
  max-width: 800px;
  margin-bottom: var(--space-lg);
}

/* Explorer layout: plot + panel */
.frontier-explorer {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: 740px;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 12px var(--shadow);
  /* Detection corners */
  position: relative;
}

.frontier-explorer::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 12px;
  height: 12px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
  z-index: 1;
  pointer-events: none;
}

.frontier-explorer::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-bottom: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  z-index: 1;
  pointer-events: none;
}

/* Plot area */
.frontier-plot {
  overflow: hidden;
  padding: var(--space-sm) var(--space-sm) 0 var(--space-sm);
  position: relative;
}

.frontier-plot #plotly-frontier {
  width: 100%;
  height: 100%;
}

/* Plotly modebar */
.frontier-plot .modebar {
  top: 8px !important;
  right: 8px !important;
  background: transparent !important;
}

.frontier-plot .modebar-group {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 2px !important;
  padding: 2px 4px !important;
  box-shadow: 0 1px 4px var(--shadow) !important;
  display: flex !important;
  gap: 0 !important;
}

.frontier-plot .modebar-btn {
  padding: 3px 4px !important;
  border-radius: 2px !important;
  transition: background 0.15s ease !important;
  line-height: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.frontier-plot .modebar-btn svg {
  width: 16px !important;
  height: 16px !important;
}

.frontier-plot .modebar-btn path {
  fill: var(--muted) !important;
}

.frontier-plot .modebar-btn:hover {
  background: var(--accent-dim) !important;
}

.frontier-plot .modebar-btn:hover path {
  fill: var(--accent) !important;
}

.frontier-plot .modebar-btn.active path {
  fill: var(--accent) !important;
}

/* Detail panel */
.frontier-panel {
  border-left: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
}

/* Empty state */
.panel-empty {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 700px;
  padding: 0 var(--space-lg);
  color: var(--muted);
}

.panel-empty.is-hidden {
  display: none !important;
}

.panel-empty-inner {
  text-align: center;
}

.panel-empty-inner svg {
  color: var(--border);
  margin-bottom: var(--space-lg);
  opacity: 0.6;
}

.panel-empty-inner h4,
.panel-empty-inner .panel-empty-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--muted);
  margin-bottom: var(--space-sm);
}

.panel-empty-inner p {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.6;
  max-width: 26ch;
  margin-left: auto;
  margin-right: auto;
  opacity: 0.7;
}

/* Loading skeleton */
.panel-loading {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-xl) var(--space-lg);
}

.skel {
  background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 2px;
}

.skel-img { width: 100%; aspect-ratio: 1; }
.skel-bar { height: 60px; }
.skel-text { height: 16px; width: 70%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Active content */
.panel-content {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  padding: 0 var(--space-lg);
}

.panel-content.is-active {
  opacity: 1;
  transform: translateY(0);
  height: auto;
  overflow: visible;
  pointer-events: auto;
  padding: var(--space-xl) var(--space-lg);
}

/* Image grid */
.panel-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.panel-img-cell {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.panel-img-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.panel-img-cell img,
.panel-schedule img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.panel-img-cell img:hover,
.panel-schedule img:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--shadow-accent);
}

/* Schedule checkerboard */
.panel-schedule {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

/* Metrics rows */
.panel-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  margin-bottom: var(--space-sm);
}

.panel-ident {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.7;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

/* Prompt blockquote */
.panel-prompt {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--muted);
  line-height: 1.55;
  border-left: 2px solid var(--accent);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0 0 0;
  background: var(--surface);
  border-radius: 0 2px 2px 0;
}

/* Lightbox */
.ecad-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.ecad-lightbox.active { display: flex; }

.ecad-lightbox-content {
  display: flex;
  flex-direction: column;
  width: 80vw;
  max-width: 900px;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  transition: width 0.3s ease, max-width 0.3s ease, max-height 0.3s ease, border-radius 0.3s ease, border 0.3s ease;
}
.ecad-lightbox-content.zoomed {
  width: 96vw;
  max-width: 1800px;
  height: 94vh;
  max-height: 94vh;
  border: none;
  border-radius: 0;
}

.ecad-lb-topbar,
.ecad-lb-bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg);
  flex-shrink: 0;
}
.ecad-lb-topbar { border-bottom: 1px solid var(--border); }
.ecad-lb-bottombar { border-top: 1px solid var(--border); padding: 0.5rem 1rem; justify-content: flex-end; }

.ecad-lb-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.ecad-lb-sublabel {
  font-family: var(--font-body);
  font-size: 0.62rem;
  color: var(--muted);
  margin-left: 0.75rem;
}
.ecad-lb-esc {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--muted);
  opacity: 0.5;
  margin-right: 0.5rem;
}

.ecad-lb-close {
  width: 28px;
  height: 28px;
  border-radius: 2px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.ecad-lb-close:hover { border-color: var(--accent); color: var(--accent); }

.ecad-lb-imgarea {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  cursor: zoom-in;
  min-height: 0;
}
.ecad-lb-imgarea.zoomed {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0;
  cursor: zoom-out;
}
.ecad-lb-imgarea img {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 6rem);
  height: auto;
  border-radius: 2px;
  background: var(--surface);
}
.ecad-lb-imgarea.zoomed img {
  width: 180vw;
  max-width: none;
  max-height: none;
}

.ecad-lb-hint {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--muted);
  opacity: 0.5;
}

.ecad-lb-imgarea.zoomed::-webkit-scrollbar { width: 6px; height: 6px; }
.ecad-lb-imgarea.zoomed::-webkit-scrollbar-track { background: transparent; }
.ecad-lb-imgarea.zoomed::-webkit-scrollbar-thumb { background: rgba(37, 99, 235, 0.3); border-radius: 3px; }

/* Responsive: stack on narrow screens */
@media (max-width: 1000px) {
  .frontier-explorer {
    grid-template-columns: 1fr;
    height: auto;
  }
  .frontier-plot { height: 500px; }
  .frontier-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .panel-empty {
    height: auto;
    min-height: 200px;
    padding: var(--space-lg);
  }
}

@media (max-width: 480px) {
  .frontier-plot { height: 360px; padding: var(--space-xs); }
  .frontier-panel { padding: var(--space-md); }
}

.caption {
  font-size: var(--text-xs);
  color: var(--muted);
  font-style: italic;
  margin-top: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Method
   -------------------------------------------------------------------------- */
.method-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-2xl);
  align-items: start;
  margin-bottom: var(--space-xl);
}

@media (max-width: 900px) {
  .method-grid { grid-template-columns: 1fr; }
}

.method-text ul {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

.method-text li {
  margin-bottom: var(--space-sm);
  line-height: 1.6;
  color: var(--muted);
}

.method-text h3 {
  margin-top: 0;
  margin-bottom: var(--space-xs);
}

.method-text > p:first-child {
  margin-bottom: var(--space-xs);
}

.key-components-list {
  margin-bottom: var(--space-sm);
}

.key-components-list li {
  margin-bottom: 0.25rem;
  line-height: 1.45;
  font-size: var(--text-sm);
}

.method-figure {
  margin: 0;
  align-self: start;
}

.method-figure img { width: 100%; }

.method-figure figcaption {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Algorithm (collapsible)
   -------------------------------------------------------------------------- */
.algorithm-wrapper {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  margin: var(--space-sm) 0;
  overflow: hidden;
  position: relative;
}

details.algorithm {
  background: transparent;
  border: none;
  border-radius: 0;
  margin: 0;
  overflow: hidden;
}

details.algorithm summary {
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: var(--text-base);
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: background 0.15s ease;
}

details.algorithm summary:hover {
  background: var(--accent-dim);
}

details.algorithm summary::before {
  content: '>';
  font-family: var(--font-mono);
  font-size: 0.7em;
  color: var(--accent);
  transition: transform 0.2s ease;
}

details.algorithm[open] summary::before {
  transform: rotate(90deg);
}

details.algorithm summary::-webkit-details-marker { display: none; }

.algorithm-content {
  padding: 0 var(--space-lg) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--muted);
}

.algorithm-preview {
  max-height: 130px;
  overflow: hidden;
  position: relative;
  padding: 0 var(--space-lg);
  font-size: var(--text-sm);
  border-top: 1px solid var(--border);
  cursor: pointer;
  color: var(--muted);
}

.algorithm-preview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to bottom, transparent 0%, var(--bg) 100%);
  pointer-events: none;
}

.algorithm-wrapper:has(details.algorithm[open]) .algorithm-preview {
  display: none;
}

.algorithm-io {
  background: var(--surface);
  border-left: 2px solid var(--accent);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  border-radius: 0 2px 2px 0;
}

.algorithm-io p {
  margin-bottom: var(--space-xs);
  line-height: 1.5;
}

.algorithm-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-body);
  counter-reset: step;
}

.algorithm-steps li {
  padding: 0.15em 0;
  display: flex;
  gap: var(--space-sm);
  line-height: 1.4;
}

.algorithm-steps li::before {
  content: counter(step) ':';
  counter-increment: step;
  font-family: var(--font-mono);
  color: var(--muted);
  min-width: 1.75em;
  text-align: right;
  font-size: 0.85em;
  opacity: 0.6;
}

.algorithm-steps .indent { padding-left: 1.25em; }
.algorithm-steps .indent2 { padding-left: 2.5em; }

.algorithm-steps .comment {
  color: var(--muted);
  font-style: italic;
  margin-left: auto;
  font-size: 0.85em;
  opacity: 0.6;
}

.algorithm-note {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Figures
   -------------------------------------------------------------------------- */
figure {
  margin: var(--space-lg) 0;
}

figure img {
  width: 100%;
  border-radius: 8px;
}

figure figcaption {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: var(--space-sm);
  text-align: center;
  line-height: 1.6;
}

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

figure.full-width {
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

figure.full-width > a,
.teaser > a {
  display: block;
  position: relative;
  cursor: zoom-in;
}

figure.full-width > a::after,
.teaser > a::after {
  content: 'Click to view full resolution';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: rgba(24, 24, 27, 0.82);
  color: white;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.5em 1em;
  border-radius: 2px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(4px);
}

figure.full-width > a:hover::after,
.teaser > a:hover::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

figure.full-width > a:hover img,
.teaser > a:hover img {
  filter: brightness(0.92);
  transition: filter 0.2s ease;
}

figure.centered {
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* --------------------------------------------------------------------------
   Collapsible Tables
   -------------------------------------------------------------------------- */
.table-section-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: var(--space-lg);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.table-section-wrapper:hover {
  border-color: var(--muted);
}

details.table-section {
  background: transparent;
  border: none;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
}

details.table-section summary {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  background: var(--bg);
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--border);
}

details.table-section summary:hover {
  background: var(--accent-dim);
}

details.table-section summary::before {
  content: '>';
  font-family: var(--font-mono);
  font-size: 0.75em;
  font-weight: 400;
  color: var(--accent);
  transition: transform 0.2s ease;
  line-height: 1;
}

details.table-section[open] summary::before {
  transform: rotate(90deg);
}

details.table-section summary::-webkit-details-marker { display: none; }

.table-preview {
  max-height: 155px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.table-preview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
}

.table-section-wrapper:has(details.table-section[open]) .table-preview {
  display: none;
}

.table-intro {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.table-note {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  margin-top: var(--space-sm);
}

.table-wrapper {
  overflow-x: auto;
}

/* --------------------------------------------------------------------------
   Tables — monospace numbers, clean lines
   -------------------------------------------------------------------------- */
.table-wrapper table,
.table-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  background: var(--surface);
  border: none;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.table-wrapper table thead,
.table-preview table thead {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.table-wrapper table thead th,
.table-preview table thead th {
  padding: 0.75rem 1rem;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  border: none;
  background: transparent;
}

.table-wrapper table thead th:first-child,
.table-wrapper table thead th:nth-child(2),
.table-preview table thead th:first-child,
.table-preview table thead th:nth-child(2) {
  text-align: left;
  padding-left: 1.25rem;
}

.table-wrapper table tbody td,
.table-preview table tbody td {
  padding: 0.625rem 1rem;
  text-align: center;
  border: none;
  color: var(--muted);
  vertical-align: middle;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.table-wrapper table tbody td:first-child,
.table-wrapper table tbody td:nth-child(2),
.table-preview table tbody td:first-child,
.table-preview table tbody td:nth-child(2) {
  text-align: left;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--text);
  padding-left: 1.25rem;
}

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

/* Baseline rows */
.table-wrapper table tbody tr.baseline,
.table-preview table tbody tr.baseline {
  background: var(--bg);
}

.table-wrapper table tbody tr.baseline td:first-child,
.table-preview table tbody tr.baseline td:first-child {
  box-shadow: inset 3px 0 0 var(--border);
}

/* ECAD "ours" rows — blue accent */
.table-wrapper table tbody tr.ours,
.table-preview table tbody tr.ours {
  background: var(--accent-dim);
}

.table-wrapper table tbody tr.ours td:first-child,
.table-preview table tbody tr.ours td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.table-wrapper table tbody tr.ours td:first-child strong,
.table-preview table tbody tr.ours td:first-child strong {
  color: var(--accent);
  font-weight: 700;
}

/* Best values */
.table-wrapper table tbody td strong,
.table-preview table tbody td strong {
  color: var(--accent);
  font-weight: 700;
  font-size: 1em;
}

/* Hover */
.table-wrapper table tbody tr {
  transition: background 0.15s ease;
}

.table-wrapper table tbody tr:hover {
  background: var(--accent-dim);
}

.table-wrapper table tbody tr.ours:hover {
  background: rgba(37, 99, 235, 0.1);
}

/* --------------------------------------------------------------------------
   Key Findings
   -------------------------------------------------------------------------- */
.key-findings {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 2px 2px 0;
  padding: var(--space-md) var(--space-lg);
  margin-top: var(--space-xl);
}

.key-findings h3 {
  margin-top: 0;
  margin-bottom: var(--space-sm);
  color: var(--text);
  font-size: var(--text-lg);
}

.key-findings ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.key-findings li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.25rem;
  line-height: 1.4;
  font-size: var(--text-sm);
  color: var(--muted);
}

.key-findings li:last-child { margin-bottom: 0; }

.key-findings li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

.key-findings li strong {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Citation
   -------------------------------------------------------------------------- */
#citation pre {
  background: var(--bg);
  color: var(--text);
  padding: var(--space-lg);
  border-radius: 2px;
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
}

#citation code {
  font-family: inherit;
  color: inherit;
  background: none;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
footer {
  padding: var(--space-4xl) var(--space-lg) var(--space-2xl);
  display: flex;
  justify-content: center;
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--border);
}

.footer-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-lg);
  background: var(--surface);
  padding: var(--space-sm) var(--space-lg);
  border-radius: 2px;
  border: 1px solid var(--border);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.4em 0.85em;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  text-decoration: none;
}

.footer-btn:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--surface);
  transform: translateY(-1px);
}

.footer-btn i { font-size: 0.85em; }

.footer-divider {
  width: 1px;
  height: 1.5em;
  background: var(--border);
}

.footer-license {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

.footer-license a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.footer-license a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

@media (max-width: 600px) {
  .footer-chip {
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-lg);
  }
  .footer-divider { width: 100%; height: 1px; }
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero h1 { animation: fadeIn 0.6s ease forwards; }
.hero .authors { animation: fadeIn 0.6s ease 0.1s forwards; opacity: 0; }
.hero .affiliation { animation: fadeIn 0.6s ease 0.15s forwards; opacity: 0; }
.hero .links { animation: fadeIn 0.6s ease 0.2s forwards; opacity: 0; }
.teaser { animation: fadeIn 0.6s ease 0.3s forwards; opacity: 0; }
.abstract-section { animation: fadeIn 0.6s ease 0.4s forwards; opacity: 0; }
.interactive-section { animation: fadeIn 0.6s ease 0.5s forwards; opacity: 0; }

/* Scroll animations */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .hero .authors, .hero .affiliation, .hero .links,
  .teaser, .abstract-section, .interactive-section,
  .animate-on-scroll {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  main.container-fluid { padding: 0 var(--space-lg); }
  .hero { padding: var(--space-xl) 0; }
  .hero .links { flex-direction: column; align-items: center; }
  .hero .links a[role="button"] { width: 100%; max-width: 180px; justify-content: center; }
  table { font-size: var(--text-xs); }
  table th, table td { padding: var(--space-xs) var(--space-sm); }
}

@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  .iclr-badge span { font-size: 0.6rem; }
  details.table-section summary,
  details.algorithm summary { padding: var(--space-sm) var(--space-md); }
  .table-wrapper { padding: var(--space-sm); }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
  .iclr-badge, footer, .hero .links { display: none; }
  body { font-size: 10pt; color: black; }
  details { display: block !important; }
  details > summary { display: none; }
  details > *:not(summary) { display: block !important; }
  .table-wrapper { overflow: visible; }
}
