  /* ─── Data visuals ──────────────────────────────────────────────────────────
     Theme-aware figures, bar charts, timelines, a line chart and a flowchart.
     Split into its own file (served as a static asset by the Cloudflare Workers
     deploy alongside styles.css). Built per the official data-viz rules: bars
     are zero-baseline (width %), no pie/3D, every series labelled. All render
     correctly while their view is hidden (display:none) because nothing depends
     on measured layout. Inherits the theme tokens defined in styles.css. */
  :root { --chart-blue: #5a7d99; --chart-gridline: #d6d3ce; }
  :root[data-theme="dark"] { --chart-blue: #7ba0c0; --chart-gridline: #383840; }

  .fig {
    margin: 1.6rem 0;
    border: 1px solid var(--border);
    background: var(--bg2);
    padding: 1.3rem 1.4rem 1.1rem;
  }
  .fig-cap {
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1.1rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .fig-cap .fig-sub {
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: none;
  }
  .fig-note {
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--text-dim);
    line-height: 1.5;
    margin-top: 1rem;
    letter-spacing: 0.03em;
  }
  .fig-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-top: 1rem;
  }
  .fig-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
  .fig-legend i { width: 0.8rem; height: 0.8rem; display: inline-block; }
  .swatch-accent { background: var(--accent); }
  .swatch-blue   { background: var(--chart-blue); }
  .swatch-gold   { background: var(--gold); }
  .swatch-dim    { background: var(--text-dim); }

  /* Horizontal bar chart */
  .barchart { display: flex; flex-direction: column; gap: 0.85rem; }
  .bar-row { display: grid; grid-template-columns: 1fr; gap: 0.3rem; }
  .bar-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
  }
  .bar-label {
    font-family: var(--sans);
    font-size: 0.84rem;
    color: var(--text);
    line-height: 1.35;
  }
  .bar-val {
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-bright);
    white-space: nowrap;
  }
  .bar-track {
    position: relative;
    height: 0.85rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    overflow: hidden;
  }
  .bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--accent);
    width: var(--w, 0);
  }
  .bar-fill.is-blue { background: var(--chart-blue); }
  .bar-fill.is-gold { background: var(--gold); }
  .bar-fill.is-dim  { background: var(--text-dim); }

  /* "Never responded" row — deliberately OFF the day-scale: a hatched full-width
     track with no fill, separated from the timed bars by a dashed rule. */
  .bar-never { margin-top: 0.35rem; padding-top: 0.95rem; border-top: 1px dashed var(--chart-gridline); }
  .bar-never .bar-val { color: var(--accent); }
  .bar-track.is-never {
    border-color: var(--accent);
    background: repeating-linear-gradient(45deg, var(--accent-dim) 0 7px, transparent 7px 14px);
  }

  /* Timeline */
  .timeline { position: relative; padding-left: 1.6rem; margin: 0.4rem 0; }
  .timeline::before {
    content: '';
    position: absolute;
    left: 0.32rem;
    top: 0.3rem;
    bottom: 0.3rem;
    width: 2px;
    background: var(--border);
  }
  .tl-item { position: relative; padding: 0 0 1.35rem 0; }
  .tl-item:last-child { padding-bottom: 0; }
  .tl-item::before {
    content: '';
    position: absolute;
    left: -1.46rem;
    top: 0.2rem;
    width: 0.72rem;
    height: 0.72rem;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg2);
    box-shadow: 0 0 0 1px var(--accent);
  }
  .tl-date {
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
  }
  .tl-title { font-weight: 600; color: var(--text-bright); font-size: 0.95rem; line-height: 1.4; }
  .tl-body { font-size: 0.86rem; color: var(--text-dim); line-height: 1.55; margin-top: 0.2rem; }
  .tl-body strong { color: var(--text); }
  /* Evidence-status badge (used in the §XII Epstein timeline to keep the
     documented-vs-alleged distinction visible at a glance). */
  .tl-tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.54rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.12rem 0.4rem;
    margin-left: 0.5rem;
    vertical-align: 0.12em;
    border: 1px solid;
    white-space: nowrap;
  }
  .tl-tag.is-doc { color: var(--gold); border-color: var(--gold); background: var(--gold-dim); }
  .tl-tag.is-alleged {
    color: var(--text-dim);
    border-style: dashed;
    border-color: var(--text-dim);
    background: transparent;
  }

  /* SVG line chart */
  .linechart { width: 100%; height: auto; display: block; font-family: var(--mono); }
  .linechart .lc-grid { stroke: var(--chart-gridline); stroke-width: 1; opacity: 0.6; }
  .linechart .lc-axis { stroke: var(--border); stroke-width: 1; }
  .linechart .lc-area { fill: var(--accent-dim); }
  .linechart .lc-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
  .linechart .lc-dot { fill: var(--accent); }
  .linechart .lc-tick { fill: var(--text-dim); font-size: 13px; }
  .linechart .lc-tick.x { text-anchor: middle; }
  .linechart .lc-tick.y { text-anchor: end; }
  .linechart .lc-anno { fill: var(--text-bright); font-size: 13px; font-weight: 600; }

  /* Decision flowchart (used for the tongue-in-cheek "Why" chart) */
  .flow { display: flex; flex-direction: column; align-items: center; gap: 0; text-align: center; }
  .flow-node {
    font-family: var(--sans);
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border);
    background: var(--bg3);
    color: var(--text);
    max-width: 30rem;
  }
  .flow-q {
    border-color: var(--accent);
    color: var(--text-bright);
    font-weight: 600;
  }
  .flow-arrow {
    width: 2px;
    height: 1.3rem;
    background: var(--border);
    position: relative;
  }
  .flow-arrow::after {
    content: '▾';
    position: absolute;
    left: 50%;
    bottom: -0.55rem;
    transform: translateX(-50%);
    color: var(--border);
    font-size: 0.8rem;
  }
  .flow-branches {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 1rem 1.4rem;
    width: 100%;
  }
  .flow-branch { display: flex; flex-direction: column; align-items: center; flex: 1 1 13rem; max-width: 17rem; }
  .flow-edge-label {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    min-height: 2.2em;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    text-align: center;
  }
  .flow-end {
    font-family: var(--sans);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border: 1.5px solid;
    width: 100%;
    line-height: 1.4;
    font-size: 0.9rem;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .flow-end .flow-end-tag {
    display: block;
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 0.4rem;
    opacity: 0.8;
  }
  .flow-end.bad   { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
  .flow-end.ok    { border-color: var(--gold);   color: var(--gold);   background: var(--gold-dim); }
  .flow-end.worst { border-color: var(--text-dim); color: var(--text-bright); background: var(--bg3); }

  /* Aim-point comparison (§III): contrasts a normal deterrent's target with the
     Samson Option's stated reach. Lit chips = stated targets; dim = not aimed at. */
  .aim { display: flex; flex-direction: column; gap: 1.1rem; }
  .aim-row { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
  .aim-label {
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
  .aim-targets { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .aim-chip {
    font-family: var(--sans);
    font-size: 0.8rem;
    line-height: 1.3;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    color: var(--text-dim);
    background: var(--bg3);
    opacity: 0.5;
  }
  .aim-chip.is-on {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
    opacity: 1;
  }

  /* Stat callouts (§V, §XV): one or two dramatic figures with a response line,
     used instead of a bar chart when there are only a couple of numbers to land. */
  .statpair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
  .stat {
    border: 1px solid var(--border);
    background: var(--bg3);
    padding: 1.2rem 1.2rem 1.3rem;
    display: flex;
    flex-direction: column;
  }
  .stat-num {
    font-family: var(--mono);
    font-size: 2.7rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-bright);
  }
  .stat-key {
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-top: 0.7rem;
  }
  .stat-sub {
    font-family: var(--sans);
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--text);
    margin-top: 0.55rem;
  }
  .stat.is-punished { border-color: var(--chart-blue); }
  .stat.is-punished .stat-num { color: var(--chart-blue); }
  .stat.is-impunity { border-color: var(--gold); }
  .stat.is-impunity .stat-num { color: var(--gold); font-size: 3.4rem; }

  /* Scatter / inversion plot (§II): warheads on x, U.S. response banded on y, to
     show that treatment doesn't track arsenal — one point sits alone in "aid". */
  .scatter { width: 100%; height: auto; display: block; font-family: var(--mono); }
  .scatter .sc-grid { stroke: var(--chart-gridline); stroke-width: 1; opacity: 0.5; }
  .scatter .sc-axis { stroke: var(--border); stroke-width: 1; }
  .scatter .sc-band { fill: var(--text-dim); font-size: 10px; letter-spacing: 0.08em; }
  .scatter .sc-xlab { fill: var(--text-dim); font-size: 10px; letter-spacing: 0.08em; }
  .scatter .sc-dot { fill: var(--chart-blue); }
  .scatter .sc-dot.is-out { fill: var(--gold); }
  .scatter .sc-lab { fill: var(--text); font-size: 11px; }
  .scatter .sc-lab.is-out { fill: var(--gold); font-weight: 600; }

  /* Waffle / proportion grid (§X): 100 cells, one share filled, to show a single
     actor accounting for the majority of a global total — Israel vs. the world. */
  .waffle-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    max-width: 300px;
    margin: 0 0 1rem;
  }
  .waffle-cell { aspect-ratio: 1; background: var(--text-dim); opacity: 0.45; }
  .waffle-cell.is-on { background: var(--accent); opacity: 1; }

  /* Lollipop plot (§X): thin stem + dot per row, used instead of filled bars to
     compare a per-day rate across conflicts while keeping chart types varied. */
  .lollipop { display: flex; flex-direction: column; gap: 0.9rem; margin: 0.4rem 0 0.6rem; }
  .lp-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 0.8rem; }
  .lp-label { font-family: var(--mono); font-size: 0.72rem; color: var(--text); line-height: 1.3; }
  .lp-track { position: relative; display: flex; align-items: center; min-height: 14px; }
  .lp-stem { height: 2px; background: var(--chart-blue); width: var(--w); flex: 0 0 auto; }
  .lp-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--chart-blue); margin-left: -2px; flex: 0 0 auto; }
  .lp-val { font-family: var(--mono); font-size: 0.72rem; color: var(--text-bright); white-space: nowrap; }
  .lp-row.is-focus .lp-stem,
  .lp-row.is-focus .lp-dot { background: var(--accent); }
  .lp-row.is-focus .lp-label,
  .lp-row.is-focus .lp-val { color: var(--accent); font-weight: 600; }

  /* Donut / proportion ring (§XIII): a single part-of-whole share — what fraction
     of Congress took the money — with a bipartisan breakdown beside it. */
  .donut { display: flex; align-items: center; gap: 1.8rem; flex-wrap: wrap; }
  .donut svg { width: 170px; height: 170px; flex: 0 0 auto; }
  .dn-track { fill: none; stroke: var(--text-dim); opacity: 0.28; stroke-width: 24; }
  .dn-arc { fill: none; stroke: var(--accent); stroke-width: 24; }
  .dn-num { fill: var(--text-bright); font-family: var(--mono); font-size: 34px; font-weight: 600; }
  .dn-key { fill: var(--text-dim); font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; }
  .dn-side { flex: 1 1 220px; display: flex; flex-direction: column; gap: 0.7rem; }
  .dn-stat { display: flex; flex-direction: column; gap: 0.1rem; }
  .dn-stat b { font-family: var(--mono); font-size: 1.4rem; color: var(--text-bright); line-height: 1; }
  .dn-stat span { font-size: 0.82rem; color: var(--text); line-height: 1.4; }
  .dn-stat span em { color: var(--text-dim); font-style: normal; }

  /* Comparison matrix (home/thesis): the cornerstone idiom — the same conduct
     read across three actors (enemy / ordinary ally / Israel) to expose the
     inverted US response. Israel column is emphasized as the subject. */
  .matrix {
    margin: 1.8rem 0 0.6rem;
    border: 1px solid var(--border);
    background: var(--bg2);
    overflow: hidden;
  }
  .mx-head,
  .mx-row { display: grid; grid-template-columns: 1.05fr 1.35fr 1.35fr 1.5fr; }
  .mx-row + .mx-row,
  .mx-head + .mx-row { border-top: 1px solid var(--border); }

  .mx-head { background: var(--bg3); }
  .mx-corner,
  .mx-col {
    padding: 0.7rem 0.9rem;
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    border-left: 1px solid var(--border);
    line-height: 1.4;
  }
  .mx-corner { border-left: 0; color: var(--text); }
  .mx-col em { display: block; font-style: normal; color: var(--text-dim); opacity: 0.8; margin-top: 0.15rem; }
  .mx-col.mx-israel { color: var(--accent); background: var(--accent-dim); }
  .mx-col.mx-israel em { color: var(--accent2); opacity: 1; }

  .mx-test,
  .mx-cell {
    padding: 0.85rem 0.9rem;
    font-size: 0.84rem;
    line-height: 1.5;
    border-left: 1px solid var(--border);
    color: var(--text);
  }
  .mx-test {
    border-left: 0;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-bright);
    display: flex;
    align-items: center;
  }
  .mx-cell.mx-is {
    background: var(--accent-dim);
    border-left: 2px solid var(--accent);
    color: var(--text-bright);
  }
  .mx-foot {
    padding: 0.75rem 0.9rem;
    border-top: 1px solid var(--border);
    background: var(--bg3);
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    line-height: 1.7;
  }
  .mx-foot a { color: var(--accent); text-decoration: none; }
  .mx-foot a:hover { text-decoration: underline; }

  @media (max-width: 600px) {
    .flow-branches { flex-direction: column; align-items: stretch; }
    /* Stacked: branches and boxes size to content (no vertical flex-grow), and
       the edge-label height normalization for equal-height boxes is irrelevant. */
    .flow-branch { max-width: none; flex: 0 0 auto; }
    .flow-end { flex: 0 0 auto; }
    .flow-edge-label { min-height: 0; }
    .bar-head { flex-direction: column; gap: 0.1rem; }
    .bar-val { align-self: flex-start; }
    .statpair { grid-template-columns: 1fr; }
    .lp-row { grid-template-columns: 1fr auto; gap: 0.3rem 0.6rem; }
    .lp-label { grid-column: 1 / -1; }

    /* Matrix collapses to one card per test; each cell labels its own column. */
    .mx-head { display: none; }
    .mx-row { grid-template-columns: 1fr; }
    .mx-test {
      border-left: 0;
      border-bottom: 1px solid var(--border);
      background: var(--bg3);
      padding: 0.6rem 0.9rem;
    }
    .mx-cell {
      border-left: 0;
      padding: 0.6rem 0.9rem 0.6rem 7.5rem;
      position: relative;
      font-size: 0.82rem;
    }
    .mx-cell + .mx-cell { border-top: 1px solid var(--border); }
    .mx-cell::before {
      content: attr(data-c);
      position: absolute;
      left: 0.9rem;
      top: 0.6rem;
      width: 6rem;
      font-family: var(--mono);
      font-size: 0.55rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-dim);
      line-height: 1.3;
    }
    .mx-cell.mx-is { border-left: 2px solid var(--accent); }
    .mx-cell.mx-is::before { color: var(--accent); }
  }
