/* ==========================================================================
   The 3D labs (lab.html). Tokens from ../design/tokens.css and the shared
   pieces (buttons, options, overline, pills) from app.css. The stage is dark
   in both themes (--stage-*): a lit model reads against black, the way an
   X-ray does; the panel beside it follows the theme.
   ========================================================================== */

.lab-page { overflow: hidden; }

.lab {
  display: grid;
  grid-template-columns: var(--filter-rail) minmax(0, 1fr);
  height: 100vh; height: 100dvh;
}

/* ── Panel ───────────────────────────────────────────────────────────── */
.lab-panel {
  display: flex; flex-direction: column; gap: var(--sp-lg);
  padding: var(--sp-lg) var(--sp-xl) var(--sp-xl);
  background: var(--surface);
  border-right: var(--line) solid var(--border);
  overflow-y: auto; min-width: 0;
}
.lab-body { display: flex; flex-direction: column; gap: var(--sp-lg); min-width: 0; }
/* The panel scrolls, and says so: a thin bar that is always there, and a
   shade at whichever edge has more beyond it. (A student, 2026-11-15, of the
   Circuit Workbench: "part of the side bar is cut off" — on a screen 768
   pixels high the tray's last rows were below the fold with nothing to say
   the panel went on.) */
@media (min-width: 900px) {
  .lab-panel {
    scrollbar-width: thin; scrollbar-color: var(--border-depth) transparent; scrollbar-gutter: stable;
    background:
      linear-gradient(var(--surface) 30%, transparent) top / 100% 36px no-repeat local,
      linear-gradient(transparent, var(--surface) 70%) bottom / 100% 36px no-repeat local,
      linear-gradient(color-mix(in srgb, var(--text) 16%, transparent), transparent) top / 100% 12px no-repeat scroll,
      linear-gradient(transparent, color-mix(in srgb, var(--text) 16%, transparent)) bottom / 100% 12px no-repeat scroll,
      var(--surface);
  }
}
.lab-head { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: var(--sp-md); row-gap: var(--sp-2xs); }
.lab-back {
  grid-column: 1 / -1; justify-self: start; min-height: var(--tap-min); display: inline-flex; align-items: center;
  color: var(--teal-dark); font-weight: 800; text-decoration: none;
}
:root[data-theme="dark"] .lab-back { color: var(--teal); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lab-back { color: var(--teal); } }
.lab-back:hover { text-decoration: underline; }
.lab-headline { min-width: 0; }
.lab-title { font-size: 28px; line-height: 32px; text-wrap: balance; }
.lab-sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 20px; font-weight: 600; }
.lab-head-tools { display: flex; gap: var(--sp-xs); }
.lab-head-tools .theme-btn { font-family: var(--font-display); font-weight: 900; font-size: 18px; }

.lab-modes { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.lab-modes button {
  flex: 1 1 30%; min-height: 46px; padding: 0 var(--sp-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-xs);
  border: var(--line) solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font-family: var(--font-display); font-weight: 900; font-size: 15px; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-micro) var(--ease-standard), border-color var(--dur-micro) var(--ease-standard);
}
.lab-modes button:hover { border-color: var(--teal-bright); }
.lab-modes button[aria-selected="true"] { border-color: var(--teal-bright); background: var(--teal-soft); color: var(--teal-dark); }
:root[data-theme="dark"] .lab-modes button[aria-selected="true"] { color: var(--teal-bright); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lab-modes button[aria-selected="true"] { color: var(--teal-bright); } }
.lab-modes button:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full);
  display: inline-grid; place-items: center;
  background: var(--coral); color: var(--on-bright); font-size: 12px; line-height: 1; font-weight: 900;
}

/* Three tabs — Learn · Explore · Quiz — in one track; the kinds of quiz are a
   row of small pills that shows only inside Quiz. (Six tabs in two rows
   until 2026-11-15; a student: "make the left bar simpler".) */
.lab-modes.three { flex-wrap: nowrap; gap: var(--sp-xs); padding: var(--sp-xs); border-radius: var(--r-md); background: var(--surface-2); }
.lab-modes.three button { flex: 1 1 0; min-width: 0; min-height: 42px; border-color: transparent; background: transparent; }
.lab-modes.three button[aria-selected="true"] { background: var(--surface); border-color: var(--teal-bright); box-shadow: var(--shadow-sm); }
/* Four in one row (the Circuit Workbench): a little smaller, never wrapped. */
.lab-modes.four button { padding: 0 var(--sp-2xs); font-size: 14px; }
.lab-kinds { display: flex; flex-wrap: wrap; gap: var(--sp-xs); margin-top: calc(-1 * var(--sp-sm)); }
.lab-kinds[hidden] { display: none; }
.lab-kinds button {
  min-height: 36px; padding: 0 var(--sp-md); display: inline-flex; align-items: center; gap: var(--sp-xs);
  border: var(--line) solid var(--border); border-radius: var(--r-full); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
}
.lab-kinds button:hover { border-color: var(--teal-bright); }
.lab-kinds button[aria-selected="true"] { border-color: var(--teal-bright); background: var(--teal-soft); }
.lab-kinds button:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }

.lab-systems { display: grid; gap: var(--sp-2xs); }
.sys {
  width: 100%; min-height: var(--tap-min); padding: var(--sp-xs) var(--sp-sm);
  display: flex; align-items: center; gap: var(--sp-md);
  border: 0; border-radius: var(--r-sm); background: none; color: var(--text);
  font: inherit; font-size: 17px; font-weight: var(--label-w); text-align: left; cursor: pointer;
}
.sys:hover { background: var(--surface-2); }
.sys[aria-expanded="true"] { background: var(--teal-soft); font-weight: 800; }
.sys:focus-visible, .part:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 1px; }
.dot { width: 12px; height: 12px; border-radius: var(--r-full); flex: none; }
.sys small { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 700; }
.parts { list-style: none; margin: 0 0 var(--sp-sm) calc(var(--sp-sm) + 5px); padding: 0 0 0 var(--sp-lg); border-left: 2px solid var(--surface-2); display: grid; }
.part {
  width: 100%; min-height: 40px; padding: var(--sp-xs) var(--sp-sm);
  display: flex; align-items: center; gap: var(--sp-sm);
  border: 0; border-radius: var(--r-sm); background: none; color: var(--text);
  font: inherit; font-size: 15px; text-align: left; cursor: pointer;
}
.part:hover { background: var(--surface-2); }
.part[aria-current="true"] { background: var(--surface-2); font-weight: 800; }
.part .dot { width: 9px; height: 9px; }
.part-name { min-width: 0; }
/* A mark beside a part that real tests ask about often. */
.part-tier { margin-left: auto; width: 8px; height: 8px; border-radius: var(--r-full); flex: none; background: var(--teal); }
.part-tier.freq-very_common { background: var(--teal-dark); box-shadow: 0 0 0 3px var(--teal-soft); }
.part-tier.freq-sometimes { background: var(--border-depth); }

/* Under the tabs, above the list: on a phone the list is long, and what was
   just tapped on the model should be read without scrolling past it. */
.lab-info { display: grid; gap: var(--sp-xs); padding-bottom: var(--sp-lg); border-bottom: var(--line) solid var(--surface-2); }
.info-name { font-size: 22px; line-height: 28px; text-wrap: balance; }
.info-text { margin: 0; font-size: 15px; line-height: 22px; text-wrap: pretty; }
/* What a part says of itself: a photograph of the real thing where the lab
   has one, ONE sentence, the pictures real tests print of it, the questions
   it is the answer to — and the rest under "Read more". */
.info-photo { margin: 0 0 var(--sp-xs); display: grid; gap: var(--sp-xs); }
.info-photo[hidden] { display: none; }
.info-photo img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--r-md); background: var(--stage-bg); }
.info-photo figcaption { display: grid; gap: 1px; font-size: 13px; line-height: 18px; font-weight: 600; }
.info-photo small { color: var(--muted); font-size: 11px; line-height: 14px; font-weight: 400; }
.info-photo small a { color: inherit; }
.info-pics { display: grid; gap: var(--sp-xs); margin-top: var(--sp-sm); }
.info-pics[hidden], .info-acts[hidden], .info-more[hidden] { display: none; }
.info-pics-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-xs); }
.info-pic { display: block; aspect-ratio: 4 / 3; border-radius: var(--r-sm); overflow: hidden; background: #fff; border: var(--line) solid var(--border); }
.info-pic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.info-pic:hover, .info-pic:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 1px; }
.info-acts { display: grid; gap: var(--sp-xs); margin-top: var(--sp-sm); }
.info-act { min-height: 44px; padding: var(--sp-xs) var(--sp-md); display: grid; place-items: center; text-align: center; text-decoration: none; font-size: 15px; box-shadow: none; }
.info-more-btn {
  justify-self: start; min-height: 36px; margin-top: var(--sp-xs); padding: 0; display: inline-flex; align-items: center; gap: var(--sp-xs);
  border: 0; background: none; color: var(--teal-dark); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
}
.info-more-btn[hidden] { display: none; }
:root[data-theme="dark"] .info-more-btn { color: var(--teal); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .info-more-btn { color: var(--teal); } }
.info-more-btn i { font-style: normal; font-size: 12px; }
.info-more-btn[aria-expanded="true"] i { transform: rotate(180deg); }
.info-more-btn:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; border-radius: var(--r-sm); }
.info-more { display: grid; gap: var(--sp-xs); }
.lab-credit { margin: auto 0 0; padding-top: var(--sp-lg); color: var(--muted); font-size: 12px; line-height: 16px; }
.lab-credit a { color: inherit; }
.lab-scope button { font-size: 13px; min-height: 36px; }

/* ── On real tests ───────────────────────────────────────────────────── */
/* What links the model to the event: how often a part is asked about, how
   hard those questions are, and the questions themselves. */
.on-tests {
  display: grid; gap: var(--sp-sm); margin-top: var(--sp-sm); padding: var(--sp-md);
  border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
}
.on-tests-head {
  margin: 0; color: var(--muted);
  font-size: 11px; line-height: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.on-tests-line { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-sm); font-size: 13px; line-height: 18px; }
.on-tests-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-xs); }
.on-tests-list .also-q { text-decoration: none; }
.on-tests-wait { color: var(--muted); font-size: 13px; line-height: 18px; }
.on-tests-go { min-height: 44px; font-size: 15px; display: grid; place-items: center; text-decoration: none; box-shadow: none; }
.level-tag {
  padding: var(--sp-2xs) var(--sp-sm); border-radius: var(--r-full);
  font-size: 11px; line-height: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  border: var(--line) solid var(--border); background: var(--surface); color: var(--text);
}
.level-0 { border-color: var(--correct); color: var(--correct-ink); }
.level-1 { border-color: var(--amber-dark); color: var(--amber-ink); }
.level-2 { border-color: var(--error); color: var(--error-ink); }

/* ── A round ─────────────────────────────────────────────────────────── */
.lab-quiz { display: grid; gap: var(--sp-md); padding-bottom: var(--sp-lg); border-bottom: var(--line) solid var(--surface-2); }
.quiz-ask { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 24px; line-height: 30px; text-wrap: balance; }
.quiz-ask.real { font-family: var(--font-body); font-weight: var(--q-w); font-size: 18px; line-height: 26px; white-space: pre-wrap; text-wrap: pretty; }
.quiz-ask b { color: var(--teal-dark); }
:root[data-theme="dark"] .quiz-ask b { color: var(--teal-bright); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .quiz-ask b { color: var(--teal-bright); } }
.station {
  display: block; margin-bottom: var(--sp-2xs); color: var(--muted);
  font-family: var(--font-body); font-size: 12px; line-height: 16px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.quiz-source { margin: 0; color: var(--muted); font-size: 13px; line-height: 18px; font-weight: 700; }
.real-tag {
  display: inline-block; margin-right: var(--sp-xs); padding: var(--sp-2xs) var(--sp-sm); border-radius: var(--r-full);
  background: var(--teal-dark); color: var(--on-teal);
  font-size: 11px; line-height: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
:root[data-theme="dark"] .real-tag { background: var(--teal); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .real-tag { background: var(--teal); } }
.quiz-said { margin: 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-md); font-weight: 700; font-size: 15px; line-height: 22px; }
.quiz-said.ok { background: var(--correct-soft); color: var(--correct-ink); }
.quiz-said.bad { background: var(--error-soft); color: var(--error-ink); }
.quiz-done { display: grid; gap: var(--sp-md); justify-items: center; text-align: center; }
.quiz-score { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 36px; line-height: 42px; }
.quiz-xp { margin: calc(-1 * var(--sp-sm)) 0 0; font-family: var(--font-display); font-weight: 900; font-size: 18px; color: var(--amber-ink); }
.quiz-done .cta { width: 100%; }
.lab-quiz .opt { min-height: 50px; font-size: 15px; line-height: 21px; }

/* ── Stage ───────────────────────────────────────────────────────────── */
.lab-stage {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, var(--stage-glow) 0%, var(--stage-bg) 70%);
}
#stage { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
#stage:active { cursor: grabbing; }
#stage:focus-visible { box-shadow: inset 0 0 0 3px var(--stage-focus); }
.stage-labels, .stage-over { position: absolute; inset: 0; pointer-events: none; }
.stage-over > * { pointer-events: auto; }
.stage-hint {
  position: absolute; left: 50%; bottom: var(--sp-xl); transform: translateX(-50%);
  margin: 0; padding: var(--sp-sm) var(--sp-lg); max-width: calc(100% - 112px);
  color: var(--stage-text); font-size: 16px; line-height: 22px; font-weight: 600; text-align: center;
  background: var(--stage-veil); border-radius: var(--r-full);
  pointer-events: none;
}
.stage-hint:empty { display: none; }
.stage-label {
  position: absolute; left: 0; top: 0; margin: 0; padding: var(--sp-xs) var(--sp-md);
  transform: translate(-50%, calc(-100% - 14px));
  background: var(--stage-text); color: var(--stage-bg); border-radius: var(--r-full);
  font-size: 14px; line-height: 20px; font-weight: 800; white-space: nowrap;
  pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.stage-label.quiet { background: var(--stage-veil); color: var(--stage-text); font-weight: 700; font-size: 12px; line-height: 16px; padding: var(--sp-2xs) var(--sp-sm); box-shadow: none; transform: translate(-50%, calc(-100% - 8px)); }
/* A lettered callout, as on a labelled diagram. */
.stage-callout {
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  display: grid; place-items: center; border-radius: var(--r-full);
  background: var(--stage-text); color: var(--stage-bg);
  font-family: var(--font-display); font-weight: 900; font-size: 17px; line-height: 1;
  box-shadow: 0 0 0 3px rgba(13, 17, 23, .55), 0 6px 18px rgba(0, 0, 0, .5);
}
.stage-callout.asked { background: var(--amber); color: var(--on-bright); box-shadow: 0 0 0 3px rgba(13, 17, 23, .55), 0 0 0 7px rgba(255, 176, 32, .35); }
.stage-pin {
  position: absolute; left: 0; top: 0; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: var(--r-full); background: var(--stage-text); box-shadow: 0 0 0 2px var(--stage-veil);
}
.stage-lead {
  position: absolute; left: 0; top: 0; height: 2px; margin-top: -1px; transform-origin: 0 50%;
  border-radius: var(--r-full); background: var(--stage-text); box-shadow: 0 0 0 1px var(--stage-veil);
}
.stage-pin.asked, .stage-lead.asked { background: var(--amber); }
.stage-tools { position: absolute; right: var(--sp-md); bottom: var(--sp-xl); display: grid; gap: var(--sp-xs); }
.stage-tools button {
  width: var(--tap-min); height: var(--tap-min);
  border: 1px solid rgba(234, 240, 242, .22); border-radius: var(--r-full);
  background: var(--stage-veil); color: var(--stage-text);
  font-size: 20px; line-height: 1; font-weight: 700; cursor: pointer;
}
.stage-tools button:hover { background: rgba(46, 221, 211, .22); }
.stage-tools button:focus-visible { outline: 3px solid var(--stage-focus); outline-offset: 2px; }
.stage-hint.shake { animation: shake var(--dur-medium) var(--ease-standard); }
.stage-hint[hidden] { display: none; }
/* "Select": lit while a tap picks a part (Explore); from a lesson or a quiz
   it is the way back to that. */
.stage-tools .tool-select { display: grid; place-items: center; }
.stage-tools .tool-select svg { width: 20px; height: 20px; }
.stage-tools .tool-select[aria-pressed="true"] { background: var(--stage-focus); border-color: var(--stage-focus); color: var(--stage-bg); }
/* What is selected, said on the stage: the answer to a tap stands where the
   tap was. A photograph of the real thing where the lab has one. */
.stage-card {
  position: absolute; left: var(--sp-md); bottom: var(--sp-xl); z-index: 3;
  width: min(380px, calc(100% - 2 * var(--sp-md) - 60px));
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--sp-md); align-items: start;
  padding: var(--sp-sm); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--stage-bg) 90%, transparent); color: var(--stage-text);
  border: 1px solid color-mix(in srgb, var(--stage-text) 22%, transparent);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.stage-card[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .stage-card:not([hidden]) { animation: rise var(--dur-short) var(--ease-enter); } }
.stage-card-img { display: block; width: 104px; height: 104px; object-fit: cover; border-radius: var(--r-md); background: #fff; }
.stage-card-img.test { object-fit: contain; }
a.stage-card-pic { display: block; border-radius: var(--r-md); }
a.stage-card-pic:focus-visible { outline: 3px solid var(--stage-focus); outline-offset: 2px; }
.stage-card-words { min-width: 0; display: grid; gap: var(--sp-2xs); padding: var(--sp-2xs) 0; }
.stage-card-words b { font-family: var(--font-display); font-weight: 900; font-size: 17px; line-height: 22px; text-wrap: balance; }
.stage-card-words p { margin: 0; font-size: 13.5px; line-height: 19px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.stage-card-acts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-xs) var(--sp-sm); margin-top: var(--sp-2xs); }
.stage-card-acts small { color: color-mix(in srgb, var(--stage-text) 72%, transparent); font-size: 11px; line-height: 14px; }
.stage-card-more {
  min-height: 30px; padding: 0 var(--sp-md); border-radius: var(--r-full);
  border: 1px solid var(--stage-focus); background: transparent; color: var(--stage-focus);
  font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
}
.stage-card-more:hover { background: color-mix(in srgb, var(--stage-focus) 16%, transparent); }
.stage-card-x { width: 30px; height: 30px; border: 0; border-radius: var(--r-full); background: transparent; color: var(--stage-text); font-size: 20px; line-height: 1; cursor: pointer; }
.stage-card-x:hover { background: color-mix(in srgb, var(--stage-text) 14%, transparent); }
.stage-card-more:focus-visible, .stage-card-x:focus-visible { outline: 3px solid var(--stage-focus); outline-offset: 2px; }

/* ── The tutorial card ───────────────────────────────────────────────── */
.coach {
  position: absolute; left: 50%; top: var(--sp-xl); transform: translateX(-50%);
  width: min(380px, calc(100% - 2 * var(--sp-lg)));
  display: grid; gap: var(--sp-sm); padding: var(--sp-lg);
  background: var(--surface); color: var(--text);
  border: var(--line) solid var(--border); border-radius: var(--r-lg);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  z-index: 5;
}
@media (prefers-reduced-motion: no-preference) { .coach:not([hidden]) { animation: rise var(--dur-medium) var(--ease-enter); } }
.coach-step { margin: 0; color: var(--muted); font-size: 11px; line-height: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.coach-text { margin: 0; font-size: 16px; line-height: 23px; text-wrap: pretty; }
.coach-text b { font-weight: 800; color: var(--teal-dark); }
:root[data-theme="dark"] .coach-text b { color: var(--teal-bright); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .coach-text b { color: var(--teal-bright); } }
.coach-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-md); }
.coach-actions .cta { width: auto; min-height: 44px; padding: 0 var(--sp-2xl); font-size: 16px; }
.coach-actions .linkish { padding-left: 0; font-size: 14px; }
.coach-dots { display: flex; justify-content: center; gap: 6px; }
.coach-dots i { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--border); }
.coach-dots i.on { background: var(--teal-bright); width: 18px; }
/* A hand that shows the gesture a step is waiting for. */
.coach-hand {
  justify-self: center; width: 38px; height: 38px; border-radius: var(--r-full);
  border: 3px solid var(--teal-bright); background: color-mix(in srgb, var(--teal-bright) 18%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .coach-hand.drag { animation: coach-drag 1.6s var(--ease-standard) infinite; }
  .coach-hand.tap { animation: coach-tap 1.2s var(--ease-standard) infinite; }
}
@keyframes coach-drag { 0%, 100% { transform: translateX(-34px); } 50% { transform: translateX(34px); } }
@keyframes coach-tap { 0%, 100% { transform: scale(1); opacity: 1; } 45% { transform: scale(.72); opacity: .7; } }
/* What a step is pointing at. */
.coach-target { outline: 3px solid var(--amber); outline-offset: 4px; border-radius: var(--r-md); }
@media (prefers-reduced-motion: no-preference) { .coach-target { animation: coach-pulse 1.4s var(--ease-standard) infinite; } }
@keyframes coach-pulse { 0%, 100% { outline-color: var(--amber); } 50% { outline-color: color-mix(in srgb, var(--amber) 30%, transparent); } }

/* ── A phone: the model on top, the panel below it ───────────────────── */
@media (max-width: 899px) {
  .lab-page { overflow: auto; }
  .lab { display: flex; flex-direction: column-reverse; height: auto; min-height: 100dvh; }
  .lab-stage { position: sticky; top: 0; z-index: 1; height: 52vh; height: 52dvh; flex: none; }
  .lab-panel { border-right: 0; overflow: visible; padding: var(--sp-lg); }
  .lab-head { grid-template-columns: auto 1fr auto; }
  .lab-back { grid-column: auto; }
  .lab-title { font-size: 20px; line-height: 24px; }
  .lab-sub { font-size: 12px; line-height: 16px; }
  .stage-hint { bottom: var(--sp-md); font-size: 14px; }
  .stage-tools { bottom: var(--sp-md); right: var(--sp-sm); }
  .stage-tools button { width: 40px; height: 40px; }
  .stage-card { left: var(--sp-sm); bottom: var(--sp-sm); width: calc(100% - 2 * var(--sp-sm) - 48px); gap: var(--sp-sm); }
  .stage-card-img { width: 76px; height: 76px; }
  .stage-card-words p { -webkit-line-clamp: 3; }
  .coach { top: var(--sp-md); padding: var(--sp-md); }
  .coach-text { font-size: 15px; line-height: 21px; }
}

/* ── Controls a lab lays over its stage ──────────────────────────────── */
/* How fast time runs (the solar system), which tool is in hand (circuits). */
.stage-speed, .stage-bar {
  position: absolute; left: var(--sp-md); top: var(--sp-md); display: flex; flex-wrap: wrap; gap: var(--sp-xs);
  padding: var(--sp-xs); border-radius: var(--r-full); background: var(--stage-veil); border: 1px solid rgba(234, 240, 242, .16);
}
.stage-speed button, .stage-bar button {
  min-height: 36px; padding: 0 var(--sp-md); border: 0; border-radius: var(--r-full);
  background: none; color: var(--stage-text); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
}
.stage-speed button:hover, .stage-bar button:hover { background: rgba(234, 240, 242, .12); }
.stage-speed button[aria-pressed="true"], .stage-bar button[aria-pressed="true"] { background: var(--stage-focus); color: var(--stage-bg); }
.stage-speed button:focus-visible, .stage-bar button:focus-visible { outline: 3px solid var(--stage-focus); outline-offset: 1px; }

/* ── The Circuit Workbench ───────────────────────────────────────────── */
.cx-meter { display: grid; gap: var(--sp-sm); padding-bottom: var(--sp-lg); border-bottom: var(--line) solid var(--surface-2); }
.cx-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-md); font-size: 15px; line-height: 22px; }
.cx-row span { color: var(--muted); font-weight: 600; }
.cx-row b { font-family: var(--font-display); font-weight: 900; font-size: 19px; }
.cx-warn { margin: 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-md); background: var(--error-soft); color: var(--error-ink); font-size: 14px; line-height: 20px; }
.cx-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-sm); }
.cx-actions .cta { width: auto; flex: 1 1 140px; min-height: 44px; font-size: 15px; box-shadow: none; }
.cx-body { display: grid; gap: var(--sp-md); min-width: 0; }
.cx-body .row[aria-current="true"] { background: var(--teal-soft); }
.cx-about { display: grid; gap: var(--sp-xs); }
.cx-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-sm); }
.cx-tool {
  min-height: 48px; padding: 0 var(--sp-xs); border: var(--line) solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
}
.cx-tool:hover { border-color: var(--teal-bright); }
.cx-tool[aria-pressed="true"] { border-color: var(--teal-bright); background: var(--teal-soft); }
.cx-tool:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.stage-label.picked { background: var(--amber); color: var(--on-bright); }
.hole-mark { width: 26px; height: 26px; margin: -13px 0 0 -13px; font-size: 13px; }

/* ── The Crime Lab ───────────────────────────────────────────────────── */
.cr-tests { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-sm); }
.cr-tests li { display: grid; gap: var(--sp-2xs); }
.cr-test {
  min-height: 42px; padding: 0 var(--sp-md); text-align: left;
  border: var(--line) solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
}
.cr-test:hover:not(:disabled) { border-color: var(--teal-bright); }
.cr-test:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.cr-test:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.cr-says { font-size: 14px; line-height: 20px; font-weight: 600; padding-left: var(--sp-xs); }
.cr-says:empty { display: none; }
.cr-names .opt { min-height: 44px; padding: var(--sp-sm) var(--sp-md); font-size: 14px; }
.ans.two-up.cr-names { grid-template-columns: 1fr 1fr; }
.cr-chart { border-top: var(--line) solid var(--surface-2); padding-top: var(--sp-md); }
.cr-chart summary { cursor: pointer; font-weight: 800; font-size: 14px; color: var(--muted); min-height: 36px; }
.cr-table { overflow-x: auto; }
.cr-table table { border-collapse: collapse; font-size: 12px; line-height: 16px; width: 100%; }
.cr-table th, .cr-table td { padding: var(--sp-xs) var(--sp-sm); border-bottom: 1px solid var(--surface-2); text-align: left; white-space: nowrap; }
.cr-table th { font-weight: 800; }

/* ── Identification from photographs (id.html) ───────────────────────── */
.id-stage { display: grid; place-items: center; }
.id-figure { margin: 0; width: 100%; height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center; padding: var(--sp-lg); gap: var(--sp-sm); }
.id-photo { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; border-radius: var(--r-lg); box-shadow: 0 18px 50px rgba(0, 0, 0, .55); background: #000; }
.id-credit { color: rgba(234, 240, 242, .72); font-size: 12px; line-height: 16px; text-align: center; }
.id-credit a { color: inherit; }
.id-hint { margin: 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-md); background: var(--teal-soft); font-size: 14px; line-height: 20px; font-weight: 700; }
.quiz-ask.small { font-size: 19px; line-height: 25px; }
.id-facts { margin: 0; display: grid; gap: var(--sp-2xs); }
.id-facts div { display: flex; align-items: baseline; gap: var(--sp-md); padding: var(--sp-xs) 0; border-bottom: 1px solid var(--surface-2); }
.id-facts dt { flex: none; width: 108px; color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.id-facts dd { margin: 0; font-size: 15px; line-height: 20px; font-weight: var(--label-w); }
.id-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--sp-sm); }
.id-grid button { width: 100%; display: grid; gap: var(--sp-2xs); padding: var(--sp-xs); border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; font-size: 12px; line-height: 16px; font-weight: 700; cursor: pointer; text-align: center; }
.id-grid button:hover { border-color: var(--teal-bright); }
.id-grid button:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.id-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-2); }
.id-page .typed { grid-template-columns: 1fr; }
@media (max-width: 899px) { .id-figure { padding: var(--sp-sm); } }

/* The subjects a part belongs to, each a lesson (2026-11-14, third request). */
.subjects { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-xs); }
.subject {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-md);
  min-height: 52px; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-md);
  border: var(--line) solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
.subject:hover { border-color: var(--teal-bright); }
.subject:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.subject-words { display: grid; gap: var(--sp-2xs); min-width: 0; }
.subject-words b { font-size: 15px; line-height: 20px; font-weight: 800; }
.subject-words small { color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 600; }
.subject-go { flex: none; color: var(--teal-dark); font-size: 13px; font-weight: 800; white-space: nowrap; }
:root[data-theme="dark"] .subject-go { color: var(--teal-bright); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .subject-go { color: var(--teal-bright); } }

/* ── The Crime Lab: a plastic, once named (2026-11-14, fourth request) ── */
.plastic-card {
  display: grid; grid-template-columns: 64px 1fr; gap: var(--sp-md); align-items: start;
  padding: var(--sp-md); border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface);
}
.resin-mark { width: 64px; height: 72px; color: var(--teal-dark); }
.plastic-words { display: grid; gap: var(--sp-xs); font-size: 14px; line-height: 20px; }
.plastic-words > b { font-family: var(--font-display); font-weight: 900; font-size: 16px; line-height: 22px; }
.plastic-words small { color: var(--muted); font-size: 12px; line-height: 16px; }
.density-bar {
  position: relative; height: 26px; margin-top: var(--sp-xs);
  border-bottom: 2px solid var(--border);
}
.density-bar i { position: absolute; bottom: -2px; width: 2px; height: 12px; background: var(--muted); transform: translateX(-1px); }
.density-bar b {
  position: absolute; bottom: 4px; transform: translateX(-50%);
  padding: 0 var(--sp-xs); border-radius: var(--r-sm); background: var(--amber); color: var(--on-bright);
  font-size: 12px; line-height: 18px; font-weight: 800; white-space: nowrap;
}
.density-bar b::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 2px; height: 6px; background: var(--amber); transform: translateX(-1px); }

/* A real past question asked in a lab's own panel (Labs.realQuestion). */
.lab-real { display: grid; gap: var(--sp-sm); padding: var(--sp-md); border: var(--line) solid var(--teal); border-radius: var(--r-md); background: var(--teal-soft); }
.lab-real[hidden] { display: none; }
.lab-real .quiz-ask { font-size: 17px; line-height: 24px; }
.source-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.source-link:hover { color: var(--teal-dark); }
.real-more { justify-self: start; }

/* ── The Circuit Workbench's missions (2026-11-14, fourth request) ───── */
.mission-formula {
  margin: 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-sm);
  background: var(--surface-2); font-family: var(--font-mono); font-size: 15px; line-height: 22px; font-weight: 700; text-align: center;
}
.mission-task {
  display: grid; gap: var(--sp-2xs); padding: var(--sp-md);
  border: var(--line) solid var(--amber); border-left-width: 4px; border-radius: var(--r-md); background: var(--surface);
  font-size: 15px; line-height: 22px; text-wrap: pretty;
}
.mission-task b { font-family: var(--font-display); font-weight: 900; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--amber-ink); }
.mission-task.done { border-color: var(--correct); }
.mission-task.done b { color: var(--correct-ink); }
.mission-path { list-style: none; margin: var(--sp-sm) 0 0; padding: 0; display: grid; gap: var(--sp-2xs); }
.mission-path button {
  width: 100%; min-height: 40px; display: flex; align-items: center; gap: var(--sp-md);
  padding: var(--sp-xs) var(--sp-sm); border: 0; border-radius: var(--r-sm); background: none; color: var(--text);
  font: inherit; font-size: 14px; line-height: 20px; font-weight: var(--label-w); text-align: left; cursor: pointer;
}
.mission-path button:hover { background: var(--surface-2); }
.mission-path button[aria-current] { background: var(--teal-soft); font-weight: 800; }
.mission-dot {
  flex: none; width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center;
  border: var(--line) solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.mission-dot.done { background: var(--correct); border-color: var(--correct); color: var(--on-correct); }

/* ══ 2026-11-15: the Circuit Workbench as a tutorial ═══════════════════ */
/* A lesson is built on the board a step at a time. The step — what to do
   now — and what the board shows stand together at the top of the panel:
   the instruction, then the conditions and the results in one box. */
.cx-lesson-head { display: grid; gap: var(--sp-xs); }
.cx-lesson-head .mission-formula { margin: 0; }
.cx-progress { display: flex; gap: 4px; margin-top: var(--sp-xs); }
.cx-progress i { flex: 1; height: 5px; border-radius: var(--r-full); background: var(--surface-2); }
.cx-progress i.done { background: var(--teal); }
.cx-progress i.now { background: var(--amber); }
.cx-step {
  display: grid; gap: var(--sp-sm); padding: var(--sp-md);
  border: 2px solid var(--amber); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
}
.cx-step .overline { color: var(--amber-ink); margin: 0; }
.cx-step.done { border-color: var(--correct); background: var(--correct-soft); }
.cx-step.done .overline { color: var(--correct-ink); }
.cx-say { margin: 0; font-size: 16px; line-height: 23px; font-weight: 600; text-wrap: pretty; }
.cx-step .cta { min-height: 46px; font-size: 16px; }
.cx-stepper { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: var(--sp-sm); }
.cx-stepper button {
  min-height: 48px; border: var(--line) solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: 24px; font-weight: 800; cursor: pointer;
}
.cx-stepper button:hover { border-color: var(--teal); }
.cx-stepper button:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.cx-stepper b { text-align: center; font-family: var(--font-display); font-weight: 900; font-size: 18px; }
.cx-readout { display: grid; gap: var(--sp-xs); padding: var(--sp-md); border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.cx-readout:empty { display: none; }
.cx-readout .overline { margin: 0 0 var(--sp-2xs); color: var(--muted); }
.cx-readout .cx-row { font-size: 14px; line-height: 20px; }
.cx-readout .cx-row b { font-size: 17px; }
.cx-law {
  margin: var(--sp-xs) 0 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-sm);
  background: var(--teal-soft); color: var(--text);
  font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 21px; text-wrap: balance;
}
.cx-log { width: 100%; margin-top: var(--sp-sm); border-collapse: collapse; font-size: 13px; line-height: 18px; }
.cx-log caption { text-align: left; padding-bottom: var(--sp-2xs); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.cx-log th, .cx-log td { padding: 3px 6px; border-bottom: var(--line) solid var(--border); text-align: right; }
.cx-log th { color: var(--muted); font-size: 11px; font-weight: 700; }
.cx-log th:first-child, .cx-log td:first-child { text-align: left; }
.cx-log tr.now td { background: color-mix(in srgb, var(--amber) 14%, transparent); font-weight: 700; }
.cx-curve { width: 100%; height: auto; margin-top: var(--sp-xs); }
.cx-curve .axis { stroke: var(--muted); stroke-width: 1; }
.cx-curve .mark { stroke: var(--border-depth); stroke-width: 1; stroke-dasharray: 3 3; }
.cx-curve .rise { fill: none; stroke: var(--correct); stroke-width: 2.4; stroke-linejoin: round; }
.cx-curve text { fill: var(--muted); font-size: 9px; font-weight: 600; }
.cx-lessons > summary { cursor: pointer; padding: var(--sp-sm) 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.cx-lessons .mission-path { margin-top: 0; }
/* While a lesson is on, the meter comes only with a selected part. */
.cx-learning .cx-meter { padding: var(--sp-md); border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.guide-tag { width: auto; height: auto; margin: 0; padding: 3px 10px; border-radius: var(--r-full); font-size: 12px; transform: translate(-50%, calc(-100% - 10px)); }
@media (prefers-reduced-motion: no-preference) { .guide-tag:not([hidden]) { animation: guide-bob 1.2s var(--ease-standard) infinite alternate; } }
@keyframes guide-bob { from { margin-top: 0; } to { margin-top: -6px; } }

/* A part, selected: what it is, how it works, the law it follows. */
.cx-does { margin: 0; font-size: 15px; line-height: 22px; text-wrap: pretty; }
.cx-lawbox { display: grid; gap: var(--sp-2xs); padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-md); border: var(--line) solid var(--teal); background: var(--teal-soft); }
.cx-lawbox .overline { margin: 0; color: var(--teal-dark); }
:root[data-theme="dark"] .cx-lawbox .overline { color: var(--teal); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cx-lawbox .overline { color: var(--teal); } }
.cx-formula { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 19px; line-height: 24px; }
.cx-lawbox .cx-law { margin: 0; padding: 0; background: none; font-size: 14px; font-weight: 600; }
.cx-actions .cta.danger { color: var(--error-ink); border-color: color-mix(in srgb, var(--error) 50%, var(--border)); }
/* Build: what a tap does — read a part, or take one out. */
.cx-hands { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-sm); }
/* Build's first build, walked through: what to do next, at the top of Build. */
.cx-first { display: grid; gap: var(--sp-sm); padding: var(--sp-md); border: var(--line) solid var(--amber); border-radius: var(--r-md); background: color-mix(in srgb, var(--amber) 9%, var(--surface)); }
.cx-first.done { border-color: var(--correct); background: var(--correct-soft); }
.cx-first .info-name { font-size: 20px; line-height: 25px; }
.cx-first-say { margin: 0; font-size: 15px; line-height: 22px; text-wrap: pretty; }
.cx-first-say b { font-weight: 800; }
.cx-first-next { margin: 0; padding-left: var(--sp-xl); display: grid; gap: var(--sp-2xs); font-size: 14px; line-height: 20px; }
.cx-first .linkish { justify-self: start; padding-left: 0; font-size: 13px; }
.cx-foot-acts { display: flex; flex-wrap: wrap; gap: var(--sp-xs) var(--sp-lg); }
.cx-hands .cx-tool[aria-pressed="true"]#cx-erase { border-color: var(--error); background: var(--error-soft); color: var(--error-ink); }

/* What a question is given: the circuit as a test draws it, and its values. */
.cx-given { display: grid; gap: var(--sp-xs); padding: var(--sp-md); border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.cx-given .overline { margin: 0; color: var(--muted); }
.cx-schematic { width: 100%; height: auto; max-height: 190px; color: var(--text); }
.cx-schematic .wire, .cx-schematic .sym > * { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cx-schematic .sym .thin { stroke-width: 1.2; }
.cx-schematic .dot { fill: currentColor; stroke: none; }
.cx-schematic .sym .dot { fill: var(--surface); stroke: currentColor; }
.cx-schematic .sym.on > * { stroke: var(--amber-dark); }
.cx-schematic text { fill: currentColor; font-size: 10px; font-weight: 700; }
.cx-given-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.cx-given-list li { display: inline-flex; align-items: baseline; gap: 6px; padding: 2px 10px; border-radius: var(--r-full); border: var(--line) solid var(--border); background: var(--surface-2); font-size: 13px; line-height: 18px; }
.cx-given-list span { color: var(--muted); font-weight: 700; }
.cx-given-list small { font-weight: 500; }
.cx-given-list b { font-weight: 800; }
.cx-about .cx-schematic { max-height: 160px; }


/* ── Learn: a lab's lesson, part by part (parts.js, 2026-11-15) ────────── */
.lab-tour { display: grid; gap: var(--sp-sm); }
.tour-bar { height: 6px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.tour-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--teal-bright); transition: width var(--dur-medium) var(--ease-standard); }
.tour-acts { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-sm); margin-top: var(--sp-xs); }
.tour-acts .cta { min-height: 48px; width: auto; padding: 0 var(--sp-lg); font-size: 16px; }
.tour-acts .cta[hidden] + .cta { grid-column: 1 / -1; }
.lab-tour .linkish { justify-self: start; padding-left: 0; }
.sys-done { margin-left: 6px; color: var(--teal-bright); font-weight: 900; }

/* The Crime Lab's Learn: every powder with its name on. */
.cr-learn { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-xs); }
.cr-known {
  width: 100%; display: grid; gap: 2px; text-align: left; padding: var(--sp-sm) var(--sp-md); cursor: pointer; font: inherit; color: var(--text);
  border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface);
}
.cr-known:hover { border-color: var(--teal-bright); }
.cr-known:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.cr-known b { font-family: var(--font-display); font-weight: 900; font-size: 16px; line-height: 22px; }
.cr-known b i { font-style: normal; color: var(--teal-bright); }
.cr-known span { font-size: 13px; line-height: 18px; color: var(--muted); text-wrap: pretty; }
.cr-known.done { background: var(--surface-2); }
