:root {
  --bg: #0b0b0f;
  --panel: #12121a;
  --panel-2: #151520;
  --border: #232334;
  --text: #f2f2f6;
  --muted: #a5a5b5;
  --accent: #fd6a8e;
  --accent-soft: rgba(253, 106, 142, 0.15);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

html {
  /*
   * IMPORTANT (Safari rubber-band overscroll):
   * The overscroll/bounce area is painted by stretching the *root background*.
   * Pseudo-elements/overlays frequently won't paint there, causing visible seams.
   *
   * So: bake the "fog" into html's background itself, on top of your original base gradient.
   */
  background-color: var(--bg);
  background-image:
    /* Fog (top): huge + low-contrast so it doesn't create a hard edge when stretched */
    radial-gradient(1400px 900px at 50% -300px, rgba(21, 21, 32, 0.28) 0%, rgba(21, 21, 32, 0.16) 40%, rgba(21, 21, 32, 0) 78%),
    /* Fog (bottom): same idea, extends beyond bottom */
    radial-gradient(1400px 900px at 50% calc(100% + 300px), rgba(21, 21, 32, 0.20) 0%, rgba(21, 21, 32, 0.10) 45%, rgba(21, 21, 32, 0) 80%),
    /* Original base background */
    radial-gradient(circle at top, #13131c 0%, #0b0b0f 40%, #08080c 100%);
  background-repeat: no-repeat;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "SF Pro Text", "Inter", system-ui, -apple-system, sans-serif;
  /* Let the html root background paint (including during overscroll) */
  background: transparent;
  color: var(--text);
  overflow-x: hidden;
}

/* Global link styling */
a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: underline;
}

a:visited {
  color: var(--accent);
}

/* Fingerprint background animation container */
.fingerprint-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.fingerprint-ghost {
  --fp-rotation: 0deg;
  position: absolute;
  width: 120px;
  height: 150px;
  opacity: 0;
  filter: blur(0.3px);
  animation: fingerprint-press 3.5s ease-out forwards;
  will-change: transform, opacity;
}

.fingerprint-ghost svg {
  width: 100%;
  height: 100%;
}

@keyframes fingerprint-press {
  0% {
    opacity: 0;
    transform: scale(0.7) rotate(var(--fp-rotation));
  }
  12% {
    opacity: 0.4;
    transform: scale(1) rotate(var(--fp-rotation));
  }
  35% {
    opacity: 0.3;
    transform: scale(1.02) rotate(var(--fp-rotation));
  }
  100% {
    opacity: 0;
    transform: scale(1.05) rotate(var(--fp-rotation));
  }
}

/* Slight variation for visual interest */
.fingerprint-ghost.variant-2 {
  animation: fingerprint-press-slow 4.5s ease-out forwards;
}

@keyframes fingerprint-press-slow {
  0% {
    opacity: 0;
    transform: scale(0.8) rotate(var(--fp-rotation));
  }
  18% {
    opacity: 0.35;
    transform: scale(1) rotate(var(--fp-rotation));
  }
  45% {
    opacity: 0.25;
    transform: scale(1.01) rotate(var(--fp-rotation));
  }
  100% {
    opacity: 0;
    transform: scale(1.03) rotate(var(--fp-rotation));
  }
}

.fingerprint-ghost.variant-3 {
  animation: fingerprint-press-quick 2.5s ease-out forwards;
}

@keyframes fingerprint-press-quick {
  0% {
    opacity: 0;
    transform: scale(0.75) rotate(var(--fp-rotation));
  }
  10% {
    opacity: 0.45;
    transform: scale(0.98) rotate(var(--fp-rotation));
  }
  28% {
    opacity: 0.32;
    transform: scale(1) rotate(var(--fp-rotation));
  }
  100% {
    opacity: 0;
    transform: scale(1.02) rotate(var(--fp-rotation));
  }
}

body.is-loading {
  overflow: hidden;
}

body.is-loading .page {
  visibility: hidden;
}

.page {
  /* Keep content more "squeezed" in the center on large screens */
  width: min(100%, 1160px);
  max-width: 1160px;
  margin: 0 auto;
  /* More generous gutters on larger screens */
  padding: 64px 22px 120px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
  z-index: 2;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero.centered {
  align-items: center;
  text-align: center;
}

.hero-logo-link {
  display: inline-block;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hero-logo-link:hover {
  opacity: 0.85;
  transform: scale(1.02);
}

.hero-logo {
  height: 24px;
  width: auto;
  margin-bottom: 8px;
  object-fit: contain;
  display: block;
}

.hero-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
}

.hero-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.hero-icon-link:hover {
  opacity: 0.85;
}

.hero-icon {
  height: 28px;
  width: auto;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 12px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 44px);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, rgba(19, 19, 28, 0.9) 0%, rgba(11, 11, 15, 0.95) 55%, rgba(8, 8, 12, 0.98) 100%);
  z-index: 10;
}

body.is-loading .loading-overlay {
  display: flex;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 16px;
  background: #101018;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.loading-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loading-title {
  font-size: 15px;
  font-weight: 600;
}

.loading-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Controls bar — compact row with Settings + actions aligned right */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

/* Settings dropdown */
.controls-dropdown {
  position: relative;
  z-index: 20;
}

.controls-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.controls-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.controls-trigger[aria-expanded="true"] {
  background: rgba(253, 106, 142, 0.08);
  border-color: rgba(253, 106, 142, 0.3);
  color: var(--accent);
}

.controls-chevron {
  transition: transform 0.25s ease;
}

.controls-trigger[aria-expanded="true"] .controls-chevron {
  transform: rotate(180deg);
}

/* Dropdown panel — overlays content below, aligned to right edge */
.controls-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: rgba(16, 16, 24, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
  min-width: max-content;
}

.controls-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
}

.controls-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control.control-button {
  min-width: auto;
}

.control.control-button label {
  visibility: hidden;
  height: 12px;
}

.control.control-button.hidden {
  display: none;
}

.control label {
  font-size: 12px;
  color: var(--muted);
}

.control select,
.control input {
  background: #0e0e14;
  border: 1px solid #1c1c28;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: none;
  min-width: 110px;
  max-width: 160px;
}

.control select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23a5a5b5' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
}

.control input:focus,
.control select:focus {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Disabled control state */
.control.is-disabled label {
  color: rgba(165, 165, 181, 0.4);
}

.control.is-disabled select,
.control.is-disabled input {
  background: rgba(14, 14, 20, 0.5);
  border-color: rgba(28, 28, 40, 0.5);
  color: rgba(242, 242, 246, 0.35);
  cursor: not-allowed;
  opacity: 0.6;
}

.control.is-disabled select:focus,
.control.is-disabled input:focus {
  outline: none;
  box-shadow: none;
}

.icon-btn {
  border: 1px solid var(--border);
  background: #0f0f16;
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative; /* anchor tooltip */
  transition: border-color 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--text);
}

#downloadBtn svg {
  width: 14px;
  height: 14px;
}

#savePlotsBtn svg {
  width: 14px;
  height: 14px;
}

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

/* Fast hover tooltips for action icons (avoid native title tooltip delay) */
.icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #1a1a2e;
  color: rgba(245, 245, 252, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  width: 220px;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.icon-btn[data-tooltip]:hover::after {
  opacity: 1;
}

.table-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}

/* Plot section gets soft fading edges - fingerprints show through at borders */
.plot-section {
  position: relative;
  z-index: 2;
  padding: 20px;
  background: transparent;
}

/* Soft glowing background that blends into the page */
.plot-section::before {
  content: '';
  position: absolute;
  /* Very small inset = fade starts very close to edges */
  inset: 3px;
  background: var(--panel-2);
  border-radius: 22px;
  z-index: -1;
  pointer-events: none;
  /* Blur creates soft edges that blend into background */
  filter: blur(25px);
  opacity: 0.95;
}

/* Secondary layer for more solid center */
.plot-section::after {
  content: '';
  position: absolute;
  inset: 9px 12px;
  background: var(--panel-2);
  border-radius: 18px;
  z-index: -1;
  pointer-events: none;
  filter: blur(12px);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.table-header h2 {
  margin: 0;
  font-size: 20px;
}

.table-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Leaderboard rank metric toggle */
.rank-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rank-toggle-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 2px;
}

.rank-toggle-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(245, 245, 252, 0.85);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.rank-toggle-btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.rank-toggle-btn.is-active,
.rank-toggle-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: rgba(253, 106, 142, 0.40);
  color: var(--accent);
}

.plot {
  width: 100%;
  height: 640px;
}

/* Two plots side-by-side (responsive) */
.plots-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.plot-panel {
  min-width: 0; /* allow Plotly to size correctly inside grid */
}

.plot-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 10px 0 4px;
}

.plot-title.centered {
  text-align: center;
}

/* Info icon next to plot titles */
.title-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.title-info:hover {
  background: rgba(253, 106, 142, 0.15);
  color: var(--accent);
  border-color: rgba(253, 106, 142, 0.4);
}

.title-info::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: rgba(245, 245, 252, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  width: 280px;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 30; /* above Settings dropdown (z-index: 20) */
}

.title-info:hover::after {
  opacity: 1;
}

.plot-wrapper {
  position: relative;
}


/* Axis info icons (?) positioned near Plotly axis labels */
.axis-info {
  position: absolute;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  z-index: 5;
  transition: background 0.15s ease, color 0.15s ease;
}

.axis-info:hover {
  background: rgba(253, 106, 142, 0.15);
  color: var(--accent);
  border-color: rgba(253, 106, 142, 0.4);
}

/* Positioned dynamically by JS after Plotly render — see positionAxisIcons() */
.axis-info-x,
.axis-info-y {
  /* starts hidden until JS positions them */
  visibility: hidden;
}

.axis-info-x.positioned,
.axis-info-y.positioned {
  visibility: visible;
}

/* Tooltip */
.axis-info::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: rgba(245, 245, 252, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  width: 220px;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.axis-info:hover::after {
  opacity: 1;
}

.plots-grid .plot {
  height: 560px;
}

.scheme-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  margin: 10px 0 4px;
  padding: 2px 0;
}

.scheme-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(16, 16, 24, 0.35);
  cursor: pointer;
  user-select: none;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
}

.scheme-legend-item:hover {
  border-color: rgba(255,255,255,0.18);
}

.scheme-legend-swatch {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35) inset;
  flex: 0 0 auto;
}

.scheme-legend-item.is-selected {
  color: rgba(245,245,252,0.95);
  border-color: rgba(245,245,252,0.22);
  background: rgba(253, 106, 142, 0.10);
}

@media (max-width: 860px) {
  .plots-grid {
    grid-template-columns: 1fr;
  }
  .plots-grid .plot {
    height: 520px;
  }
}

/* Plotly hoverlabel transparency workaround */
.plot g.hovertext > path {
  opacity: 0.50;
}

/* Point type legend */
.point-type-legend {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
  margin-top: -8px;
}

.legend-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Animated legend items — two-phase: fully fade out THEN collapse (or expand THEN fade in) */
.legend-item-animated {
  overflow: hidden;
  white-space: nowrap;
  max-width: 250px;
  opacity: 1;
  /* Appearing: expand instantly, then fade in after space is made */
  transition: max-width 0.01s ease, opacity 0.3s ease 0.05s;
}

.legend-item-animated.is-hidden {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
  /* Disappearing: fade out fast (150ms), then collapse AFTER fully invisible (delay 180ms) */
  transition: opacity 0.15s ease, max-width 0.01s ease 0.18s;
}

.legend-item.hidden {
  display: none;
}

.legend-marker {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #888;
}

.legend-marker.cross {
  background: transparent;
  position: relative;
  width: 12px;
  height: 12px;
}

.legend-marker.cross::before,
.legend-marker.cross::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 2px;
  background: #888;
}

.legend-marker.cross::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.legend-marker.cross::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Detectability curve legend marker (matches dashed curve outlines) */
.legend-marker.detectability {
  background: transparent;
  width: 18px;
  height: 0;
  border-top: 2px dashed rgba(245, 245, 252, 0.55);
}

/* Uninformed Attack line legend marker (dotted line) */
.legend-marker.uninformed-line {
  background: transparent;
  width: 18px;
  height: 0;
  border-top: 2px dotted rgba(245, 245, 252, 0.5);
}

/* Config view button (appears when specific config selected) */
.config-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(253, 106, 142, 0.12);
  border: 1px solid rgba(253, 106, 142, 0.3);
  border-radius: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  position: relative; /* anchor tooltip */
  transition: background 0.15s ease, border-color 0.15s ease;
  height: 30px;
}

.config-download-btn:hover {
  background: rgba(253, 106, 142, 0.25);
  border-color: var(--accent);
}

.config-download-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #1a1a2e;
  color: rgba(245, 245, 252, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  width: 220px;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.config-download-btn[data-tooltip]:hover::after {
  opacity: 1;
}

/* Fast tooltip for disabled controls in Settings (e.g., fingerprint config selector) */
.control[data-tooltip] {
  position: relative;
}

.control[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #1a1a2e;
  color: rgba(245, 245, 252, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  width: 240px;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.control[data-tooltip]:hover::after {
  opacity: 1;
}

.config-download-btn.hidden {
  display: none;
}

/* Mode toggle (Absolute/Relative) — minimal, no bounding box */
#modeToggleControl {
  margin-left: 6px;
}

.mode-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px; /* match select height for vertical alignment */
  transition: opacity 0.3s ease;
}

.mode-toggle-container.hidden {
  display: none;
}

.mode-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.mode-label.active {
  color: var(--accent);
}

.mode-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.mode-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.mode-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.25s ease, background 0.25s ease;
}

.mode-toggle input:checked + .mode-slider {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.mode-toggle input:checked + .mode-slider::before {
  transform: translateX(16px);
  background: var(--accent);
}

.mode-toggle:hover .mode-slider {
  border-color: rgba(255, 255, 255, 0.35);
}

.mode-toggle input:checked:hover + .mode-slider {
  border-color: var(--accent);
}

/* Credible-interval legend marker (vertical error bar) */
.legend-marker.ci {
  background: transparent;
  width: 14px;
  height: 12px;
  border-radius: 2px;
  position: relative;
  /* Center vertical bar */
  background-image: linear-gradient(
    to right,
    transparent calc(50% - 1px),
    rgba(245, 245, 252, 0.55) calc(50% - 1px),
    rgba(245, 245, 252, 0.55) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
}

.legend-marker.ci::before,
.legend-marker.ci::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 2px;
  background: rgba(245, 245, 252, 0.55);
}

.legend-marker.ci::before {
  top: 0;
}

.legend-marker.ci::after {
  bottom: 0;
}

.chip {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(253, 106, 142, 0.4);
}

.chip.hidden {
  display: none;
}

.qa-section {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}

.qa-section h2 {
  margin: 0 0 20px;
  font-size: 20px;
}

.qa-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 193, 7, 0.35);
  border-radius: 10px;
  margin-bottom: 20px;
  color: rgba(255, 235, 59, 0.95);
  font-size: 14px;
  line-height: 1.5;
}

.qa-warning .warning-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
  color: rgba(255, 193, 7, 0.9);
}

.qa-warning strong {
  color: rgba(255, 235, 59, 1);
  font-weight: 600;
}

.qa-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qa-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #101018;
  transition: border-color 0.2s ease;
}

.qa-item:hover {
  border-color: rgba(253, 106, 142, 0.4);
}

.qa-item.is-open {
  border-color: var(--accent);
}

.qa-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s ease;
}

.qa-question:hover {
  color: var(--accent);
}

.qa-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-left: 16px;
  color: var(--muted);
  transition: transform 0.3s ease, color 0.2s ease;
}

.qa-item.is-open .qa-icon {
  transform: rotate(180deg);
  color: var(--accent);
}

.qa-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.qa-answer p {
  margin: 0 0 12px;
  padding: 0 18px 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.qa-answer p:last-child {
  margin-bottom: 0;
  padding-bottom: 18px;
}

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

.qa-answer code {
  background: rgba(253, 106, 142, 0.15);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
}

.qa-answer pre {
  background: #0e0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
}

.qa-answer pre code {
  background: transparent;
  color: var(--text);
  padding: 0;
}

.qa-answer ul {
  margin: 12px 0;
  padding-left: 24px;
  color: var(--muted);
}

.qa-answer li {
  margin: 6px 0;
  line-height: 1.6;
}

.leaderboard-nav {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.nav-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #101018;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
}

.nav-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  display: grid;
  place-items: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-btn svg {
  width: 16px;
  height: 16px;
}

.nav-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-label {
  font-size: 13px;
  color: var(--muted);
  min-width: 140px;
  text-align: center;
}

.nav-label strong {
  color: var(--text);
}

.no-data-message {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-top: 8px;
}

.no-data-message.hidden {
  display: none;
}

#leaderboard {
  margin-top: 8px;
  overflow-x: auto;
}

.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.simple-table thead {
  background: #101018;
}

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

.simple-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  position: relative;
  padding-right: 22px;
}

/* Column header tooltip "?" icon */
.th-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.th-info:hover {
  background: rgba(253, 106, 142, 0.15);
  color: var(--accent);
  border-color: rgba(253, 106, 142, 0.4);
}

/* Body-level tooltip for table header icons (escapes overflow containers) */
.th-tooltip {
  position: fixed;
  transform: translateX(-50%) translateY(-100%);
  background: #1a1a2e;
  color: rgba(245, 245, 252, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  width: 220px;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.th-tooltip.is-visible {
  opacity: 1;
}

.simple-table th::after {
  content: "▴";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-60%);
  font-size: 20px;
  color: var(--accent);
  opacity: 0;
}

.simple-table th.is-sorted::after {
  opacity: 1;
}

.simple-table th.is-sorted.desc::after {
  content: "▾";
}

.simple-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.simple-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.simple-table tbody tr.is-selected {
  background: rgba(253, 106, 142, 0.18);
}

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

.simple-table a:hover {
  text-decoration: underline;
}

.config-buttons {
  display: flex;
  gap: 6px;
}

.config-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  background: rgba(253, 106, 142, 0.12);
  border: 1px solid rgba(253, 106, 142, 0.3);
  border-radius: 6px;
  color: var(--accent);
  font-size: 11px;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.config-btn:hover {
  background: rgba(253, 106, 142, 0.25);
  border-color: var(--accent);
  text-decoration: none;
}

/* Config Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-close:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
}

.modal-body pre {
  margin: 0;
  background: #0a0a0f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}

.modal-body code {
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  color: var(--text);
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn-download svg {
  width: 16px;
  height: 16px;
}

.btn-download:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Site footer */
.site-footer {
  text-align: center;
  padding: 40px 20px 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.footer-tagline {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.footer-tagline:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.footer-copyright {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .page {
    padding: 20px 14px 64px;
    gap: 20px;
  }

  .table-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .plot {
    height: 440px;
  }

  .control select,
  .control input {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  /* Leaderboard nav: full-width, easier tap targets */
  .leaderboard-nav {
    gap: 10px;
  }

  .nav-control {
    width: 100%;
    justify-content: space-between;
  }

  .nav-label {
    min-width: 0;
    flex: 1;
    text-align: center;
  }

  .nav-btn {
    width: 34px;
    height: 34px;
  }
}

/* Citation section */
.cite-section {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}

.cite-section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.cite-intro {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.cite-block {
  margin-bottom: 14px;
}

.cite-block:last-child {
  margin-bottom: 0;
}

.cite-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cite-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.cite-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cite-copy-btn:hover {
  background: rgba(253, 106, 142, 0.12);
  color: var(--accent);
  border-color: rgba(253, 106, 142, 0.3);
}

.cite-copy-btn.copied {
  color: rgba(245, 245, 252, 0.7);
  border-color: rgba(245, 245, 252, 0.3);
}

.cite-bibtex {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(245, 245, 252, 0.82);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
