/* Shared styles for the interactive (Observable JS) figures. */
.fig-readout { margin: 0.6rem 0 0.4rem; font-size: 1.05rem; text-align: left; }
.fig-readout .fig-counts { font-size: 0.9rem; opacity: 0.75; }
.fig-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; align-items: center; font-size: 0.85rem; margin: 0.5rem 0 0.2rem; }
.fig-legend-title { font-weight: 600; }
.fig-legend i { display: inline-block; width: 1.4rem; height: 3px; margin-right: 0.35rem; vertical-align: middle; border-radius: 2px; }
.ct-table { border-collapse: collapse; margin: 0.4rem 0; }
.ct-table th, .ct-table td { padding: 0.3rem 0.6rem; text-align: center; border-bottom: 1px solid rgba(127,127,127,0.3); }
.ct-table thead th { font-weight: 600; }
.ct-table tbody th { text-align: left; font-weight: 600; }
.ct-input { width: 6.5em; text-align: right; font: inherit; font-variant-numeric: tabular-nums; padding: 0.2rem 0.4rem; color: inherit; background: transparent; border: 1px solid rgba(127,127,127,0.35); border-radius: 6px; }
.ct-input:focus { outline: none; border-color: var(--bs-link-color, #2780e3); }
.ch-panels { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: center; margin-top: 0.5rem; }
.ch-panel { flex: 1 1 180px; max-width: 380px; }
.ch-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.2rem; }

/* ---------- Control panel for interactive figures ----------
   All controls of one figure live in one OJS cell; that cell becomes a
   light panel with a responsive grid. Each slider: small label on top,
   slider and value side by side. Works in light and dark mode. */
:root { --ctl-accent: var(--bs-link-color, #2780e3); --ctl-tint: rgba(127,127,127,0.07); --ctl-line: rgba(127,127,127,0.28); }

.cell:has(> .cell-output-display form[class^="oi-"]) {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.9rem 1.6rem;
  align-items: end; text-align: left;
  background: var(--ctl-tint); border: 1px solid var(--ctl-line); border-radius: 10px;
  padding: 0.85rem 1.1rem 0.9rem; margin: 0.4rem 0 0.9rem;
}
.cell:has(> .cell-output-display form[class^="oi-"]) > .code-copy-outer-scaffold { display: none; }
.cell:has(> .cell-output-display form[class^="oi-"]) > .cell-output-display { margin: 0; overflow: visible; }

.cell form[class^="oi-"] {
  --label-width: auto; display: block; width: 100%; max-width: none; margin: 0;
  font: inherit; font-size: 0.9rem; text-align: left;
}
.cell form[class^="oi-"] > label {
  display: block; width: auto; padding: 0; margin: 0 0 0.3rem 0;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em; line-height: 1.25;
  opacity: 0.8; text-align: left; white-space: normal;
}
.cell form[class^="oi-"] > div { display: flex; align-items: center; gap: 0.7rem; width: 100%; }

/* numeric value: compact, right-aligned, no spinner */
.cell form[class^="oi-"] input[type="number"] {
  order: 2; flex: 0 0 4.4em; width: 4.4em; padding: 0.15rem 0.35rem; margin: 0;
  font: inherit; font-size: 0.88rem; font-variant-numeric: tabular-nums; text-align: right;
  color: inherit; background: transparent; border: 1px solid var(--ctl-line); border-radius: 6px;
  -moz-appearance: textfield; appearance: textfield;
}
.cell form[class^="oi-"] input[type="number"]::-webkit-outer-spin-button,
.cell form[class^="oi-"] input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cell form[class^="oi-"] input[type="number"]:focus { outline: none; border-color: var(--ctl-accent); }

/* slider: thin track, round thumb in the link color */
.cell form[class^="oi-"] input[type="range"] {
  order: 1; flex: 1 1 auto; width: auto; min-width: 0; margin: 0; height: 18px;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.cell form[class^="oi-"] input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--ctl-line); }
.cell form[class^="oi-"] input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--ctl-line); }
.cell form[class^="oi-"] input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--ctl-accent); }
.cell form[class^="oi-"] input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--ctl-accent); border: 2px solid var(--bs-body-bg, #fff); box-shadow: 0 0 0 1px var(--ctl-accent), 0 1px 3px rgba(0,0,0,0.25);
}
.cell form[class^="oi-"] input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ctl-accent); border: 2px solid var(--bs-body-bg, #fff); box-shadow: 0 0 0 1px var(--ctl-accent), 0 1px 3px rgba(0,0,0,0.25);
}
.cell form[class^="oi-"] input[type="range"]:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: 3px; border-radius: 4px; }

/* buttons and toggles */
.cell form[class^="oi-"] > button, [id^="fig-"] .btn.btn-quarto, .callout .btn.btn-quarto {
  font: inherit; font-size: 0.85rem; font-weight: 600; line-height: 1.2;
  padding: 0.4rem 1rem; border-radius: 999px; cursor: pointer;
  color: var(--ctl-accent); background: transparent; border: 1px solid var(--ctl-accent);
}
.cell form[class^="oi-"] > button:hover, [id^="fig-"] .btn.btn-quarto:hover, .callout .btn.btn-quarto:hover { background: color-mix(in srgb, var(--ctl-accent) 12%, transparent); }
/* toggles become switches, placed before their label */
.cell form[class^="oi-"]:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 0.6rem; }
.cell form[class^="oi-"]:has(input[type="checkbox"]) > div, .cell form[class^="oi-"] > input[type="checkbox"] { order: -1; width: auto; }
.cell form[class^="oi-"]:has(input[type="checkbox"]) > label { margin: 0; font-size: 0.88rem; font-weight: 600; opacity: 0.9; cursor: pointer; }
.cell form[class^="oi-"] input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; position: relative; flex: 0 0 auto;
  width: 2.3rem; height: 1.3rem; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--ctl-line); transition: background 0.15s ease;
}
.cell form[class^="oi-"] input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.3rem - 4px); height: calc(1.3rem - 4px);
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: transform 0.15s ease;
}
.cell form[class^="oi-"] input[type="checkbox"]:checked { background: var(--ctl-accent); }
.cell form[class^="oi-"] input[type="checkbox"]:checked::before { transform: translateX(1rem); }
.cell form[class^="oi-"] input[type="checkbox"]:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: 2px; }

/* ---------- Shared chart style (bookplot.js) ---------- */
.bp-wrap { position: relative; display: inline-block; max-width: 100%; }
.bp-legend {
  position: absolute; z-index: 1; text-align: left; pointer-events: none;
  font-size: 0.88rem; line-height: 1.35; padding: 0.35rem 0.6rem 0.4rem;
  background: var(--bs-body-bg, #fff); border: 1px solid rgba(127,127,127,0.35); border-radius: 6px;
}
.bp-legend-title { margin-bottom: 0.15rem; }
.bp-legend-item { white-space: nowrap; }
.bp-legend-item i { display: inline-block; width: 1.7rem; height: 4px; margin-right: 0.55rem; vertical-align: middle; border-radius: 1px; }
/* axis labels a bit larger than tick labels, as in the static figures */
.bp-wrap svg g[aria-label="x-axis label"] text, .bp-wrap svg g[aria-label="y-axis label"] text,
.bp-chart svg g[aria-label="x-axis label"] text, .bp-chart svg g[aria-label="y-axis label"] text,
.bk-figure svg g[aria-label="x-axis label"] text, .bk-figure svg g[aria-label="y-axis label"] text,
.bk-code-output svg g[aria-label="x-axis label"] text, .bk-code-output svg g[aria-label="y-axis label"] text { font-size: 17px; }

/* ---------- Biomarker cutoff figure (direct manipulation, no panel) ---------- */
.td-figure { text-align: left; }
.td-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1.5rem; margin: 0.3rem 0 0.6rem; }
.td-toolbar-left { display: flex; align-items: center; gap: 0.7rem; }
.td-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.6; }
.td-seg { display: inline-flex; border: 1px solid var(--ctl-accent); border-radius: 999px; overflow: hidden; }
.td-figure .td-seg .btn.btn-quarto, .td-figure .td-seg button {
  font: inherit; font-size: 0.85rem; font-weight: 600; line-height: 1.2; padding: 0.3rem 0.95rem; margin: 0; cursor: pointer;
  color: var(--ctl-accent); background: transparent; border: 0; border-left: 1px solid var(--ctl-accent); border-radius: 0; box-shadow: none;
}
.td-figure .td-seg .btn.btn-quarto:first-child { border-left: 0; }
.td-figure .td-seg .btn.btn-quarto:hover { background: color-mix(in srgb, var(--ctl-accent) 10%, transparent); }
.td-figure .td-seg .btn.btn-quarto.active { color: var(--bs-body-bg, #fff); background: var(--ctl-accent); }
.td-figure .td-seg .btn.btn-quarto:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: -3px; }
.td-switch { display: inline-flex; align-items: center; gap: 0.55rem; margin: 0; font-size: 0.88rem; font-weight: 600; cursor: pointer; }
.td-switch input {
  -webkit-appearance: none; appearance: none; position: relative; flex: 0 0 auto; margin: 0;
  width: 2.3rem; height: 1.3rem; border-radius: 999px; cursor: pointer; background: var(--ctl-line); transition: background 0.15s ease;
}
.td-switch input::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.3rem - 4px); height: calc(1.3rem - 4px);
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: transform 0.15s ease;
}
.td-switch input:checked { background: var(--ctl-accent); }
.td-switch input:checked::before { transform: translateX(1rem); }
.td-area { cursor: ew-resize; touch-action: none; border-radius: 6px; }
.td-area:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: 4px; }
.td-hint { font-size: 0.8rem; opacity: 0.6; margin-top: -0.2rem; }

/* ---------- Slim toolbar controls (bookui.js) ---------- */
.bk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 1.8rem; margin: 0.35rem 0 0.55rem; text-align: left; }
.bk-slider { display: inline-flex; align-items: center; gap: 0.65rem; margin: 0; font-size: 0.9rem; cursor: pointer; }
.bk-slider-label { font-weight: 600; white-space: nowrap; }
.bk-slider-label i { font-family: var(--bs-font-serif, Georgia, serif); font-size: 1.05em; }
.bk-slider-value { min-width: 3.4em; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ctl-accent); }
.bk-slider input[type="range"] {
  --bk-fill: 50%; width: clamp(5rem, 28vw, 9.5rem); height: 18px; margin: 0; cursor: pointer; background: transparent;
  -webkit-appearance: none; appearance: none;
}
.bk-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--ctl-accent) 0 var(--bk-fill), var(--ctl-line) var(--bk-fill) 100%);
}
.bk-slider input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--ctl-line); }
.bk-slider input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--ctl-accent); }
.bk-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--ctl-accent); border: 2px solid var(--bs-body-bg, #fff); box-shadow: 0 0 0 1px var(--ctl-accent), 0 1px 3px rgba(0,0,0,0.25);
}
.bk-slider input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ctl-accent); border: 2px solid var(--bs-body-bg, #fff); box-shadow: 0 0 0 1px var(--ctl-accent), 0 1px 3px rgba(0,0,0,0.25);
}
.bk-slider input[type="range"]:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: 3px; border-radius: 4px; }
.bk-btn, .bk-btn.btn.btn-quarto {
  display: inline-flex; align-items: center; gap: 0.4rem; margin: 0;
  font: inherit; font-size: 0.85rem; font-weight: 600; line-height: 1.2;
  padding: 0.32rem 0.95rem; border-radius: 999px; cursor: pointer; box-shadow: none;
  color: var(--ctl-accent); background: transparent; border: 1px solid var(--ctl-accent);
}
.bk-btn:hover, .bk-btn.btn.btn-quarto:hover { color: var(--ctl-accent); background: color-mix(in srgb, var(--ctl-accent) 12%, transparent); }
.bk-btn:disabled, .bk-btn.btn.btn-quarto:disabled { opacity: 0.4; cursor: default; background: transparent; }
.bk-btn:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: 2px; }
.bk-btn.bk-btn-solid, .bk-btn.bk-btn-solid.btn.btn-quarto { color: var(--bs-body-bg, #fff); background: var(--ctl-accent); }
.bk-btn.bk-btn-solid:hover, .bk-btn.bk-btn-solid.btn.btn-quarto:hover { color: var(--bs-body-bg, #fff); background: color-mix(in srgb, var(--ctl-accent) 85%, black); }
.bk-btn.bk-run-again::before { content: "↻"; font-size: 1.05em; line-height: 1; }
.bk-seg-wrap { display: inline-flex; align-items: center; gap: 0.65rem; }
.bk-seg { display: inline-flex; border: 1px solid var(--ctl-accent); border-radius: 999px; overflow: hidden; }
.bk-seg button, .bk-seg button.btn.btn-quarto {
  font: inherit; font-size: 0.85rem; font-weight: 600; line-height: 1.2; padding: 0.3rem 0.85rem; margin: 0; cursor: pointer;
  color: var(--ctl-accent); background: transparent; border: 0; border-left: 1px solid var(--ctl-accent); border-radius: 0; box-shadow: none;
}
.bk-seg button:first-child { border-left: 0; }
.bk-seg button.active, .bk-seg button.active.btn.btn-quarto { color: var(--bs-body-bg, #fff); background: var(--ctl-accent); }
.bk-note { font-size: 0.85rem; opacity: 0.7; }
.bk-hint { font-size: 0.8rem; opacity: 0.6; margin-top: 0.1rem; margin-bottom: 0.9rem; text-align: left; }
.bk-drag { cursor: ew-resize; touch-action: pan-y; border-radius: 6px; user-select: none; -webkit-user-select: none; }
.bk-drag:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: 4px; }
.bk-figure { text-align: left; }
.bk-figure .fig-readout { min-height: 2.9em; }
.bk-legend-button { pointer-events: auto; }
.bp-legend .bk-legend-item { pointer-events: auto; cursor: pointer; border-radius: 3px; padding: 0 0.25rem; margin: 0 -0.25rem; white-space: nowrap; }
.bp-legend .bk-legend-item:hover, .bp-legend .bk-legend-item.active { background: color-mix(in srgb, currentColor 10%, transparent); }
.bp-legend .bk-legend-item i { display: inline-block; width: 1.7rem; height: 4px; margin-right: 0.55rem; vertical-align: middle; border-radius: 1px; }

/* ---------- Editable code (codebox.js) ---------- */
.bk-code { margin: 1rem 0 1.4rem; text-align: left; }
.bk-code-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; padding: 0.45rem 0.55rem 0.45rem 0.9rem;
  border: 1px solid var(--ctl-line); border-bottom: 0; border-radius: 8px 8px 0 0;
  background: color-mix(in srgb, currentColor 6%, transparent);
}
.bk-code-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.65; }
.bk-code-status { flex: 1 1 auto; font-size: 0.8rem; opacity: 0.65; }
.bk-code-actions { display: inline-flex; gap: 0.45rem; margin-left: auto; }
.bk-code-actions .bk-btn { padding: 0.22rem 0.85rem; font-size: 0.8rem; }
.bk-code-run::before { content: "▶"; font-size: 0.7em; }
.bk-code-run.bk-running::before { content: "■"; }
.bk-code-scroll {
  display: flex; overflow-x: auto; border: 1px solid var(--ctl-line); border-radius: 0 0 8px 8px;
  background: color-mix(in srgb, currentColor 3%, transparent);
  font-family: var(--bs-font-monospace, SFMono-Regular, Menlo, Consolas, monospace); font-size: 0.84rem; line-height: 1.55;
}
.bk-code-gutter {
  position: sticky; left: 0; z-index: 1; flex: 0 0 auto; padding: 0.75rem 0.6rem 0.75rem 0.7rem; text-align: right;
  font-variant-numeric: tabular-nums; opacity: 0.45; user-select: none;
  background: var(--bs-body-bg, #fff); background-image: linear-gradient(color-mix(in srgb, currentColor 3%, transparent), color-mix(in srgb, currentColor 3%, transparent));
}
.bk-code-gutter .bk-code-errline { color: #fc4f30; font-weight: 700; opacity: 1; }
.bk-code-area { position: relative; flex: 1 0 auto; min-width: 0; }
.bk-code-hl, .bk-code-input {
  margin: 0; padding: 0.75rem 1rem 0.75rem 0.4rem; border: 0; border-radius: 0;
  font: inherit; line-height: inherit; letter-spacing: normal; tab-size: 2; white-space: pre; overflow: hidden; word-wrap: normal;
}
.bk-code-hl { background: transparent; color: inherit; pointer-events: none; }
.bk-code-hl code { font: inherit; padding: 0; background: transparent; color: inherit; white-space: pre; }
.bk-code-hl code span { font-weight: inherit !important; font-style: inherit !important; text-decoration: none !important; }
.bk-code-input {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; outline: none;
  color: transparent; background: transparent; caret-color: var(--bs-body-color, #000); -webkit-text-fill-color: transparent;
}
.bk-code-input::selection { background: color-mix(in srgb, var(--ctl-accent) 30%, transparent); -webkit-text-fill-color: transparent; }
.bk-code-scroll:focus-within { border-color: color-mix(in srgb, var(--ctl-accent) 60%, var(--ctl-line)); }
.bk-code-output { margin-top: 0.6rem; }
.bk-code-output:empty { display: none; }
.bk-code-print { margin: 0.3rem 0; padding: 0.4rem 0.7rem; font-size: 0.84rem; background: transparent; border-left: 3px solid var(--ctl-line); }
.bk-code-error {
  margin: 0.3rem 0; padding: 0.45rem 0.75rem; font-family: var(--bs-font-monospace, monospace); font-size: 0.84rem;
  color: #c0392b; background: color-mix(in srgb, #fc4f30 9%, transparent); border-left: 3px solid #fc4f30; border-radius: 0 6px 6px 0;
}
body.quarto-dark .bk-code-error { color: #ff8a73; }
/* several sliders: align them in columns (label, track, value) */
.bk-toolbar:has(> .bk-slider + .bk-slider) {
  display: grid; grid-template-columns: max-content minmax(7rem, 14rem) max-content; gap: 0.45rem 0.8rem; justify-content: start; align-items: center;
}
.bk-toolbar:has(> .bk-slider + .bk-slider) > .bk-slider { display: contents; }
.bk-toolbar:has(> .bk-slider + .bk-slider) input[type="range"] { width: 100%; }
/* narrow screens: smaller legends so they cover less of the chart */
@media (max-width: 520px) {
  .bp-legend { font-size: 0.74rem; padding: 0.2rem 0.45rem 0.25rem; }
  .bp-legend-item i, .bp-legend .bk-legend-item i { width: 1.1rem; margin-right: 0.35rem; }
}

/* ---------- Spatial model grids (ch6) ---------- */
.sp-panels { display: flex; gap: 14px; justify-content: flex-start; flex-wrap: nowrap; margin: 0.2rem 0 0.4rem; }
.sp-panel { margin: 0; text-align: center; }
.sp-panel figcaption { font-size: 0.82rem; opacity: 0.75; margin-top: 0.25rem; }
.sp-grid { display: block; image-rendering: pixelated; image-rendering: crisp-edges; border-radius: 3px; }
.rl-chart { margin-top: 0.4rem; }
.rl-marker { position: absolute; width: 2px; margin-left: -1px; background: currentColor; opacity: 0.55; pointer-events: none; }
.bk-btn.rl-play { min-width: 5.6rem; justify-content: center; }
.nv-title { font-weight: 600; font-size: 0.95rem; margin: 0.6rem 0 0.1rem; }

/* ---------- Network drawings (ch6) ---------- */
.nw-svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.nw-edge { stroke: currentColor; stroke-opacity: 0.35; stroke-width: 1; transition: stroke-opacity 0.12s; }
.nw-node { fill: var(--bs-body-bg, #fff); stroke: currentColor; stroke-opacity: 0.85; stroke-width: 1.2; cursor: pointer; }
.nw-focus .nw-edge { stroke-opacity: 0.1; }
.nw-focus .nw-edge.nw-spoke { stroke: #fc4f30; stroke-opacity: 0.9; stroke-width: 2; }
.nw-focus .nw-edge.nw-tri { stroke: #008fd5; stroke-opacity: 1; stroke-width: 2.5; }
.nw-node.nw-self { fill: #fc4f30; stroke: #fc4f30; }
.nw-node.nw-nb { fill: #008fd5; stroke: #008fd5; }
.nw-readout { min-height: 2.8em; margin-top: 0.3rem; }

/* ---------- Contact tracing (ch7) ---------- */
.td-chart { cursor: crosshair; outline: none; }
.td-chart:focus-visible { outline: 2px solid var(--ctl-accent); outline-offset: 4px; border-radius: 6px; }
.td-handle {
  position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 0 2.5px var(--bs-body-bg, #fff), 0 1px 4px rgba(0,0,0,0.35);
  cursor: grab; touch-action: none;
}
.td-handle::before { content: ""; position: absolute; inset: -13px; border-radius: 50%; }   /* larger target for fingers */
.td-handle:active { cursor: grabbing; }
.bp-legend-item i.td-swatch { width: 1.05rem; height: 0.8rem; border-radius: 2px; }

.ae-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem 1.4rem; margin: 0.3rem 0 0.2rem; }
@media (max-width: 520px) { .ae-grid { grid-template-columns: minmax(0, 1fr); } }
.ae-panel { margin: 0; position: relative; }
.ae-letter { position: absolute; top: -0.1rem; left: 0; font-weight: 700; font-size: 1.25rem; }
.ae-svg { display: block; width: 100%; height: auto; max-width: 360px; margin: 0 auto; overflow: visible; }
.ae-rooms { max-width: 260px; }
.ae-room { fill: none; stroke: currentColor; stroke-width: 1.4; }
.ae-divider { stroke: currentColor; stroke-width: 1.6; stroke-dasharray: 1.5 5; stroke-linecap: round; }
.ae-time { text-anchor: middle; font-size: 15px; fill: currentColor; }
.ae-node { cursor: pointer; outline: none; }
.ae-node circle { fill: var(--bs-body-bg, #fff); stroke: currentColor; stroke-width: 1.5; transition: fill 0.12s; }
.ae-node text { text-anchor: middle; font-size: 12px; font-weight: 700; fill: currentColor; pointer-events: none; }
.ae-link path { fill: none; stroke-width: 1.6; transition: opacity 0.12s; }
.ae-link .ae-head { stroke: none; }
.ae-close path { stroke: currentColor; }
.ae-air path { stroke: #6d904f; }
.ae-air .ae-head { fill: #6d904f; }
.ae-focus .ae-link { opacity: 0.15; }
.ae-focus .ae-link.ae-on { opacity: 1; }
.ae-focus .ae-link.ae-on path { stroke-width: 2.6; }
.ae-focus .ae-close.ae-on path { stroke: #008fd5; }
.ae-node.ae-self circle { fill: #fc4f30; stroke: #fc4f30; }
.ae-node.ae-c circle { fill: #008fd5; stroke: #008fd5; }
.ae-node.ae-a circle { fill: #6d904f; stroke: #6d904f; }
.ae-node.ae-self text, .ae-node.ae-c text, .ae-node.ae-a text { fill: #fff; }
.ae-node:focus-visible circle { stroke: var(--ctl-accent); stroke-width: 3; }
.ae-txt-c { color: #008fd5; }
.ae-txt-a { color: #6d904f; }
body.quarto-dark .ae-air path { stroke: #8fb86b; }
body.quarto-dark .ae-air .ae-head, body.quarto-dark .ae-node.ae-a circle { fill: #8fb86b; }
body.quarto-dark .ae-node.ae-a circle { stroke: #8fb86b; }
body.quarto-dark .ae-txt-a { color: #8fb86b; }
.td-key { display: flex; gap: 0.9rem; align-items: center; font-size: 0.85rem; margin: 0.15rem 0 0.1rem 70px; opacity: 0.85; }
.td-key span { display: inline-flex; align-items: center; gap: 0.35rem; }
.td-key i { display: inline-block; width: 1rem; height: 0.75rem; border-radius: 2px; }

/* long links (footnote URLs) wrap instead of widening the page on phones */
main a, .footnotes a { overflow-wrap: anywhere; }

/* ---------- DP3T demo (ch7) ---------- */
.dp-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; margin: 0.3rem 0 0.4rem; }
@media (max-width: 640px) { .dp-cols { grid-template-columns: minmax(0, 1fr); } }
.dp-card { border: 1.5px solid var(--ctl-line); padding: 0.55rem 0.6rem 0.6rem; font-size: 0.78rem; line-height: 1.35; min-width: 0; }
.dp-phone { border-radius: 16px; position: relative; padding-top: 0.85rem; }
.dp-phone::before { content: ""; position: absolute; top: 5px; left: 50%; width: 34px; height: 4px; margin-left: -17px; border-radius: 2px; background: var(--ctl-line); }
.dp-server { border-radius: 6px; }
.dp-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.2rem; }
.dp-sub { font-weight: 600; opacity: 0.7; margin: 0.4rem 0 0.15rem; }
.dp-row { display: grid; grid-template-columns: 2.1em 2.9em minmax(0, 1fr) auto; gap: 0.35rem; align-items: center; padding: 0.08rem 0.25rem; margin: 0 -0.25rem; border-radius: 4px; }
.dp-row code, .dp-note code { font-size: 0.95em; padding: 0; background: none; color: inherit; white-space: nowrap; }
.dp-note { opacity: 0.75; margin-top: 0.25rem; }
.dp-empty { font-style: italic; }
.dp-up { background: color-mix(in srgb, #e5ae38 24%, transparent); }
.dp-hit { background: color-mix(in srgb, #fc4f30 20%, transparent); }
.dp-alert { margin-top: 0.4rem; font-weight: 700; color: #fc4f30; }
body.quarto-dark .dp-alert { color: #ff7a5e; }
.dp-none { font-weight: 600; }
.dp-sig { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 12px; }
.dp-sig i { display: block; width: 3px; border-radius: 1px; background: currentColor; opacity: 0.2; }
.dp-sig i.on { opacity: 0.8; }
.dp-figure .bk-seg-wrap { flex-wrap: wrap; row-gap: 0.35rem; }

/* ---------- Wastewater figure (ch8) ---------- */
.wwf-wrap { position: relative; display: inline-block; max-width: 100%; }
.wwf-wrap svg { display: block; }
.wwf-marker { position: absolute; top: 6px; bottom: 54px; width: 1.5px; margin-left: -0.75px; background: currentColor; opacity: 0.45; pointer-events: none; }
.tg-key { flex-wrap: wrap; margin: 0.1rem 0 0.4rem 0; gap: 0.2rem 0.9rem; }
.tg-key i { width: 1.3rem; height: 4px; border-radius: 1px; }

/* ---------- Next-word demo (ch10) ---------- */
.ntp-sentence { font-size: 1.1rem; margin: 0.6rem 0 0.5rem; min-height: 1.6em; }
.ntp-picked { color: #fc4f30; }
body.quarto-dark .ntp-picked { color: #ff7a5e; }
.ntp-blank { opacity: 0.4; }
.ntp-bars { display: grid; gap: 0.22rem; max-width: 560px; }
.ntp-row { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 3.6rem; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.ntp-word { text-align: right; }
.ntp-row.ntp-last .ntp-word { font-weight: 700; }
.ntp-track { height: 0.85rem; background: var(--ctl-tint); border-radius: 3px; overflow: hidden; }
.ntp-track i { display: block; height: 100%; border-radius: 3px; transition: width 0.15s; }
.ntp-p { font-variant-numeric: tabular-nums; font-size: 0.82rem; opacity: 0.75; }
.ntp-history { margin: 0.6rem 0 0.2rem; font-size: 0.88rem; min-height: 1.6em; }
.ntp-step { font-size: 0.82rem; opacity: 0.7; margin-bottom: 0.15rem; }
.ntp-earlier { opacity: 0.85; margin: 0.1rem 0; }
.ntp-hlabel { opacity: 0.75; margin-right: 0.2rem; }
@media (max-width: 520px) { .ntp-row { grid-template-columns: 7.5rem minmax(0, 1fr) 3.2rem; font-size: 0.82rem; } }
.aic-readout { min-height: 3.2em; }
.aic-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
