/* app.css - every rule the application uses.
 *
 * Lifted out of index.html, which was 858 lines of CSS wrapped around 155
 * lines of markup. A stylesheet is NOT the thing the zero-dependency rule
 * forbids: a browser refuses `fetch` of a neighbouring file and refuses an ES
 * module under file://, which is why those two are banned and why every script
 * here is a classic one - but <link rel=stylesheet> to a relative path has
 * always worked under file://. Double-clicking index.html still boots the app,
 * styled, with no server. That is the test the rule actually protects.
 *
 * The ids and classes here are a contract with js/*.js and with test/ui-smoke.mjs;
 * --dock in particular is read back by the layout gate. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #070b0f; }
/* `manipulation` takes the double-tap zoom away on touch screens (the viewport
   allows pinch zoom); #view below goes further and keeps every gesture. */
html { touch-action: manipulation; }
body { font: 14px/1.45 var(--font-ui); color: #dfe8f2; }

/* --dock is the width the docked column takes OUT of the viewport. The
   canvases are inset by it, so the simulation is never drawn underneath the
   column — a docked column that overlaps the water is just a floating card
   with extra steps. Everything that centres on the water (the tips line, the
   toast) centres on `100vw - var(--dock)` for the same reason. --dockb is
   what the same dock takes as a bottom sheet on a phone; one of the two is
   always zero. Both are set by DOCK.sync (js/dock.js).

   The geometry constants are written HERE and nowhere else; js/dock.js reads
   them back with getComputedStyle once per sync:
     --dock-w     the docked column's width;
     --dock-min   the window width below which the dock overlays the water
                  instead of taking width from it;
     --phone-max  the window width below which the dock becomes a bottom sheet
                  (a media query cannot read a variable, so the two
                  `@media (max-width: 620px)` rules below, each commented
                  "= --phone-max", repeat the number);
     --sheet-h    the sheet's height (a calc on vh, so DOCK measures the sheet
                  itself rather than parsing the formula).
   --bar-h is the strip's measured height, kept by fitBar (js/strip.js) at
   every compaction step; the panel, toast and legend hang from it. --gcw is
   the width the gauge corner cards take from the bottom right. */
:root {
  --dock: 0px; --dockb: 0px; --gcw: 0px;
  --dock-w: 348px; --dock-min: 900px; --phone-max: 620px; --sheet-h: min(58vh, 520px);
  --bar-h: 63px;
  --font-mono: ui-monospace, SFMono-Regular, monospace;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Sized, not just inset: a <canvas> has an intrinsic 300 × 150, and a fixed
   box with `width: auto` keeps it rather than stretching to the four edges. */
#view, #over {
  position: fixed; top: 0; left: 0;
  width: calc(100vw - var(--dock)); height: calc(100vh - var(--dockb));
}
#view { touch-action: none; cursor: crosshair; }
#over { pointer-events: none; }

.glass {
  background: rgba(12, 17, 26, 0.60);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------- small buttons */
/* One look for the small text buttons: the inspector's CSV pair, the exercise
   Reset, the discard / cancel pair of a menu warning (class `btn-sm`), and —
   because their buttons are made at a dozen sites in panel.js / rig.js —
   the Controls panel's button rows and the legend's actions, by selector.
   Each family then states only what differs from this base (font, padding,
   radius, border), after it, with the same specificity. */
.btn-sm, #panel .btnrow button, #panel .rigui button, #panel .rigfile, #legActs button {
  appearance: none; background: rgba(255,255,255,0.07); color: inherit;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 7px;
  font: 600 11px var(--font-ui); padding: 4px 9px; cursor: pointer;
}
.btn-sm:hover, #panel .rigui button:hover, #panel .rigfile:hover { background: rgba(77,195,255,0.20); }

/* ------------------------------------------------ minimisable UI boxes */
/* A floating box carries a small – in a corner; clicking it collapses the
   box to a pill that restores it. The boxes are chrome and the water is the
   point — a lecture wants the water. */
.minbtn {
  appearance: none; border: 0; background: transparent; color: inherit;
  width: 20px; height: 20px; padding: 0; border-radius: 6px;
  font: 14px/18px var(--font-mono); text-align: center;
  cursor: pointer; opacity: .40; flex: 0 0 auto;
}
.minbtn:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.minbtn.corner { position: absolute; top: 5px; right: 5px; z-index: 3; }
.minpill {
  position: fixed; z-index: 10; padding: 6px 12px; cursor: pointer;
  font: 600 12px var(--font-ui); opacity: .78; display: none;
  white-space: nowrap; user-select: none;
}
.minpill:hover { opacity: 1; background: rgba(20, 30, 44, 0.72); }
.minpill.show { display: block; }

/* ------------------------------------------------------------- top strip */
/* ONE horizontal bar across the top of the water: the mark, the icon groups,
   and the scene chip at its right end. Everything that used to be a worded
   button is an icon with a hover card carrying its name, what it does and
   its shortcut — sixteen words of chrome became sixteen glyphs. */
#bar {
  position: fixed; top: 10px; left: 12px; right: calc(var(--dock) + 12px);
  z-index: 10; height: 63px; display: flex; align-items: center; gap: 4px;
  padding: 0 8px 0 12px;
}
#brand {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  opacity: .92; padding-right: 4px; white-space: nowrap;
}
#brand svg { flex: 0 0 auto; }
.brandmark { fill: none; stroke: #4dc3ff; stroke-width: 1.7; stroke-linecap: round;
  stroke-linejoin: round; flex: 0 0 auto; }
/* The strip must never silently drop a control. It shrinks first (the two
   media queries below), and if a window is narrower than even that, the
   groups scroll sideways rather than being clipped away. */
#groups {
  display: flex; align-items: center; gap: 1px; flex: 0 1 auto; min-width: 0;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
}
#groups::-webkit-scrollbar { display: none; }
/* A group is a captioned COLUMN. The caption names the family — build the
   rig, measure it, look at it — which is the distinction the strip could not
   make when the families were adjacent rows split by a hairline: nothing on
   screen said that Wall changes the rig and Gauge does not. */
/* Each family gets a tinted bed as well as a caption. The caption names the
   family but only at full width — it is the first thing the compaction
   ladder drops — whereas the tint survives every rung, so the distinction
   that matters most on a cramped strip is the one that is still there. */
.tgrp {
  display: flex; flex-direction: column; align-items: stretch; gap: 1px;
  /* The bed costs width, and the strip had about a hundred pixels of slack
     at 1440 — so it is paid for out of the gap BETWEEN groups, which the bed
     now provides visually. Spend more and the captions are the thing that
     gets dropped, which defeats the point of tinting them. */
  border-radius: 10px; padding: 1px 2px 2px;
  background: rgba(255,255,255,0.07);
}
.trow { display: flex; align-items: center; gap: 2px; }
.tcap {
  font: 600 8.5px var(--font-mono);
  letter-spacing: .13em; text-align: center; line-height: 10px; height: 10px;
  opacity: .75; user-select: none; white-space: nowrap;
  color: rgba(223,232,242,0.55);
}
/* One accent per family, on the caption only: the buttons keep the single
   "this is in your hand" blue, because two colour languages on one glyph is
   one too many. */
.fam-build   .tcap { color: rgba(255,207,148,0.85); }
.fam-measure .tcap { color: rgba(127,212,255,0.85); }
.fam-view    .tcap { color: rgba(169,230,192,0.85); }
/* The three families that mean something get their own bed; SESSION and RUN
   keep the neutral one, because "load a thing" and "run the clock" are not
   part of the build / measure / view distinction. `meta` is chrome and gets
   no bed at all. */
.fam-build   { background: rgba(255,178,84,0.20);  box-shadow: inset 0 0 0 1px rgba(255,178,84,0.24); }
.fam-measure { background: rgba(88,190,255,0.20);  box-shadow: inset 0 0 0 1px rgba(88,190,255,0.24); }
.fam-view    { background: rgba(112,222,158,0.18); box-shadow: inset 0 0 0 1px rgba(112,222,158,0.22); }
.fam-meta    { background: transparent; }
.tbtn {
  appearance: none; border: 0; background: transparent; padding: 0;
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(223,232,242,0.78); cursor: pointer;
  transition: background .12s, color .12s;
}
.tbtn:hover { background: rgba(255,255,255,0.10); color: #dfe8f2; }
.tbtn:focus-visible { outline: 2px solid rgba(77,195,255,0.7); outline-offset: -2px; }
/* `.active` is the class the two menus set on their own opener (see PICKER /
   EX), so it is spelled the same as `.on` rather than teaching those modules
   a second word for "lit". */
.tbtn.on, .tbtn.active {
  background: rgba(77,195,255,0.20); color: #dfe8f2;
  box-shadow: inset 0 0 0 1px rgba(77,195,255,0.55);
}
/* A held state that is NOT a tool choice (valves shut, the clock stopped) is
   amber: "this rig is not in its normal condition" is a different kind of
   fact from "this is the tool in your hand". */
.tbtn.hot {
  background: rgba(255,182,72,0.18); color: #ffd9a0;
  box-shadow: inset 0 0 0 1px rgba(255,182,72,0.50);
}
/* The hairline and the caption do the same job, so only one of them is ever
   shown. Captions are what a desktop strip has; touch machines drop them at
   every width (see the pointer: coarse block), so there the rule is shown
   instead; strip.js builds `.tsep` only under a coarse pointer, and it is
   display:none unless that block shows it. */
.tsep { width: 1px; height: 32px; background: rgba(255,255,255,0.13);
        margin: 0 3px; flex: 0 0 auto; display: none; }

/* The scene chip: still the scene picker's affordance, now the right end of
   the strip. Two lines — what is loaded, and the live clock. */
/* `flex-shrink: 100` against the groups' 1: when the strip runs out of room
   the SCENE NAME gives way (and ellipsizes), never a control. */
#title {
  margin-left: auto; flex: 0 100 auto; max-width: 300px; min-width: 92px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block; text-align: right; cursor: pointer; appearance: none;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  color: inherit; font: inherit; padding: 5px 10px;
  transition: background .12s, border-color .12s;
}
#title:hover, #title.open { background: rgba(255,255,255,0.08); border-color: rgba(77,195,255,0.40); }
#title:focus-visible { outline: 2px solid rgba(77,195,255,0.7); outline-offset: 2px; }
#title b { font-size: 13px; letter-spacing: .01em; }
#title .caret { font-size: 9px; opacity: .5; margin-left: 5px; vertical-align: 1.5px; }
#title:hover .caret, #title.open .caret { color: #7fd4ff; opacity: 1; }
#status {
  display: block; font: 10px var(--font-mono);
  opacity: .48; margin-top: 1px; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#status.gone { display: none; }   /* UIMODE withholds it (updateStatus) */
/* Three steps of compaction (.tight, .tighter, .tightest; a touch screen
   wraps instead of taking the last one), applied by `fitBar()` from a
   MEASUREMENT of the strip rather than from a viewport media query — the dock
   takes its width out of the bar too, so the window size does not say whether
   the icons fit. fitBar then publishes the resulting height as --bar-h. */
/* The caption is decoration before it is information, so it is the first
   thing dropped when the strip runs out of room — never a control — and the
   bar loses the row's height. (On touch machines the hairline takes its
   place; see .tsep.) */
#bar.tight .tcap { display: none; }
#bar.tight { height: 52px; }
#bar.tight .tbtn { width: 32px; height: 32px; }
#bar.tight .tsep { margin: 0 2px; height: 22px; }   /* shown only when coarse */
#bar.tight #brand .word { display: none; }
#bar.tighter .tbtn { width: 30px; height: 30px; }
#bar.tighter #groups { gap: 2px; }
#bar.tighter .trow { gap: 0; }
#bar.tighter #status { display: none; }
/* The last rung before the groups have to scroll. Twenty-six glyphs at
   26 px still fit an 1100 px strip, which is what a 1440 px window with the
   exercise panel open actually has. */
#bar.tightest .tbtn { width: 26px; height: 26px; }
#bar.tightest #groups { gap: 1px; }
/* At this width the mark is the only thing on the strip that is decoration,
   so it is the last thing to go before a control would have to. */
#bar.tighter #brand { display: none; }
#bar.tighter { padding: 0 6px; }
/* The strip has more in it than fits, and a hard edge reads as "that is all
   of them". The fade says it carries on. */
#bar.scrolls #groups {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
}

/* An exercise can open the panel FOCUSED: only the sections it actually
   touches, with the way back to everything at its head. */
#panel [data-sec].off { display: none; }
.panelfocus { display: none; padding: 0 0 8px; }
.panelfocus.on { display: block; }
#panelAll {
  appearance: none; width: 100%; text-align: left; cursor: pointer;
  background: rgba(77,195,255,0.10); color: #bfe6ff;
  border: 1px solid rgba(77,195,255,0.30); border-radius: 8px;
  padding: 6px 10px; font: 11px var(--font-ui);
}
#panelAll:hover { background: rgba(77,195,255,0.20); }

/* ------------------------------------------------------------- the legend */
/* Nine colourings existed long before anything on screen said which one was
   up, over what range, in what units — so a screenshot pasted into a
   worksheet carried no statement of what it showed. Top right, because the
   gauge cards stack bottom-right and the ruler owns the edges, immediately
   left of the Controls panel. `--dock` is the width
   the dock takes out of the viewport, so this is the same expression
   #bar uses and the legend tracks the panel opening and closing for free --
   including the phone case, where the panel becomes a bottom sheet and --dock
   goes to 0, leaving this at the right edge with no special case.

   Once the reader DRAGS it, js/main.js sets `left`/`top` inline and adds
   .placed, which drops the `right` anchor: from then on the position is
   theirs and stops following the panel. Same bargain as the vertical
   exaggeration -- fitted until somebody sets it by hand. */
#legend {
  position: fixed; z-index: 12; right: calc(var(--dock) + 12px);
  top: calc(var(--bar-h) + 21px);   /* 84px under the full-height strip */
  cursor: grab; width: 236px;
  display: none; padding: 9px 11px 8px; gap: 5px; flex-direction: column;
  font: 11.5px var(--font-ui);
}
#legend.placed { right: auto; }
/* The whole card drags (the cursor above); dragWindow's own guard excludes
   every button, the editable range numbers and anything else you can click. */
#legend button { cursor: pointer; }
#legend [contenteditable] { cursor: text; }

/* Live | Average. A segmented pair rather than one toggle button: the two
   states are equally real and a student should be able to see which one they
   are in without having to know what a pressed button looks like. */
#legMode {
  display: flex; gap: 2px; padding: 2px; margin: 1px 0 2px;
  background: rgba(255,255,255,0.05); border-radius: 8px;
}
#legMode button {
  appearance: none; flex: 1 1 0; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: #9fb0c4; font: 600 11px var(--font-ui);
  padding: 3px 0; letter-spacing: .02em;
}
#legMode button:hover { background: rgba(255,255,255,0.07); color: #dfe8f2; }
#legMode button[aria-pressed="true"] {
  background: rgba(77,195,255,0.20); border-color: rgba(77,195,255,0.55);
  color: #cdeaff;
}
/* Averaging is a measurement MODE, not a view setting, so when it is on the
   whole card says so rather than leaving one small pressed button to carry it. */
#legend.avg { border-color: rgba(77,195,255,0.42); }
#legend.open { display: flex; }
#legPick {
  appearance: none; background: transparent; border: 1px solid transparent;
  border-radius: 8px; color: inherit; cursor: pointer; text-align: left;
  padding: 2px 30px 2px 4px; margin: -2px -4px 0;   /* clears the corner - */
  display: flex; align-items: baseline; gap: 6px;
}
#legPick:hover, #legPick.open { background: rgba(255,255,255,0.08); border-color: rgba(77,195,255,0.40); }
#legPick b { font-size: 12.5px; font-weight: 600; }
#legPick i { font: 11px var(--font-mono); opacity: .60; font-style: normal; }
#legPick .caret { font-size: 9px; opacity: .5; margin-left: auto; }
#legPick:hover .caret, #legPick.open .caret { color: #7fd4ff; opacity: 1; }
.legrow { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.legbar { height: 10px; border-radius: 3px; border: 1px solid rgba(255,255,255,0.10); }
.legcap {
  font: 10px var(--font-mono); opacity: .58;
  display: flex; justify-content: space-between; gap: 8px;
}
#legFoot, #legActs { display: flex; align-items: center; gap: 6px; }
#legFoot { font: 10.5px var(--font-mono); opacity: .82; margin-top: 2px; }
#legFoot .grow { flex: 1 1 auto; }
.legnum {
  padding: 1px 4px; border-radius: 5px; cursor: text; outline: none;
  border: 1px solid transparent; font-variant-numeric: tabular-nums;
}
.legnum:hover { background: rgba(255,255,255,0.08); }
.legnum:focus { background: rgba(12,17,26,0.92); border-color: rgba(77,195,255,0.55); }
#legActs button { border-color: rgba(255,255,255,0.12); padding: 2px 9px; font: 10.5px var(--font-ui); }
#legActs button:hover { background: rgba(77,195,255,0.22); }
/* The Average block. Present in the markup and revealed by a class rather
   than built on demand: the card above it is painted from the ramps, and a
   section that rebuilt the card to appear would be one more way for the key
   and the water to drift apart. */
#legAvg {
  display: none; flex-direction: column; gap: 3px; margin-top: 5px;
  padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.14);
}
#legend.avg #legAvg { display: flex; }
.legahd { display: flex; align-items: baseline; gap: 8px; }
.legahd b { font: 600 11px var(--font-ui); color: #7fd4ff; }
.legahd span {
  margin-left: auto; font: 10.5px var(--font-mono);
  font-variant-numeric: tabular-nums; opacity: .85;
}
#legAvgRead {
  font: 10.5px var(--font-mono); opacity: .88;
  font-variant-numeric: tabular-nums;
}
.legnote { font-size: 10px; line-height: 1.35; opacity: .58; }
#legmenu {
  position: fixed; z-index: 40; display: none; padding: 6px; width: 312px;
  max-height: 70vh; overflow: auto;
}
#legmenu.open { display: block; }
.legopt {
  display: block; width: 100%; text-align: left; appearance: none;
  background: transparent; border: 0; border-radius: 8px; color: inherit;
  padding: 6px 9px; cursor: pointer;
}
.legopt:hover { background: rgba(255,255,255,0.09); }
.legopt.on { background: rgba(77,195,255,0.18); }
.legopt b { font: 600 12px var(--font-ui); }
.legopt i { font: 10.5px var(--font-mono); opacity: .6; font-style: normal; margin-left: 6px; }
.legopt span { display: block; font-size: 11px; opacity: .62; margin-top: 2px; }
/* On a phone the bottom sheet owns the lower half and the strip the top, so
   there is no room for a floating card as well. The field stays reachable
   from Controls. */
@media (max-width: 620px) { #legend.open { display: none; } }   /* = --phone-max */

/* ---------------------------------------------------------- hover card */
/* Replaces every `title=` on the strip: a native tooltip cannot carry the
   shortcut, waits half a second, and cannot be styled. */
#tip {
  position: fixed; z-index: 40; display: none; padding: 7px 11px;
  pointer-events: none; max-width: 320px;
}
#tip.show { display: flex; align-items: center; gap: 9px; }
#tip b { font: 600 12.5px var(--font-ui); white-space: nowrap; }
#tip span { font-size: 11.5px; opacity: .62; }
#tip kbd {
  font: 10.5px var(--font-mono); background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 4px; padding: 1px 5px;
  flex: 0 0 auto; margin-left: auto;
}

#hint {
  position: fixed; bottom: calc(var(--dockb) + 18px);
  z-index: 10; padding: 9px 34px 9px 18px;
  /* --gcw is the width the gauges' corner cards take out of the bottom right
     (main.js sets it while any are drawn): the tips line centres on what is
     left, so it never sits on top of a gauge's chart. */
  left: calc((100vw - var(--dock) - var(--gcw)) / 2); transform: translateX(-50%);
  font-size: 13px; opacity: .92; pointer-events: none; text-align: center;
  max-width: min(640px, 70vw, calc(100vw - var(--dock) - var(--gcw) - 24px));
}
#hint b { color: #7fd4ff; }
#hint .minbtn { pointer-events: auto; }

#toast {
  position: fixed; top: calc(var(--bar-h) + 13px);   /* 76px under the full-height strip */
  z-index: 11; padding: 12px 20px; text-align: center;
  left: calc((100vw - var(--dock)) / 2); transform: translateX(-50%) translateY(-8px);
  opacity: 0; transition: opacity .35s, transform .35s;
  pointer-events: none; max-width: min(560px, 80vw);
}
/* An announcement is dismissable the moment it is readable. */
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0);
  pointer-events: auto; cursor: pointer; }
#toastTitle { font-weight: 700; font-size: 14.5px; }
#toastSub { font-size: 12.5px; opacity: .72; margin-top: 2px; }

#panel {
  --panel-top: calc(var(--bar-h) + 9px);   /* 72px under the full-height strip */
  position: fixed; top: var(--panel-top); left: 14px; z-index: 10;
  width: min(340px, calc(100vw - 28px));
  padding: 14px 16px; display: none; max-height: calc(100vh - 100px); overflow: auto;
}
#panel.open { display: block; }
#panel::-webkit-scrollbar { width: 6px; }
#panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
#panel h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .5; margin: 15px 0 4px; }
#panel h3:first-child { margin-top: 0; }
#panel label.row { display: flex; align-items: center; gap: 8px; margin: 7px 0 1px; font-size: 13px; }
#panel .row .lbl { flex: 1 1 auto; white-space: nowrap; }
#panel input[type=range] { width: 138px; flex: 0 0 auto; accent-color: #4dc3ff; }
#panel .notes { font: 11px var(--font-mono); opacity: .5; margin: 0 0 6px; min-height: 12px; }
/* A dynamic row (Geometry's geom0…geom5) with nothing to bind to — most
   scenes declare no params, so these stay hidden rather than showing a dead
   slider. The section's own h3 rides the same class: when every one of its
   rows is gone (no declared params at all), the heading goes with them
   rather than fronting an empty section. */
#panel .row.gone, #panel .notes.gone, #panel h3.gone { display: none; }
#panel .info { flex: 0 0 auto; opacity: .35; cursor: help; font-size: 12px; padding: 2px; user-select: none; }
#panel .info:hover { opacity: .9; }
#panel select, #panel input[type=checkbox] { accent-color: #4dc3ff; }
#panel select {
  background: rgba(255,255,255,0.08); color: inherit; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 7px; padding: 3px 6px; font: inherit; font-size: 12.5px;
}

#panel .btnrow { display: flex; gap: 4px; flex: 0 0 auto; }
#panel .btnrow button { font: 600 11.5px var(--font-mono); padding: 3px 8px; }
#panel .btnrow button:hover:not(:disabled) { background: rgba(77,195,255,0.20); }
#panel .btnrow button:disabled { opacity: .35; cursor: default; }
/* A chosen one of several, as opposed to a button that DOES something. */
#panel .btnrow button.on {
  background: rgba(77,195,255,0.22); border-color: rgba(77,195,255,0.55); color: #dfe8f2;
}

/* ------------------------------------------------------ rig save / share */
#panel .row.stack { flex-wrap: wrap; }
#panel .rigui { flex: 1 0 100%; display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
#panel .rigrow { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
#panel .rigui button, #panel .rigfile {
  font: 600 11.5px var(--font-mono); white-space: nowrap;
}
#panel .rigtx {
  width: 100%; height: 52px; resize: vertical; display: block;
  background: rgba(0,0,0,0.28); color: #dfe8f2;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
  font: 10.5px/1.35 var(--font-mono);
  padding: 6px 7px; user-select: text; word-break: break-all;
}
#panel .rigtx:focus { outline: 1px solid rgba(77,195,255,0.55); }
#panel .rigtx::placeholder { color: rgba(223,232,242,0.35); }
#panel .rigmsg {
  font: 10.5px var(--font-mono); opacity: .62;
  margin-left: auto; text-align: right; color: #7fd4ff;
}

/* ------------------------------------------------ gauge inspector windows */
.gcardBtn {
  position: fixed; z-index: 12; width: 19px; height: 19px; padding: 0;
  appearance: none; cursor: pointer; color: #dfe8f2;
  background: rgba(12,17,26,0.85); border: 1px solid rgba(255,255,255,0.20);
  border-radius: 6px; font: 11px/17px var(--font-mono); text-align: center;
}
.gcardBtn:hover { background: rgba(77,195,255,0.30); }
/* What one gauge plots: a small select hung just outside its corner card,
   under the ⤢, so the card itself stays as every worksheet shows it. */
.gcardSel {
  position: fixed; z-index: 12; min-width: 42px; max-width: 64px; height: 20px; padding: 0 2px;
  cursor: pointer; color: #dfe8f2; background: rgba(12,17,26,0.85);
  border: 1px solid rgba(255,255,255,0.20); border-radius: 6px;
  font: 11px var(--font-mono);
}
.gcardSel:hover { background: rgba(77,195,255,0.30); }
.gcardSel option { background: #0c111a; color: #dfe8f2; }
/* Remove this gauge: inside the card's top-right corner (the card moves its
   upper value label down to make room). */
.gcardX {
  position: fixed; z-index: 12; width: 17px; height: 17px; padding: 0;
  appearance: none; cursor: pointer; color: #dfe8f2; background: rgba(12,17,26,0.6);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 5px;
  font: 13px/15px var(--font-mono); text-align: center;
}
.gcardX:hover { background: rgba(255,90,110,0.45); }
.ginsp-rm {
  appearance: none; cursor: pointer; color: #ffb3bf; background: transparent;
  border: 1px solid rgba(255,143,163,0.35); border-radius: 6px;
  font: 11px var(--font-mono); padding: 2px 7px;
}
.ginsp-rm:hover { background: rgba(255,90,110,0.30); }

.ginsp {
  position: fixed; z-index: 21; width: 400px;
  font-size: 12px; user-select: none; touch-action: none;
}
.ginsp-h {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px;
  cursor: move; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ginsp-dot { width: 9px; height: 9px; border-radius: 50%; background: #7fd4ff; flex: 0 0 auto; }
.ginsp-h b { font-size: 12.5px; letter-spacing: .01em; white-space: nowrap; }
.ginsp-pos { font: 10.5px var(--font-mono); opacity: .58;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ginsp-grow { flex: 1 1 auto; }
.ginsp-x {
  appearance: none; border: 0; background: transparent; color: inherit;
  font-size: 15px; line-height: 1; padding: 2px 5px; border-radius: 6px; cursor: pointer;
}
.ginsp-x:hover { background: rgba(255,255,255,0.12); }

.ginsp-vals { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 2px; }
.ginsp-vals div {
  flex: 1 1 88px; padding: 4px 6px; border-radius: 7px;
  background: rgba(255,255,255,0.04); border: 1px solid transparent;
}
.ginsp-vals div.on { border-color: rgba(77,195,255,0.40); background: rgba(77,195,255,0.10); }
.ginsp-vals span { font: 10px var(--font-mono); opacity: .55; }
.ginsp-vals b { display: block; font: 700 12.5px var(--font-mono);
  font-variant-numeric: tabular-nums; margin: 1px 0; user-select: text; }
.ginsp-vals i { display: block; font-style: normal; font-size: 9.5px; opacity: .42; line-height: 1.25; }

.ginsp-tabs { display: flex; gap: 4px; padding: 7px 10px 6px; }
.ginsp-tabs button {
  appearance: none; background: rgba(255,255,255,0.06); color: inherit;
  border: 1px solid rgba(255,255,255,0.14); border-radius: 999px;
  font: 600 10.5px var(--font-mono); padding: 2px 10px; cursor: pointer;
}
.ginsp-tabs button.on { background: rgba(77,195,255,0.22); border-color: rgba(77,195,255,0.55); }

.ginsp-c {
  display: block; width: calc(100% - 20px); height: 158px; margin: 0 10px;
  cursor: crosshair; touch-action: none;
}

.ginsp-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px 2px; }
.ginsp-b { border-radius: 8px; white-space: nowrap; flex: 0 0 auto; }
.ginsp-span {
  margin-left: auto; text-align: right; font: 10px var(--font-mono);
  opacity: .5; font-variant-numeric: tabular-nums; user-select: text;
}
.ginsp-span.frozen { color: #ffb648; opacity: .8; }
.ginsp-cap { padding: 6px 10px 10px; font-size: 10px; line-height: 1.4; opacity: .42; }
.ginsp-cap b { opacity: .85; }
@media (max-width: 560px) { .ginsp { width: calc(100vw - 20px); } }

/* ------------------------------------------------------------ scene picker */
/* One menu, three entry points (the strip's chip, its Scenes icon, the panel
   row). It is built from the SCENES registry every time it opens, so a scene
   added to js/scenes.js appears here with no further edit. */
.gmenu {
  position: fixed; z-index: 30; width: 390px; max-width: calc(100vw - 24px);
  padding: 7px; display: none; max-height: calc(100vh - 96px); overflow: auto;
}
.gmenu.open { display: block; }
.gmenu::-webkit-scrollbar { width: 6px; }
.gmenu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
.gmenu .smh {
  display: flex; align-items: baseline; gap: 8px; padding: 5px 9px 7px;
  border-bottom: 1px solid rgba(255,255,255,0.07); margin-bottom: 3px;
}
.gmenu .smh b { font-size: 12.5px; letter-spacing: .01em; }
.gmenu .smh i {
  font-style: normal; margin-left: auto; opacity: .45;
  font: 10.5px var(--font-mono);
}
.gmenu .smg {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  opacity: .45; padding: 10px 9px 3px;
}
.gmenu .smi {
  display: block; width: 100%; text-align: left; appearance: none;
  background: transparent; color: inherit; font: inherit;
  border: 1px solid transparent; border-radius: 9px;
  padding: 6px 9px 7px; cursor: pointer; transition: background .1s;
}
.gmenu .smi:hover, .gmenu .smi.hi { background: rgba(255,255,255,0.08); }
.gmenu .smi.on {
  background: rgba(77,195,255,0.16); border-color: rgba(77,195,255,0.45);
}
.gmenu .smi b { font-size: 13px; font-weight: 600; }
.gmenu .smi em {
  font-style: normal; margin-left: 7px; opacity: .45;
  font: 10px var(--font-mono);
}
.gmenu .smi .tag {
  float: right; font: 9.5px var(--font-mono); letter-spacing: .06em;
  text-transform: uppercase; opacity: .75; color: #7fd4ff; margin-top: 3px;
}
.gmenu .smi p { font-size: 11.5px; line-height: 1.35; opacity: .60; margin: 2px 0 0; }
.gmenu .smwarn {
  margin: 4px 2px 2px; padding: 8px 10px; border-radius: 9px;
  background: rgba(255,182,72,0.12); border: 1px solid rgba(255,182,72,0.45);
  font-size: 11.5px; line-height: 1.4;
}
.gmenu .smwarn b { color: #ffb648; }
.gmenu .smwarn .r { display: flex; gap: 5px; margin-top: 7px; }
.gmenu .smwarn button { border-color: rgba(255,255,255,0.20); padding: 4px 10px; }
.gmenu .smwarn button:hover { background: rgba(255,255,255,0.16); }
.gmenu .smwarn button.go { border-color: rgba(255,182,72,0.6); color: #ffd9a0; }

/* ---------------------------------------------------------- exercises */
/* The exercise menu is the scene menu's twin (.gmenu above) plus a filter
   box and an id chip. Picking one loads it into the dock below. */
#exmenu { width: 428px; }
.gmenu .smf {
  display: block; width: calc(100% - 6px); margin: 2px 3px 4px;
  background: rgba(0,0,0,0.28); color: #dfe8f2;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
  font: 12px var(--font-ui); padding: 5px 8px;
}
.gmenu .smf:focus { outline: 1px solid rgba(77,195,255,0.55); }
.gmenu .smf::placeholder { color: rgba(223,232,242,0.35); }
.gmenu .smi .eid {
  display: inline-block; min-width: 38px; margin-right: 7px;
  font: 700 10.5px var(--font-mono);
  color: #7fd4ff; letter-spacing: .04em;
}
.gmenu .smi .rigtag {
  float: right; font: 9.5px var(--font-mono); letter-spacing: .05em;
  text-transform: uppercase; opacity: .6; margin-top: 3px;
}
.gmenu .smi .rigtag.has  { color: #5fd08a; }   /* the card ships its drawing */
.gmenu .smi .rigtag.draw { color: #ffb648; }   /* the student draws it */
.gmenu .smnone { padding: 10px 9px; font-size: 12px; opacity: .5; }
/* Compact exercise menu (EXERCISE_MENU.compact): one line per item, the
   description in a floating box beside it. The menu never runs off the page:
   place() clamps it and this caps its height (--menu-room, which place()
   sets when the menu hangs below its opener), the list scrolls inside. */
#exmenu.compact { width: 360px; max-height: var(--menu-room, calc(100vh - 16px)); }
#exmenu.compact .smi {
  padding: 4px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#exmenu.compact .smi b { font-size: 12.5px; }
/* No hover on this screen (pickers.js): the aim is printed under the title,
   so the item wraps rather than ellipsizing. */
#exmenu.compact.inline .smi { white-space: normal; padding: 8px 9px 9px; }
#exmenu.compact .smg { padding: 7px 9px 2px; }
.exdesc {
  position: fixed; z-index: 31; display: none; pointer-events: none;
  width: 280px; max-width: calc(100vw - 16px); padding: 8px 11px;
  font-size: 12px; line-height: 1.4;
}
.exdesc.open { display: block; }

/* ------------------------------------------------------- keyboard sheet */
#keysmenu { width: 336px; }
#keysmenu .kline {
  display: flex; align-items: baseline; gap: 9px; padding: 3px 9px; font-size: 11.5px;
}
#keysmenu .kline span { opacity: .72; }
#keysmenu kbd {
  background: rgba(255,255,255,0.10); border-radius: 4px; padding: 1px 5px;
  font: 10.5px var(--font-mono); border: 1px solid rgba(255,255,255,0.12);
  flex: 0 0 auto; min-width: 62px; text-align: center;
}

/* ============================================================ dock */
/* The exercise lives HERE, not in a window over the water: the canvases are
   inset by --dock, so the dock takes its width out of the viewport instead
   of covering it. Below the width where there is anything to give away it
   goes back to overlaying (`.over`) and the canvas keeps the whole window. */
#dock {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--dock-w); z-index: 14;
  display: none; flex-direction: column;
  background: rgba(12, 17, 26, 0.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255,255,255,0.09);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
}
#dock.open { display: flex; }
#dock.over { width: min(var(--dock-w), 100vw); box-shadow: -8px 0 48px rgba(0,0,0,0.6); }
.dock-h {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  padding: 14px 12px 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.dock-h .eid {
  font: 700 11px var(--font-mono); color: #7fd4ff; letter-spacing: .04em;
  background: rgba(77,195,255,0.14); border-radius: 6px; padding: 2px 6px; flex: 0 0 auto;
}
.dock-h .kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .5;
}
.dock-h .grow { flex: 1 1 auto; }
.dock-x {
  appearance: none; border: 0; background: transparent; color: inherit;
  font-size: 16px; line-height: 1; padding: 3px 7px; border-radius: 7px;
  cursor: pointer; opacity: .6;
}
.dock-x:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.dock-body {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 11px; font-size: 12px;
}
.dock-body::-webkit-scrollbar { width: 6px; }
.dock-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
.dock-foot {
  flex: 0 0 auto; display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.08);
}
/* The seam handle: a tab straddling the panel's left edge that folds it away,
   and the same tab parked on the window edge to bring it back. */
#dockfold, #docktab {
  position: fixed; z-index: 15; appearance: none; cursor: pointer; color: #dfe8f2;
  background: rgba(12,17,26,0.92); border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 4px 24px rgba(0,0,0,0.35); display: none; padding: 0;
}
#dockfold {
  width: 26px; height: 52px; top: 50%; margin-top: -26px;
  right: calc(var(--dock) - 13px); border-radius: 8px;
  align-items: center; justify-content: center;
}
#dockfold.show { display: flex; }
#dockfold:hover, #docktab:hover { background: rgba(77,195,255,0.25); }
#docktab {
  /* "open instructions" is longer than the old "exercise", so the tab reads
     taller (measured ~194px) than the fold handle it centres against — half
     that height keeps it centred on the seam the same way -26px does for
     #dockfold above. */
  right: 0; top: 50%; margin-top: -97px; width: 30px; padding: 12px 4px;
  border-right: 0; border-radius: 10px 0 0 10px;
  flex-direction: column; align-items: center; gap: 8px;
}
#docktab.show { display: flex; }
#docktab .eid {
  writing-mode: vertical-rl; font: 700 10.5px var(--font-mono);
  color: #7fd4ff; letter-spacing: .06em;
}
#docktab .kind {
  writing-mode: vertical-rl; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .08em; opacity: .5;
}

/* ------------------------------------------------- the panel as a sheet */
/* On a phone a --dock-w panel down the side would leave a 40px slice of water,
   which is no use to anybody. It becomes a bottom sheet instead: the flume
   keeps the top of the screen — the only part of a phone tall enough to
   read one in — and the brief takes the bottom, where a thumb is. */
#dock.sheet {
  top: auto; left: 0; right: 0; bottom: 0; width: auto;
  height: var(--sheet-h);
  border-left: 0; border-top: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
}
/* A grab bar, so the thing reads as a sheet rather than as a stuck dialog. */
#dock.sheet .dock-h::before {
  content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 34px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.22);
}
#dock.sheet .dock-h { position: relative; padding-top: 18px; }
/* The seam handle has no seam to sit on; the × closes and the pill reopens. */
#dock.sheet ~ #dockfold { display: none; }
#dock.sheet ~ #docktab {
  top: auto; bottom: 14px; right: 14px; margin-top: 0; width: auto;
  flex-direction: row; align-items: center; gap: 7px; padding: 9px 14px;
  border-right: 1px solid rgba(255,255,255,0.14); border-radius: 999px;
}
#dock.sheet ~ #docktab .eid, #dock.sheet ~ #docktab .kind { writing-mode: horizontal-tb; }

/* ------------------------------------------------------ touch machines */
/* A finger is not a mouse pointer: 44px is the smallest target most people
   hit reliably, and anything under a 16px font makes iOS Safari zoom the
   page the moment the field is focused. */
@media (pointer: coarse) {
  .tbtn { width: 44px; height: 44px; }
  #bar.tight .tbtn { width: 42px; height: 42px; }
  #bar.tighter .tbtn { width: 40px; height: 40px; }
  #bar.tightest .tbtn { width: 38px; height: 38px; }
  /* Out of room on a touch screen: the groups WRAP rather than shrink below
     40 px or scroll out of sight (fitBar). The bar grows a row, and the
     legend, the toast and the panel follow its bottom edge (--bar-h). */
  #bar.wraps { height: auto; min-height: 58px; padding-top: 5px; padding-bottom: 5px; }
  #bar.wraps #groups { flex: 1 1 auto; flex-wrap: wrap; row-gap: 5px; overflow: visible; }
  #bar.wraps .tbtn { width: 42px; height: 42px; }
  #bar.notitle #title { display: none; }
  /* The gauge cards' small DOM controls keep their look (every worksheet
     screenshot has one) but get a finger-sized hit area. */
  .gcardBtn, .gcardX { overflow: visible; }
  .gcardX::after { content: ""; position: absolute; inset: -11px; }
  .gcardBtn::after { content: ""; position: absolute; inset: -9px -11px -3px -11px; }
  .gcardSel { height: 28px; }
  /* A slider is dragged with a fingertip: a taller track to land on. */
  #dock input[type=range], #panel input[type=range] { height: 32px; }
  #panel {
    --panel-top: max(78px, calc(var(--bar-h) + 18px));
    max-height: calc(100vh - var(--panel-top) - 20px);
  }
  /* The canvas is a surface to touch, not text: no callout, no selection
     loupe and no grey flash on a long press. */
  #view, #over, #bar { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  button, .tbtn, [role="button"] { -webkit-tap-highlight-color: transparent; }
  /* A 44 px target and a caption do not both fit a strip this tall, and the
     target is the one that cannot be given up. */
  .tcap { display: none; }
  .tsep { display: block; }
  #bar { height: 58px; }
  /* Shortcuts are for machines with keys. */
  #keysBtn { display: none; }
  .dock-x { font-size: 20px; padding: 6px 10px; }
  .exb, #dock .exd input, #startpack .pf input, .gmenu .smf,
  #dock .exset > summary { font-size: 16px; }
  .gmenu .smi { padding: 10px 9px 11px; }
  #startlist .si { padding: 9px 8px; }
}

/* The exercise brief inside the panel. ONE neutral style: no green "your
   values" block, no amber warning, no blue "you draw this" — a brief that
   colour-codes six kinds of sentence is one nobody reads in a lecture.
   Emphasis is a bold lead-in and nothing else. */
#dock .extitle { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
#dock .exline { font-size: 12px; line-height: 1.5; user-select: text; }
#dock .exline b { font-weight: 700; opacity: .78; }
#dock .exd { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
#dock .exd label { font-size: 11.5px; opacity: .72; white-space: nowrap; }
#dock .exd input {
  width: 52px; background: rgba(0,0,0,0.30); color: #dfe8f2; text-align: center;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 7px;
  font: 700 13px var(--font-mono); padding: 3px 5px;
}
#dock .exd input:focus { outline: 1px solid rgba(77,195,255,0.55); }
#dock .exval { font: 11.5px var(--font-mono); opacity: .85; user-select: text; }
/* "Yours": the printed rule, and the control the answer goes on. The field
   is the Controls panel's own control, moved to where the rule is — before
   this the only thing saying where q went was the words "· Inflow q slider"
   trailing a run-on sentence, with the slider itself in a floating panel on
   the far side of the screen. */
#dock .exrules { display: flex; flex-direction: column; gap: 7px; }
#dock .exrow {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 8px 10px; border-radius: 9px;
  background: rgba(255,255,255,0.05);
}
#dock .exrowt { flex: 1 1 auto; min-width: 0; font-size: 12px; line-height: 1.45; }
#dock .exrowt b { font-weight: 700; opacity: .9; }
#dock .exrowt i {
  display: block; font-style: normal; font-size: 11px; opacity: .55; margin-top: 2px;
}
#dock .exrowf { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; }
#dock .exrowf input[type=number] {
  width: 76px; background: rgba(0,0,0,0.32); color: #dfe8f2; text-align: right;
  border: 1px solid rgba(255,255,255,0.20); border-radius: 7px;
  font: 700 13px var(--font-mono); padding: 4px 6px;
}
#dock .exrowf input[type=number]:focus { outline: 1px solid rgba(77,195,255,0.65); }
#dock .exrowf input[type=checkbox] { width: 17px; height: 17px; accent-color: #4dc3ff; }
#dock .exrowf select {
  background: rgba(0,0,0,0.32); color: inherit; border: 1px solid rgba(255,255,255,0.20);
  border-radius: 7px; padding: 3px 6px; font: inherit; font-size: 12px; max-width: 130px;
}
#dock .exunit {
  font: 10.5px var(--font-mono); opacity: .5; min-width: 26px;
}

#dock .exsteps {
  margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.45;
  user-select: text;
}
#dock .exsteps li { opacity: .88; }
/* A strip button named in a step ({tool:force}, {btn:legendBtn}): its own
   icon and label, in line, looking like the button and not like a link. */
#dock .exico, #hint .exico {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: -2px;
  padding: 0 5px 0 3px; margin: 0 1px; border-radius: 5px; white-space: nowrap;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  line-height: 17px;
}
#dock .exico svg, #hint .exico svg { flex: 0 0 auto; color: #7fd4ff; }
#dock .exico b, #hint .exico b { font-weight: 600; opacity: 1; }
#dock .exico.bad, #hint .exico.bad { color: #ffb648; }
#dock .exkey, #hint .exkey {
  display: inline-block; min-width: 15px; padding: 0 4px; text-align: center;
  font: 700 10.5px var(--font-mono); line-height: 16px;
  border: 1px solid rgba(255,255,255,0.28); border-bottom-width: 2px; border-radius: 4px;
  background: rgba(255,255,255,0.06);
}
/* Tabs: one scene, several questions (CR-1). Switching keeps the bench. */
#dock .extabs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: -4px; }
#dock .extab {
  appearance: none; cursor: pointer; color: inherit; font: 600 11.5px var(--font-ui);
  padding: 4px 10px; border-radius: 7px; border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04); opacity: .7;
}
#dock .extab:hover { opacity: 1; background: rgba(77,195,255,0.14); }
#dock .extab.on {
  opacity: 1; background: rgba(77,195,255,0.22); border-color: rgba(77,195,255,0.55);
}
/* Background: the definitions, formulas and remarks, closed by default. */
#dock .exbg { font-size: 12px; line-height: 1.45; user-select: text; }
#dock .exbg > summary {
  cursor: pointer; list-style: none; font-weight: 700; opacity: .7; padding: 2px 0;
}
#dock .exbg > summary::-webkit-details-marker { display: none; }
#dock .exbg > summary::before { content: "▸ "; }
#dock .exbg[open] > summary::before { content: "▾ "; }
#dock .exbg > summary:hover { opacity: 1; }
#dock .exbgl {
  display: flex; flex-direction: column; gap: 6px; margin-top: 4px;
  padding: 7px 10px; border-radius: 8px; background: rgba(255,255,255,0.05);
}
#dock .exbgl p { margin: 0; opacity: .88; }
#dock .exset { font-size: 11px; user-select: text; }
#dock .exset > summary {
  cursor: pointer; opacity: .62; list-style: none;
  font: 10px var(--font-mono); letter-spacing: .03em; padding: 2px 0;
}
#dock .exset > summary::before { content: "▸ "; }
#dock .exset[open] > summary::before { content: "▾ "; }
#dock .exset > summary:hover { opacity: .95; }
#dock .exsetl {
  display: flex; flex-direction: column; gap: 2px; padding: 6px 9px; margin-top: 3px;
  background: rgba(255,255,255,0.05); border-radius: 7px; opacity: .78;
  font: 10.5px var(--font-mono);
}
#dock .exsetl b { opacity: .9; font-weight: 700; }
#dock .exsetl i {
  display: block; font-style: normal; opacity: .7; padding-left: 9px;
  font: 10px var(--font-ui); line-height: 1.35;
}
#dock .exsettle { font: 10.5px var(--font-mono); opacity: .6; }
/* JS hides a part of the brief with `.gone`, never with an inline display —
   an inline value beats every rule above and the part could not be restyled.
   Last of the #dock rules, so no later display value can win. */
#dock .gone { display: none; }
/* The dock footer Reset: .btn-sm plus this. The font-size is restated AFTER the
   touch media query above (which lists .exb at 16px): on main this rule came
   later and won, so the button stayed 11px on tablets; as a bare .btn-sm base it
   lost to the query and grew. */
.btn-sm.exb { border-radius: 8px; padding: 5px 10px; white-space: nowrap; font-size: 11px; }
.exlink {
  font: 10px var(--font-mono); opacity: .5; margin-left: auto;
  color: inherit; text-decoration: none; user-select: text;
}
.exlink:hover { opacity: .9; color: #7fd4ff; text-decoration: underline; }

/* =========================================================== start screen */
/* This is a TEACHING tool, so it opens on the teaching pack: the exercises
   are the front door and the sandbox is a deliberate choice beside them,
   not the other way round. The simulation keeps running dimmed behind it —
   the thing is alive before you have chosen anything. Any `?scene=`, `?ex=`
   or `#rig=` link skips this screen entirely, so a lecture permalink lands
   exactly where it always did. */
#start {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(7, 11, 15, 0.74);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  overflow: auto; padding: 40px 24px;
}
#start.open { display: block; }
#startwrap { width: min(1180px, 100%); margin: 0 auto; }
#starthead { text-align: center; margin-bottom: 26px; }
#starthead .mark { display: flex; align-items: center; justify-content: center; gap: 12px; }
#starthead h1 { font-size: 27px; font-weight: 700; letter-spacing: .01em; }
#starthead p { font-size: 13px; opacity: .6; margin-top: 6px; }
#startcols { display: flex; gap: 22px; align-items: flex-start; }
#startpack { flex: 1 1 auto; min-width: 0; padding: 0; overflow: hidden; }
#startside { flex: 0 0 320px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) { #startcols { flex-direction: column; } #startside { flex: 1 1 auto; width: 100%; } }

#startpack .ph {
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 16px 11px; border-bottom: 1px solid rgba(255,255,255,0.07);
}
#startpack .ph b { font-size: 13.5px; }
#startpack .ph i { font-style: normal; margin-left: auto; opacity: .45; font: 10.5px var(--font-mono); }
#startpack .pf { padding: 10px 12px 4px; }
#startpack .pf input {
  display: block; width: 100%; background: rgba(0,0,0,0.28); color: #dfe8f2;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
  font: 12.5px var(--font-ui); padding: 7px 10px;
}
#startpack .pf input:focus { outline: 1px solid rgba(77,195,255,0.55); }
#startpack .pf input::placeholder { color: rgba(223,232,242,0.35); }
/* Two real columns, balanced in JS (see START.renderList). NOT CSS
   `columns` — a multi-column box with a max-height lays its overflow out
   SIDEWAYS, so the pack scrolled horizontally and two thirds of it could
   not be reached — and not a grid either, whose rows are as tall as their
   tallest group and leave the short one trailing white space. */
#startlist {
  display: flex; gap: 18px; align-items: flex-start; padding: 8px 14px 16px;
  max-height: min(52vh, 460px); overflow-y: auto; overflow-x: hidden;
}
#startlist .col { flex: 1 1 0; min-width: 0; }
@media (max-width: 700px) { #startlist { flex-direction: column; gap: 0; } }
#startlist::-webkit-scrollbar { width: 6px; }
#startlist::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
#startlist .g { margin-bottom: 10px; }
#startlist .gh {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  opacity: .45; padding: 6px 8px 4px;
}
#startlist .si {
  display: block; width: 100%; text-align: left; appearance: none;
  background: transparent; color: inherit; font: inherit;
  border: 1px solid transparent; border-radius: 8px;
  padding: 5px 8px; cursor: pointer;
}
#startlist .si:hover { background: rgba(255,255,255,0.08); }
#startlist .si .eid {
  display: inline-block; min-width: 38px;
  font: 700 10.5px var(--font-mono); color: #7fd4ff; letter-spacing: .04em;
}
#startlist .si .t { font-size: 12px; }
/* The aim, printed only where there is no hover to show it as a tooltip. */
#startlist .si .aim { display: block; margin: 2px 0 0 38px; font-size: 11px; line-height: 1.35; opacity: .55; }
#startlist .none { padding: 10px 8px; font-size: 12px; opacity: .5; }

.startcard {
  display: block; width: 100%; text-align: left; appearance: none;
  color: inherit; font: inherit; cursor: pointer; padding: 15px 16px 14px;
  transition: border-color .12s, background .12s;
}
.startcard:hover { background: rgba(20, 30, 44, 0.72); border-color: rgba(77,195,255,0.45); }
.startcard .r { display: flex; align-items: center; gap: 9px; }
.startcard b { font-size: 13.5px; }
.startcard .go { margin-left: auto; opacity: .5; }
.startcard p { font-size: 12px; line-height: 1.5; opacity: .65; margin: 7px 0 0; }
.startcard.primary { border-color: rgba(77,195,255,0.35); }
@media (max-width: 620px) {   /* = --phone-max */
  #start { padding: 18px 12px 28px; }
  #starthead { margin-bottom: 16px; }
  #starthead h1 { font-size: 22px; }
  #starthead .mark svg { width: 24px; height: 24px; }
  #starthead p { font-size: 12px; }
  #startcols { gap: 14px; }
  #startlist { max-height: min(46vh, 400px); }
}
#startfoot { text-align: center; margin-top: 22px; font-size: 11.5px; opacity: .5; }
#startfoot a { color: inherit; text-decoration: none; }
#startfoot a:hover { color: #7fd4ff; text-decoration: underline; }


/* The foot of the exercise menu: course menu <-> whole register. */
.gmenu .smscope {
  display: block; width: 100%; margin-top: 6px; padding: 8px 9px; text-align: left;
  background: none; border: 0; border-top: 1px solid rgba(255,255,255,.08);
  color: inherit; font-size: 11.5px; opacity: .6; cursor: pointer;
}
.gmenu .smscope:hover { opacity: 1; }

/* Collapsible course sections (EXERCISE_MENU.collapsible). */
.gmenu .smg.fold { cursor: pointer; user-select: none; }
.gmenu .smg.fold:hover { opacity: 1; color: #fff; }
.gmenu .smg.fold i { opacity: .5; font-style: normal; }
