/* ==================================================================
   Fault injection for cooperative perception: project page styles.

   Dark first: the page opts into the dark theme unless the visitor has
   explicitly chosen light, and the dark steps below are the ones that
   were tuned. Light remains fully supported through the site's own
   theme toggle.

   Every visualization colour is a CSS custom property so the canvas and
   SVG code can read it with getComputedStyle and repaint on a theme
   flip. JS never hard-codes a colour.
================================================================== */

:root {
  /* categorical agent slots: 1 is always the ego */
  --viz-s1: #2a78d6;   /* blue:    ego */
  --viz-s2: #d9622a;   /* orange:  A1 */
  --viz-s3: #0f9e75;   /* teal:    A2, also "agent loss" family */
  --viz-s4: #b58a00;   /* yellow:  A3, also "attenuated" */
  --viz-s5: #c8437f;   /* magenta: A4 */
  --viz-s6: #6b4ee6;   /* violet:  A5 */

  --viz-crit: #cf3a34; /* corrupted data family, added scatter */
  --viz-good: #17913f;
  --viz-warn: #a86e00;

  --viz-ink:   #141414;
  --viz-ink2:  #52514e;
  --viz-muted: #8b8984;
  --viz-grid:  #ece9e3;
  --viz-axis:  #c3c2b7;
  --viz-surface:  #fafaf8;
  --viz-surface2: #f1efea;
  --viz-surface3: #e8e6e0;
  --viz-border: #e4e2dc;
  --viz-halo: rgba(42, 120, 214, 0.12);

  /* BEV scene furniture */
  --viz-road:      #e6e4de;
  --viz-roadline:  #cbc9c2;
  --viz-build:     #dedcd4;
  --viz-buildline: #bcbab1;
  --viz-ghost:     rgba(20, 20, 20, 0.16);

  /* intensity ramp, low to high (viridis steps) */
  --viz-i0: #4a2064;
  --viz-i1: #3b528b;
  --viz-i2: #21918c;
  --viz-i3: #5ec962;
  --viz-i4: #d7c00a;
}

html[data-theme="dark"] {
  --viz-s1: #4a9eff;
  --viz-s2: #ff8a3d;
  --viz-s3: #23c9a0;
  --viz-s4: #f5c542;
  --viz-s5: #ff7ab6;
  --viz-s6: #a48cff;

  --viz-crit: #ff5f56;
  --viz-good: #4ade80;
  --viz-warn: #fbbf24;

  --viz-ink:   #e2e2e0;
  --viz-ink2:  #b4b4b0;
  --viz-muted: #83837f;
  --viz-grid:  #1f2126;
  --viz-axis:  #3a3c42;
  --viz-surface:  #1e1f22;
  --viz-surface2: #141518;
  --viz-surface3: #26272c;
  --viz-border: #2a2c31;
  --viz-halo: rgba(74, 158, 255, 0.18);

  --viz-road:      #202227;
  --viz-roadline:  #383b43;
  --viz-build:     #26282e;
  --viz-buildline: #3e414a;
  --viz-ghost:     rgba(226, 226, 224, 0.14);

  --viz-i0: #5c2a76;
  --viz-i1: #3b528b;
  --viz-i2: #21918c;
  --viz-i3: #5ec962;
  --viz-i4: #fde725;
}

/* ------------------------------------------------------------------
   Layout: the site's 760px column, with an escape hatch for the big
   figures on wide screens.
------------------------------------------------------------------ */

.fi-section { margin-top: 5em; scroll-margin-top: 3.4em; }

.fi-wide { position: relative; }
@media (min-width: 1060px) {
  .fi-wide {
    width: min(1020px, calc(100vw - 32px));
    left: calc((760px - min(1020px, calc(100vw - 32px))) / 2);
  }
}

/* ------------------------------------------------------------------
   Sticky in-page nav
------------------------------------------------------------------ */

.fi-toc {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--viz-border);
}
html[data-theme="dark"] .fi-toc { background: rgba(23, 24, 27, 0.9); }

.fi-toc-inner {
  max-width: min(1020px, 100vw);
  margin: 0 auto;
  padding: 0.45em 2%;
  display: flex;
  gap: 0.2em;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  box-sizing: border-box;
}
.fi-toc-inner::-webkit-scrollbar { display: none; }

.fi-toc a {
  font-size: 12.5px;
  color: var(--viz-muted);
  text-decoration: none;
  padding: 0.25em 0.65em;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.fi-toc a:hover { color: var(--viz-ink); }
.fi-toc a.is-active {
  color: var(--viz-ink);
  border-color: var(--viz-border);
  background: var(--viz-surface);
}

/* ------------------------------------------------------------------
   Hero
------------------------------------------------------------------ */

.fi-hero { text-align: center; padding-top: 1.4em; margin-bottom: 1em; }

.fi-venue {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--viz-muted);
  margin-bottom: 0.4em;
}

.fi .fi-title {
  font-size: 40px;
  line-height: 1.12;
  border-bottom: none;
  margin: 0 0 0.35em;
  padding-bottom: 0;
  text-align: center;
}

.fi-subtitle {
  font-size: 1.16em;
  color: var(--viz-ink);
  max-width: 30em;
  margin: -0.15em auto 0.9em;
  line-height: 1.35;
}

.fi-tagline {
  font-size: 1.02em;
  color: var(--viz-ink2);
  max-width: 36em;
  margin: 0 auto 1.3em;
}

.fi-authors { margin-bottom: 0.2em; font-size: 1.02em; }
.fi-author { margin: 0 0.8em; white-space: nowrap; }
.fi-affils {
  color: var(--viz-muted);
  font-size: 0.85em;
  margin-top: 0;
  line-height: 1.5;
}

.fi-badge-wip {
  border-color: var(--viz-warn);
  color: var(--viz-ink2);
}
.fi-badge-wip b { color: var(--viz-warn); }

.fi-hero-lede {
  max-width: 40em;
  margin: 0 auto 1.4em;
  text-align: left;
  font-size: 0.98em;
}

.fi-hero-links { margin: 1.2em 0 0.4em; }

.fi-btn {
  display: inline-block;
  margin: 0.25em 0.3em;
  padding: 0.4em 1.1em;
  border: 1px solid var(--viz-axis);
  border-radius: 99px;
  font-size: 0.86em;
  color: var(--viz-ink) !important;
  background: var(--viz-surface);
  background-image: none !important;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.fi-btn:hover {
  border-color: var(--viz-ink);
  text-decoration: none;
  transform: translateY(-1px);
}

/* inline-block, not inline-flex: a flex gap would insert space between the
   text runs inside the badge and push punctuation away from its word */
.fi-badge {
  display: inline-block;
  font-size: 0.76em;
  color: var(--viz-ink2);
  background: var(--viz-surface);
  border: 1px solid var(--viz-border);
  border-radius: 99px;
  padding: 0.3em 0.9em;
  margin: 0.4em 0.2em;
}
.fi-badge b { font-weight: bold; color: var(--viz-ink); }

/* ------------------------------------------------------------------
   Typography helpers
------------------------------------------------------------------ */

.fi-kicker {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--viz-muted);
  margin-bottom: 0.2em;
}

.fi .fi-h2 {
  font-size: 27px;
  border-bottom: none;
  margin-top: 0.2em;
  padding-bottom: 0;
}
.fi .fi-h3 { font-size: 19px; margin-top: 1.8em; }

.fi-one-line {
  font-size: 1.12em;
  color: var(--viz-ink);
  border-left: 3px solid var(--viz-s1);
  padding-left: 0.9em;
  margin: 1em 0 1.4em;
}

.fi-punch {
  font-size: 1.06em;
  border-left: 3px solid var(--viz-crit);
  padding-left: 0.9em;
  margin: 1.6em 0;
}

.fi-callout {
  background: var(--viz-surface);
  border: 1px solid var(--viz-border);
  border-left: 3px solid var(--viz-s1);
  border-radius: 8px;
  padding: 0.9em 1.2em;
  margin: 1.5em 0;
}
.fi-callout p { margin: 0; }
.fi-callout p + p { margin-top: 0.6em; }
.fi-callout-warn { border-left-color: var(--viz-crit); }

.fi-note { font-size: 0.82em; color: var(--viz-muted); margin: 0.5em 0 0; }
.fi-disclaimer { font-size: 0.78em; color: var(--viz-muted); font-style: italic; }

/* ------------------------------------------------------------------
   Widget cards
------------------------------------------------------------------ */

.fi-widget {
  display: block;
  background: var(--viz-surface);
  border: 1px solid var(--viz-border);
  border-radius: 12px;
  padding: 1.1em 1.2em 1em;
  margin: 1.6em 0;
  text-align: left;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.fi-widget canvas { width: 100%; display: block; border-radius: 8px; }
.fi-widget svg { max-width: 100%; display: block; }

.fi-widget-head { margin-bottom: 0.8em; }
.fi-widget-title { display: block; font-weight: bold; font-size: 0.95em; }
.fi-widget-sub {
  display: block;
  font-size: 0.8em;
  color: var(--viz-muted);
  margin-top: 0.15em;
}

/* main canvas + side panel */
.fi-panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.95fr);
  gap: 1.2em;
  align-items: start;
}
@media (max-width: 820px) {
  .fi-panel-grid { grid-template-columns: 1fr; }
}

.fi-panel-side > * + * { margin-top: 1em; }

/* two equal panels (BEV beside fusion graph) */
.fi-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.2em;
  align-items: start;
}
@media (max-width: 820px) { .fi-two { grid-template-columns: 1fr; } }

.fi-panel-label {
  display: block;
  font-size: 0.76em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--viz-muted);
  margin-bottom: 0.4em;
}

/* ------------------------------------------------------------------
   Controls
------------------------------------------------------------------ */

.fi-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5em 1em;
  margin-top: 0.9em;
  padding-top: 0.8em;
  border-top: 1px dashed var(--viz-border);
}

.fi-ctl {
  background: none;
  border: 1px solid var(--viz-axis);
  border-radius: 6px;
  color: var(--viz-ink);
  font-size: 13px;
  line-height: 1;
  width: 44px;
  height: 30px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.fi-ctl:hover { border-color: var(--viz-ink); }
.fi-ctl.is-playing { background: var(--viz-halo); }

.fi-ctl-text {
  background: none;
  border: 1px solid var(--viz-axis);
  border-radius: 6px;
  color: var(--viz-ink);
  font-family: inherit;
  font-size: 0.82em;
  padding: 0.35em 0.9em;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.fi-ctl-text:hover { border-color: var(--viz-ink); }

.fi-field { font-size: 0.8em; color: var(--viz-ink2); }
.fi-field select {
  font-family: inherit;
  font-size: 1em;
  margin-left: 0.3em;
  background: var(--viz-surface);
  color: var(--viz-ink);
  border: 1px solid var(--viz-axis);
  border-radius: 6px;
  padding: 0.15em 0.35em;
}

.fi-scrub {
  flex: 1 1 180px;
  font-size: 0.8em;
  color: var(--viz-ink2);
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.fi-scrub input[type="range"] { flex: 1; accent-color: var(--viz-s1); }

/* --- the shared scene bar (agent count + reseed) ------------------ */

.fi-scene-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6em 1.2em;
  background: var(--viz-surface2);
  border: 1px solid var(--viz-border);
  border-radius: 10px;
  padding: 0.7em 1em;
  margin: 1.2em 0;
}
.fi-scene-bar label {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: 0.83em;
  color: var(--viz-ink2);
  flex: 1 1 240px;
}
.fi-scene-bar input[type="range"] { flex: 1; min-width: 110px; accent-color: var(--viz-s1); }
.fi-scene-count {
  font-size: 0.83em;
  color: var(--viz-ink);
  font-variant-numeric: tabular-nums;
  min-width: 15em;
}
.fi-scene-hint { font-size: 0.78em; color: var(--viz-muted); flex-basis: 100%; margin: 0; }

/* --- severity slider with four labelled stops --------------------- */

.fi-sev { margin: 0; }
.fi-sev-label {
  display: block;
  font-size: 0.76em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--viz-muted);
  margin-bottom: 0.3em;
}
.fi-sev-now {
  text-transform: none;
  letter-spacing: 0;
  color: var(--viz-ink);
  font-size: 1.15em;
  margin-left: 0.5em;
  font-variant-numeric: tabular-nums;
}
.fi-sev-range {
  display: block;
  width: 100%;
  margin: 0.2em 0 0.35em;
  accent-color: var(--viz-crit);
}
.fi-sev-ticks {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.2em;
}
.fi-sev-ticks button {
  background: none;
  border: none;
  border-top: 2px solid var(--viz-border);
  padding: 0.35em 0.1em 0;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  color: var(--viz-muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.fi-sev-ticks button:first-child { text-align: left; }
.fi-sev-ticks button:last-child { text-align: right; }
.fi-sev-ticks button:hover { color: var(--viz-ink); }
.fi-sev-ticks button[aria-current="true"] {
  color: var(--viz-ink);
  border-top-color: var(--viz-crit);
}
.fi-tick-name { display: block; font-size: 12px; }
.fi-tick-val { display: block; font-size: 10.5px; opacity: 0.75; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------
   Readouts
------------------------------------------------------------------ */

.fi-stat + .fi-stat { margin-top: 0.9em; }
.fi-stat-label {
  display: block;
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--viz-muted);
}
.fi-stat-value {
  display: block;
  font-size: 1.75em;
  font-weight: bold;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--viz-ink);
}
.fi-stat-value.fi-bad { color: var(--viz-crit); }
.fi-of { font-size: 0.55em; font-weight: normal; color: var(--viz-muted); }
.fi-stat-sub { display: block; font-size: 0.76em; color: var(--viz-muted); margin-top: 0.1em; }
.fi-stat-row { display: flex; gap: 1.6em; flex-wrap: wrap; }
.fi-stat-row .fi-stat + .fi-stat { margin-top: 0; }

.fi-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 1em;
  font-size: 0.78em;
  color: var(--viz-ink2);
  margin-bottom: 0.8em;
}
.fi-legend i {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  margin-right: 0.4em;
}

.fi-chip {
  display: inline-block;
  font-size: 0.75em;
  color: var(--viz-ink2);
  border: 1px solid var(--viz-border);
  border-left: 3px solid var(--c, var(--viz-s1));
  border-radius: 4px;
  padding: 0.15em 0.55em;
  margin: 0.2em 0.3em 0.2em 0;
  font-variant-numeric: tabular-nums;
}
.fi-chip-total { border-left-color: var(--viz-muted); font-weight: bold; }

.fi-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 0.4em;
}

/* small tables inside readouts */
.fi-mini { width: 100%; border-collapse: collapse; font-size: 0.76em; margin-top: 0.4em; }
.fi-mini caption {
  text-align: left;
  color: var(--viz-muted);
  font-size: 0.95em;
  padding-bottom: 0.3em;
}
.fi-mini th, .fi-mini td {
  text-align: left;
  padding: 0.22em 0.4em 0.22em 0;
  border-bottom: 1px solid var(--viz-border);
  font-variant-numeric: tabular-nums;
  font-weight: normal;
}
.fi-mini thead th { color: var(--viz-muted); font-size: 0.92em; }

/* per-agent bar rows */
.fi-bars { margin-top: 0.9em; }
.fi-bar-row {
  display: grid;
  grid-template-columns: 2.6em 1fr 3.4em;
  align-items: center;
  gap: 0.5em;
  font-size: 0.76em;
  color: var(--viz-ink2);
  margin: 0.25em 0;
  font-variant-numeric: tabular-nums;
}
.fi-bar-row > span:last-child { text-align: right; }
.fi-bar {
  height: 6px;
  background: var(--viz-surface3);
  border-radius: 3px;
  overflow: hidden;
}
.fi-bar i { display: block; height: 100%; border-radius: 3px; transition: width 0.2s ease; }

/* ------------------------------------------------------------------
   Measured-numbers table
------------------------------------------------------------------ */

.fi-nums table { width: 100%; border-collapse: collapse; font-size: 0.8em; }
.fi-nums caption {
  text-align: left;
  font-size: 0.9em;
  color: var(--viz-muted);
  padding-bottom: 0.45em;
  line-height: 1.4;
}
.fi-nums th, .fi-nums td {
  text-align: right;
  padding: 0.3em 0.35em;
  border-bottom: 1px solid var(--viz-border);
  font-variant-numeric: tabular-nums;
}
.fi-nums thead th {
  color: var(--viz-muted);
  font-weight: normal;
  font-size: 0.92em;
  border-bottom-color: var(--viz-axis);
}
.fi-nums tbody th { text-align: left; font-weight: normal; color: var(--viz-ink2); }
.fi-nums thead th:first-child, .fi-nums tbody td:first-of-type { text-align: left; }
.fi-nums .fi-num-key { color: var(--viz-ink); font-weight: bold; }
.fi-nums tbody tr { transition: background 0.15s ease; }
.fi-nums tbody tr.is-active {
  background: var(--viz-halo);
  box-shadow: inset 3px 0 0 var(--viz-crit);
}
.fi-na { color: var(--viz-muted); font-style: italic; }
.fi-nums-note { font-size: 0.75em; color: var(--viz-muted); margin: 0.5em 0 0; }

/* ------------------------------------------------------------------
   AgentDrop vs MissingModality contrast
------------------------------------------------------------------ */

.fi-cmp-row {
  display: grid;
  grid-template-columns: 11em 1fr 4.4em 4.4em;
  align-items: center;
  gap: 0.6em;
  margin: 0.5em 0;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}
.fi-cmp-name { font-weight: bold; min-width: 0; overflow-wrap: anywhere; }
.fi-cmp-bar {
  height: 10px;
  background: var(--viz-surface3);
  border-radius: 5px;
  overflow: hidden;
}
.fi-cmp-bar i { display: block; height: 100%; border-radius: 5px; transition: width 0.25s ease; }
.fi-cmp-val { text-align: right; color: var(--viz-ink); }
.fi-cmp-dim { color: var(--viz-muted); }
.fi-cmp-legend { font-size: 0.75em; color: var(--viz-muted); margin-top: 0.4em; }
.fi-cmp-gap {
  font-size: 0.88em;
  margin: 0.9em 0 0;
  padding-top: 0.7em;
  border-top: 1px dashed var(--viz-border);
}

@media (max-width: 560px) {
  .fi-cmp-row { grid-template-columns: minmax(0, 1fr) 3.9em 3.9em; }
  .fi-cmp-bar { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------------
   Ranking chart
------------------------------------------------------------------ */

.fi-rank-row {
  display: grid;
  grid-template-columns: 12.5em 1fr 4.6em;
  align-items: center;
  gap: 0.7em;
  padding: 0.42em 0.3em;
  border-radius: 6px;
  text-decoration: none !important;
  color: var(--viz-ink) !important;
  background-image: none !important;
  transition: background 0.15s ease;
}
.fi-rank-row:hover { background: var(--viz-surface2); }
.fi-rank-name { font-size: 0.88em; }
.fi-rank-unit { color: var(--viz-muted); font-size: 0.82em; margin-left: 0.5em; }
.fi-rank-bar {
  height: 13px;
  background: var(--viz-surface3);
  border-radius: 3px;
  overflow: hidden;
}
.fi-rank-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.fi-rank-val { text-align: right; font-size: 0.88em; font-variant-numeric: tabular-nums; }
.fi-rank-row.is-na .fi-rank-val { font-size: 0.72em; }

.fi-rank-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 1.2em;
  font-size: 0.78em;
  color: var(--viz-ink2);
  margin-top: 0.9em;
  padding-top: 0.7em;
  border-top: 1px dashed var(--viz-border);
}
.fi-rank-key i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 0.4em;
}
.fi-rank-scale { color: var(--viz-muted); margin-left: auto; }

@media (max-width: 620px) {
  .fi-rank-row { grid-template-columns: 1fr 4.4em; }
  .fi-rank-bar { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------------
   Tabs and step groups
------------------------------------------------------------------ */

.fi-tabs { display: flex; flex-wrap: wrap; gap: 0.35em; margin: 0.8em 0; }
.fi-tabs button {
  background: none;
  border: 1px solid var(--viz-border);
  border-radius: 99px;
  color: var(--viz-muted);
  font-family: inherit;
  font-size: 13px;
  padding: 0.3em 0.9em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.fi-tabs button:hover { color: var(--viz-ink); }
.fi-tabs button[aria-selected="true"] {
  color: var(--viz-ink);
  border-color: var(--viz-s1);
  background: var(--viz-halo);
}
.fi-tabs-label {
  font-size: 0.76em;
  color: var(--viz-muted);
  align-self: center;
  margin-right: 0.2em;
}

/* ------------------------------------------------------------------
   Cards
------------------------------------------------------------------ */

.fi-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9em;
  margin: 1.4em 0;
}
@media (max-width: 640px) { .fi-cards { grid-template-columns: 1fr; } }

.fi-card {
  background: var(--viz-surface);
  border: 1px solid var(--viz-border);
  border-radius: 10px;
  padding: 1em 1.1em;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}
.fi .fi-card h3 { font-size: 15.5px; margin: 0 0 0.4em; }
.fi-card p { font-size: 0.85em; margin: 0; color: var(--viz-ink2); }
.fi-card-out { border-left: 3px solid var(--viz-muted); }

/* ------------------------------------------------------------------
   Optional real-data layer
------------------------------------------------------------------ */

.fi-real-host[hidden] { display: none; }
.fi-real-box { margin-top: 0.8em; }
.fi-real-box video, .fi-real-box img {
  width: 100%;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--viz-border);
}

/* ------------------------------------------------------------------
   Tooltip
------------------------------------------------------------------ */

.fi-tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: var(--viz-ink);
  color: var(--viz-surface);
  font-size: 12px;
  line-height: 1.45;
  border-radius: 6px;
  padding: 0.4em 0.65em;
  max-width: 240px;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
html[data-theme="dark"] .fi-tooltip { background: #f0f0ee; color: #17181b; }
.fi-tooltip.is-visible { opacity: 0.96; transform: none; }

/* ------------------------------------------------------------------
   Resources
------------------------------------------------------------------ */

.fi-resources { padding-left: 1.2em; }
.fi-resources li { margin: 0.5em 0; }

.fi-codebox { position: relative; margin-top: 1em; }
.fi-codebox pre {
  background: var(--viz-surface2);
  border: 1px solid var(--viz-border);
  border-radius: 8px;
  padding: 0.9em 1em;
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
  max-width: calc(100vw - 3.5em);
  box-sizing: border-box;
  color: var(--viz-ink2);
}
.fi-copy {
  position: absolute;
  top: 0.5em; right: 0.5em;
  background: var(--viz-surface);
  border: 1px solid var(--viz-axis);
  border-radius: 5px;
  color: var(--viz-ink2);
  font-family: inherit;
  font-size: 11px;
  padding: 0.15em 0.5em;
  cursor: pointer;
}

/* ------------------------------------------------------------------
   Scroll reveal (collapses under reduced motion)
------------------------------------------------------------------ */

.fi-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.fi-reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .fi-reveal { opacity: 1; transform: none; transition: none; }
  .fi-btn, .fi-toc a, .fi-tooltip, .fi-rank-bar i, .fi-cmp-bar i, .fi-bar i {
    transition: none;
  }
  html { scroll-behavior: auto; }
}

/* KaTeX inline snippets should not blow up line height */
.fi-math .katex { font-size: 1em !important; }
