/* ==========================================================================
   Teaching figures and models (components/teaching-figures.js), shared by the
   Board Review and EEG Fundamentals

   One Frame per figure, plain panels inside it. Chart colors are the first
   three slots of the reference categorical palette, validated against this
   site's own surfaces (light #ffffff, dark #403359): they pass the CVD and
   normal-vision checks all-pairs, and every chart labels its rows, which the
   lower-contrast slots require. Text never wears a series color. Gridlines
   and axes are solid hairlines. Waveforms are drawn in the ink color,
   negative up.
   ========================================================================== */

.brf {
  --viz-1: #2a78d6;
  --viz-1-deep: #1c5cab;
  --viz-2: #eb6834;
  --viz-3: #1baf7a;
  --viz-ctl: #bdb6c7;
  --viz-grid: #ebe7f0;
  --viz-axis: #c9c1d3;
  --viz-band: rgba(41, 35, 50, 0.05);
  --viz-risk: rgba(208, 59, 59, 0.14);
  position: relative;
  padding: 1.1rem 1.1rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-color);
}

body.dark .brf {
  --viz-1: #3987e5;
  --viz-1-deep: #86b6ef;
  --viz-2: #d95926;
  --viz-3: #199e70;
  --viz-ctl: #8f82a3;
  --viz-grid: rgba(255, 255, 255, 0.1);
  --viz-axis: rgba(255, 255, 255, 0.28);
  --viz-band: rgba(255, 255, 255, 0.06);
  --viz-risk: rgba(230, 103, 103, 0.22);
}

.brf-svg { display: block; width: 100%; height: auto; overflow: visible; }
.brf-panel { min-width: 0; overflow-x: auto; }
.brf-panel + .brf-panel { margin-top: 1.25rem; }

/* Charts with text keep a legible size and scroll sideways on a phone. */
.brf-maturation .brf-svg,
.brf-syndromes .brf-svg,
.brf-mcm .brf-svg,
.brf-neuromod .brf-svg,
.brf-pht .brf-svg { min-width: 540px; }

.brf-sub,
.brf-group-label {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-color);
}

.brf-group-label { margin-top: 0.9rem; }
.brf-muted { color: var(--text-secondary); fill: var(--text-secondary); }
.brf-note, .brf-detail { margin: 0.75rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--text-secondary); }
.brf-detail strong { color: var(--text-color); }

/* marks */
.brf-trace { fill: none; stroke: var(--text-color); stroke-width: 1.1; stroke-linejoin: round; stroke-linecap: round; }
.brf-trace-key { stroke-width: 1.5; }
.brf-grid { stroke: var(--viz-grid); stroke-width: 1; }
.brf-axis { stroke: var(--viz-axis); stroke-width: 1; fill: none; }
.brf-svg text { font-family: inherit; }
.brf-tick { font-size: 11px; fill: var(--text-secondary); font-variant-numeric: tabular-nums; }
.brf-strong { font-weight: 700; fill: var(--text-color); }
.brf-rowlabel { font-size: 12px; fill: var(--text-color); }
.brf-label, .brf-value { font-size: 12px; font-weight: 600; fill: var(--text-color); }
.brf-value .brf-muted { font-weight: 400; }
.brf-note-text { font-size: 11px; fill: var(--text-secondary); }
.brf-subsvg { font-size: 12px; font-weight: 700; fill: var(--text-color); }
.brf-bar, .brf-barh, .brf-c1 { fill: var(--viz-1); }
.brf-c2 { fill: var(--viz-2); }
.brf-c3, .brf-barh-long { fill: var(--viz-3); }
.brf-barh-ctl { fill: var(--viz-ctl); }
.brf-bar-peak { fill: var(--viz-1-deep); }
.brf-tail { stroke-width: 2; stroke-linecap: round; fill: none; }
.brf-tail.brf-c1 { stroke: var(--viz-1); }
.brf-tail.brf-c2 { stroke: var(--viz-2); }
.brf-tail.brf-c3 { stroke: var(--viz-3); }
.brf-peak { fill: var(--surface-1); stroke: var(--text-color); stroke-width: 2; }
.brf-line { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.brf-line-ref { fill: none; stroke: var(--viz-axis); stroke-width: 1.5; }
.brf-range { stroke: var(--viz-1); stroke-width: 3; stroke-linecap: round; }
.brf-dot { fill: var(--viz-1); stroke: var(--surface-1); stroke-width: 2; }
.brf-dot-soft { fill: var(--surface-1); stroke: var(--viz-1); stroke-width: 2; }
.brf-ci { fill: none; stroke: var(--text-color); stroke-width: 1.4; }
.brf-band { fill: var(--viz-band); }
.brf-limit, .brf-cross { stroke: var(--viz-axis); stroke-width: 1; }
.brf-guide { stroke: var(--text-secondary); stroke-width: 1; fill: none; }
.brf-term { stroke: var(--text-color); stroke-width: 1.2; }
.brf-maturation stop { stop-color: var(--viz-1); }

/* hover and focus targets are bigger than the marks */
.brf-hitbox { fill: transparent; }
.brf-hit { cursor: default; outline: none; }
.brf-hit:hover .brf-bar, .brf-hit:hover .brf-barh, .brf-hit:focus-visible .brf-bar, .brf-hit:focus-visible .brf-barh { opacity: 0.8; }
.brf-hit:focus-visible .brf-hitbox { stroke: var(--accent-color); stroke-width: 2; rx: 4; }
.brf-hit:hover .brf-dot, .brf-hit:focus-visible .brf-dot { r: 7; }

.brf-tip {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 0.1rem;
  max-width: 18rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  box-shadow: 0 6px 18px rgba(20, 12, 30, 0.14);
  pointer-events: none;
  font-size: 0.8125rem;
  line-height: 1.35;
}

.brf-tip[hidden] { display: none; }
.brf-tip strong { font-size: 0.9375rem; color: var(--text-color); }
.brf-tip span { color: var(--text-secondary); }

/* legends mirror the marks */
.brf-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; margin: 0 0 0.75rem; padding: 0; list-style: none; font-size: 0.8125rem; color: var(--text-secondary); }
.brf-legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.brf-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--viz-1); }
.brf-swatch.brf-c2 { background: var(--viz-2); }
.brf-swatch.brf-c3, .brf-swatch.brf-long { background: var(--viz-3); }
.brf-swatch.brf-ctl { background: var(--viz-ctl); }
.brf-swatch-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--text-color); background: var(--surface-1); }
.brf-swatch-tail { display: inline-block; width: 16px; height: 2px; background: var(--text-secondary); }
.brf-swatch-ci { display: inline-block; width: 16px; height: 8px; border: 1.4px solid var(--text-color); border-top: 0; border-bottom: 0; background: linear-gradient(var(--text-color), var(--text-color)) center / 100% 1.4px no-repeat; }

/* scale bar and key under a waveform figure */
.brf-key { display: flex; align-items: center; gap: 0.9rem; margin-top: 0.85rem; font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
.brf-scale { flex: none; width: 150px; height: 34px; }
.brf-scale-line { fill: none; stroke: var(--text-color); stroke-width: 1.5; }
.brf-scale text { font-size: 11px; fill: var(--text-secondary); }

/* ---------------------------------------------------- normal variants */
.brf-var-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.1rem 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.brf-var-name { margin: 0 0 0.2rem; font-size: 0.9375rem; font-weight: 700; line-height: 1.3; }
.brf-var-facts { margin: 0.25rem 0 0; font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }

/* ------------------------------------------------ IED criteria */
.brf-ied-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.brf-chan { font-size: 11px; font-weight: 600; fill: var(--text-secondary); }
.brf-wash { fill: rgba(var(--accent-rgb), 0.07); }
.brf-mark circle { fill: var(--accent-color); }
.brf-mark text { font-size: 11px; font-weight: 700; fill: #fff; text-anchor: middle; }
body.dark .brf-mark text { fill: #2a1f3a; }
.brf-bracket { fill: none; stroke: var(--accent-color); stroke-width: 1.4; }
.brf-legend-list { margin: 0.4rem 0 0; padding-left: 1.3rem; font-size: 0.875rem; line-height: 1.5; columns: 2 16rem; column-gap: 1.5rem; }
.brf-legend-list li { margin-bottom: 0.2rem; break-inside: avoid; }
.brf-legend-list li::marker { font-weight: 700; color: var(--accent-color); }
.brf-check { margin: 0.5rem 0 0; padding: 0; list-style: none; font-size: 0.875rem; line-height: 1.45; }
.brf-check li { position: relative; padding-left: 1.4rem; margin-bottom: 0.25rem; }
.brf-check li::before { position: absolute; left: 0; top: 0; font-weight: 700; }
.brf-check .is-yes::before { content: "✓"; color: var(--text-secondary); }
.brf-check .is-no::before { content: "✗"; color: #b42318; }
body.dark .brf-check .is-no::before { color: #ffaaa2; }

/* ------------------------------------------------ generalized ladder */
.brf-ladder-rows { margin: 0; padding: 0; list-style: none; }
.brf-ladder-row,
.brf-ladder-ruler { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 1rem; align-items: center; }
.brf-ladder-row { padding: 0.35rem 0; border-bottom: 1px solid var(--viz-grid); }
.brf-ladder-label { display: grid; gap: 0.1rem; font-size: 0.8125rem; line-height: 1.35; color: var(--text-secondary); }
.brf-ladder-label strong { font-size: 0.9375rem; color: var(--text-color); }
.brf-to { font-weight: 600; color: var(--text-color); }
.brf-ladder-ruler .brf-svg text { font-size: 11px; fill: var(--text-secondary); }

/* ------------------------------------------------ ASM target map */
.brf-asm-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.brf-asm-pic .brf-svg { min-width: 420px; }
.brf-asm-pic { overflow-x: auto; }
.brs-cell { fill: var(--surface-2); stroke: var(--text-secondary); stroke-width: 1.2; }
.brs-axon { stroke: var(--text-secondary); stroke-width: 6; stroke-linecap: round; }
.brs-post { stroke: var(--text-secondary); stroke-width: 1.4; }
.brs-cap { font-size: 13px; fill: var(--text-secondary); }
.brs-ves { fill: var(--surface-1); stroke: var(--text-secondary); stroke-width: 1.1; }
.brs-ves-gaba { stroke-dasharray: 2 2; }
.brs-tx { fill: var(--text-secondary); }
.brs-target { cursor: pointer; }
.brs-target > * { fill: rgba(var(--accent-rgb), 0.16); stroke: var(--accent-color); stroke-width: 1.4; transition: fill 0.15s ease, opacity 0.15s ease; }
.brs-target.is-on > * { fill: var(--accent-color); }
.brs-label { font-size: 15px; font-weight: 700; fill: var(--text-color); pointer-events: none; }
.is-picking .brs-target:not(.is-on) > * { opacity: 0.35; }
.is-picking .brs-label:not(.is-on) { opacity: 0.45; }
.brf-asm-readout { min-height: 8rem; padding: 0.85rem 1rem; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 0.9375rem; line-height: 1.5; }
.brf-asm-readout p { margin: 0 0 0.4rem; }
.brf-asm-readout p:last-child { margin-bottom: 0; }
.brf-asm-title { font-weight: 700; }
.brf-asm-note { font-size: 0.875rem; color: var(--text-secondary); }

.brf-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.brf-chip {
  min-height: 34px;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-color);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.brf-chip:hover { border-color: var(--accent-color); }
.brf-chip:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.brf-chip.is-active { border-color: var(--action-bg); background: var(--action-bg); color: var(--action-ink, #fff); }

/* ------------------------------------------------ phenytoin model */
.brf-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem 1.25rem; margin-bottom: 0.85rem; }
.brf-field { display: grid; gap: 0.3rem; font-size: 0.8125rem; color: var(--text-secondary); }
.brf-field output { font-weight: 700; color: var(--text-color); }
.brf-field input { width: 100%; accent-color: var(--action-bg); }
.brf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-top: 0.85rem; }
.brf-stat { display: grid; gap: 0.1rem; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.brf-stat span { font-size: 0.8125rem; color: var(--text-secondary); }
.brf-stat strong { font-size: 1.25rem; font-weight: 650; color: var(--text-color); }
.brf-stat em { font-style: normal; font-size: 0.8125rem; color: var(--text-secondary); }
.brf-stats-note { grid-column: 1 / -1; margin: 0; font-size: 0.875rem; color: var(--text-secondary); }
.brf-link { margin-top: 0.6rem; padding: 0; border: 0; background: none; color: var(--accent-color); font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ------------------------------------------------ status epilepticus */
.brf-se-lanes { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 0.55rem 1rem; align-items: center; }
.brf-se-type { display: grid; font-size: 0.875rem; font-weight: 600; line-height: 1.35; }
.brf-se-type small { font-size: 0.75rem; font-weight: 400; color: var(--text-secondary); }
.brf-se-type-head { color: var(--text-secondary); font-weight: 700; }
.brf-se-lane { position: relative; height: 26px; border-radius: 6px; background: var(--viz-band); }
.brf-se-strip { background: none; }
.brf-se-seg { position: absolute; top: 0; bottom: 0; display: grid; place-items: center; border-right: 2px solid var(--surface-1); color: #fff; font-size: 0.75rem; }
.brf-se-p0 { background: #8a8496; }
.brf-se-p1 { background: var(--viz-1); }
.brf-se-p2 { background: #1c5cab; }
.brf-se-p3 { background: #0d366b; }
body.dark .brf-se-p2 { background: #256abf; }
body.dark .brf-se-p3 { background: #184f95; }
.brf-se-seg:first-child { border-radius: 6px 0 0 6px; }
.brf-se-seg:last-child { border-radius: 0 6px 6px 0; border-right: 0; }
.brf-se-before { position: absolute; left: 0; top: 0; bottom: 0; }
.brf-se-t1, .brf-se-t2 { position: absolute; top: -3px; bottom: -3px; min-width: 2px; border-left: 2px solid var(--text-color); }
.brf-se-t1 { background: rgba(var(--accent-rgb), 0.18); border-right: 2px solid transparent; }
.brf-se-t1 b, .brf-se-t2 b { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); font-size: 0.75rem; color: var(--text-color); }
.brf-se-risk { position: absolute; top: 0; bottom: 0; background: var(--viz-risk); border-radius: 0 6px 6px 0; }
.brf-se-axis { height: 18px; background: none; border-top: 1px solid var(--viz-axis); border-radius: 0; }
.brf-se-axis span { position: absolute; top: 3px; transform: translateX(-50%); font-size: 0.75rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.brf-se-axis span:first-child { transform: none; }
.brf-se-axis span:last-child { transform: translateX(-100%); }
.brf-se-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin: 1.1rem 0 0; padding: 0; list-style: none; }
.brf-se-card { display: grid; align-content: start; gap: 0.2rem; font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
.brf-se-card strong { font-size: 0.9375rem; color: var(--text-color); }
.brf-se-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 0.75rem; font-weight: 700; }
.brf-se-time { font-weight: 600; color: var(--text-color); }

/* ------------------------------------------------ SUDEP */
.brf-sudep-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.25rem; align-items: center; }
.brf-dot-bg { fill: var(--text-secondary); opacity: 0.28; }
.brf-dot-hit { fill: var(--accent-color); stroke: var(--surface-1); stroke-width: 2; }
.brf-sudep-tiles { display: grid; gap: 0.6rem; }
.brf-sudep-tiles .brf-note { margin: 0; }

/* ------------------------------------------------ phones */
@media (max-width: 760px) {
  .brf { padding: 0.9rem 0.8rem; }
  .brf-ied-grid, .brf-asm-grid, .brf-sudep-grid { grid-template-columns: minmax(0, 1fr); }
  .brf-ladder-row, .brf-ladder-ruler { grid-template-columns: minmax(0, 1fr); gap: 0.3rem; }
  .brf-ladder-ruler > div:first-child { display: none; }
  .brf-controls, .brf-stats { grid-template-columns: minmax(0, 1fr); }
  .brf-se-lanes { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .brf-se-type { margin-top: 0.4rem; }
  .brf-se-cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .brf-key { align-items: flex-start; flex-direction: column; gap: 0.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .brs-target > * { transition: none; }
}

.brf-diamond { fill: var(--text-color); }
.brf-se-t2.is-end { border-left: 0; border-right: 2px solid var(--text-color); transform: translateX(-100%); }
.brf-se-t2.is-end b { left: auto; right: 4px; }

.brf-cal text { font-size: 10px; fill: var(--text-secondary); }
.brf-swipe { display: none; margin: 0 0 0.4rem; font-size: 0.8125rem; color: var(--text-secondary); }
@media (max-width: 620px) { .brf-swipe { display: block; } }

/* ======================================================================
   EEG Fundamentals models (October 1, 2026)
   ====================================================================== */
.brf-chips + .brf-chips, .brf-chips + .brf-actions, .brf-act-controls > .brf-chips + .brf-chips { margin-top: 0.5rem; }
.brf-chip-label { align-self: center; margin-right: 0.3rem; font-size: 0.8125rem; font-weight: 700; color: var(--text-secondary); }
.brf-filter-controls, .brf-act-controls { margin-bottom: 0.75rem; }
.brf-linked { margin: 0 0 0.25rem; }
.brf-stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.brf-stats-6 .brf-stat strong { font-size: 1.125rem; }
.brf-bandwash { fill: var(--viz-band); }
.brf-bandwash.is-alt { fill: transparent; }

.brf-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0 0.75rem; }
.brf-btn {
  min-height: 38px;
  padding: 0.45rem 1rem;
  border: 1px solid var(--action-bg);
  border-radius: var(--radius-sm);
  background: var(--action-bg);
  color: var(--action-ink, #fff);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}
.brf-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.brf-stim { stroke: var(--accent-color); stroke-width: 2; }

.brf-var-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.brf-var-cell .brf-sub { font-weight: 700; }

.brf-tabs { display: inline-flex; gap: 0.25rem; margin-bottom: 0.75rem; padding: 0.25rem; border: 1px solid var(--border-color); border-radius: 999px; }
.brf-tab { min-height: 34px; padding: 0.3rem 0.9rem; border: 0; border-radius: 999px; background: none; color: var(--text-color); font: inherit; font-size: 0.875rem; font-weight: 700; cursor: pointer; }
.brf-tab.is-active { background: var(--action-bg); color: var(--action-ink, #fff); }
.brf-tab:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.brf-flash { stroke: var(--text-color); stroke-width: 1.2; }
.brf-flash-span { fill: rgba(var(--accent-rgb), 0.06); }

.brf-controls-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }
.brf-lowv { fill: rgba(var(--accent-rgb), 0.1); }
.brf-seg-0 { fill: #86b6ef; }
.brf-seg-1 { fill: #5598e7; }
.brf-seg-2 { fill: #2a78d6; }
.brf-seg-3 { fill: #1c5cab; }
.brf-seg-4 { fill: #104281; }
.brf-seg.is-on { stroke: var(--text-color); stroke-width: 2; }
.brf-pointer { fill: var(--text-color); }

.brf-iic-no { fill: var(--viz-band); stroke: var(--viz-axis); stroke-width: 1; }
.brf-iic-maybe { fill: rgba(250, 178, 25, 0.28); stroke: #d99a10; stroke-width: 1; }
.brf-iic-iic { fill: #ec835a; }
.brf-iic-sz { fill: #d03b3b; }
.brf-iic-text { font-size: 11.5px; font-weight: 700; fill: var(--text-color); pointer-events: none; }
.brf-iic-t-iic { fill: #2a1a14; }
.brf-iic-t-sz { fill: #fff; }
.brf-fo-label { display: flex; align-items: center; height: 100%; font-size: 12.5px; font-weight: 600; line-height: 1.25; color: var(--text-color); }
.brf-iicmap .brf-svg { min-width: 560px; }
.brf-filters .brf-svg, .brf-continuity .brf-svg { min-width: 0; }

@media (max-width: 900px) {
  .brf-stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .brf-var-pair, .brf-controls-2 { grid-template-columns: minmax(0, 1fr); }
  .brf-stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brf-activation .brf-svg { min-width: 560px; }
}

/* A figure placed in an EEG Fundamentals lesson */
.fr-teach-figure { margin: 1.25rem 0 1.5rem; }
.fr-teach-figure figcaption { margin-top: 0.55rem; font-size: 0.875rem; line-height: 1.5; color: var(--text-secondary); }
.brf-cont-controls { display: grid; gap: 0.6rem; margin-bottom: 0.75rem; }
.brf-cont-controls .brf-field { max-width: 32rem; }
.brf-iic-text { font-size: 12px; }

/* Continuity scale: five equal steps that wrap on a phone */
.brf-scale-wrap { margin-top: 0.9rem; }
.brf-scale-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 14px 0 0; list-style: none; }
.brf-scale-steps li { position: relative; display: grid; gap: 0.15rem; align-content: start; text-align: center; font-size: 0.75rem; line-height: 1.3; color: var(--text-secondary); }
.brf-scale-steps strong { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); }
.brf-scale-steps li.is-on strong { font-weight: 700; color: var(--text-color); }
.brf-scale-bar { display: block; height: 16px; margin-bottom: 0.3rem; border-radius: 4px; }
.brf-scale-steps li.is-on .brf-scale-bar { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--text-color); }
.brf-segbg-0 { background: #86b6ef; }
.brf-segbg-1 { background: #5598e7; }
.brf-segbg-2 { background: #2a78d6; }
.brf-segbg-3 { background: #1c5cab; }
.brf-segbg-4 { background: #104281; }
.brf-scale-mark { position: absolute; top: -12px; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-top: 9px solid var(--text-color); border-bottom: 0; }

/* Waveform and chart figures keep a legible size and scroll on a phone */
@media (max-width: 620px) {
  .brf-filters .brf-svg, .brf-activation .brf-svg, .brf-react .brf-panel .brf-svg { min-width: 540px; }
  .brf-scale-steps strong { font-size: 0.75rem; }
}
@media (max-width: 620px) {
  .brf-scale-steps strong { display: none; }
}

/* Fundamentals: counting phases */
.brf-phase-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.brf-phase-card { min-width: 0; }
.brf-phase { opacity: 0.2; }
.brf-phase-up { fill: var(--viz-1); }
.brf-phase-down { fill: var(--viz-2); }
.brf-phase-hit:hover .brf-phase, .brf-phase-hit:focus-visible .brf-phase { opacity: 0.38; }
.brf-phase-hit:focus-visible { outline: none; }
.brf-phase-hit:focus-visible .brf-phase { stroke: var(--accent-color); stroke-width: 1.5; }
.brf-baseline { stroke-dasharray: 3 3; }
.brf-cross-dot { fill: var(--surface-1); stroke: var(--text-color); stroke-width: 1.5; }
.brf-phase-num circle { fill: var(--surface-1); stroke-width: 2; }
.brf-phase-num.is-up circle { stroke: var(--viz-1); }
.brf-phase-num.is-down circle { stroke: var(--viz-2); }
.brf-phase-num text, body.dark .brf-phase-num text { fill: var(--text-color); font-size: 10px; }
.brf-phase-name { display: grid; gap: 0.1rem; margin: 0.35rem 0 0.15rem; font-size: 0.875rem; }
.brf-phase-name span { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.brf-phase-note { margin: 0; font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
@media (max-width: 760px) { .brf-phase-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Fundamentals: rhythmicity and background organization */
.brf-rhythm .brf-svg, .brf-org .brf-svg { min-width: 520px; }
.brf-rhythm .brf-controls { margin-top: 0.25rem; }
.brf-org-block + .brf-org-block { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.brf-org-block .brf-sub .brf-muted { font-weight: 400; }
.brf-org-read { margin: 0.4rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--text-secondary); }
/* The lesson centres its own paragraphs at a reading measure; not the figure's. */
.bg-organization-panel .brf p { max-width: none; margin-left: 0; margin-right: 0; line-height: 1.5; }
.bg-organization-panel .brf .brf-sub { margin: 0 0 0.5rem; }
.bg-organization-panel .brf .brf-org-read { margin: 0.4rem 0 0; }

/* Neuromodulation devices: an anatomical front view. Anatomy is neutral, the
   implanted parts wear the accent, and vessels and nerve keep the red, blue
   and yellow of anatomical drawings, named in the legend. */
.brf-nm {
  --nm-skin: #f8f3f7; --nm-line: #d6cce0; --nm-brain: #ede5f2; --nm-deep: #dccfe8; --nm-bone: #c6b9d3;
  --nm-artery: #c4574f; --nm-vein: #4f78b8; --nm-nerve: #c98f0a; --nm-metal: #c9ccd4; --nm-metal-line: #737987;
}
body.dark .brf-nm {
  --nm-skin: #4a3c62; --nm-line: #6f5e88; --nm-brain: #56476f; --nm-deep: #6c5b88; --nm-bone: #8f80a8;
  --nm-artery: #e07a72; --nm-vein: #86a8e0; --nm-nerve: #e9b949; --nm-metal: #a3a8b4; --nm-metal-line: #dfe2e8;
}
.nm-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem 1.75rem; align-items: start; margin-top: 0.9rem; }
.nm-pic .nm-svg { max-width: 30rem; margin: 0 auto; }
.nm-side .brf-sub { font-size: 1rem; }
.nm-parts { margin: 0 0 0.25rem; padding-left: 1.3rem; font-size: 0.875rem; line-height: 1.5; color: var(--text-secondary); }
.nm-parts li + li { margin-top: 0.2rem; }
.nm-parts li::marker { font-weight: 700; color: var(--accent-color); }
.nm-parts strong { color: var(--text-color); }
.nm-facts { display: grid; grid-template-columns: 7.25rem minmax(0, 1fr); gap: 0.45rem 0.9rem; margin: 0.85rem 0 0; font-size: 0.875rem; line-height: 1.5; }
.nm-facts dt { font-weight: 700; color: var(--text-color); }
.nm-facts dd { margin: 0; color: var(--text-secondary); }
.nm-when { margin-top: 0.4rem; }
.nm-when:empty { display: none; }
.nm-strip .brf-svg { min-width: 520px; }
.nm-legend { margin: 0.9rem 0 0; }
.nm-sw { display: inline-block; width: 16px; height: 4px; border-radius: 2px; }
.nm-sw-dev { background: var(--accent-color); }
.nm-sw-artery { background: var(--nm-artery); }
.nm-sw-vein { background: var(--nm-vein); }
.nm-sw-nerve { background: var(--nm-nerve); }
@media (max-width: 760px) {
  .nm-grid { grid-template-columns: minmax(0, 1fr); }
  .nm-facts { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
  .nm-facts dd + dt { margin-top: 0.45rem; }
}

.nm-skin { fill: var(--nm-skin); stroke: var(--nm-line); stroke-width: 1.4; }
.nm-skull { fill: none; stroke: var(--nm-bone); stroke-width: 3; stroke-linecap: round; }
.nm-brain, .nm-stem { fill: var(--nm-brain); stroke: var(--nm-line); stroke-width: 1.2; }
.nm-sulcus { fill: none; stroke: var(--nm-line); stroke-width: 1; stroke-linecap: round; }
.nm-deep { fill: var(--nm-deep); stroke: var(--nm-line); stroke-width: 1; stroke-dasharray: 3 2; }
.nm-trachea, .nm-larynx { fill: var(--nm-skin); stroke: var(--nm-bone); stroke-width: 1.2; }
.nm-ring { stroke: var(--nm-bone); stroke-width: 1; }
.nm-bone { fill: none; stroke: var(--nm-bone); stroke-width: 5; stroke-linecap: round; }
.nm-artery { fill: none; stroke: var(--nm-artery); stroke-width: 4; stroke-linecap: round; }
.nm-vein { fill: none; stroke: var(--nm-vein); stroke-width: 5; stroke-linecap: round; opacity: 0.8; }
.nm-nerve { fill: none; stroke: var(--nm-nerve); stroke-width: 2.2; stroke-linecap: round; }
.nm-faint { opacity: 0.45; }
.nm-flow { fill: none; stroke: var(--nm-nerve); stroke-width: 1.4; stroke-dasharray: 4 3; }
.nm-lead { fill: none; stroke: var(--accent-color); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nm-ext { stroke-width: 3.2; }
.nm-coil { fill: none; stroke: var(--accent-color); stroke-width: 2; }
.nm-contact { fill: var(--text-color); }
.nm-can, .nm-cap { fill: var(--nm-metal); stroke: var(--nm-metal-line); stroke-width: 1.4; }
.nm-header { fill: var(--surface-1); stroke: var(--nm-metal-line); stroke-width: 1; }
.nm-target { fill: rgba(var(--accent-rgb), 0.18); stroke: var(--accent-color); stroke-width: 1.2; stroke-dasharray: 3 2; }
.nm-label { font-size: 12px; font-weight: 600; fill: var(--text-color); }
.nm-label.nm-muted { font-weight: 500; fill: var(--text-secondary); }
.nm-leader { fill: none; stroke: var(--text-secondary); stroke-width: 1; }
.nm-tag { display: none; font-size: 13px; font-weight: 700; fill: var(--accent-color); text-anchor: middle; }
.nm-burst { fill: rgba(var(--accent-rgb), 0.3); }
.nm-extra { fill: var(--accent-color); }
.nm-part { cursor: default; outline: none; }
.nm-part:focus-visible .nm-can, .nm-part:focus-visible .nm-lead, .nm-part:focus-visible .nm-target { stroke-width: 3.5; }

/* one device at a time, or all three with name tags instead of numbers */
.brf-nm .nm-dev { display: none; }
.brf-nm[data-show="all"] .nm-dev,
.brf-nm[data-show="vns"] .nm-dev[data-dev="vns"],
.brf-nm[data-show="rns"] .nm-dev[data-dev="rns"],
.brf-nm[data-show="dbs"] .nm-dev[data-dev="dbs"] { display: inline; }
.brf-nm[data-show="all"] .nm-dev :is(.brf-mark, .nm-label, .nm-leader, .nm-flow) { display: none; }
.brf-nm[data-show="all"] .nm-tag { display: inline; }
.brf-nm[data-show="vns"] .nm-vagus-left { stroke-width: 3.4; }
.nm-fissure { fill: none; stroke: var(--nm-line); stroke-width: 1.4; stroke-linecap: round; }
.nm-vent { opacity: 0.8; }
.brf-nm:not([data-show="dbs"]):not([data-show="all"]) .nm-thal,
.brf-nm:not([data-show="rns"]):not([data-show="all"]) .nm-hip { opacity: 0.55; }
.brf-svg.nm-svg { overflow: hidden; }
.nm-stem { opacity: 0.7; }
@media (max-width: 620px) {
  .nm-chip-long { display: none; }
  .nm-label { font-size: 14px; }
  .nm-tag { font-size: 15px; }
}

/* Neuromodulation hardware: each device's parts, and the same parts on a
   film. Hardware panels follow the theme; films stay dark in both themes,
   as radiographs do. Numbers on the pictures match the list below each. */
.brf-nmhw {
  --nmh-ti-hi: #f4f5f8; --nmh-ti: #c8ccd4; --nmh-ti-lo: #8d939e; --nmh-line: #6a707c;
  --nmh-sil: #fbfbfc; --nmh-sil-line: #9aa0aa; --nmh-pt: #737a87; --nmh-pt-line: #4d5360;
  --nmh-nerve: #f3dc97; --nmh-nerve-lo: #d6ae45; --nmh-epoxy: rgba(196, 220, 240, 0.7); --nmh-bone: #e6dcca;
  display: grid;
  gap: 1.25rem;
}
body.dark .brf-nmhw {
  --nmh-ti-hi: #eef0f4; --nmh-ti: #b7bcc6; --nmh-ti-lo: #7d8390; --nmh-line: #dfe2e8;
  --nmh-sil: #f6f6f8; --nmh-sil-line: #c7cbd3; --nmh-pt: #6d7482; --nmh-pt-line: #2f3440;
  --nmh-nerve: #f0d27a; --nmh-nerve-lo: #c89a2c; --nmh-epoxy: rgba(196, 220, 240, 0.55); --nmh-bone: #b9ab96;
}
.nmhw-row + .nmhw-row { padding-top: 1.25rem; border-top: 1px solid var(--border-color); }
.nmhw-title { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 700; line-height: 1.3; color: var(--text-color); }
.nmhw-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; align-items: start; }
.nmhw-cell { min-width: 0; margin: 0; }
.nmhw-art { overflow: hidden; border-radius: var(--radius-sm); }
.nmhw-hw { padding: 0.35rem; background: var(--surface-2); }
.nmhw-xr { background: #050607; }
.nmhw-cap { margin: 0.65rem 0 0.3rem; font-size: 0.875rem; color: var(--text-color); }
.nmhw-key { margin: 0; }
.nmhw-tip { margin-top: 0.5rem; }
.brf-nmhw .brf-mark circle { r: 12px; }
.brf-nmhw .brf-mark text { font-size: 13px; }
@media (max-width: 760px) {
  .nmhw-grid { grid-template-columns: minmax(0, 1fr); }
}

/* hardware */
.nmh-can { stroke: var(--nmh-line); stroke-width: 1.4; }
.nmh-sheen { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; opacity: 0.55; }
.nmh-header { fill: var(--nmh-epoxy); stroke: #7f95ab; stroke-width: 1.2; }
.nmh-screw { fill: var(--nmh-ti-lo); stroke: var(--nmh-line); stroke-width: 1; }
.nmh-pin { fill: none; stroke: var(--nmh-pt); stroke-width: 4; stroke-linecap: round; }
.nmh-lead-edge, .nmh-lead-core { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.nmh-lead-edge { stroke: var(--nmh-sil-line); stroke-width: 7.6; }
.nmh-lead-core { stroke: var(--nmh-sil); stroke-width: 5.2; }
.nmh-lead-edge.nmh-thin { stroke-width: 6.6; }
.nmh-lead-core.nmh-thin { stroke-width: 4.2; }
.nmh-lead-edge.nmh-ext { stroke-width: 8.8; }
.nmh-lead-core.nmh-ext { stroke-width: 6.4; }
.nmh-lead-edge.nmh-big { stroke-width: 16; stroke-linecap: butt; }
.nmh-lead-core.nmh-big { stroke-width: 13.6; stroke-linecap: butt; }
.nmh-helix { fill: none; stroke: var(--nmh-sil-line); stroke-width: 3.6; stroke-linecap: round; }
.nmh-helix.nmh-active { stroke: var(--nmh-pt); }
.nmh-helix-back { opacity: 0.45; }
.nmh-ribbon { fill: none; stroke: var(--nmh-sil-line); stroke-width: 2.4; stroke-linecap: round; }
.nmh-nerve { stroke: var(--nmh-nerve-lo); stroke-width: 1; }
.nmh-fascicle { fill: none; stroke: var(--nmh-nerve-lo); stroke-width: 0.8; opacity: 0.6; }
.nmh-contact { fill: var(--nmh-pt); stroke: var(--nmh-pt-line); stroke-width: 0.8; }
.nmh-tip { fill: none; stroke: var(--nmh-sil-line); stroke-width: 1.4; }
.nmh-ferrule { fill: none; stroke: var(--nmh-ti-lo); stroke-width: 5; }
.nmh-seam { fill: none; stroke: var(--nmh-line); stroke-width: 1; opacity: 0.6; }
.nmh-port { fill: var(--nmh-epoxy); stroke: #7f95ab; stroke-width: 1; }
.nmh-strip { fill: var(--nmh-sil); stroke: var(--nmh-sil-line); stroke-width: 1.4; }
.nmh-disc { fill: var(--nmh-pt); stroke: var(--nmh-pt-line); stroke-width: 0.8; }
.nmh-break { fill: none; stroke: var(--surface-2); stroke-width: 3.2; }
.nmh-bonecut { fill: var(--nmh-bone); stroke: var(--nmh-line); stroke-width: 1; opacity: 0.85; }
.nmh-cap { fill: var(--nmh-sil); stroke: var(--nmh-line); stroke-width: 1.4; }
.nmh-capclip { stroke: var(--nmh-line); stroke-width: 1.2; }
.nmh-boot { fill: var(--nmh-epoxy); stroke: #7f95ab; stroke-width: 1.2; }
.nmh-target { fill: rgba(var(--accent-rgb), 0.12); stroke: var(--accent-color); stroke-width: 1.2; stroke-dasharray: 4 3; }
.nmh-inset { fill: var(--surface-1); stroke: var(--border-color); stroke-width: 1.2; }
.nmh-leader { fill: none; stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 3 3; }
.nmh-note { font-size: 13px; font-weight: 600; fill: var(--text-secondary); }
.nmh-note-quiet { font-size: 12px; font-weight: 500; }
.nmh-dim path { fill: none; stroke: var(--text-secondary); stroke-width: 1; }
.nmh-dim text { font-size: 12px; fill: var(--text-color); }
.nmh-dim .nmh-dim-muted { fill: var(--text-secondary); }
.nmh-scale path { fill: none; stroke: var(--text-color); stroke-width: 1.4; }
.nmh-scale text { font-size: 12px; font-weight: 600; fill: var(--text-color); }

/* films */
.nmx-bg { fill: #050607; }
.nmx-soft { fill: #2b2c31; }
.nmx-lung { fill: #050607; opacity: 0.8; }
.nmx-air { fill: #000; opacity: 0.4; }
.nmx-bone { fill: none; stroke: #c3c4ca; stroke-linecap: round; stroke-linejoin: round; stroke-width: 5; }
.nmx-thick { stroke-width: 9; opacity: 0.85; }
.nmx-thin { stroke-width: 3.5; opacity: 0.75; }
.nmx-faint { stroke-width: 3; opacity: 0.45; }
.nmx-rib { stroke-width: 6; opacity: 0.45; }
.nmx-clav { stroke-width: 13; opacity: 0.9; }
.nmx-table { stroke-width: 11; opacity: 0.9; }
.nmx-inner { stroke-width: 3.5; opacity: 0.6; }
.nmx-base { stroke-width: 6; opacity: 0.7; }
.nmx-vert { fill: #a8a9af; opacity: 0.75; }
.nmx-dense { fill: #dcdde2; opacity: 0.45; }
.nmx-teeth { fill: #e3e4e8; opacity: 0.8; }
.nmx-metal { fill: #fff; }
.nmx-metal-inner { fill: #c9cacf; }
.nmx-metal-rim { fill: none; stroke: #fff; stroke-width: 3; }
.nmx-wire { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nmx-coil { stroke-width: 2.6; }
.nmx-lead { stroke-width: 2.8; }
.nmx-ext { stroke-width: 2.6; }
.nmx-ring { fill: none; stroke: #fff; stroke-width: 2; }
.nmx-view { font-size: 14px; font-weight: 600; fill: #e8e8ec; }
.nmx-tag rect { fill: none; stroke: #e8e8ec; stroke-width: 1.4; }
.nmx-tag text { font-size: 15px; font-weight: 700; fill: #e8e8ec; text-anchor: middle; }
.brf-nmhw .nmx-mark circle { fill: #f29ac9; }
.brf-nmhw .nmx-mark text { fill: #2a1633; }

/* Women's health figures (Seizure Management). Hormone curves use the
   first two chart colours and are named in the legend and on the lines in
   ink; windows where seizures cluster wear the brand tint. */

/* lifespan */
.brf-whl { padding-bottom: 1rem; }
.whl-track { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.6rem; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.whl-stage { position: relative; display: grid; align-content: start; gap: 0.35rem; padding: 0.75rem 0.7rem 0.8rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
.whl-stage strong { font-size: 0.875rem; line-height: 1.3; color: var(--text-color); }
.whl-step { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--action-bg); color: var(--action-ink, #fff); font-size: 0.75rem; font-weight: 700; }
.whl-band { display: grid; gap: 0.2rem; margin: 0.6rem 0 0; padding: 0.65rem 0.8rem; border: 1px dashed color-mix(in srgb, var(--action-bg) 45%, var(--border-color)); border-radius: var(--radius-sm); font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); max-width: none; }
.whl-band strong { color: var(--text-color); font-size: 0.875rem; }
@media (max-width: 1100px) { .whl-track { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 620px) { .whl-track { grid-template-columns: minmax(0, 1fr); } }

/* interactions */
.whi-svg { max-width: 44rem; margin: 0 auto; }
.whi-node rect { fill: var(--surface-2); stroke: var(--border-color); stroke-width: 1.4; }
.whi-node-asm rect { fill: rgba(var(--accent-rgb), 0.1); stroke: var(--accent-color); }
.whi-title { font-size: 15px; font-weight: 700; fill: var(--text-color); }
.whi-sub { font-size: 12px; fill: var(--text-secondary); }
.whi-mod rect { fill: none; stroke: var(--text-secondary); stroke-width: 1.2; stroke-dasharray: 4 3; }
.whi-mod text { font-size: 13px; font-weight: 600; fill: var(--text-color); }
.whi-line { fill: none; stroke: var(--text-secondary); stroke-width: 1.8; }
.whi-head { fill: var(--text-secondary); }
.whi-hitline { fill: none; stroke: transparent; stroke-width: 16; }
.whi-arrow { cursor: default; outline: none; }
.whi-arrow:hover .whi-line, .whi-arrow:focus-visible .whi-line { stroke: var(--accent-color); stroke-width: 2.6; }
.whi-key { margin-top: 0.75rem; }
.whg-label { font-size: 12px; fill: var(--text-secondary); }

/* catamenial cycle */
.whc-svg { min-width: 560px; }
.whc-band { fill: rgba(var(--accent-rgb), 0.12); }
.whc-bandlabel { font-size: 12px; font-weight: 700; fill: var(--text-color); }
.whc-e2 { fill: none; stroke: var(--viz-1); stroke-width: 2.6; stroke-linecap: round; }
.whc-p4 { fill: none; stroke: var(--viz-2); stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 7 4; }
.whc-lab { font-size: 12px; font-weight: 600; fill: var(--text-color); }
.whc-ovu { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 3 3; }
.whc-phase { stroke: var(--viz-axis); stroke-width: 6; stroke-linecap: round; }
.whc-phaselabel { font-size: 12px; font-weight: 700; fill: var(--text-secondary); }
.whc-sw { display: inline-block; width: 18px; height: 3px; border-radius: 2px; }
.whc-sw-e2 { background: var(--viz-1); }
.whc-sw-p4 { background: repeating-linear-gradient(90deg, var(--viz-2) 0 6px, transparent 6px 9px); }
.whc-sw-band { width: 14px; height: 12px; background: rgba(var(--accent-rgb), 0.18); }
.brf-whc .brf-chips { margin-bottom: 0.6rem; }

/* catamenial calculator */
.whcc-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 14rem)); gap: 0.75rem 1.25rem; margin-bottom: 0.9rem; }
.whcc-inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem 1rem; margin-bottom: 0.9rem; }
.brf-whcc select, .brf-whcc input[type="number"] { width: 100%; min-height: 40px; padding: 0.4rem 0.6rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--surface-1); color: var(--text-color); font: inherit; font-size: 0.9375rem; }
.brf-whcc select:focus-visible, .brf-whcc input:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.whcc-field label { display: grid; gap: 0.1rem; font-weight: 600; color: var(--text-color); }
.whcc-field small, .whcc-days { font-weight: 500; font-size: 0.75rem; color: var(--text-secondary); }
.whcc-chart .brf-svg { max-width: 36rem; }
.whcc-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.6rem; margin: 0.8rem 0 0; }
.whcc-results > div { padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.whcc-results dt { font-size: 0.8125rem; font-weight: 700; color: var(--text-color); }
.whcc-results dd { margin: 0.15rem 0 0; font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
.whcc-results strong { font-size: 1.1rem; color: var(--text-color); }
.whcc-yes, .whcc-no { display: inline-block; margin-top: 0.3rem; padding: 0.05rem 0.5rem; border-radius: 999px; font-weight: 700; font-size: 0.75rem; }
.whcc-yes { background: rgba(var(--accent-rgb), 0.16); color: var(--text-color); box-shadow: inset 0 0 0 1px var(--accent-color); }
.whcc-no { background: var(--surface-1); color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border-color); }
@media (max-width: 760px) {
  .whcc-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .whcc-controls { grid-template-columns: minmax(0, 1fr); }
}

/* contraception categories */
.whk-scroll { overflow-x: auto; }
.whk-table { width: 100%; min-width: 30rem; border-collapse: separate; border-spacing: 0 6px; font-size: 0.875rem; }
.whk-table thead th { padding: 0 0.6rem 0.2rem; font-size: 0.8125rem; font-weight: 700; text-align: left; color: var(--text-secondary); }
.whk-table tbody th { padding: 0.55rem 0.6rem; font-weight: 600; text-align: left; color: var(--text-color); background: var(--surface-2); border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.whk-cell { padding: 0.5rem 0.6rem; vertical-align: middle; color: var(--text-secondary); line-height: 1.4; }
.whk-cell:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.whk-cell .whk-badge { margin-right: 0.5rem; }
.whk-note { display: inline; }
.whk-badge { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; border-radius: 6px; font-weight: 800; font-size: 0.8125rem; vertical-align: middle; }
.whk-cat1 .whk-badge, .whk-badge.whk-cat1 { background: #d9f2e6; color: #0f5132; }
.whk-cat2 .whk-badge, .whk-badge.whk-cat2 { background: #fdeccc; color: #7a4a00; }
.whk-cat3 .whk-badge, .whk-badge.whk-cat3 { background: #fbd9d3; color: #8a1c0f; }
td.whk-cat1 { background: color-mix(in srgb, #1baf7a 7%, var(--surface-1)); }
td.whk-cat2 { background: color-mix(in srgb, #e09a1a 9%, var(--surface-1)); }
td.whk-cat3 { background: color-mix(in srgb, #d0503b 9%, var(--surface-1)); }
.whk-legend { margin: 0.4rem 0 0; }
.whk-legend .whk-badge { min-width: 1.35rem; height: 1.35rem; font-size: 0.75rem; }

/* pregnancy levels */
.whp-svg { min-width: 560px; }
.whp-risk { fill: rgba(208, 59, 59, 0.08); }
body.dark .whp-risk { fill: rgba(245, 154, 143, 0.12); }
.whp-base { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 4 3; }
.whp-delivery { stroke: var(--viz-axis); stroke-width: 1.2; }
.whp-line { fill: none; stroke: var(--viz-1); stroke-width: 2.8; stroke-linejoin: round; stroke-linecap: round; }
.whp-callout { font-size: 12px; font-weight: 600; fill: var(--text-color); }
.brf-whp .brf-chips { margin-bottom: 0.6rem; }

/* gender-affirming hormones */
.whg-svg { max-width: 44rem; margin: 0 auto; }
.whg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; margin-top: 0.9rem; }
.whg-grid section { padding: 0.8rem 0.9rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.whg-grid h4 { margin: 0 0 0.45rem; font-size: 0.9375rem; color: var(--text-color); }
.whg-grid ul { margin: 0; padding-left: 1.1rem; font-size: 0.875rem; line-height: 1.5; color: var(--text-secondary); }
.whg-grid li + li { margin-top: 0.35rem; }
.whg-grid strong { color: var(--text-color); }
@media (max-width: 760px) { .whg-grid { grid-template-columns: minmax(0, 1fr); } }

/* menopause */
.brf-whm .brf-svg { min-width: 520px; }
.whm-seg.whm-s0, .brf-swatch.whm-sw0 { fill: var(--viz-2); background: var(--viz-2); }
.whm-seg.whm-s1, .brf-swatch.whm-sw1 { fill: var(--viz-ctl); background: var(--viz-ctl); }
.whm-seg.whm-s2, .brf-swatch.whm-sw2 { fill: var(--viz-1); background: var(--viz-1); }
.whm-in { font-size: 12px; font-weight: 700; fill: #fff; }
.whm-in.whm-in-dark { fill: #292332; }
.brf-barh.whm-pbo { fill: var(--viz-ctl); }
.brf-barh.whm-hrt { fill: var(--viz-2); }

/* Presurgical workup flow and the stereo EEG implant (Seizure Management) */
.psw-flow { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 0.9rem; margin: 0; padding: 0; list-style: none; }
.psw-stage { position: relative; display: grid; align-content: start; gap: 0.35rem; padding: 0.85rem 0.9rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
.psw-stage:not(:last-child)::after { content: ""; position: absolute; top: 50%; right: -0.75rem; width: 0.6rem; height: 0.6rem; border-top: 2px solid var(--text-secondary); border-right: 2px solid var(--text-secondary); transform: translateY(-50%) rotate(45deg); }
.psw-stage > strong { font-size: 0.9375rem; line-height: 1.3; color: var(--text-color); }
.psw-stage ul { margin: 0; padding-left: 1rem; }
.psw-stage li + li { margin-top: 0.2rem; }
.psw-stage b { color: var(--text-color); font-weight: 600; }
.psw-asneeded { margin: 0.2rem 0 0; }
.psw-tag { justify-self: start; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--border-color); font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); }
.psw-meet { align-content: center; background: rgba(var(--accent-rgb), 0.08); border-color: color-mix(in srgb, var(--accent-color) 40%, var(--border-color)); }
.psw-branches { gap: 0.5rem; background: transparent; border: 0; padding: 0; }
.psw-branch { display: grid; gap: 0.15rem; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--border-color); background: var(--surface-1); }
.psw-branch strong { font-size: 0.8125rem; color: var(--text-color); }
.psw-b2 { border-color: var(--accent-color); box-shadow: inset 3px 0 0 var(--accent-color); }
@media (max-width: 900px) {
  .psw-flow { grid-template-columns: minmax(0, 1fr); }
  .psw-stage:not(:last-child)::after { top: auto; bottom: -0.75rem; right: auto; left: 1.4rem; transform: rotate(135deg); }
}

.sg-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem 1.5rem; align-items: start; }
.sg-svg { max-width: 38rem; }
@media (max-width: 900px) { .sg-grid { grid-template-columns: minmax(0, 1fr); } }
.brf-sg { --sg-brain: #efe7f3; --sg-wm: #faf7fb; --sg-line: #cdbfd9; --sg-gm: #dccbe8; --sg-hip: #e7c9dc; }
body.dark .brf-sg { --sg-brain: #5b4b77; --sg-wm: #4a3c63; --sg-line: #7c6a98; --sg-gm: #6f5d8e; --sg-hip: #7c5a86; }
.sg-brain { fill: var(--sg-brain); stroke: var(--sg-line); stroke-width: 1.4; }
.sg-wm { fill: var(--sg-wm); stroke: none; }
.sg-gm { fill: none; stroke: var(--sg-gm); stroke-width: 7; stroke-linecap: round; }
.sg-sulcus { fill: none; stroke: var(--sg-line); stroke-width: 1.4; stroke-linecap: round; }
.sg-deep { stroke-width: 2; }
.sg-fissure { stroke: var(--sg-line); stroke-width: 2; }
.sg-cc { fill: none; stroke: var(--sg-line); stroke-width: 7; stroke-linecap: round; opacity: 0.8; }
.sg-vent { fill: var(--surface-1); stroke: var(--sg-line); stroke-width: 1; }
.sg-deepgm { fill: var(--sg-gm); stroke: var(--sg-line); stroke-width: 1; opacity: 0.7; }
.sg-hip { fill: var(--sg-hip); stroke: var(--sg-line); stroke-width: 1.2; }
.sg-anat { font-size: 12px; font-weight: 600; fill: var(--text-secondary); }
.sg-shaft { stroke: var(--text-secondary); stroke-width: 2.2; stroke-linecap: round; }
.sg-shaft-big { stroke-width: 5; }
.sg-contact { fill: var(--accent-color); }
.sg-contact-deep { fill: var(--viz-2); }
.sg-contact-big { fill: var(--accent-color); }
.sg-contact-big.sg-contact-deep { fill: var(--viz-2); }
.sg-bolt { fill: var(--surface-1); stroke: var(--text-secondary); stroke-width: 1.6; }
.sg-hitline { stroke: transparent; stroke-width: 16; }
.sg-lead { cursor: default; outline: none; }
.sg-lead:hover .sg-shaft, .sg-lead:focus-visible .sg-shaft { stroke: var(--text-color); stroke-width: 3.2; }
.sg-strip { fill: none; stroke: var(--text-secondary); stroke-width: 7; stroke-linecap: round; opacity: 0.35; }
.sg-disc { fill: var(--surface-1); stroke: var(--accent-color); stroke-width: 2; }
.sg-dim { fill: none; stroke: var(--text-secondary); stroke-width: 1; }
.sg-inset { max-width: 36rem; }
.sg-trace { min-width: 620px; }

@media (max-width: 620px) {
  .whi-svg, .whg-svg, .sg-svg { min-width: 520px; }
}
