:root {
  --bg: #000; --panel: #050608; --panel2: #0c0e12; --line: #14171c; --line2: #22262e;
  --fg: #e6eaf0; --fg2: #c4cad4; --fg3: #b9c0ca; --dim: #7c8490; --faint: #4c535e;     /* text: main, body, controls, quiet, quietest */
  --rim: #5b636e;      /* outlines drawn in the diagrams */
  --accent: #a9c4e6; --accent-ink: #05080d; --switch: #4f6a8f; --warm: #d98a92; --act: #d8424f; --ok: #7fcf9f; --bad: #e07a86;
  --chrome: 212px;      /* height kept for the header, the status row and the hint, so the stage and they fit one screen */
  --r: 10px; --t: .18s ease;      /* one radius for panels and overlays; one timing for hovers, switches and overlays arriving */
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { min-height: 100vh; background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; transition: color var(--t), background var(--t), border-color var(--t); }
:is(button, select, summary, a, input[type=range]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* ---------- header ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 22px 24px 6px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { width: 30px; height: 30px; color: var(--faint); flex: none; }
.brand h1 { margin: 0; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.05; letter-spacing: .01em; font-weight: 200; }
.brand p { margin: 3px 0 0; font-size: 12.5px; font-weight: 300; color: var(--dim); letter-spacing: .02em; }
.modes { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; }
.modes button { background: none; border: 0; padding: 6px 14px; border-radius: 6px; color: var(--faint); font-weight: 400; font-size: 13px; letter-spacing: .02em; }
.modes button:hover { color: var(--fg); }
.modes button[aria-selected="true"] { background: var(--panel2); color: var(--fg); }

/* ---------- layout ---------- */
.wrap { display: flex; gap: 20px; padding: 14px 24px 24px; align-items: flex-start; }
.stagecol { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.stage { container: stage / inline-size; position: relative; width: min(100%, calc((100vh - var(--chrome)) * var(--ar, 1.7778))); aspect-ratio: var(--ar, 1.7778);
         border-radius: 8px; overflow: hidden; background: #000; border: 1px solid #0c0e11; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#gl { transform: scaleX(-1); }
#hud { pointer-events: none; }
.hint { margin: 0; max-width: 72ch; min-height: 1.5em; font-size: 12.5px; font-weight: 300; color: var(--dim); text-align: center; text-wrap: balance; }

/* ---------- overlays on the stage ---------- */
.session-controls { min-height: 30px; width: min(100%, calc((100vh - var(--chrome)) * var(--ar, 1.7778))); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.session-controls > button { flex: none; margin-left: auto; border-radius: 6px; padding: 5px 12px; font-size: 13px; }
.session-controls > button:hover, .session-controls > button:focus-visible { border-color: var(--accent); }
.session-controls > .zoom:not([hidden]) + button { margin-left: 0; }
/* zoom: the close-up steps, beside End camera so nothing covers the picture */
.zoom { margin-left: auto; display: flex; border: 1px solid var(--line2); border-radius: 6px; overflow: hidden; }
.zoom button { width: 32px; height: 28px; display: grid; place-items: center; padding: 0; background: none; border: 0; color: var(--fg); }
.zoom button + button { border-left: 1px solid var(--line2); }
.zoom button:enabled:hover { background: var(--panel2); }
.zoom button:disabled { color: var(--faint); cursor: default; }
.zoom button:focus-visible { outline-offset: -2px; }
.zoom svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.pill { padding: 4px 10px; border-radius: var(--r); font-size: 12px; border: 1px solid var(--line); color: var(--dim); }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--bad); }

.intro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
         padding: 32px; text-align: center; background: radial-gradient(ellipse at 50% 40%, rgba(8, 12, 20, .94), rgba(0, 0, 0, .98) 70%); }
.intro h2 { margin: 0; font-size: clamp(24px, 3.2vw, 38px); font-weight: 200; letter-spacing: .005em; }
.intro p { margin: 0; max-width: 56ch; color: var(--dim); font-weight: 300; }
.intro-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
button.big { font-weight: 500; font-size: 15px; padding: 10px 20px; border-radius: 8px; border: 0; background: var(--fg); color: var(--accent-ink); }
button.big:disabled { opacity: .6; cursor: default; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line2); }
button.ghost.big { color: var(--fg); }
.small { font-size: 12.5px; color: var(--faint); }
.intro .intro-status { min-height: 1.5em; font-size: 13px; color: var(--dim); }
.intro .intro-status.bad { color: var(--bad); }

.card { position: absolute; left: 14px; top: 50px; width: min(340px, calc(100% - 28px)); padding: 12px 14px 10px; border-radius: var(--r);
        max-height: calc(100% - 58px); overflow-y: auto;
        background: rgba(0, 0, 0, .72); border: 1px solid var(--line2); backdrop-filter: blur(12px); }
.card header { display: flex; justify-content: space-between; align-items: center; }
.card h2 { margin: 4px 0 6px; font-size: 19px; font-weight: 300; }
.card p { margin: 0 0 6px; font-size: 13.5px; font-weight: 300; color: var(--fg2); }
.card .fact { color: var(--dim); font-size: 13px; }
.card .try { color: var(--warm); font-size: 13px; font-weight: 400; }
.card .try:empty, .card .fact:empty { display: none; }
.card.pinned { border-color: var(--accent); }
.card:not(.pinned) { pointer-events: none; }
.card .x { pointer-events: auto; }
.card-depth { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.card-depth span { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.card-depth button { min-width: 32px; height: 28px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel2); color: var(--fg); font-size: 20px; line-height: 1; }
.card-depth button:disabled { color: var(--faint); cursor: default; }
.card-depth button:enabled:hover, .card-depth button:focus-visible { border-color: var(--accent); }
.chip { font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--dim);
        display: inline-flex; align-items: center; gap: 7px; }
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--accent)); }
.x { background: none; border: 0; color: var(--dim); font-size: 20px; line-height: 1; padding: 0 2px; }
.x:hover { color: var(--fg); }

/* overlays ease in when they arrive (display changes restart the animation) */
@keyframes arrive { from { opacity: 0; } }
.card, .activity, .prompt, .notice { animation: arrive var(--t); }

.notice { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px); padding: 9px 14px;
          display: grid; gap: 2px; text-align: center; border-radius: var(--r); background: rgba(0, 0, 0, .72); border: 1px solid var(--line2); backdrop-filter: blur(12px); }
.notice b { font-size: 13.5px; font-weight: 400; }
.notice span { font-size: 12.5px; font-weight: 300; color: var(--dim); }

.activity { position: absolute; top: 14px; right: 14px; width: 248px; padding: 9px 11px; border-radius: var(--r);
            background: rgba(0, 0, 0, .72); border: 1px solid var(--line2); backdrop-filter: blur(12px); }
.activity h4 { margin: 0 0 6px; font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.activity ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.activity li { font-size: 12.5px; display: grid; grid-template-columns: 1fr 48px; gap: 8px; align-items: center; }
.activity li b { font-weight: 300; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity li i { height: 2px; border-radius: 1px; background: var(--act); transform-origin: left; }
.activity li.idle { color: var(--dim); grid-template-columns: 1fr; }

.prompt { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); min-width: min(440px, 80%); padding: 14px 20px 12px;
          border-radius: var(--r); text-align: center; background: rgba(0, 0, 0, .7); border: 1px solid var(--line2); backdrop-filter: blur(12px); }
.prompt-step { font-size: 10.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.prompt-say { font-size: clamp(20px, 2.4vw, 28px); font-weight: 300; margin: 2px 0 10px; }
.prompt-sub { font-size: 13px; font-weight: 300; color: var(--dim); min-height: 1.4em; margin-top: 8px; }
.prompt-sub b { color: var(--fg); font-weight: 500; }
.prompt.win { border-color: var(--ok); } .prompt.win .prompt-say { color: var(--ok); }
.prompt.miss { border-color: var(--bad); }
.prompt-actions { margin-top: 6px; }
.prompt { max-width: calc(100% - 28px); }
/* in a lesson the prompt is small (its words are in the panel) and sits in the bottom-right corner, clear of the face */
.prompt.aside { left: auto; right: 14px; bottom: 14px; transform: none; min-width: 0; width: 236px; text-align: left; padding: 10px 13px 9px; }
.prompt.aside .prompt-say { font-size: 19px; margin: 1px 0 8px; }
.prompt.aside .prompt-sub:empty { display: none; }
.prompt.aside .prompt-actions { margin-top: 8px; }
/* the movement card (Conditions): how much each part of the face moves, left and right; a weak part says so */
.signal { position: absolute; top: 14px; right: 14px; width: 236px; padding: 9px 12px 11px; border-radius: var(--r);
          background: rgba(0, 0, 0, .72); border: 1px solid var(--line2); backdrop-filter: blur(12px); animation: arrive var(--t); }
.signal h4 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline;
             font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.signal h4 em { font-style: normal; font-size: 11.5px; font-weight: 300; letter-spacing: .02em; text-transform: none; color: var(--faint); }
.sig-grid { display: grid; grid-template-columns: 62px 1fr 1fr; gap: 6px 12px; align-items: center; }
.sig-h { font-size: 11.5px; font-weight: 300; color: var(--dim); }
.sig-name { font-size: 12.5px; font-weight: 300; color: var(--fg2); }
.sig-cell { height: 18px; display: flex; align-items: center; }
.sig-cell i { flex: 1; height: 4px; border-radius: 2px; background: var(--line2); overflow: hidden; }
.sig-cell b { display: block; height: 100%; background: var(--fg); transform-origin: left; transform: scaleX(0); }
.sig-cell em { display: none; font-style: normal; font-size: 11.5px; font-weight: 400; color: var(--lost); white-space: nowrap; }
.sig-cell.none i { display: none; } .sig-cell.none em { display: block; }
/* on a smaller stage the prompt becomes one slim row along the bottom and the movement card is left out, so the face
   (and in a lesson the marks beside it) stay in view */
@container stage (max-width: 720px) {
  .signal { display: none; }
  .prompt, .prompt.aside { left: 8px; right: 8px; bottom: 8px; width: auto; min-width: 0; max-width: none; transform: none; padding: 7px 10px 8px;
                           text-align: left; display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: center; }
  .prompt .prompt-step { grid-column: 1 / -1; grid-row: 1; font-size: 10px; }     /* keeps the step and the score */
  .prompt .prompt-say, .prompt.aside .prompt-say { grid-column: 1; grid-row: 2; font-size: 15px; margin: 0; }
  .prompt .prompt-actions, .prompt.aside .prompt-actions { margin: 0; grid-column: 2; grid-row: 2; }
  .prompt .meter { grid-column: 1 / -1; grid-row: 3; margin-top: 6px; }
  .prompt .prompt-sub { grid-column: 1 / -1; grid-row: 4; min-height: 0; margin-top: 4px; font-size: 12px; }
  .prompt .prompt-sub:empty { display: none; }
  .card { width: min(256px, calc(100% - 28px)); padding: 10px 12px 8px; }     /* clear of the head and the activity card */
  .card h2 { font-size: 17px; }
  .card p { font-size: 12.5px; }
  .card .fact, .card .try { font-size: 12px; }
  .activity { width: 200px; }
}
@container stage (max-width: 720px) {
  .stage .sighteyes { left: 14px; top: 46px; transform: none; }     /* below the simulation note, not crowding it */
}
@container stage (max-width: 560px) {
  .stage .simnote { left: 8px; top: 8px; font-size: 10.5px; padding: 3px 8px; }     /* .stage: wins over the base rules below */
  .stage .sighteyes { left: 8px; top: 36px; }
}
.simnote { position: absolute; left: 14px; top: 14px; padding: 4px 10px; border-radius: var(--r); font-size: 11.5px; font-weight: 300; color: var(--dim);
           background: rgba(0, 0, 0, .62); border: 1px solid var(--line2); backdrop-filter: blur(12px); animation: arrive var(--t); }
.simnote:not([hidden]) ~ .notice { top: 50px; }
/* the sight view: which eyes it is seeing with, at the top of the stage */
.sighteyes { left: 50%; transform: translateX(-50%); color: var(--fg); white-space: nowrap; }
.prompt-actions button { font-size: 12px; padding: 3px 12px; border-radius: 6px; }
.meter { height: 2px; border-radius: 1px; background: var(--line2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

/* ---------- side panel ---------- */
/* the Conditions lesson panel: a list of lessons, or one lesson's controls */
.lesson h2 { margin: 2px 0 4px; font-size: 19px; font-weight: 300; }
.lesson .lead { margin: 0 0 12px; font-size: 13.5px; font-weight: 300; color: var(--dim); }
.lesson .back { margin: 0 0 8px; font-size: 12.5px; }
.lesson-list { display: grid; gap: 6px; }
.lesson-item { display: grid; gap: 1px; text-align: left; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); }
.lesson-item b { font-size: 14px; font-weight: 400; }
.lesson-item span { font-size: 12px; font-weight: 300; color: var(--dim); }
.lesson-item:enabled:hover, .lesson-item:focus-visible { border-color: var(--accent); }
.lesson-item:disabled { background: none; border-color: var(--line); cursor: default; }
.lesson-item:disabled b { color: var(--faint); }
.lesson-item:disabled span { color: var(--faint); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; }
.field { margin-top: 12px; transition: opacity var(--t); }
.field.off { opacity: .4; pointer-events: none; }
.label { display: block; margin-bottom: 6px; font-size: 10.5px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .14em; }
.picks { display: grid; gap: 4px; }
.pick { display: grid; grid-template-columns: 10px 1fr; column-gap: 9px; align-items: center; text-align: left; padding: 6px 9px;
        border-radius: 7px; border: 1px solid var(--line); background: none; }
.pick i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); opacity: .55; grid-row: span 2; justify-self: center; transition: opacity var(--t); }
.pick b { font-size: 13px; font-weight: 300; color: var(--fg3); }
.pick span { font-size: 11.5px; font-weight: 300; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick:hover { border-color: var(--line2); }
.pick[aria-pressed="true"] { background: var(--panel2); border-color: var(--c); }
.pick[aria-pressed="true"] i { opacity: 1; } .pick[aria-pressed="true"] b { color: var(--fg); } .pick[aria-pressed="true"] span { color: var(--dim); }
.note { margin: 6px 0 0; font-size: 11.5px; font-weight: 300; color: var(--faint); }
.note:empty { display: none; }
.pattern { margin-top: 10px; }
.pattern p { margin: 0 0 8px; font-size: 14px; font-weight: 300; color: var(--fg2); }
.pattern .why { color: var(--fg); }
.pattern .why:empty { display: none; }
.look { margin-top: 14px; padding: 9px 11px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line2); }
.look .label { margin-bottom: 3px; text-transform: none; letter-spacing: .02em; font-size: 12px; color: var(--dim); font-weight: 400; }
.look p { margin: 0; font-size: 14px; font-weight: 300; color: var(--fg); }
.pick em { display: none; grid-column: 2; margin-top: 3px; font-style: normal; font-size: 12px; font-weight: 300; color: var(--fg2); }
.pick[aria-pressed="true"] em { display: block; }
.pick[aria-pressed="true"] span { white-space: normal; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; font-weight: 300; color: var(--fg3); }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend span::before { content: ""; width: 18px; border-top: 1.5px solid var(--kept); flex: none; }
.legend .lost::before { border-top: 1.5px dashed var(--lost); }
.legend .problem::before { width: 9px; height: 9px; border: 1.5px solid var(--site); border-radius: 50%; }
.legend .unseen::before { width: 11px; height: 9px; border: 0; border-radius: 2px; background: color-mix(in srgb, var(--lost) 42%, transparent); }
.legend em { flex-basis: 100%; font-style: normal; font-size: 11.5px; color: var(--faint); }
/* the lesson's longer sections: the pathway diagram, a closer look, the side-by-side table */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row + .note { margin-top: 8px; }
.field-row:has(#lshow > :nth-child(3)), .field-row:has(> [hidden]) { grid-template-columns: 1fr; }     /* three views need the whole width; one control alone takes it */
.block { margin-top: 18px; }
.block > .label { margin: 0 0 8px; }
.path { padding: 12px 6px 6px; border-radius: 8px; background: #000; border: 1px solid var(--line); }
.pathway { display: block; width: 100%; height: auto; overflow: visible; }
.pathway text { text-anchor: middle; font-family: inherit; }
.pw-cap { font-size: 9px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; fill: var(--faint); }
.pathway .pw-cap.start { text-anchor: start; } .pathway .pw-cap.end { text-anchor: end; }
.pw-half, .pw-stem { fill: var(--panel2); stroke: var(--line2); }
.pw-half.hurt { fill: color-mix(in srgb, var(--site) 13%, var(--panel2)); stroke: var(--site); }
.pw-nuc { fill: #000; stroke: var(--line2); }
.pw-dot { fill: var(--kept); }
.pw-dot.off { fill: #000; stroke: var(--lost); stroke-width: 1.2; }
.pw-line { fill: none; stroke-width: 1.4; }
.pw-line.kept { stroke: var(--kept); opacity: .5; }
.pw-line.lost { stroke: var(--lost); stroke-dasharray: 4 3.5; }
.pw-flow { fill: none; stroke: var(--kept); stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 0.01 22; animation: pwflow 1.6s linear infinite; }
@keyframes pwflow { to { stroke-dashoffset: -22.01; } }
.pw-chip rect { fill: var(--panel2); stroke: var(--line2); }
.pw-chip.lost rect { fill: color-mix(in srgb, var(--lost) 9%, var(--panel2)); stroke: var(--lost); stroke-dasharray: 3 2.5; }
.pw-name { font-size: 11px; fill: var(--fg); }
.pw-state { font-size: 9.5px; fill: var(--dim); }
.pw-chip.lost .pw-state { fill: var(--lost); }
.pw-lens { fill: none; stroke: var(--dim); stroke-width: 1.2; stroke-linecap: round; }
/* bones up close (the fracture diagram): a bone, a piece that loses its blood, the straight bone before a break */
.pw-bone { fill: var(--panel2); stroke: var(--rim); stroke-width: 1; }
.pw-bone.lost { fill: color-mix(in srgb, var(--lost) 9%, var(--panel2)); stroke: var(--lost); stroke-dasharray: 3 2.5; }
.pw-ghost { fill: none; stroke: var(--line2); stroke-width: 1; stroke-dasharray: 3 2.5; }
.pw-artery { fill: none; stroke: var(--kept); stroke-width: 1.4; opacity: .5; }
.pw-rule { stroke: var(--line); stroke-width: 1; }
/* a field of view (diagrams.js): what is not seen is shaded, the centre dot is where the eye looks */
.fd-bg { fill: rgba(255, 255, 255, .05); }
.fd-lost rect { fill: color-mix(in srgb, var(--lost) 42%, transparent); }
.fd-rim { fill: none; stroke: var(--rim); stroke-width: 1; }
.fd-dot { fill: var(--dim); }
.fglyph { display: block; margin: 0 auto; }
.legend .hatch::before { width: 11px; height: 9px; border: 1px solid var(--lost); border-radius: 2px;
                         background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--lost) 55%, transparent) 0 1.2px, transparent 1.2px 3.5px); }
/* the blood supply (diagrams.js): each artery's territory in its colour (--c), a territory without blood hatched */
.sd-zone:not(.lost) { fill: color-mix(in srgb, var(--c) 38%, var(--panel2)); }
.sd-hatch-bg { fill: color-mix(in srgb, var(--lost) 10%, var(--panel2)); }
.sd-hatch { stroke: var(--lost); stroke-width: 1.3; opacity: .6; }
.sd-groove { fill: none; stroke: rgba(0, 0, 0, .5); stroke-width: 1.3; stroke-linecap: round; }
.sd-callosum { fill: var(--panel); stroke: rgba(0, 0, 0, .5); }
.sd-rim { fill: none; stroke: var(--rim); stroke-width: 1; }
.sd-label { font-size: 10px; fill: var(--fg); paint-order: stroke; stroke: rgba(0, 0, 0, .6); stroke-width: 2.5px; stroke-linejoin: round; }
.sd-label.lost { fill: var(--lost); }
.sd-key:not(.lost) rect { fill: color-mix(in srgb, var(--c) 45%, var(--panel2)); stroke: var(--c); }
.sd-key.lost rect { stroke: var(--lost); }
.pathway .sd-key text { text-anchor: start; font-size: 10.5px; fill: var(--fg2); }
.pathway .sd-key.lost text { fill: var(--lost); }
.pw-x circle { fill: #000; stroke: var(--site); stroke-width: 1.6; }
.pw-x path { stroke: var(--site); stroke-width: 1.6; stroke-linecap: round; }
.more { padding: 11px 12px 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); }
.more dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 7px 12px; }
.more dt { font-size: 13px; font-weight: 500; color: var(--fg); }
.more dd { margin: 0; font-size: 13px; font-weight: 300; color: var(--fg2); }
.cmp { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; font-weight: 300; }
.cmp th, .cmp td { padding: 6px 7px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.cmp thead th { border-top: 0; padding-top: 0; font-size: 11.5px; font-weight: 500; color: var(--faint); }
.cmp thead th.on { color: var(--fg); }
.cmp tbody th { width: 31%; padding-left: 0; font-weight: 300; color: var(--dim); }
.cmp td { color: var(--fg2); }
.cmp td.on { background: var(--panel2); color: var(--fg); }
.cmp td.lost { color: var(--lost); }
/* a row per pattern, with pictures of what each eye still sees */
.cmp.by-pattern col.name { width: 32%; } .cmp.by-pattern col.fig1 { width: 22%; }
.cmp.by-pattern th, .cmp.by-pattern td { vertical-align: middle; }
.cmp.by-pattern thead th:not(:first-child) { text-align: center; white-space: nowrap; padding-left: 2px; padding-right: 2px; }
.cmp.by-pattern tbody th { padding-left: 7px; }
.cmp.by-pattern td.fig { padding: 6px 4px; }
.cmp tbody th.on { background: var(--panel2); color: var(--fg); }
.sim { margin-top: 14px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line2); background: #000; }
.sim p { margin: 0; font-size: 12px; font-weight: 300; color: var(--dim); }
.sim p + p { margin-top: 5px; color: var(--faint); }
.side { flex: 0 0 320px; display: flex; flex-direction: column; gap: 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; }
.panel h3, .panel summary { margin: 0 0 10px; font-size: 10.5px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .14em; }
details.panel summary { cursor: pointer; margin: 0; list-style: none; display: flex; justify-content: space-between; }
details.panel summary::after { content: "+"; font-size: 15px; line-height: 1; }
details[open].panel summary::after { content: "–"; }
details[open].panel summary { margin-bottom: 10px; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.toggles label { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--line);
                 font-size: 13px; font-weight: 300; cursor: pointer; user-select: none; color: var(--faint);
                 transition: color var(--t), background var(--t), border-color var(--t); }
.toggles label:hover { border-color: var(--line2); }
.toggles input { position: absolute; opacity: 0; pointer-events: none; }
.toggles i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); opacity: .3; flex: none; }
.toggles label:has(input:checked) { color: var(--fg); background: var(--panel2); border-color: var(--line2); }
.toggles label:has(input:checked) i { opacity: 1; }
.toggles label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.switches { display: grid; gap: 8px; margin-top: 12px; }
.sw { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 300; color: var(--fg3); cursor: pointer; user-select: none; }
.sw input { position: absolute; opacity: 0; }
.sw span { width: 26px; height: 15px; border-radius: 8px; background: var(--line2); position: relative; flex: none; transition: background var(--t); }
.sw span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #6b737f; transition: transform var(--t), background var(--t); }
.sw input:checked + span { background: var(--switch); }
.sw input:checked + span::after { transform: translateX(11px); background: #e6eaf0; }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: #000; border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 6px; font-size: 13px; font-weight: 400; color: var(--faint); }
.seg button.on { background: var(--panel2); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line2); }
.seg button:not(.on):hover { color: var(--dim); }
.row { display: grid; grid-template-columns: 1fr 48%; align-items: center; gap: 10px; font-size: 13px; font-weight: 300; margin-top: 10px; color: var(--fg3); }
.row b { font-weight: 500; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.row:has(> b) { grid-template-columns: 1fr auto 44%; }     /* a slider with its value: name, value, slider on one line */
.row:has(> b) b { text-align: right; min-width: 40px; }
input[type=range] { width: 100%; accent-color: var(--switch); }
select { font: inherit; font-size: 13px; font-weight: 300; color: var(--fg); background: #000; border: 1px solid var(--line2); border-radius: 6px; padding: 5px 7px; width: 100%; }
.link { background: none; border: 0; color: var(--accent); font-size: 13px; padding: 0; margin-top: 10px; }
pre#data { margin: 0; padding: 9px 10px; background: #000; border: 1px solid var(--line); border-radius: 8px; color: var(--dim);
           font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; font-variant-numeric: tabular-nums; }
.credits p { font-size: 11px; font-weight: 300; color: var(--faint); margin: 0 0 8px; }
.credits a { color: var(--dim); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (min-width: 981px) { .stagecol { position: sticky; top: 12px; } }     /* the picture stays in view beside a long lesson */
@media (max-width: 980px) {
  .wrap { flex-direction: column; align-items: stretch; padding: 10px 12px 20px; }
  .side { flex: none; }
  .stage, .session-controls { min-height: 30px; width: 100%; }
  .top { padding: 12px 12px 0; }
}
@media (max-width: 600px) {
  .stage:has(.intro:not([hidden])) { min-height: 280px; }
  .intro { padding: 16px; gap: 8px; }
}
