/* Statistical intuitions, on top of ../shared/base.css: the site's colours and compact
   surfaces, on a warm paper plane in the light theme,
   with a serif voice for titles and prose and the system sans for controls, numbers and
   figures. No transitions or animation. Chart colours were checked with the dataviz
   validator: groups A/B (and arrows A/B/C) are categorical slots 1–3, categories an ordinal
   teal ramp, probabilities a sequential blue ramp. */

/* Light: the warm paper plane over the shared tokens. Dark uses the shared tokens as they are. */
:root {
  --bg: #f6f5f1;
  --prose-width: 42rem;
  --surface-2: #f3f2ee;
  --border: #e2e0da;
  --faint: #8a8984;
  --grid: #ecebe6;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "URW Palladio L", P052, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, "Noto Sans", sans-serif;

  --ink: #1b1b1b;
  --a: #2a78d6;
  --a-soft: rgba(42, 120, 214, 0.16);
  --a-strong: rgba(42, 120, 214, 0.66);
  --b: #eb6834;
  --b-soft: rgba(235, 104, 52, 0.16);
  --b-strong: rgba(235, 104, 52, 0.66);
  --c: #1baf7a;
  /* Categorical slots 4–6 of the same validated order, for up to six series. */
  --d: #eda100;
  --e: #e87ba4;
  --f: #008300;
  --cat-0: #77bfa8; --cat-1: #5fa690; --cat-2: #488e79; --cat-3: #317663; --cat-4: #175f4d; --cat-5: #004939;
  --seq-0: #f3f7fd; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --seq-ink-low: #1b1b1b; --seq-ink-high: #ffffff;
}

:root[data-theme="dark"] {
  --faint: #85868a;
  --grid: #262a31;

  --ink: #e8e8e8;
  --a: #3987e5;
  --a-soft: rgba(57, 135, 229, 0.22);
  --a-strong: rgba(57, 135, 229, 0.72);
  --b: #d95926;
  --b-soft: rgba(217, 89, 38, 0.22);
  --b-strong: rgba(217, 89, 38, 0.74);
  --c: #199e70;
  --d: #c98500;
  --e: #d55181;
  --f: #008300;
  --cat-0: #115a48; --cat-1: #2f7460; --cat-2: #4a8e7a; --cat-3: #64a994; --cat-4: #7fc6af; --cat-5: #9ae3cb;
  --seq-0: #1a2130; --seq-1: #0d366b; --seq-2: #104281; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef;
  --seq-ink-low: #ffffff; --seq-ink-high: #10141a;
}

body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1 0 auto; }

/* Every focus ring sits 2 px out, controls included (base.css draws theirs at 1 px). */
:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; }
h1 { margin: 0; font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.6rem); }
h2 { margin: 0 0 0.5rem; font-size: 1.3rem; }
h3 { margin: 1.2rem 0 0.4rem; font-size: 1.08rem; }

var, .math { font-family: var(--serif); font-style: italic; }
.num { font-variant-numeric: tabular-nums; }

[hidden] { display: none !important; }

/* ---------- Header and footer ---------- */

.header-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
}
.crumbs { display: flex; flex-wrap: wrap; gap: 0.2rem 0.5rem; align-items: baseline; font-size: 0.95rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs .sep { color: var(--faint); }
.crumbs [aria-current="page"] { color: var(--text); }

.entry-head { padding: 1.6rem 0 0.4rem; }
.lede {
  margin: 0.6rem 0 0;
  max-width: var(--prose-width);
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--text);
}

.site-footer { margin-top: 2.5rem; background: var(--surface); }

/* ---------- Buttons and fields ----------
   The gallery's own shapes and weights, over the shared ones; a disabled button takes the
   shared grey, dashed look. On a phone or touch screen the shared floor applies here too:
   controls and labelled checkboxes at least 44 px high, field text at least 16 px. */

button, .button {
  font-weight: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.92rem;
}
button:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button.quiet:hover { color: var(--text); background: var(--surface-2); }

select, input[type="number"], input[type="text"] {
  min-height: 2.25rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}
input[type="number"] { width: 5.5rem; font-variant-numeric: tabular-nums; text-align: right; }
input[aria-invalid="true"] { border-color: var(--alert); background: var(--alert-soft); }
/* The shared field box is for text and numbers; sliders, checkboxes and radios stay native. */
input[type="range"], input[type="checkbox"], input[type="radio"] { min-width: revert; max-width: revert; padding: revert; border: revert; border-radius: revert; background: revert; }
input[type="range"] { width: 100%; margin: 0.2rem 0 0; accent-color: var(--primary); min-height: 1.75rem; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); }

/* ---------- The bench: controls beside the figures ---------- */

.bench {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 1rem;
}
@media (min-width: 1000px) {
  .bench {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-areas: "controls main" "controls rest";
    align-items: start;
  }
  .bench > .controls { grid-area: controls; position: sticky; top: 1rem; }
  .bench > .main { grid-area: main; }
  .bench > .rest { grid-area: rest; }
}
.bench > * { min-width: 0; }
.stack { display: grid; gap: 1rem; min-width: 0; }

.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
@media (max-width: 480px) {
  .card { padding: 0.8rem; }
}

.controls h2 { font-size: 1.1rem; }
.control { display: grid; gap: 0.1rem; padding: 0.55rem 0; border-top: 1px solid var(--grid); }
.control:first-of-type { border-top: 0; }
.control-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  align-items: center;
  justify-content: space-between;
}
.control-head label, .control-head .label { font-size: 0.95rem; }
.control .hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.unit { color: var(--muted); font-size: 0.9rem; }
.value-field { display: inline-flex; gap: 0.3rem; align-items: center; }
.control-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.threshold-list { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; }
.threshold-list label { display: inline-flex; gap: 0.3rem; align-items: center; font-size: 0.9rem; }
.threshold-list input { width: 4.8rem; }
.controls-foot { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.field-error { margin: 0.2rem 0 0; color: var(--alert); font-size: 0.85rem; }
.field-error::before { content: "⚠ "; }

/* ---------- Figures ---------- */

figure { margin: 0; }
.figure-head { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: baseline; justify-content: space-between; margin-bottom: 0.4rem; }
.figure-head h2 { margin: 0; font-size: 1.12rem; }
figcaption, .caption { margin: 0.1rem 0 0.5rem; max-width: var(--prose-width); color: var(--muted); font-size: 0.92rem; }
.plot-box { position: relative; width: 100%; min-width: 0; touch-action: pan-y; }
.plot-box svg { display: block; max-width: 100%; height: auto; }
.plot-box.scrub { cursor: ew-resize; }
.figure-row { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) {
  .figure-row.wide-narrow { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: end; }
  .figure-row.halves { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0 0 0.5rem; padding: 0; list-style: none; font-size: 0.88rem; color: var(--muted); }
.legend li { display: inline-flex; gap: 0.35rem; align-items: center; }
.legend svg { flex: none; }

/* SVG chrome */
.plot { font-family: var(--sans); overflow: visible; }
.plot text { font-size: 12px; fill: var(--muted); }
.plot .tick { font-variant-numeric: tabular-nums; }
.plot .axis-label { fill: var(--muted); font-size: 12px; }
.plot .tier-label { fill: var(--text); font-size: 12.5px; font-weight: 600; }
.plot .direct-label { fill: var(--text); font-size: 12px; }
.plot .axis-line { stroke: var(--faint); stroke-width: 1; }
.plot .grid { stroke: var(--grid); stroke-width: 1; }
.plot .baseline { stroke: var(--faint); stroke-width: 1; }
.plot .ink-line { fill: none; stroke: var(--ink); stroke-width: 2; }
.plot .ink-thin { fill: none; stroke: var(--ink); stroke-width: 1; }
.plot .muted-line { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 5 4; }
.plot .marker-line { stroke: var(--ink); stroke-width: 1; }
.plot .cut-pooled { stroke: var(--ink); stroke-width: 1.5; }
.plot .a-line { fill: none; stroke: var(--a); stroke-width: 2; }
.plot .b-line { fill: none; stroke: var(--b); stroke-width: 2; }
.plot .a-cut { stroke: var(--a); stroke-width: 1.5; stroke-dasharray: 4 3; }
.plot .b-cut { stroke: var(--b); stroke-width: 1.5; stroke-dasharray: 4 3; }
.plot .a-soft { fill: var(--a-soft); }
.plot .b-soft { fill: var(--b-soft); }
.plot .a-strong { fill: var(--a-strong); }
.plot .b-strong { fill: var(--b-strong); }
.plot .a-mark { fill: var(--a); stroke: var(--surface); stroke-width: 1.5; }
.plot .b-mark { fill: var(--b); stroke: var(--surface); stroke-width: 1.5; }
.plot .ink-mark { fill: var(--ink); stroke: var(--surface); stroke-width: 1.5; }
.plot .hollow-mark { fill: var(--surface); stroke: var(--faint); stroke-width: 1.5; }
.plot .surface-fill { fill: var(--surface); }
.plot .handle { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; cursor: grab; }
.plot .handle-hit { fill: transparent; cursor: grab; }
.plot .handle-label { fill: var(--text); font-size: 11px; }
.plot .threshold-line { stroke: var(--ink); stroke-width: 1.5; }
.plot .ellipse { fill: none; stroke: var(--ink); stroke-width: 1; opacity: 0.75; }
.plot .ellipse-label { font-size: 11px; fill: var(--muted); }
.plot .point-path { fill: none; stroke: var(--ink); stroke-width: 3.4; stroke-linecap: round; opacity: 0.5; }
.plot .frame { fill: none; stroke: var(--faint); stroke-width: 1; }
.plot .small { font-size: 11px; }
.plot .cell-outline { fill: none; stroke: var(--surface); stroke-width: 2; }
.plot .margin-bar { fill: var(--faint); opacity: 0.55; }
.plot .value-label { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.plot .cell-text { font-size: 13px; font-variant-numeric: tabular-nums; }
.plot .cell-count { font-size: 11px; font-variant-numeric: tabular-nums; }

.plot .cat-0 { fill: var(--cat-0); } .plot .cat-1 { fill: var(--cat-1); } .plot .cat-2 { fill: var(--cat-2); }
.plot .cat-3 { fill: var(--cat-3); } .plot .cat-4 { fill: var(--cat-4); } .plot .cat-5 { fill: var(--cat-5); }
/* Text in a cell takes whichever ink contrasts better with that step (4.5:1 or more). */
.plot .seq-0 { --cell: var(--seq-0); --cell-ink: var(--seq-ink-low); }
.plot .seq-1 { --cell: var(--seq-1); --cell-ink: var(--seq-ink-low); }
.plot .seq-2 { --cell: var(--seq-2); --cell-ink: var(--seq-ink-low); }
.plot .seq-3 { --cell: var(--seq-3); --cell-ink: var(--seq-ink-low); }
.plot .seq-4 { --cell: var(--seq-4); --cell-ink: var(--seq-ink-low); }
.plot .seq-5 { --cell: var(--seq-5); --cell-ink: var(--seq-ink-high); }
.plot .seq-6 { --cell: var(--seq-6); --cell-ink: var(--seq-ink-high); }
.plot .cell-fill { fill: var(--cell); }
.plot .cell-ink { fill: var(--cell-ink); }

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

.readout { margin: 0.2rem 0 0.6rem; max-width: var(--prose-width); font-family: var(--serif); font-size: 1.05rem; }
.table-wrap { overflow-x: auto; }
table.numbers { width: 100%; border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
table.numbers th, table.numbers td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--grid); text-align: right; vertical-align: top; }
table.numbers th:first-child, table.numbers td:first-child { text-align: left; }
table.numbers thead th { color: var(--muted); font-weight: 500; font-size: 0.88rem; }
table.numbers tbody th { font-weight: 500; }
table.numbers tr.total th, table.numbers tr.total td { border-bottom: 0; font-weight: 600; }
.group-tag { display: inline-flex; gap: 0.35rem; align-items: center; white-space: nowrap; }
.glyph { flex: none; }

dl.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.6rem 1rem; margin: 0.4rem 0 0.2rem; }
dl.stats div { min-width: 0; }
dl.stats dt { color: var(--muted); font-size: 0.86rem; }
dl.stats dd { margin: 0; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
dl.stats dd small { font-size: 0.85rem; color: var(--muted); }

.note { margin: 0.4rem 0 0; padding: 0.55rem 0.75rem; border-left: 3px solid var(--faint); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.92rem; }
.issues { margin: 0.5rem 0; padding: 0.5rem 0.75rem; border: 1px solid var(--alert); border-radius: var(--radius-sm); background: var(--alert-soft); color: var(--text); font-size: 0.92rem; }
.issues p { margin: 0; }
.issues p::before { content: "⚠ "; color: var(--alert); }

/* ---------- Tabs ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0 0; padding: 0; }
.tabs [role="tab"] { border-radius: 999px; }
.tabs [role="tab"][aria-selected="true"] { border-color: var(--primary); background: var(--primary); color: var(--surface); }
:root[data-theme="dark"] .tabs [role="tab"][aria-selected="true"] { color: #0f1114; }
.tabs [role="tab"][aria-selected="true"]::before { content: "● "; }

/* ---------- Prose notes ---------- */

.notes { margin-top: 1.5rem; }
.notes .prose { columns: auto; }
.entry-head > .note, .prose ul, .prose ol { max-width: var(--prose-width); }
.prose p, .prose li { font-family: var(--serif); font-size: 1.04rem; line-height: 1.6; max-width: var(--prose-width); }
.prose p { margin: 0 0 0.8rem; break-inside: avoid; }
.prose h3 { break-after: avoid; }
.prose h3:first-child { margin-top: 0; }

/* ---------- Count grid (fit a table) ---------- */

.count-grid { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.count-grid th { padding: 0.2rem 0.4rem; color: var(--muted); font-weight: 500; font-size: 0.85rem; text-align: center; }
.count-grid td { padding: 0.15rem; }
.count-grid input { width: 4.2rem; }
.count-grid .corner { text-align: left; }

/* ---------- Gallery index ---------- */

/* Keep the teaching pages' narrower reading measure; the index uses the available wall. */
.gallery-page .container { width: min(100% - 32px, 1760px); }
.gallery-page .entry-head { padding-top: 1.1rem; }
.gallery-page .lede { font-size: 1.04rem; }
.gallery {
  --cols: 1;
  --gap: 0.85rem;
  --wall-width: min(calc(100vw - 2rem), 1760px);
  --unit: calc((var(--wall-width) - (var(--cols) - 1) * var(--gap)) / var(--cols));
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
  margin-top: 1.1rem;
}
@media (min-width: 760px) {
  .gallery { --cols: 4; grid-auto-rows: minmax(calc(var(--unit) * 0.68), auto); }
}
@media (min-width: 1200px) { .gallery { --cols: 6; } }
@media (min-width: 1680px) { .gallery { --cols: 8; } }
.entry-card { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.8rem; color: inherit; text-decoration: none; }
.entry-card:hover { border-color: var(--primary); }
.entry-card:hover h2 { text-decoration: underline; text-underline-offset: 3px; }
.entry-card h2 { margin: 0; font-size: 1.22rem; color: var(--text); }
.entry-card p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.4; }
.entry-card .thumb { flex: 1 0 100px; min-height: 100px; border-radius: var(--radius-sm); background: var(--surface-2); }
.entry-card .thumb svg, .entry-card .thumb img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 0.4rem; object-fit: contain; }
.entry-card .meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; align-items: center; color: var(--muted); font-size: 0.8rem; }
.entry-card time { padding: 0.05rem 0.5rem; border: 1px solid var(--border); border-radius: 999px; font-variant-numeric: tabular-nums; }
@media (max-width: 759px), (max-height: 540px) {
  .gallery { --mosaic-flow: 1; grid-auto-rows: auto; }
  .entry-card .thumb { flex: none; height: clamp(120px, 36vw, 180px); }
}
.calibration-observed { stroke: #c62828; }
.calibration-marker { fill: #c62828; stroke: var(--surface-2); stroke-width: 1; }
:root[data-theme="dark"] .calibration-observed { stroke: #ff6b6b; }
:root[data-theme="dark"] .calibration-marker { fill: #ff6b6b; }
.intro { max-width: var(--prose-width); }
.first-figure-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 0.4rem; color: var(--primary); font: 600 0.95rem var(--sans); text-underline-offset: 3px; }
.plot-box[tabindex="-1"] { scroll-margin-top: 3rem; }
.plot-box[tabindex="-1"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }

/* ---------- Explorable panels (correlation geometry) ---------- */

.panel-nav ol { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; margin: 0.9rem 0 0; padding-left: 0; list-style-position: inside; font-size: 0.95rem; }
.panel-nav li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.panel { margin-top: 1.2rem; scroll-margin-top: 1rem; }
.panel > h2 { font-size: 1.35rem; }
.panel-number {
  display: inline-grid;
  margin-right: 0.5rem;
  vertical-align: 0.12em;
  place-items: center;
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border: 1.5px solid var(--primary);
  border-radius: 50%;
  color: var(--primary);
  font: 600 0.95rem/1 var(--sans);
}
.panel-intro { margin: 0 0 0.9rem; max-width: var(--prose-width); font-family: var(--serif); font-size: 1.04rem; line-height: 1.6; }
.panel-body { display: grid; gap: 1.2rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .panel-body { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 1.6rem; }
}
.panel-side { display: grid; gap: 0.5rem; align-content: start; min-width: 0; }
.panel-side .control:first-child { border-top: 0; }
.panel-side .readout { margin: 0.3rem 0 0; }
@media (min-width: 900px) {
  .panel-body.recovery-layout { grid-template-columns: minmax(16rem, 0.8fr) minmax(0, 1.35fr); }
}
.recovery-layout output { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--primary); }
.recovery-layout .control-head { display: grid; grid-template-columns: 1fr auto; align-items: baseline; }
.recovery-readings h3, .recovery-detail h3 { font-size: 1rem; margin: 0.6rem 0 0.4rem; }
.recovery-readings dl { margin: 0; }
.recovery-readings dl > div { display: flex; justify-content: space-between; gap: 0.4rem; border-bottom: 1px solid var(--grid); padding: 0.3rem 0; }
.recovery-readings dt { display: flex; gap: 0.45rem; align-items: center; }
.recovery-readings dt svg { flex: none; }
.plot .recovery-pairwise { stroke-dasharray: 2 3; }
.plot .recovery-equal { stroke-dasharray: 6 3; }
.recovery-readings dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.recovery-detail { border-top: 1px solid var(--border); margin-top: 0.7rem; }
.recovery-detail summary { padding: 0.6rem 0; cursor: pointer; font-weight: 600; }
.recovery-detail p { max-width: var(--prose-width); margin: 0.3rem 0 0.8rem; }
.recovery-spectrum { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); max-width: 34rem; gap: 0.2rem; margin: 0.7rem 0; }
.recovery-spectrum div { display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 0.2rem; }
.recovery-spectrum span, .recovery-spectrum small { font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.recovery-spectrum i { background: var(--a); width: min(65%,2.4rem); }
.side-heading { margin: 0.6rem 0 0; font-size: 1rem; }
.curve-block { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--grid); }
.curve-block h3 { margin: 0; }
.panel .tabs { margin: 0 0 0.8rem; }
.note strong { font-family: var(--sans); }

.scene { border-radius: var(--radius-sm); background: var(--surface-2); cursor: grab; }
.scene:active { cursor: grabbing; }
.scene:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.view-controls { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.45rem 0 0.2rem; }
.view-controls button { min-height: 2.25rem; padding: 0.25rem 0.75rem; font-size: 0.88rem; }
.view-controls button.icon { min-width: 2.5rem; justify-content: center; }
.view-controls .hint { color: var(--muted); font-size: 0.85rem; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.segmented label { display: inline-flex; gap: 0.35rem; align-items: center; min-height: 2.25rem; padding: 0.25rem 0.8rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.segmented input { accent-color: var(--primary); margin: 0; }
.panel-side > .control { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; }
.panel-side > .control:has(input[type="range"]) { display: grid; }

.data-row { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; align-items: flex-start; }
.data-row .table-wrap { flex: none; }
.data-row .scatter { flex: 1 1 200px; min-width: 180px; max-width: 320px; }
.data-grid { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-grid th { padding: 0.2rem 0.4rem; color: var(--muted); font-weight: 500; font-size: 0.88rem; text-align: center; }
.data-grid td { padding: 0.15rem; }
.data-grid input { width: 4.6rem; }

.matrix-grid { border-collapse: separate; border-spacing: 3px; font-variant-numeric: tabular-nums; }
.matrix-grid th { padding: 0.1rem 0.3rem; color: var(--muted); font-weight: 500; font-size: 0.88rem; text-align: center; }
.matrix-grid td { min-width: 3.9rem; padding: 0.2rem; border: 2px solid transparent; border-radius: 6px; background: var(--seq-0); color: var(--seq-ink-low); text-align: center; vertical-align: top; }
.matrix-grid td.diag { background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.matrix-grid td[data-shade="1"] { background: var(--seq-1); }
.matrix-grid td[data-shade="2"] { background: var(--seq-2); }
.matrix-grid td[data-shade="3"] { background: var(--seq-3); }
.matrix-grid td[data-shade="4"] { background: var(--seq-4); }
.matrix-grid td[data-shade="5"] { background: var(--seq-5); color: var(--seq-ink-high); }
.matrix-grid td[data-shade="6"] { background: var(--seq-6); color: var(--seq-ink-high); }
.matrix-grid td.chosen { border-color: var(--ink); border-style: dashed; }
.matrix-grid td.primary { border-style: solid; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.matrix-grid input { width: 4.1rem; min-height: 2rem; padding: 0.15rem 0.35rem; background: var(--surface); color: var(--text); appearance: textfield; -moz-appearance: textfield; }
.matrix-grid input[aria-invalid="true"] { background: var(--alert-soft); }
/* The arrow keys still step a cell; the spinner would cover its digits. */
.matrix-grid input::-webkit-inner-spin-button, .matrix-grid input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.matrix-grid .cell-width { display: block; margin-top: 0.1rem; font-size: 0.75rem; line-height: 1.2; white-space: nowrap; }

/* 3-D scene marks */
.plot .wire { stroke: var(--border); stroke-width: 1; }
.plot .wire.back { stroke: var(--grid); stroke-dasharray: 2 3; }
.plot .sphere-outline { stroke: var(--faint); stroke-width: 1.2; }
.plot .great-circle { stroke: var(--ink); stroke-width: 2; }
.plot .great-circle.back { stroke-width: 1.3; stroke-dasharray: 4 4; opacity: 0.55; }
.plot .plane-patch { fill: var(--faint); fill-opacity: 0.13; }
.plot .box-patch { fill: var(--primary); fill-opacity: 0.08; stroke: var(--primary); stroke-opacity: 0.35; stroke-width: 0.8; }
.plot .axis3 { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 1 3; }
.plot .axis-common { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 6 4; }
.plot .centred-line { stroke: var(--faint); stroke-width: 1.2; stroke-dasharray: 5 4; }
.plot .arrow { stroke-width: 3; stroke-linecap: round; }
.plot .arrow.dashed { stroke-width: 2.2; stroke-dasharray: 6 4; }
.plot .a-stroke { stroke: var(--a); }
.plot .b-stroke { stroke: var(--b); }
.plot .c-stroke { stroke: var(--c); }
.plot .ink-stroke { stroke: var(--ink); stroke-width: 2.2; }
.plot .c-mark { fill: var(--c); stroke: var(--surface); stroke-width: 1.5; }
.plot .b-cone { fill: var(--b); fill-opacity: 0.12; }
.plot .b-ring { stroke: var(--b); stroke-width: 1.6; }
.plot .angle-arc { fill: none; stroke: var(--ink); stroke-width: 1.3; }
.plot .simplex-edge { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.plot .scene-label { fill: var(--text); font-size: 12.5px; paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round; }
.plot .scene-label.strong { font-weight: 700; font-size: 13.5px; }
.plot .scene-label.small { fill: var(--muted); font-size: 11px; }

/* Intervals, eigenvalues and curves */
.plot .det-fill { fill: var(--primary); fill-opacity: 0.12; }
.plot .det-outside { fill: none; stroke: var(--alert); stroke-width: 1.5; stroke-dasharray: 4 3; }
.plot .range-track { stroke: var(--grid); stroke-width: 8; stroke-linecap: round; }
.plot .range-bar { stroke: var(--primary); stroke-width: 8; stroke-linecap: round; }
.plot .range-bar.thin { stroke-width: 5; stroke-opacity: 0.6; }
.plot .range-end { stroke: var(--primary); stroke-width: 2; }
.plot .eig-bar { fill: var(--primary); fill-opacity: 0.75; }
.plot .eig-bar.negative { fill: var(--alert); fill-opacity: 0.85; }
.plot .feasible-band { fill: var(--primary); fill-opacity: 0.1; }
.plot .equal-line { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.plot .alert-mark { fill: var(--alert); stroke: var(--surface); stroke-width: 1.5; }
.plot .c-line { fill: none; stroke: var(--c); stroke-width: 2; }
.plot .c-line.zero { stroke-width: 3; }
.plot .hollow-strong { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }

.entry-card.feature { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .entry-card.feature { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: 1fr auto auto auto 1fr; column-gap: 1.6rem; }
  .entry-card.feature .thumb { grid-row: 1 / -1; }
  .entry-card.feature > :not(.thumb) { grid-column: 2; }
  .entry-card.feature h2 { grid-row: 2; }
  .entry-card.feature p { grid-row: 3; }
  .entry-card.feature .meta { grid-row: 4; }
}

/* ---------- Probability mass (typical set) ---------- */

.plot .b-line.dashed, .plot .ink-line.dashed { stroke-dasharray: 6 4; }
.plot .mass-fill { fill: var(--ink); fill-opacity: 0.07; }
.plot .shell-fill { fill: var(--primary); fill-opacity: 0.18; }
.plot .region-fill { fill: var(--primary); fill-opacity: 0.3; }
.plot .water-line { stroke: var(--primary); stroke-width: 1.5; stroke-dasharray: 6 3; }
.plot .ball-line { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 2 3; }
.plot .a-range { stroke: var(--a); stroke-width: 2; stroke-linecap: round; opacity: 0.7; }
.plot .hist-bar { fill: var(--faint); fill-opacity: 0.35; }
.plot .direct-label.strong { font-weight: 600; }
.plot .mass-swatch { fill: var(--ink); fill-opacity: 0.15; }
/* A label that may cross a curve keeps a ring of the card's colour around its letters. */
.plot .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.panel-side > .hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.component-grid select { min-height: 2rem; padding: 0.15rem 0.3rem; }

/* ---------- Adjustment (causal graphs) ---------- */

.preset-row { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; margin: 0 0 0.9rem; padding: 0; border-top: 0; }
.control-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.45rem 0.7rem; align-items: center; }
.control-grid select { width: 100%; }
.choice-list { margin: 0.3rem 0 0; padding: 0.55rem 0 0; border: 0; border-top: 1px solid var(--grid); }
.choice-list legend { padding: 0; font-size: 0.95rem; }
.checks { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: 0.3rem; }
.checks label { display: inline-flex; gap: 0.35rem; align-items: center; min-height: 2rem; }
#adjust-coefficients .control:first-child { border-top: 0; }

.verdict { margin: 0.6rem 0; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); font-family: var(--serif); font-size: 1.05rem; line-height: 1.5; }
.verdict strong { font-family: var(--sans); }
.verdict.ok { border: 1.5px solid var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.verdict.bad { border: 2px dashed var(--alert); background: var(--alert-soft); }
.good { color: var(--ok); font-weight: 600; white-space: nowrap; }
.poor { color: var(--alert); font-weight: 600; }

.path-list { margin: 0.4rem 0 0; padding: 0; list-style: none; }
.path-list li { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.35rem 0; border-bottom: 1px solid var(--grid); }
.path-glyph { flex: none; width: 1rem; text-align: center; }
.path-text { font-weight: 600; font-variant-numeric: tabular-nums; }
.path-status { color: var(--muted); font-size: 0.92rem; }
.path.open.bias .path-glyph, .path.open.bias .path-status { color: var(--alert); }
.path.open.causal .path-glyph { color: var(--ok); }
.path.blocked .path-glyph { color: var(--faint); }

.sets-table td, .sets-table th { vertical-align: middle; }
.set-button { min-height: 2rem; padding: 0.15rem 0.6rem; font-variant-numeric: tabular-nums; }
.sets-table tr.current .set-button { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.sample-row { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .sample-row { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 1.6rem; } }

/* Legend chips that repeat the node outlines in the graph. */
.key { display: inline-block; padding: 0.05rem 0.55rem; border: 1.5px solid var(--faint); border-radius: 999px; color: var(--text); font-size: 0.85rem; }
.key.exposure { border: 2.5px solid var(--a); }
.key.outcome { border: 2.5px solid var(--b); }
.key.adjusted { border: 2px solid var(--ink); border-radius: 2px; background: color-mix(in srgb, var(--ink) 12%, var(--surface)); }
.key.latent { border-style: dashed; }

.plot.dag { overflow: visible; }
.plot .dag-node { fill: var(--surface); stroke: var(--faint); stroke-width: 1.5; }
.plot .dag-node.exposure { stroke: var(--a); stroke-width: 3; }
.plot .dag-node.outcome { stroke: var(--b); stroke-width: 3; }
.plot .dag-node.adjusted { fill: color-mix(in srgb, var(--ink) 12%, var(--surface)); stroke: var(--ink); stroke-width: 2; }
.plot .dag-node.latent { stroke-dasharray: 4 3; }
.plot .node-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.plot .node-role { fill: var(--muted); font-size: 11px; }
.plot .dag-toggle { cursor: pointer; }
.plot .dag-edge { stroke: var(--ink); stroke-width: 1.6; }
.plot .dag-edge.thin { stroke-width: 1.1; opacity: 0.8; }
.plot .dag-edge.zero { stroke: var(--faint); stroke-dasharray: 3 4; }
.plot .dag-edge.bias { stroke: var(--alert); stroke-width: 2.8; stroke-dasharray: 7 3; }
.plot .arrow-head { fill: var(--ink); }
.plot .arrow-head.bias { fill: var(--alert); }
.plot .arrow-head.zero { fill: var(--faint); }
.plot .edge-label { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.plot .edge-label.zero { fill: var(--muted); }
.plot .sample-dot { fill: var(--a); fill-opacity: 0.35; }
.plot .effect-line { stroke: var(--c); stroke-width: 2; stroke-dasharray: 6 4; }
.plot .ink-line.heavy { stroke-width: 3; }
.plot .seq-line { fill: none; stroke-width: 1.6; }
.plot .seq-line.s1 { stroke: var(--seq-2); } .plot .seq-line.s2 { stroke: var(--seq-3); } .plot .seq-line.s3 { stroke: var(--seq-4); }
.plot .seq-line.s4 { stroke: var(--seq-5); } .plot .seq-line.s5 { stroke: var(--seq-6); } .plot .seq-line.s6 { stroke: var(--seq-6); stroke-dasharray: 5 3; }

/* ---------- Null p-values ---------- */

.alpha-row { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; margin: 0.9rem 0 0; }
.hist-pair { display: grid; gap: 0.4rem 1rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-bottom: 0.8rem; }
@media (max-width: 359px) { .hist-pair { grid-template-columns: minmax(0, 1fr); } }
.hist-pair > div { display: flex; flex-direction: column; min-width: 0; }
.hist-pair .plot-box { margin-top: auto; }
.hist-title { display: grid; gap: 0.05rem; margin: 0 0 0.2rem; font-size: 0.9rem; line-height: 1.3; overflow-wrap: break-word; }
.hist-name { font-weight: 600; }
.hist-name svg { vertical-align: -2px; }
.hist-rate { color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-note { margin: 2rem 0; }
.sim-status { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.88rem; }
.sim-control .control-row { margin-top: 0.3rem; }
.plot .alpha-line { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 2 3; }
.plot .ink-line.thin-dash { stroke-width: 1.5; }
.plot .cut-mark { stroke: var(--surface); stroke-width: 3; }

/* ---------- Marchenko–Pastur ---------- */

.plot .edge-line { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 5 4; opacity: 0.75; }
.plot .variance-line { stroke: var(--a); stroke-width: 1.5; }
.plot .hollow-b { fill: var(--surface); stroke: var(--b); stroke-width: 1.8; }
.plot .b-range { stroke: var(--b); stroke-width: 2; stroke-linecap: round; opacity: 0.7; }
.plot .a-dot { fill: var(--a); fill-opacity: 0.6; }
.plot .b-dot { fill: var(--b); fill-opacity: 0.6; }
.check-row { gap: 0.45rem; padding: 0.55rem 0; border-top: 1px solid var(--grid); }

/* ---------- Traits on a tree ---------- */

.playback { display: flex; flex-wrap: wrap; gap: 0.45rem 0.8rem; align-items: center; margin: 0.5rem 0 0.4rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.playback .play { min-width: 6.2rem; justify-content: center; font-weight: 600; }
.playback .play[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.playback .glyph { display: inline-block; width: 1em; text-align: center; }
.playback input[type="range"] { flex: 1 1 12rem; width: auto; margin: 0; }
.playback .time-field, .playback .speed-field { display: inline-flex; gap: 0.35rem; align-items: center; font-size: 0.92rem; white-space: nowrap; }
.playback output { min-width: 6.5em; font-variant-numeric: tabular-nums; color: var(--muted); }
.playback .reduced-note { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 0.85rem; }
.sub-controls { display: grid; gap: 0.3rem; margin-top: 0.4rem; }
.sub-controls textarea { width: 100%; min-height: 4.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.choice-list.bare { margin: 0; padding: 0; border-top: 0; }
.panel-side textarea[aria-invalid="true"] { border-color: var(--alert); background: var(--alert-soft); }
.point-grid { display: grid; grid-template-columns: auto minmax(0, 5.5rem) minmax(0, 5.5rem); gap: 0.35rem 0.5rem; align-items: center; margin-top: 0.3rem; }
.point-grid input { width: 100%; }

.plot .tree-future { fill: none; stroke: var(--border); stroke-width: 1.4; }
.plot .tree-branch { fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: square; }
.plot .tree-branch.clade { stroke: var(--b); stroke-width: 2.4; }
.plot .tip-label { fill: var(--text); font-size: 11.5px; }
.plot .tip-label.clade { font-weight: 700; }
.plot .clade-bracket { fill: none; stroke: var(--b); stroke-width: 2; }
.plot .front-line { stroke: var(--primary); stroke-width: 1.3; stroke-dasharray: 4 3; }
.plot .front-ring { fill: none; stroke: var(--primary); stroke-width: 1.3; stroke-dasharray: 4 3; }
.plot .off { display: none; }
.plot .front-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; }
.plot .front-dot.clade { stroke: var(--b); stroke-width: 2; }
.plot .lineage { fill: none; stroke: var(--ink); stroke-width: 1.25; stroke-opacity: 0.85; stroke-linejoin: round; }
.plot .lineage.clade { stroke: var(--b); stroke-opacity: 0.95; }
.plot .band { fill: var(--a-soft); }
.plot .band.ink { fill: var(--faint); fill-opacity: 0.16; }
.plot .band.clade { fill: var(--b-soft); }
.plot .optimum-line { stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 6 4; }
.plot .optimum-line.clade { stroke: var(--b); }
.plot .burst-line { stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 2 3; }
.plot .leader { fill: none; stroke: var(--faint); stroke-width: 0.8; }
.plot .band-swatch { fill: var(--a-soft); }
.plot .band-swatch.ink { fill: var(--faint); fill-opacity: 0.3; }
.plot .shadow-line { stroke: var(--faint); stroke-width: 1.5; }
.plot .hollow-a { fill: var(--surface); stroke: var(--a); stroke-width: 1.5; }
.plot .wall-patch { fill: var(--faint); fill-opacity: 0.07; }
.plot .now-patch { fill: var(--primary); fill-opacity: 0.09; stroke: var(--primary); stroke-opacity: 0.45; stroke-width: 1; }
.plot .shadow { fill: none; stroke: var(--faint); stroke-width: 1; stroke-opacity: 0.7; }
.plot .path3 { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.plot .region, .plot .region-swatch { fill: color-mix(in srgb, var(--c) 13%, var(--surface)); stroke: var(--c); stroke-width: 1.5; }
.plot .bridge-path { fill: none; stroke: var(--ink); stroke-width: 1; stroke-linejoin: round; }
.plot .free-ellipse { fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 5 4; }

/* ---------- A tree is a covariance matrix ---------- */

.plot .branch { stroke: var(--ink); stroke-width: 2; stroke-linecap: square; }
.plot .branch.strong { stroke: var(--primary); stroke-width: 4.5; }
.plot .branch.faded { stroke: var(--faint); stroke-width: 1.3; stroke-dasharray: 3 3; }
.plot .extension { stroke: var(--ink); stroke-width: 2.4; stroke-dasharray: 1.5 3.5; stroke-linecap: round; }
.plot .length-label { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.plot .length-label.faded { fill: var(--faint); }
.plot .tip-name { fill: var(--text); font-size: 13px; font-weight: 700; }
.plot .tip-name.faded { fill: var(--faint); font-weight: 400; }
.plot .node-name { fill: var(--muted); font-size: 12px; }
.plot .node-name.strong { fill: var(--text); font-weight: 700; font-size: 13px; }
.plot .node-note { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.plot .scatter-dots { stroke: var(--a); stroke-width: 3.2; stroke-linecap: round; stroke-opacity: 0.4; }
.plot .ellipse-ring { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 5 4; }
.plot .root-line, .plot .root-swatch { stroke: var(--primary); stroke-width: 2.5; }
.plot .strong-tick { fill: var(--text); font-weight: 600; }
.vcv-grid td { min-width: 3.4rem; vertical-align: middle; }
.vcv-grid td.chosen { border-color: var(--ink); border-style: solid; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.cell-button { width: 100%; min-height: 2rem; padding: 0.15rem 0.4rem; justify-content: center; border: 0; border-radius: 4px; background: transparent; color: inherit; font-variant-numeric: tabular-nums; }
.cell-button:hover:not(:disabled) { background: color-mix(in srgb, var(--surface) 40%, transparent); }
.cell-button[aria-pressed="true"] { font-weight: 700; }
.cell-button[aria-pressed="true"]::before { content: "● "; font-size: 0.7em; }
.step-bar { display: flex; flex-wrap: wrap; gap: 0.45rem 0.6rem; align-items: center; margin: 0 0 0.5rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.step-count { min-width: 9rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.step-table tr.current th, .step-table tr.current td { background: var(--primary-soft); font-weight: 600; }
.step-table tr.future th, .step-table tr.future td { color: var(--faint); }
.matrix-row { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; align-items: flex-start; }
.small-matrix .hist-name { margin: 0 0 0.25rem; font-size: 0.9rem; }
.bracket-matrix { border-collapse: collapse; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); font-variant-numeric: tabular-nums; }
.bracket-matrix td { min-width: 2.6rem; padding: 0.2rem 0.45rem; text-align: center; }
.length-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.35rem 0.8rem; align-items: center; }
.length-grid label { display: inline-flex; justify-content: space-between; gap: 0.4rem; font-size: 0.92rem; }
.length-grid { grid-template-columns: max-content minmax(0, 6rem) max-content minmax(0, 6rem); }
.length-grid input { width: 100%; }
.sub-label { margin: 0.35rem 0 0.15rem; font-size: 0.92rem; color: var(--muted); }
.panel-side textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.panel-side > .control.stacked { display: grid; gap: 0.3rem; align-items: start; }
.step-table td:nth-child(2) { text-align: left; }
.plot .cell-picked { stroke: var(--ink); stroke-width: 2; }

/* ---------- The backpack fallacy ---------- */

/* One colour per series, in the categorical order: k0 is slot 1 (--a) and k5 slot 6. */
.plot .k0 { --k: var(--a); } .plot .k1 { --k: var(--b); } .plot .k2 { --k: var(--c); }
.plot .k3 { --k: var(--d); } .plot .k4 { --k: var(--e); } .plot .k5 { --k: var(--f); }
.plot .k-line { fill: none; stroke: var(--k); stroke-width: 2; stroke-linejoin: round; }
.plot .k-line.dashed { stroke-dasharray: 6 4; stroke-width: 1.6; }
.plot .k-mark { fill: var(--k); stroke: var(--surface); stroke-width: 1.5; }
.plot .k-hollow { fill: var(--surface); stroke: var(--k); stroke-width: 2; }
.plot .k-soft { fill: var(--k); fill-opacity: 0.14; }
.plot .k-bar { stroke: var(--k); stroke-width: 6; stroke-linecap: round; }
.plot .k-bar.thin { stroke-width: 2; }
.plot .context-line { fill: none; stroke: var(--faint); stroke-width: 1; stroke-opacity: 0.6; }
.plot .at-line { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 2 3; }
.plot .scrub-hit { fill: transparent; }
.scrub-plot { cursor: ew-resize; }
.check-label { display: inline-flex; gap: 0.45rem; align-items: center; min-height: 2rem; }
.panel-side input[type="text"] { width: 100%; }

/* ---------- Samplers ---------- */

.figure-title { margin: 0.3rem 0 0.25rem; font-size: 0.98rem; }
.figure-row.single { grid-template-columns: minmax(0, 1fr); }
.plot .contour { fill: none; stroke: var(--muted); stroke-linejoin: round; }
.plot .contour.c50 { stroke-width: 1.6; }
.plot .contour.c90 { stroke-width: 1.1; }
.plot .contour.c99 { stroke-width: 0.9; stroke-dasharray: 1.5 3; }
.plot .settled-contour { fill: none; stroke: var(--b); stroke-width: 1.8; stroke-dasharray: 6 4; }
.plot .settled-contour.c90 { stroke-width: 1.2; }
.plot .settled-line { fill: none; stroke: var(--b); stroke-width: 2; stroke-dasharray: 6 4; }
.plot .chain-path { fill: none; stroke: var(--a); stroke-width: 1; stroke-opacity: 0.6; stroke-linejoin: round; }
.plot .trajectory { fill: none; stroke: var(--c); stroke-width: 1.8; stroke-linejoin: round; }
.plot .proposal { stroke: var(--c); stroke-width: 1.6; }
.plot .trajectory.rejected, .plot .proposal.rejected { stroke-dasharray: 4 3; }
.plot .move-mark { fill: var(--c); stroke: var(--surface); stroke-width: 1.5; }
.plot .move-hollow { fill: var(--surface); stroke: var(--c); stroke-width: 1.8; }
.plot .divergent-mark { fill: none; stroke: var(--alert); stroke-width: 2.2; stroke-linecap: round; }
.plot .current-mark { fill: var(--surface); stroke: var(--ink); stroke-width: 2.2; }
.plot .quantile-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 4 3; stroke-opacity: 0.7; }
.plot .trace-line { fill: none; stroke: var(--a); stroke-width: 1; stroke-linejoin: round; }

/* ---------- Priors on transformed parameters ---------- */

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.choice-stack { display: grid; flex: 1 1 100%; gap: 0.35rem; margin-top: 0.3rem; }
.choice-stack label { display: flex; gap: 0.5rem; align-items: flex-start; padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; line-height: 1.35; }
.choice-stack label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice-stack label:has(input:checked) .choice-main { font-weight: 600; }
.choice-stack input { flex: none; margin: 0.2rem 0 0; accent-color: var(--primary); }
.choice-main { display: block; font-variant-numeric: tabular-nums; }
.choice-sub { display: block; color: var(--muted); font-size: 0.88rem; }
.plot .sampled-contour { fill: none; stroke: var(--a); stroke-linejoin: round; }
.plot .sampled-contour.c50 { stroke-width: 2.2; }
.plot .sampled-contour.c90 { stroke-width: 1.3; }
.plot .improper-contour { fill: none; stroke: var(--alert); stroke-linejoin: round; stroke-dasharray: 5 3; }
.plot .improper-contour.c50 { stroke-width: 2; }
.plot .improper-contour.c90 { stroke-width: 1.2; }
.plot .improper-line { fill: none; stroke: var(--alert); stroke-width: 2; stroke-dasharray: 5 3; }
.plot .improper-label { fill: var(--alert); font-weight: 600; }
.plot .k-line.thin { stroke-width: 1.2; }
.plot .draw-dot { fill: var(--a); fill-opacity: 0.45; }
.plot .conditional-line { stroke-width: 2; }
/* Two figures side by side need more of the panel than one does. */
@media (min-width: 900px) { .panel-body.wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }

/* ---------- Probability puzzles ---------- */

.plot .card-face { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.plot .card-face.end { stroke: var(--ink); stroke-width: 2.6; }
.plot .card-index { fill: var(--faint); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.plot .card-rank { font-size: 15px; font-weight: 600; }
.plot .card-rank.small { font-size: 12.5px; }
.plot .suit-red { fill: var(--alert); }
.plot .suit-black { fill: var(--text); }
.plot .card-count { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.plot .card-end-label { fill: var(--text); font-size: 9.5px; font-weight: 700; }
.plot .walk-line { stroke-width: 1.7; stroke-opacity: 0.85; }
.plot .skip-zone, .plot rect.skip-zone { fill: var(--faint); fill-opacity: 0.16; }
.plot .threshold-curve { fill: none; stroke: var(--b); stroke-width: 1.6; stroke-dasharray: 5 3; }
.plot .applicant-dot { fill: var(--faint); fill-opacity: 0.6; }
.plot .best-ring { fill: none; stroke: var(--ink); stroke-width: 2; }
.plot .box { fill: var(--surface); stroke: var(--faint); stroke-width: 1; }
.plot .box.open { fill: var(--a-soft); stroke: var(--a); stroke-width: 1.4; }
.plot .box.own { fill: color-mix(in srgb, var(--ok) 18%, var(--surface)); stroke: var(--ok); stroke-width: 2.4; }
.plot .box.failed { stroke: var(--alert); stroke-width: 2.4; stroke-dasharray: 4 2; }
.plot .box-number { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .box-number.small { font-size: 8.5px; }
.plot .box-ticket { fill: var(--text); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plot .box-ticket.small { font-size: 10px; }
.plot .loop-segment { fill: var(--faint); fill-opacity: 0.3; }
.plot .loop-segment.long { fill: var(--alert-soft); stroke: var(--alert); stroke-width: 1.2; }
.plot .loop-segment.mine { stroke: var(--ink); stroke-width: 2.4; }
.plot .loop-label { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.plot .loop-label.long { fill: var(--alert); font-weight: 700; }
.plot .trial { fill: none; stroke: var(--grid); stroke-width: 1; }
.plot .trial.kept { fill: var(--a-soft); stroke: var(--a); stroke-width: 1.4; }
.plot .coin-label { fill: var(--muted); font-size: 11px; }
.plot .coin-label.two { fill: var(--text); font-weight: 700; }
.plot .flip.head { fill: var(--a); }
.plot .flip.tail { fill: var(--surface); stroke: var(--faint); stroke-width: 1.2; }
.plot .flip.next { stroke: var(--ink); stroke-width: 2.4; }
.plot .flip-letter { font-size: 8.5px; font-weight: 700; }
.plot .flip-letter.head { fill: var(--surface); }
.plot .flip-letter.tail { fill: var(--muted); }
.plot .walk-line.shared { stroke: var(--ink); stroke-width: 2.6; stroke-opacity: 0.9; }
dl.stats dd small.sim-line { display: block; }
.panel-side input[id$="-replicates-number"] { width: 7.5rem; }
.plot .box.current { stroke: var(--ink); stroke-width: 2.4; }
.plot .box-order { fill: var(--text); font-size: 9.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plot .coin-label.small { font-size: 9.5px; }

/* The HMC energy panel uses the same recorded transition as the path. */
#funnel-row.has-space #funnel-energy-block { grid-column: 1 / -1; }
.integration-detail { margin: 1rem 0; padding-top: .8rem; border-top: 1px solid var(--border); }
.integration-detail h3 { margin: 0 0 .4rem; }
.integration-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .7rem 0; }
.integration-controls label { display: inline-flex; align-items: center; gap: .4rem; }
.integration-controls input { width: 6rem; }
.integration-detail > input[type="range"] { width: 100%; }
.integration-detail > label { display: block; font-size: .9rem; }
.integration-phases { display: grid; gap: .4rem; padding: 0; list-style: none; margin: .7rem 0; }
.integration-phases li { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45rem .6rem; }
.integration-phases li[aria-current="step"] { border-color: var(--primary); background: var(--surface-2); box-shadow: inset 3px 0 var(--primary); }
.integration-phases strong, .integration-phases span { display: block; }
.integration-phases span { font-size: .88rem; }
.integration-components { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .5rem; margin: .7rem 0; }
.integration-components dt { color: var(--muted); font-size: .82rem; }
.integration-components dd { margin: .2rem 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.plot .energy-start { stroke: var(--muted); stroke-width: 1; }
.plot .energy-threshold { stroke: var(--alert); stroke-width: 1.5; stroke-dasharray: 6 4; }
.plot .energy-threshold-label { fill: var(--alert); font-size: 11px; }
.plot .energy-path { fill: none; stroke: var(--a); stroke-width: 2; }
.plot .energy-point { fill: var(--a); stroke: var(--surface); stroke-width: 1; }
