:root {
  --ink: #1b1d22;
  --muted: #5b6270;
  --paper: #fbfaf7;
  --line: #d9d6cf;
  --inside: #3b6fb6;
  --outside: #d9822b;
  --bad: #c0392b;
  --good: #2e8b57;
  --accent: #6a4c93;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: 0.4rem; z-index: 10; }
header, nav, main, footer { padding: 0 1.2rem; }
header h1 { margin: 0.8rem 0 0.2rem; font-size: 1.35rem; }
.source, .small { color: var(--muted); font-size: 0.85rem; }
.noscript { background: #fff3cd; padding: 0.6rem; }

nav ol { display: flex; flex-wrap: wrap; gap: 0.3rem; list-style: none; padding: 0; margin: 0.6rem 0; }
nav button { font: inherit; font-size: 0.82rem; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; padding: 0.25rem 0.5rem; cursor: pointer; }
nav button[aria-current="step"] { border-color: var(--ink); background: var(--ink); color: #fff; }

main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.2rem; }
main > * { min-width: 0; }
@media (max-width: 900px) { main { grid-template-columns: minmax(0, 1fr); } }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.4rem; }
.toolbar button { font: inherit; font-size: 0.85rem; padding: 0.3rem 0.6rem; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; }
.toolbar button[aria-pressed="true"] { background: #e8e3f3; border-color: var(--accent); }
.toolbar button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.progress { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

#figure { width: 100%; aspect-ratio: 1 / 1; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.finite { font-size: 0.85rem; background: #f1efe9; border-left: 4px solid var(--accent); padding: 0.4rem 0.6rem; }
.controls { display: grid; gap: 0.4rem; }
.control label { font-size: 0.85rem; display: block; }
.control input { width: 100%; }

.panel h2 { margin-top: 0.4rem; font-size: 1.2rem; }
.panel h3 { margin: 0.8rem 0 0.2rem; font-size: 0.95rem; color: var(--muted); }
.question { background: #fff; border: 1px dashed var(--line); padding: 0.5rem; border-radius: 6px; }
.anchors { padding-left: 1rem; font-size: 0.85rem; }
.anchors code { font-size: 0.82rem; }
.anchors a, .anchors code, .anchors .where { overflow-wrap: anywhere; }
.anchors .where { color: var(--muted); }
.anchors .role { color: var(--muted); }
.quote { min-width: 0; margin-inline: 0; }
.quote figcaption, #scene-quote-file { overflow-wrap: anywhere; }
.quote pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.8rem; background: #fff; border: 1px solid var(--line); padding: 0.5rem; }

footer { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.4rem; padding-bottom: 1rem; }
#caption { font-weight: 600; overflow-wrap: anywhere; }

/* Text-only view hides the drawing; the explanation and the text description remain. */
body.text-only #figure, body.text-only .controls { display: none; }
body.text-only .textalt { display: block; }
body.text-only details.textalt > p { display: block; }

/* Figure classes */
.curve { fill: none; stroke: #8a8f99; stroke-width: 1.4px; }
.curve.faint { stroke: #c4c7cd; }
.polygon { fill: none; stroke: var(--ink); stroke-width: 1.6px; }
.polygon.thin { stroke-width: 1px; }
.polygon.ghost { stroke: var(--accent); stroke-width: 1px; }
.bad { fill: none; stroke: var(--bad); stroke-width: 2.6px; }
.chord { fill: none; stroke: var(--accent); stroke-width: 2.6px; stroke-dasharray: 6 4; }
.vertex { fill: var(--ink); }
.doomed { fill: #fff; stroke: var(--bad); stroke-width: 0.006; }
.probe { fill: var(--accent); }
.probe.wrong { fill: var(--bad); }
.probe.right { fill: var(--good); }
.cell { stroke: none; }
.cell.inside { fill: var(--inside); fill-opacity: 0.35; }
.cell.outside { fill: var(--outside); fill-opacity: 0.25; }
.cell.unsettled { fill: #9aa0a6; fill-opacity: 0.18; }
.cell.wrongcell { fill: var(--bad); fill-opacity: 0.8; }
.ball { fill: none; stroke-width: 0.004; }
.ball.sampled-clear { stroke: var(--good); }
.ball.sampled-close { stroke: var(--bad); stroke-dasharray: 0.02 0.015; }
.arc { fill: none; stroke-width: 2px; }
.arc.fwd { stroke: #2b7a78; }
.arc.bwd { stroke: #a64ca6; }
.ring { fill: none; stroke: #b9bec7; stroke-width: 1px; stroke-dasharray: 4 3; }
.conn { fill: none; stroke-width: 3px; }
.conn.in { stroke: var(--inside); }
.conn.out { stroke: var(--outside); }
.deltaball { fill: #6a4c93; fill-opacity: 0.12; stroke: var(--accent); stroke-width: 0.0006; }
.balanced { fill: var(--accent); }
.site { fill: var(--ink); }
.region { fill: var(--inside); fill-opacity: 0.18; stroke: none; }
.inner { fill: none; stroke: var(--inside); stroke-width: 1.4px; stroke-dasharray: 5 3; }
.ear { fill: var(--outside); fill-opacity: 0.6; stroke: var(--bad); stroke-width: 1px; }
.loop { fill: none; stroke: var(--accent); stroke-width: 2px; }
.axis, .tick { stroke: #8a8f99; stroke-width: 0.25; }
.interval { stroke: var(--inside); stroke-width: 0.6; }
.ray { stroke: var(--outside); stroke-width: 0.5; }
.witness { fill: var(--ink); }
.stdpart { fill: var(--good); }
svg text.small { font-size: 2.6px; fill: var(--muted); }
.family { fill: none; stroke: #c4c7cd; stroke-width: 0.6px; stroke-opacity: 0.6; }
.subseq { fill: none; stroke: var(--accent); stroke-width: 1.4px; }
.limit { fill: none; stroke: var(--ink); stroke-width: 2.4px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
