/* tutor-stage.css — "The stage that breathes" (Task #221)
 * A cinematic lecture layout. The live 3D legend keeps the stage; a crisp 2D
 * board docks on one side and "breathes": tutor-forward while the legend
 * explains (board narrow + softened), board-forward while showing something
 * (board wide + bright). The backdrop stays click-through so the legend is
 * still orbitable. Themed off the Tuscan-dusk tokens (light default; dark via
 * body[data-mode="dark"]).
 */

#tutor-stage {
  position: fixed;
  inset: 0;
  z-index: 1450;
  display: none;
  pointer-events: none; /* backdrop is click-through; children opt back in */
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  --ts-paper: #fbf4e9;
  --ts-ink: #2a1c0e;
  --ts-accent: #b5651d;
  --ts-accent-soft: #a9712e;
  --ts-line: rgba(120, 84, 44, 0.16);
}
#tutor-stage.is-open { display: block; }

/* ---------- top bar ---------- */
#tutor-stage .ts-topbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 120px));
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: rgba(34, 21, 10, 0.55);
  border-radius: 16px;
  color: #fff;
  pointer-events: auto;
}
#tutor-stage .ts-head { flex: 1; min-width: 0; }
#tutor-stage .ts-subtitle {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e0a96d;
}
#tutor-stage .ts-title {
  margin: 1px 0 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#tutor-stage .ts-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#tutor-stage .ts-dots { display: flex; gap: 6px; align-items: center; }
/* Clickable step dots (Task #251): reset native <button> chrome to a dot. */
#tutor-stage .ts-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
#tutor-stage .ts-dot:hover { background: rgba(255, 255, 255, 0.5); }
#tutor-stage .ts-dot:focus-visible {
  outline: 2px solid #f0c089; outline-offset: 2px;
}
#tutor-stage .ts-dot.done { background: rgba(224, 169, 109, 0.7); }
#tutor-stage .ts-dot.on { background: #f0c089; transform: scale(1.4); }
#tutor-stage .ts-count {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
}
#tutor-stage .ts-exit {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
#tutor-stage .ts-exit:hover { background: rgba(255, 255, 255, 0.26); }

/* ---------- the board (right dock, breathing) ---------- */
#tutor-stage .ts-stage-board {
  position: absolute;
  top: 78px;
  bottom: 118px;
  right: 26px;
  width: min(420px, 38vw);
  pointer-events: auto;
  transition: width .55s cubic-bezier(.22,.61,.36,1),
              right .55s cubic-bezier(.22,.61,.36,1),
              opacity .45s ease;
  opacity: 0.92;
}
/* board-forward: wider + fully bright + nudged toward center */
#tutor-stage[data-focus="board"] .ts-stage-board {
  width: min(560px, 52vw);
  right: 40px;
  opacity: 1;
}
/* tutor-forward: narrower + softened so the legend dominates */
#tutor-stage[data-focus="tutor"] .ts-stage-board {
  width: min(400px, 36vw);
  opacity: 0.82;
}
/* Single-focus board (Task #251): the board is a STAGE; cards are stacked and
   only the current one is shown, so there is never a scrolling wall of cards. */
#tutor-stage .ts-board {
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* ---------- a board card ---------- */
#tutor-stage .ts-card {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* when a card is taller than the stage, fall back to top-align so the
     scrollable overflow never gets clipped above the centered content */
  justify-content: safe center;
  background: var(--ts-paper);
  color: var(--ts-ink);
  border: 1px solid var(--ts-line);
  border-radius: 16px;
  box-shadow: 0 16px 44px rgba(40, 22, 6, 0.3);
  padding: 24px 22px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(.99);
  transition: opacity .42s ease,
              transform .42s cubic-bezier(.22,.61,.36,1),
              visibility 0s linear .42s;
  pointer-events: none;
}
/* the one idea on stage right now */
#tutor-stage .ts-card.is-current {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition: opacity .42s ease,
              transform .42s cubic-bezier(.22,.61,.36,1),
              visibility 0s;
}
/* already-seen cards drift up and out; upcoming cards wait just below */
#tutor-stage .ts-card.is-past { transform: translateY(-10px) scale(.99); }
#tutor-stage .ts-card.is-future { transform: translateY(10px) scale(.99); }
#tutor-stage .ts-card::-webkit-scrollbar { width: 8px; }
#tutor-stage .ts-card::-webkit-scrollbar-thumb {
  background: rgba(120, 84, 44, 0.28); border-radius: 8px;
}

#tutor-stage .ts-card-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 600;
  margin: 0 0 12px;
}
#tutor-stage .ts-kicker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ts-accent-soft);
  margin-bottom: 6px;
}

/* heading card */
#tutor-stage .ts-card-heading { padding: 26px 22px; }
#tutor-stage .ts-heading .ts-card-title { font-size: 26px; margin: 0; }

/* lists (points / example / summary) — staged reveal */
#tutor-stage .ts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#tutor-stage .ts-line {
  position: relative;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(6px);
  animation: tsLineIn .45s ease forwards;
  animation-delay: calc(var(--d) * 0.32s + 0.2s);
}
#tutor-stage .ts-line::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ts-accent);
}
#tutor-stage .ts-list-summary .ts-line::before {
  border-radius: 2px;
  background: var(--ts-accent-soft);
}
@keyframes tsLineIn { to { opacity: 1; transform: translateY(0); } }

/* equation card */
#tutor-stage .ts-equation {
  font-family: "Fraunces", Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  text-align: center;
  color: #7a3f0f;
  padding: 16px 8px;
  background: rgba(181, 101, 29, 0.08);
  border-radius: 12px;
  letter-spacing: 0.01em;
  overflow-x: auto; /* KaTeX (Task #251): wide math scrolls, never overflows */
}
/* KaTeX inherits the card ink unless told otherwise; keep it on-brand. */
#tutor-stage .ts-equation .katex { color: #7a3f0f; font-size: 1.05em; }
#tutor-stage .ts-equation .katex-display { margin: 0; }
#tutor-stage .ts-eq-cap {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: #5a3d1c;
}

/* definition card */
#tutor-stage .ts-def-term {
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ts-accent);
}
#tutor-stage .ts-def-meaning {
  margin: 8px 0 0;
  font-size: 15.5px;
  line-height: 1.55;
}

/* diagram card */
#tutor-stage .ts-diagram {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
#tutor-stage .ts-step {
  background: #fff;
  border: 1.5px solid rgba(120, 84, 44, 0.3);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transform: scale(.9);
  animation: tsStepIn .4s ease forwards;
  animation-delay: calc(var(--d) * 0.3s + 0.2s);
}
#tutor-stage .ts-arrow { color: var(--ts-accent-soft); font-weight: 700; }
@keyframes tsStepIn { to { opacity: 1; transform: scale(1); } }

/* problem drop-in card — interactive widgets can be tall, so top-align
   (never center) to keep a stable layout as feedback/messages appear */
#tutor-stage .ts-card-problem {
  border-color: rgba(120, 84, 44, 0.16);
  justify-content: flex-start;
}
/* persistent feedback frame (kept until Continue, matching Brilliant) */
#tutor-stage .ts-card-problem.is-correct {
  border-color: #3fae6e;
  box-shadow: 0 0 0 2px rgba(63, 174, 110, 0.28), 0 16px 44px rgba(40, 22, 6, 0.16);
}
#tutor-stage .ts-card-problem.is-wrong {
  border-color: #d9a23b;
  box-shadow: 0 0 0 2px rgba(217, 162, 59, 0.28), 0 16px 44px rgba(40, 22, 6, 0.16);
}
#tutor-stage .ts-card-problem.is-strict {
  border-color: #d6584f;
  box-shadow: 0 0 0 2px rgba(214, 88, 79, 0.28), 0 16px 44px rgba(40, 22, 6, 0.16);
}

/* ---------- minimal (Brilliant tap-to-shade) chrome ---------- */
#tutor-stage .ts-card-minimal { align-items: center; }
#tutor-stage .ts-prob-prompt-center {
  text-align: center;
  font-family: "Fraunces", Georgia, serif;
  font-size: 21px; font-weight: 600; line-height: 1.35;
  margin: 4px 0 18px; max-width: 26ch;
}
#tutor-stage .ts-card-minimal .ts-prob-widget {
  display: flex; justify-content: center; width: 100%; margin-bottom: 10px;
}
#tutor-stage .ts-prob-reset-row { width: 100%; text-align: center; margin: 2px 0 14px; }
#tutor-stage .ts-prob-reset {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: #6f5a3c; padding: 4px 6px; opacity: .8;
}
#tutor-stage .ts-prob-reset:hover { opacity: 1; text-decoration: underline; }
#tutor-stage .ts-prob-foot-center { justify-content: center; }
#tutor-stage .ts-prob-foot-center .ts-prob-check { flex: 0 0 auto; min-width: 220px; }
#tutor-stage .ts-prob-head h3 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  margin: 4px 0 0;
}
#tutor-stage .ts-prob-prompt {
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  margin: 12px 0 14px;
}
#tutor-stage .ts-prob-widget { margin-bottom: 14px; }
#tutor-stage .ts-prob-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
#tutor-stage .ts-prob-skip-note { font-size: 14px; color: #5a3d1c; margin: 6px 0 14px; }
#tutor-stage .ts-flash-right { animation: tsRight .6s ease; }
#tutor-stage .ts-flash-wrong { animation: tsWrong .5s ease; }
@keyframes tsRight {
  40% { box-shadow: 0 0 0 3px #3fae6e, 0 16px 44px rgba(40,22,6,.3); }
}
@keyframes tsWrong {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

/* ---------- problem/game slot placeholder (never flashes empty) ---------- */
#tutor-stage .ts-slot-ph {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; height: 100%;
  color: #5a3d1c; font-size: 14px; font-weight: 600;
}
#tutor-stage .ts-slot-ph .ts-spin { width: 22px; height: 22px; }

/* ============================================================
   Fraction visuals + interactive widgets (Task #251)
   Shared classes live in FractionWidgets.js.
   ============================================================ */

/* ---------- static teaching visual (board.kind === "visual") ---------- */
#tutor-stage .ts-visual {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 6px 0 2px;
}
#tutor-stage .ts-frac-svg {
  width: 100%; max-width: 260px; height: auto; display: block;
}
#tutor-stage .ts-frac-bar { max-width: 300px; }
#tutor-stage .ts-frac-nl { max-width: 320px; }
#tutor-stage .ts-visual-cap {
  font-family: "Fraunces", Georgia, serif;
  font-size: 20px; font-weight: 600;
  color: var(--ts-accent); text-align: center;
}

/* Brilliant tap-to-shade palette: white fill, crisp dark outline, blue when on */
#tutor-stage { --ts-shade-blue: #6d8cf0; --ts-shade-stroke: #1f2530; }

/* pie / bar segments + area regions (static + interactive share this look) */
#tutor-stage .ts-seg,
#tutor-stage .ts-region {
  fill: #ffffff;
  stroke: var(--ts-shade-stroke); stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  transition: fill .15s ease;
}
#tutor-stage .ts-seg.on,
#tutor-stage .ts-region.on { fill: var(--ts-shade-blue); }
#tutor-stage .ts-seg.ts-tappable,
#tutor-stage .ts-region.ts-tappable { cursor: pointer; }
#tutor-stage .ts-seg.ts-tappable:hover,
#tutor-stage .ts-region.ts-tappable:hover { fill: #e7edfd; }
#tutor-stage .ts-seg.ts-tappable.on:hover,
#tutor-stage .ts-region.ts-tappable.on:hover { fill: #5b7ce8; }
#tutor-stage .ts-frac-region { max-width: 232px; }

/* number line (static + draggable) */
#tutor-stage .ts-nl-axis {
  stroke: var(--ts-ink); stroke-width: 2; stroke-linecap: round;
}
#tutor-stage .ts-nl-tick { stroke: rgba(120, 84, 44, 0.55); stroke-width: 1.5; }
#tutor-stage .ts-nl-tick.major { stroke: var(--ts-ink); stroke-width: 2; }
#tutor-stage .ts-nl-mark { stroke: var(--ts-accent); stroke-width: 2.5; }
#tutor-stage .ts-nl-dot { fill: var(--ts-accent); }
#tutor-stage .ts-nl-handle { cursor: grab; stroke: #fff; stroke-width: 2; }
#tutor-stage .ts-nl-label,
#tutor-stage .ts-nl-handle-label {
  fill: var(--ts-ink);
  font: 600 12px "Manrope", sans-serif; text-anchor: middle;
}
#tutor-stage .ts-nl-handle-label { fill: var(--ts-accent); font-weight: 700; }

/* ---------- interactive practice widgets ---------- */
#tutor-stage .ts-fw-stage {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 4px 0;
}
#tutor-stage .ts-fw-count {
  font-size: 13px; font-weight: 600; color: #5a3d1c;
  font-variant-numeric: tabular-nums;
}

/* build widget — two steppers around a fraction slash */
#tutor-stage .ts-fw-ref { margin-bottom: 4px; }
#tutor-stage .ts-fw-build { gap: 16px; }
#tutor-stage .ts-fw-preview { width: 100%; max-width: 280px; }
#tutor-stage .ts-fw-frac { display: flex; align-items: center; gap: 18px; }
#tutor-stage .ts-fw-fracbar {
  width: 3px; height: 54px; border-radius: 3px;
  background: var(--ts-accent); transform: rotate(18deg);
}
#tutor-stage .ts-fw-stepper {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#tutor-stage .ts-fw-pm {
  width: 34px; height: 34px; border-radius: 10px; border: none; cursor: pointer;
  background: rgba(120, 84, 44, 0.12); color: var(--ts-accent);
  font-size: 20px; font-weight: 700; line-height: 1;
}
#tutor-stage .ts-fw-pm:hover { background: rgba(120, 84, 44, 0.2); }
#tutor-stage .ts-fw-val {
  font-family: "Fraunces", Georgia, serif;
  font-size: 24px; font-weight: 600;
  min-width: 28px; text-align: center; color: var(--ts-ink);
}

/* compare widget — two tappable bars */
#tutor-stage .ts-fw-compare {
  flex-direction: row; gap: 14px;
  align-items: stretch; justify-content: center;
}
#tutor-stage .ts-fw-opt {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: #fff; border: 2px solid rgba(120, 84, 44, 0.22);
  border-radius: 14px; padding: 14px 14px 10px;
  cursor: pointer; flex: 1; max-width: 200px;
  transition: border-color .15s ease, transform .08s ease, box-shadow .15s ease;
}
#tutor-stage .ts-fw-opt:hover { border-color: var(--ts-accent); }
#tutor-stage .ts-fw-opt:active { transform: translateY(1px); }
#tutor-stage .ts-fw-opt.chosen {
  border-color: var(--ts-accent); box-shadow: 0 0 0 3px rgba(181, 101, 29, 0.18);
}
#tutor-stage .ts-fw-opt.is-answer {
  border-color: #3fae6e; box-shadow: 0 0 0 3px rgba(63, 174, 110, 0.22);
}
#tutor-stage .ts-fw-opt-label {
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px; font-weight: 600; color: var(--ts-ink);
}

/* widget feedback line */
#tutor-stage .ts-fw-msg {
  font-size: 14px; font-weight: 600; margin-top: 8px; text-align: center;
}

/* ---------- buttons (shared) ---------- */
#tutor-stage .ts-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 11px;
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
}
#tutor-stage .ts-btn:active { transform: translateY(1px); }
#tutor-stage .ts-btn[disabled] { opacity: .45; cursor: default; }
#tutor-stage .ts-btn-primary { background: var(--ts-accent); color: #fff; flex: 1; }
#tutor-stage .ts-btn-primary:hover:not([disabled]) { background: #9d5616; }
#tutor-stage .ts-btn-ghost { background: rgba(120, 84, 44, 0.1); color: #5a3d1c; }
#tutor-stage .ts-btn-ghost:hover { background: rgba(120, 84, 44, 0.18); }

/* ---------- caption (what the legend says) ---------- */
#tutor-stage .ts-caption {
  position: absolute;
  left: 32px;
  bottom: 116px;
  max-width: min(520px, 44vw);
  pointer-events: none;
  background: rgba(34, 21, 10, 0.82);
  color: #faf3e7;
  padding: 13px 20px;
  border-radius: 16px;
  font-size: 15.5px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s ease, transform .3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
#tutor-stage .ts-caption.show { opacity: 1; transform: translateY(0); }
#tutor-stage .ts-caption-who {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e0a96d;
  margin-bottom: 3px;
}
/* a soft speaking pulse on the caption while audio plays */
#tutor-stage.is-speaking .ts-caption {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(224, 169, 109, 0.35);
}

/* resume affordance after an interruption */
#tutor-stage .ts-resume {
  position: absolute;
  left: 32px;
  bottom: 178px;
  display: none;
  pointer-events: auto;
  background: var(--ts-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 11px;
  box-shadow: 0 10px 26px rgba(40, 22, 6, 0.3);
}
#tutor-stage .ts-resume.show { display: inline-block; }

/* gentle checkpoint chips */
#tutor-stage .ts-checkpoint {
  position: absolute;
  left: 32px;
  bottom: 178px;
  display: none;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  background: rgba(251, 244, 233, 0.96);
  border: 1px solid var(--ts-line);
  padding: 9px 12px;
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(40, 22, 6, 0.22);
}
#tutor-stage .ts-checkpoint.show { display: flex; }
#tutor-stage .ts-cp-q { font-size: 14px; font-weight: 600; color: var(--ts-ink); }
#tutor-stage .ts-cp-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--ts-accent);
  color: #fff;
}
#tutor-stage .ts-cp-btn.ts-cp-again { background: rgba(120, 84, 44, 0.14); color: #5a3d1c; }

/* end-of-lesson note */
#tutor-stage .ts-endnote {
  display: none;
  margin: 4px 4px 0;
  padding: 14px 16px;
  background: rgba(34, 21, 10, 0.06);
  border: 1px dashed var(--ts-line);
  border-radius: 14px;
  font-size: 14px;
  color: #5a3d1c;
  text-align: center;
}
#tutor-stage .ts-endnote.show { display: block; }

/* ---------- transport bar ---------- */
#tutor-stage .ts-transport {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(34, 21, 10, 0.6);
  border-radius: 999px;
  pointer-events: auto;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}
#tutor-stage .ts-tbtn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
#tutor-stage .ts-tbtn:hover { background: rgba(255, 255, 255, 0.24); }
#tutor-stage .ts-tbtn svg {
  width: 18px; height: 18px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#tutor-stage .ts-play {
  width: 48px; height: 48px;
  background: var(--ts-accent);
}
#tutor-stage .ts-play:hover { background: #9d5616; }
#tutor-stage .ts-play svg { fill: #fff; stroke: none; }
#tutor-stage .ts-replay svg, #tutor-stage .ts-prev svg, #tutor-stage .ts-next svg {
  fill: none;
}
#tutor-stage .ts-prev svg, #tutor-stage .ts-next svg { fill: currentColor; stroke: none; }

#tutor-stage .ts-ask {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
#tutor-stage .ts-ask-input {
  width: 190px;
  max-width: 30vw;
  border: none;
  outline: none;
  background: rgba(255, 255, 255, 0.92);
  color: #2a1c0e;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 999px;
}
#tutor-stage .ts-ask-send {
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 14px;
  border-radius: 999px;
}
#tutor-stage .ts-ask-send:hover { background: rgba(255, 255, 255, 0.3); }

/* Assist controls (Why / Here's the answer / Skip explanation) — shown only
   while a problem or mini-game beat is live. Sits just above the transport. */
#tutor-stage .ts-assist {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(34, 21, 10, 0.55);
  border-radius: 999px;
  pointer-events: auto;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  z-index: 2;
}
#tutor-stage .ts-assist[hidden] { display: none; }
#tutor-stage .ts-assist-btn {
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
#tutor-stage .ts-assist-btn:hover { background: rgba(255, 255, 255, 0.28); }
#tutor-stage .ts-assist .ts-reveal { background: var(--ts-accent); }
#tutor-stage .ts-assist .ts-reveal:hover { background: #9d5616; }
@media (max-width: 720px) {
  #tutor-stage .ts-assist { bottom: 92px; flex-wrap: wrap; justify-content: center; max-width: 92vw; }
  #tutor-stage .ts-assist-btn { font-size: 12px; padding: 7px 11px; }
}

/* ---------- loading ---------- */
#tutor-stage .ts-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: #5a3d1c;
  padding: 8px 2px;
}
#tutor-stage .ts-spin {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(181, 101, 29, 0.25);
  border-top-color: var(--ts-accent);
  border-radius: 50%;
  animation: tsSpin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes tsSpin { to { transform: rotate(360deg); } }

/* ---------- dark theme (Tuscan dusk, night) ---------- */
body[data-mode="dark"] #tutor-stage {
  --ts-paper: #241a10;
  --ts-ink: #f3e7d3;
  --ts-line: rgba(224, 169, 109, 0.18);
}
body[data-mode="dark"] #tutor-stage .ts-card-title { color: #f3e7d3; }
body[data-mode="dark"] #tutor-stage .ts-equation {
  color: #f0c089;
  background: rgba(224, 169, 109, 0.1);
}
body[data-mode="dark"] #tutor-stage .ts-eq-cap,
body[data-mode="dark"] #tutor-stage .ts-def-meaning { color: #d8c4a6; }
body[data-mode="dark"] #tutor-stage .ts-step {
  background: #2e2216;
  border-color: rgba(224, 169, 109, 0.3);
  color: #f3e7d3;
}
body[data-mode="dark"] #tutor-stage .ts-btn-ghost { color: #e6cfa9; }
body[data-mode="dark"] #tutor-stage .ts-checkpoint {
  background: rgba(36, 26, 16, 0.96);
}
body[data-mode="dark"] #tutor-stage .ts-cp-q { color: #f3e7d3; }
body[data-mode="dark"] #tutor-stage .ts-ask-input {
  background: rgba(40, 30, 18, 0.95);
  color: #f3e7d3;
}
/* fraction visuals + widgets (Task #251) — night palette */
body[data-mode="dark"] #tutor-stage .ts-equation .katex { color: #f0c089; }
body[data-mode="dark"] #tutor-stage .ts-visual-cap { color: #f0c089; }
body[data-mode="dark"] #tutor-stage .ts-seg,
body[data-mode="dark"] #tutor-stage .ts-region {
  fill: rgba(255, 255, 255, 0.06); stroke: #cdd3e0;
}
body[data-mode="dark"] #tutor-stage .ts-seg.on,
body[data-mode="dark"] #tutor-stage .ts-region.on { fill: var(--ts-shade-blue); }
body[data-mode="dark"] #tutor-stage .ts-seg.ts-tappable:hover,
body[data-mode="dark"] #tutor-stage .ts-region.ts-tappable:hover { fill: rgba(109, 140, 240, 0.28); }
body[data-mode="dark"] #tutor-stage .ts-nl-axis,
body[data-mode="dark"] #tutor-stage .ts-nl-tick.major { stroke: #f3e7d3; }
body[data-mode="dark"] #tutor-stage .ts-nl-tick { stroke: rgba(224, 169, 109, 0.5); }
body[data-mode="dark"] #tutor-stage .ts-nl-mark { stroke: #f0c089; }
body[data-mode="dark"] #tutor-stage .ts-nl-dot { fill: #f0c089; }
body[data-mode="dark"] #tutor-stage .ts-nl-label { fill: #f3e7d3; }
body[data-mode="dark"] #tutor-stage .ts-nl-handle-label { fill: #f0c089; }
body[data-mode="dark"] #tutor-stage .ts-fw-count,
body[data-mode="dark"] #tutor-stage .ts-slot-ph { color: #d8c4a6; }
body[data-mode="dark"] #tutor-stage .ts-fw-pm {
  background: rgba(224, 169, 109, 0.16); color: #f0c089;
}
body[data-mode="dark"] #tutor-stage .ts-fw-pm:hover { background: rgba(224, 169, 109, 0.26); }
body[data-mode="dark"] #tutor-stage .ts-fw-val { color: #f3e7d3; }
body[data-mode="dark"] #tutor-stage .ts-fw-fracbar { background: #f0c089; }
body[data-mode="dark"] #tutor-stage .ts-fw-opt {
  background: #2e2216; border-color: rgba(224, 169, 109, 0.28);
}
body[data-mode="dark"] #tutor-stage .ts-fw-opt-label { color: #f3e7d3; }

/* ---------- mobile: board takes the full lower stage ---------- */
@media (max-width: 720px) {
  #tutor-stage .ts-topbar { width: calc(100vw - 24px); top: 10px; }
  #tutor-stage .ts-title { font-size: 16px; }
  #tutor-stage .ts-stage-board,
  #tutor-stage[data-focus="board"] .ts-stage-board,
  #tutor-stage[data-focus="tutor"] .ts-stage-board {
    left: 12px; right: 12px; width: auto;
    top: auto;
    height: 46vh;
    bottom: 150px;
    opacity: 1;
  }
  #tutor-stage .ts-caption {
    left: 12px; right: 12px; max-width: none; bottom: 150px;
    display: none;
  }
  #tutor-stage .ts-transport {
    width: calc(100vw - 24px);
    justify-content: center;
    flex-wrap: wrap;
    border-radius: 18px;
  }
  #tutor-stage .ts-ask { margin-left: 0; width: 100%; }
  #tutor-stage .ts-ask-input { width: 100%; max-width: none; flex: 1; }
  #tutor-stage .ts-checkpoint, #tutor-stage .ts-resume {
    left: 12px; right: 12px; bottom: 210px;
  }
}

/* ============================================================
   Task #251 — Brilliant-style calm redesign.
   Appended LAST so it WINS the cascade over the original "Tuscan dusk"
   stage rules above (same #tutor-stage specificity, later in the file).
   The page-linked CSS is cache-busted (?v=) in tutor_stage.html.

   Look: a single big CENTERED near-white card carries the idea; ONE warm
   accent survives (fraction fills + the primary button rail). The board
   no longer "breathes"/docks. The resident legend lives in a small corner
   portrait (styled in tutor_stage.html), so the caption transcript is
   dropped (you hear the legend; the card shows the idea).
   ============================================================ */

/* tokens: near-monochrome paper + ink; keep ONE warm accent */
#tutor-stage {
  --ts-paper: #ffffff;
  --ts-ink: #1b1d21;
  --ts-muted: #6b7280;
  --ts-line: #e8e7e2;
  --ts-accent: #b5651d;
  --ts-accent-soft: #b5651d;
}

/* ---------- topbar: transparent, 3-zone (× left · progress center) ---------- */
#tutor-stage .ts-topbar {
  top: 0; left: 0; right: 0; width: auto; transform: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 16px; padding: 16px 22px;
  background: transparent; border-radius: 0; color: var(--ts-ink);
}
#tutor-stage .ts-head { display: none; }      /* title lives in the card */
#tutor-stage .ts-count { display: none; }     /* the bar shows progress */
#tutor-stage .ts-exit {
  grid-column: 1; justify-self: start;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(20, 22, 28, 0.05); color: var(--ts-ink);
  font-size: 20px;
}
#tutor-stage .ts-exit:hover { background: rgba(20, 22, 28, 0.1); }
#tutor-stage .ts-progress { grid-column: 2; justify-self: center; gap: 0; }

/* segmented progress bar (pills, no scaling) */
#tutor-stage .ts-dots { gap: 7px; }
#tutor-stage .ts-dot {
  width: 30px; height: 6px; border-radius: 999px;
  background: rgba(20, 22, 28, 0.12); transform: none;
}
#tutor-stage .ts-dot:hover { background: rgba(20, 22, 28, 0.22); }
#tutor-stage .ts-dot.done,
#tutor-stage .ts-dot.on { background: var(--ts-accent); transform: none; }
#tutor-stage .ts-dot:focus-visible { outline: 2px solid var(--ts-accent); outline-offset: 3px; }

/* ---------- board: ONE big centered card; kill the breathing/dock ---------- */
#tutor-stage .ts-stage-board,
#tutor-stage[data-focus="board"] .ts-stage-board,
#tutor-stage[data-focus="tutor"] .ts-stage-board {
  left: 50%; right: auto; transform: translateX(-50%);
  /* reserve >=200px each side so the centered card never collides with the
     bottom-left corner portrait */
  width: min(800px, calc(100vw - 420px));
  top: 84px; bottom: 168px;
  opacity: 1; transition: none;
}
#tutor-stage .ts-card {
  border-radius: 28px;
  border: 1px solid var(--ts-line);
  box-shadow: 0 40px 90px -50px rgba(20, 22, 40, 0.28);
  padding: 56px;
  align-items: center; text-align: center;
}
/* keep teaching content on a comfortable measure, centered
   (Task #284: widened with the card so it doesn't float in empty space) */
#tutor-stage .ts-card:not(.ts-card-problem) > * {
  max-width: 680px; width: 100%; margin-left: auto; margin-right: auto;
}
#tutor-stage .ts-list { text-align: left; max-width: 520px; gap: 14px; }
#tutor-stage .ts-diagram { justify-content: center; }

/* problem cards stay left-aligned + full width (widgets need the room) */
#tutor-stage .ts-card-problem { align-items: stretch; text-align: left; }

/* ---------- calmer, bigger type ---------- */
#tutor-stage .ts-card-title { font-size: 30px; margin: 0 0 16px; }
#tutor-stage .ts-heading .ts-card-title { font-size: 42px; }
#tutor-stage .ts-kicker { color: var(--ts-muted); }
#tutor-stage .ts-line { font-size: 18px; line-height: 1.55; }
#tutor-stage .ts-def-term { font-size: 30px; color: var(--ts-ink); }
#tutor-stage .ts-def-meaning { font-size: 18px; color: var(--ts-muted); }

/* equation: monochrome ink, no warm tint box */
#tutor-stage .ts-equation {
  font-size: 40px; color: var(--ts-ink);
  background: transparent; padding: 8px 0;
}
#tutor-stage .ts-equation .katex { color: var(--ts-ink); font-size: 1.1em; }
#tutor-stage .ts-eq-cap { font-size: 16px; color: var(--ts-muted); margin-top: 16px; }

/* visuals: the warm accent fraction fill is the one pop of color */
#tutor-stage .ts-frac-svg { max-width: 320px; }
#tutor-stage .ts-frac-bar { max-width: 380px; }
#tutor-stage .ts-visual-cap { font-size: 24px; }

/* ---------- big primary "Continue" rail (Brilliant) ---------- */
#tutor-stage .ts-actionbar {
  position: absolute; left: 0; right: 0; bottom: 34px;
  display: none; justify-content: center; pointer-events: none;
}
#tutor-stage .ts-actionbar.is-on { display: flex; }
#tutor-stage .ts-continue {
  pointer-events: auto;
  min-width: 300px; padding: 17px 30px;
  font: 700 17px "Manrope", sans-serif;
  border: none; border-radius: 16px; cursor: pointer;
  background: var(--ts-ink); color: #fff;
  box-shadow: 0 16px 34px -14px rgba(20, 22, 40, 0.6);
  transition: transform .08s ease, filter .15s ease;
}
#tutor-stage .ts-continue:hover { filter: brightness(1.14); }
#tutor-stage .ts-continue:active { transform: translateY(1px); }

/* ---------- caption (narration transcript): light, centered above the rail ----------
   Kept visible (not removed) so the legend's words stay on screen and act as the
   fallback when audio is blocked/fails. Sits in the gap between the card bottom
   (168px) and the Continue rail (top ~90px); clears the corner + transport. */
#tutor-stage .ts-caption {
  display: block;
  left: 50%; right: auto;
  bottom: 100px;
  transform: translateX(-50%) translateY(8px);
  max-width: min(640px, calc(100vw - 460px));
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ts-ink);
  border: 1px solid var(--ts-line);
  border-radius: 14px;
  padding: 11px 18px;
  font-size: 15.5px; line-height: 1.45;
  box-shadow: 0 16px 36px -20px rgba(20, 22, 40, 0.45);
}
#tutor-stage .ts-caption.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#tutor-stage .ts-caption-who { color: var(--ts-accent); }
#tutor-stage.is-speaking .ts-caption {
  box-shadow: 0 16px 36px -20px rgba(20, 22, 40, 0.45), 0 0 0 2px rgba(176, 106, 44, 0.28);
}
body[data-mode="dark"] #tutor-stage .ts-caption {
  background: rgba(32, 34, 40, 0.94);
  border-color: rgba(255, 255, 255, 0.1);
}
@media (max-width: 720px) {
  #tutor-stage .ts-caption {
    bottom: 96px;
    max-width: calc(100vw - 120px);
    font-size: 14.5px; padding: 10px 14px;
  }
}
/* Stage-presence teacher (/learn player): the caption centers in the zone
   RIGHT of the teacher column — mirroring the lesson card — so it never
   sits on his legs at the bigger stage sizes. Falls back to classic
   centering anywhere --legend-w is undefined (/lab's tutor overlay). */
@media (min-width: 721px) {
  body.learn-player #tutor-stage .ts-caption {
    left: calc(50% + var(--legend-w, 0px) / 2);
    max-width: min(640px, calc(100vw - var(--legend-w, 250px) - 300px));
  }
}

/* ---------- transport: subtle ghost cluster bottom-right ---------- */
#tutor-stage .ts-transport {
  left: auto; right: 22px; bottom: 28px; transform: none;
  background: transparent; box-shadow: none; padding: 0; gap: 8px;
}
#tutor-stage .ts-prev, #tutor-stage .ts-next, #tutor-stage .ts-ask { display: none; }
#tutor-stage .ts-tbtn {
  background: rgba(20, 22, 28, 0.06); color: var(--ts-ink);
  width: 42px; height: 42px;
}
#tutor-stage .ts-tbtn:hover { background: rgba(20, 22, 28, 0.12); }
#tutor-stage .ts-play {
  background: rgba(20, 22, 28, 0.06); color: var(--ts-ink);
  width: 46px; height: 46px;
}
#tutor-stage .ts-play:hover { background: rgba(20, 22, 28, 0.12); }
#tutor-stage .ts-play svg { fill: var(--ts-ink); stroke: none; }

/* ---------- assist pills (problem beats): light, centered ---------- */
#tutor-stage .ts-assist {
  background: transparent; box-shadow: none; padding: 0; gap: 10px;
  bottom: 34px;
}
#tutor-stage .ts-assist-btn {
  background: #fff; border: 1px solid var(--ts-line); color: var(--ts-ink);
  box-shadow: 0 8px 22px -14px rgba(20, 22, 40, 0.4);
}
#tutor-stage .ts-assist-btn:hover { background: #f6f6f3; }
#tutor-stage .ts-assist .ts-reveal { background: var(--ts-accent); color: #fff; border-color: transparent; }
#tutor-stage .ts-assist .ts-reveal:hover { background: #9d5616; }

/* checkpoint / resume: recolor light + centered (off the corner) */
#tutor-stage .ts-checkpoint, #tutor-stage .ts-resume {
  left: 50%; right: auto; transform: translateX(-50%); bottom: 104px;
}
#tutor-stage .ts-checkpoint {
  background: #fff; border: 1px solid var(--ts-line);
  box-shadow: 0 18px 40px -22px rgba(20, 22, 40, 0.3);
}
#tutor-stage .ts-cp-q { color: var(--ts-ink); }
#tutor-stage .ts-cp-btn.ts-cp-again { background: rgba(20, 22, 28, 0.08); color: var(--ts-ink); }

/* ---------- DARK parity (calm near-black card) ---------- */
body[data-mode="dark"] #tutor-stage {
  --ts-paper: #1c1d22;
  --ts-ink: #ece9e3;
  --ts-muted: #9a978f;
  --ts-line: rgba(255, 255, 255, 0.08);
}
body[data-mode="dark"] #tutor-stage .ts-card {
  box-shadow: 0 40px 90px -50px rgba(0, 0, 0, 0.7);
}
body[data-mode="dark"] #tutor-stage .ts-card-title,
body[data-mode="dark"] #tutor-stage .ts-def-term { color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-def-meaning,
body[data-mode="dark"] #tutor-stage .ts-eq-cap,
body[data-mode="dark"] #tutor-stage .ts-kicker { color: var(--ts-muted); }
body[data-mode="dark"] #tutor-stage .ts-exit { background: rgba(255, 255, 255, 0.06); color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-exit:hover { background: rgba(255, 255, 255, 0.12); }
body[data-mode="dark"] #tutor-stage .ts-dot { background: rgba(255, 255, 255, 0.14); }
body[data-mode="dark"] #tutor-stage .ts-dot.done,
body[data-mode="dark"] #tutor-stage .ts-dot.on { background: var(--ts-accent); }
body[data-mode="dark"] #tutor-stage .ts-continue { background: #f1efe9; color: #16171b; }
body[data-mode="dark"] #tutor-stage .ts-equation,
body[data-mode="dark"] #tutor-stage .ts-equation .katex { color: var(--ts-ink); background: transparent; }
body[data-mode="dark"] #tutor-stage .ts-tbtn,
body[data-mode="dark"] #tutor-stage .ts-play { background: rgba(255, 255, 255, 0.08); color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-play svg { fill: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-assist-btn { background: #26272d; border-color: rgba(255, 255, 255, 0.1); color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-checkpoint { background: #1c1d22; border-color: rgba(255, 255, 255, 0.08); }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  #tutor-stage .ts-stage-board,
  #tutor-stage[data-focus="board"] .ts-stage-board,
  #tutor-stage[data-focus="tutor"] .ts-stage-board {
    left: 12px; right: 12px; width: auto; transform: none;
    top: 66px; bottom: 196px;
  }
  #tutor-stage .ts-card { padding: 28px 22px; border-radius: 22px; }
  #tutor-stage .ts-card:not(.ts-card-problem) > * { max-width: none; }
  #tutor-stage .ts-heading .ts-card-title { font-size: 32px; }
  #tutor-stage .ts-card-title { font-size: 24px; }
  #tutor-stage .ts-equation { font-size: 30px; }
  #tutor-stage .ts-continue { min-width: 0; width: calc(100vw - 48px); }
  #tutor-stage .ts-transport { right: 12px; bottom: 86px; }
}

/* ============================================================
   Task #251 — BRILLIANT LESSON CHROME (final layer).
   Replaces the abandoned left-rail layout. The board is a centered
   white card; a thin HUD (× · green segmented progress · XP) rides the
   top; the live legend keeps its fixed bottom-left corner with a speech
   bubble above it; a Continue action bar + a feedback banner sit at the
   bottom; the conversation is a slide-in panel from the right.
   Appended LAST so it WINS the cascade. Cache-busted (?v=) in
   templates/tutor_stage.html.
   ============================================================ */
#tutor-stage {
  --ts-muted: #6b7280;
  --ts-green: #2fae66;
  --ts-green-ink: #1c8a4e;
  --ts-green-soft: #e7f7ee;
  --ts-amber: #d98a2b;
  --ts-amber-ink: #b25a16;
  --ts-amber-soft: #fbefdb;
  --ts-red: #d6452f;
  --ts-red-ink: #b3331f;
  --ts-red-soft: #fbe8e4;
  --ts-teal: #1f9b8e;
  --ts-teal-ink: #157f74;
  --ts-teal-soft: #e3f5f2;
}

/* ---------- board: centered in the FULL stage (no rail offset) ---------- */
#tutor-stage .ts-stage-board,
#tutor-stage[data-focus="board"] .ts-stage-board,
#tutor-stage[data-focus="tutor"] .ts-stage-board {
  left: 50%; right: auto; transform: translateX(-50%);
  width: min(880px, calc(100vw - 220px)); /* Task #284: wider lesson card */
  top: 92px; bottom: 156px;
  opacity: 1; transition: none;
}
#tutor-stage .ts-board { max-width: none; margin: 0; }

/* ---------- top HUD ---------- */
#tutor-stage .ts-hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  pointer-events: auto; z-index: 5;
}
#tutor-stage .ts-hud .ts-exit {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 50%; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(20, 22, 28, 0.06); color: var(--ts-ink);
}
#tutor-stage .ts-hud .ts-exit:hover { background: rgba(20, 22, 28, 0.12); }
#tutor-stage .ts-hud .ts-exit svg {
  width: 18px; height: 18px; fill: none;
  stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
}
#tutor-stage .ts-hud .ts-flag,
#tutor-stage .ts-hud .ts-sound {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 50%; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(20, 22, 28, 0.06); color: var(--ts-ink);
}
#tutor-stage .ts-hud .ts-flag:hover,
#tutor-stage .ts-hud .ts-sound:hover { background: rgba(20, 22, 28, 0.12); }
#tutor-stage .ts-hud .ts-flag svg,
#tutor-stage .ts-hud .ts-sound svg {
  width: 16px; height: 16px; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
#tutor-stage .ts-hud .ts-sound.is-muted { color: var(--ts-muted); }
#tutor-stage .ts-hud .ts-sound.is-muted svg { opacity: .55; }
#tutor-stage .ts-hud .ts-progress {
  flex: 1; min-width: 0; display: block; padding: 0; background: none; gap: 0;
}
#tutor-stage .ts-segbar { display: flex; gap: 4px; align-items: center; width: 100%; }
#tutor-stage .ts-segbar .ts-seg {
  flex: 1 1 0; height: 11px; min-width: 6px; padding: 0;
  border: none; -webkit-appearance: none; appearance: none;
  border-radius: 6px; cursor: pointer; stroke: none;
  background: rgba(20, 22, 28, 0.10);
  transition: background .25s ease, opacity .25s ease;
}
#tutor-stage .ts-segbar .ts-seg.done { background: var(--ts-green); opacity: 1; }
#tutor-stage .ts-segbar .ts-seg.on { background: var(--ts-green); opacity: .5; }
#tutor-stage .ts-segbar .ts-seg:focus-visible { outline: 2px solid var(--ts-green-ink); outline-offset: 2px; }
#tutor-stage .ts-hud .ts-count {
  flex: 0 0 auto; font-size: 12px; font-weight: 700;
  color: var(--ts-muted); font-variant-numeric: tabular-nums;
}
#tutor-stage .ts-xp {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  font: 800 16px "Manrope", sans-serif; color: var(--ts-green-ink);
  transition: transform .2s ease;
}
#tutor-stage .ts-xp-bolt { width: 18px; height: 18px; fill: var(--ts-green); }
#tutor-stage .ts-xp-num { font-variant-numeric: tabular-nums; }
#tutor-stage .ts-xp.is-bump { animation: tsXpBump .5s cubic-bezier(.22,.61,.36,1); }
@keyframes tsXpBump {
  0% { transform: scale(1); } 35% { transform: scale(1.28); } 100% { transform: scale(1); }
}

/* ---------- correct / wrong card persistence ---------- */
#tutor-stage .ts-card.ts-flash-right {
  border-color: var(--ts-green);
  box-shadow: 0 0 0 2px var(--ts-green), 0 40px 90px -50px rgba(20, 22, 40, 0.28);
}
#tutor-stage .ts-card.ts-flash-wrong { border-color: var(--ts-amber); }
#tutor-stage .ts-card.ts-flash-strict { border-color: var(--ts-red); box-shadow: 0 0 0 2px var(--ts-red), 0 40px 90px -50px rgba(20, 22, 40, 0.28); }

/* ---------- feedback banner ---------- */
#tutor-stage .ts-feedback {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(8px);
  bottom: 104px; z-index: 5; pointer-events: none;
  display: inline-flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-radius: 16px;
  font: 800 16px "Manrope", sans-serif; color: var(--ts-ink);
  background: #fff; border: 1px solid var(--ts-line);
  box-shadow: 0 20px 44px -22px rgba(20, 22, 40, 0.4);
  opacity: 0; transition: opacity .2s ease, transform .2s ease;
}
#tutor-stage .ts-feedback[hidden] { display: none; }
#tutor-stage .ts-feedback.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#tutor-stage .ts-feedback-icon {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 900; color: #fff; background: var(--ts-green);
}
#tutor-stage .ts-feedback.is-correct { color: var(--ts-green-ink); background: var(--ts-green-soft); border-color: rgba(47, 174, 102, 0.4); }
#tutor-stage .ts-feedback.is-correct .ts-feedback-icon { background: var(--ts-green); }
#tutor-stage .ts-feedback.is-wrong { color: var(--ts-amber-ink); background: var(--ts-amber-soft); border-color: rgba(217, 138, 43, 0.4); }
#tutor-stage .ts-feedback.is-wrong .ts-feedback-icon { background: var(--ts-amber); }
#tutor-stage .ts-feedback.is-strict { color: var(--ts-red-ink); background: var(--ts-red-soft); border-color: rgba(214, 69, 47, 0.4); }
#tutor-stage .ts-feedback.is-strict .ts-feedback-icon { background: var(--ts-red); }
#tutor-stage .ts-feedback.is-review { color: var(--ts-teal-ink); background: var(--ts-teal-soft); border-color: rgba(31, 155, 142, 0.4); }
#tutor-stage .ts-feedback.is-review .ts-feedback-icon { background: var(--ts-teal); }
#tutor-stage .ts-feedback-xp {
  font-size: 13px; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  background: rgba(47, 174, 102, 0.16); color: var(--ts-green-ink);
}
#tutor-stage .ts-feedback-xp:empty { display: none; }

/* ---------- assist pills: centered above the action bar ---------- */
#tutor-stage .ts-assist { left: 50%; right: auto; transform: translateX(-50%); bottom: 34px; }

/* ---------- tutor speech bubble (above the fixed corner portrait) ----------
   The bubble is anchored by its BOTTOM edge and grows upward. GUARANTEE: the
   resident legend's WebGL canvas clips at its .legend-corner box (250x360 at
   bottom:0), so nothing of the character can render above 360px — anchoring
   the bubble's bottom ABOVE the box top means it can never cover his face,
   for any model, pose, or animation frame. (bottom:200px sat the text on
   Newton's head; 264px still clipped his eyes on real WebGL framing.)
   The corner box is var-sized now (--legend-h, defined by the /learn player
   page for the stage-presence teacher); anchoring to the var keeps the
   guarantee at EVERY stage size, including the compact chat-docked tier.
   (Task #394: the box now nearly fills the column, so the page vars cap it
   at `100vh - 180px` — a reserved band the bubble grows into, keeping it
   fully on screen at any window height.)
   The 358px fallback reproduces the classic 368px anchor on pages that
   never define the var (/lab's tutor overlay). */
#tutor-stage .ts-speech {
  position: absolute; left: clamp(16px, 3vw, 28px);
  bottom: calc(var(--legend-h, 358px) + 10px);
  max-width: min(320px, 30vw); z-index: 5; pointer-events: none;
  background: #fff; color: var(--ts-ink);
  border: 1px solid var(--ts-line); border-radius: 16px; border-bottom-left-radius: 5px;
  padding: 12px 15px;
  box-shadow: 0 18px 40px -22px rgba(20, 22, 40, 0.4);
  opacity: 0; transform: translateY(8px); transition: opacity .22s ease, transform .22s ease;
}
#tutor-stage .ts-speech[hidden] { display: none; }
#tutor-stage .ts-speech.show { opacity: 1; transform: translateY(0); }
#tutor-stage .ts-speech-who {
  display: block; margin-bottom: 3px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ts-accent);
}
#tutor-stage .ts-speech-text { display: block; font-size: 14.5px; line-height: 1.45; }
#tutor-stage.is-speaking .ts-speech { box-shadow: 0 18px 40px -22px rgba(20, 22, 40, 0.4), 0 0 0 2px rgba(47, 174, 102, 0.3); }

/* ---------- tutor control bar (chat · mic · sound), bottom-left ---------- */
/* Sits to the RIGHT of the resident portrait (left:22 + width:158 = 180px) so
   the buttons never hide behind Newton's corner. */
#tutor-stage .ts-tutorbar {
  /* Anchored just RIGHT of the resident teacher's box so the chat/mic
     buttons never sit on his legs at the bigger stage sizes. The 186px
     fallback reproduces the classic 196px on /lab (no --legend-w there). */
  position: absolute; left: calc(var(--legend-w, 186px) + 10px); right: auto; bottom: 26px;
  display: flex; align-items: center; gap: 8px; z-index: 5; pointer-events: auto;
}
#tutor-stage .ts-tutorbar > button {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--ts-ink);
  box-shadow: 0 10px 26px -14px rgba(20, 22, 40, 0.5);
  transition: transform .08s ease, background .15s ease;
}
#tutor-stage .ts-tutorbar > button:hover { background: #f6f3ee; }
#tutor-stage .ts-tutorbar > button:active { transform: translateY(1px); }
#tutor-stage .ts-tutorbar > button[hidden] { display: none; }
#tutor-stage .ts-tutorbar svg {
  width: 20px; height: 20px; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
#tutor-stage .ts-chat-toggle.is-on { background: var(--ts-accent); color: #fff; }
#tutor-stage .ts-mic.is-live { background: var(--ts-accent); color: #fff; }
#tutor-stage .ts-sound.is-muted { color: var(--ts-muted); }
#tutor-stage .ts-sound.is-muted svg { opacity: .55; }

/* One motion language for the chat-open split: the panel, the lesson board and
   the divider all share this duration + easing, so nothing arrives early or late
   and the whole transition reads as a single coordinated move. */
#tutor-stage { --ts-anim-dur: .42s; --ts-anim-ease: cubic-bezier(.22, .61, .36, 1); }

/* ---------- conversation panel (slides + fades in) ---------- */
#tutor-stage .ts-chatpanel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(380px, 92vw);
  display: flex; flex-direction: column;
  background: var(--ts-paper); border-left: 1px solid var(--ts-line);
  box-shadow: -24px 0 60px -40px rgba(20, 22, 40, 0.45);
  transform: translateX(100%); opacity: 0;
  transition: transform var(--ts-anim-dur) var(--ts-anim-ease),
              opacity var(--ts-anim-dur) ease;
  pointer-events: auto; z-index: 7;
  will-change: transform, opacity;
}
#tutor-stage .ts-chatpanel[hidden] { display: flex; } /* slide off-screen, keep transition */
#tutor-stage .ts-chatpanel.show { transform: translateX(0); opacity: 1; }
#tutor-stage .ts-chatpanel-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 18px 18px 12px; border-bottom: 1px solid var(--ts-line);
}
#tutor-stage .ts-chatpanel-head-text { flex: 1; min-width: 0; }
#tutor-stage .ts-chatpanel .ts-subtitle {
  display: block; margin: 0; font-size: 10.5px; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ts-accent);
}
#tutor-stage .ts-chatpanel .ts-title {
  display: block; margin: 3px 0 0; font-family: "Fraunces", Georgia, serif;
  font-size: 20px; font-weight: 600; line-height: 1.15; color: var(--ts-ink);
  white-space: normal; overflow: visible; text-overflow: clip;
}
#tutor-stage .ts-chat-close {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 20px; line-height: 1;
  background: rgba(20, 22, 28, 0.06); color: var(--ts-ink);
}
#tutor-stage .ts-chat-close:hover { background: rgba(20, 22, 28, 0.12); }
#tutor-stage .ts-chatpanel .ts-chat {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth;
}
#tutor-stage .ts-chatpanel .ts-chat::-webkit-scrollbar { width: 8px; }
#tutor-stage .ts-chatpanel .ts-chat::-webkit-scrollbar-thumb { background: rgba(20, 22, 40, 0.18); border-radius: 8px; }
#tutor-stage .ts-chatpanel .ts-ask {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 12px 14px; border-top: 1px solid var(--ts-line);
}
#tutor-stage .ts-chatpanel .ts-ask-input {
  flex: 1; min-width: 0; border: 1px solid var(--ts-line); background: #fff;
  border-radius: 12px; font: 500 15px "Manrope", sans-serif; color: var(--ts-ink); padding: 10px 12px;
}
#tutor-stage .ts-chatpanel .ts-ask-input:focus { outline: none; border-color: var(--ts-accent); }
#tutor-stage .ts-chatpanel .ts-ask-send {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ts-accent); color: #fff;
}
#tutor-stage .ts-chatpanel .ts-ask-send svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
#tutor-stage .ts-chatpanel .ts-ask-send:hover { filter: brightness(1.12); }

/* ---------- conversation bubbles ---------- */
#tutor-stage .ts-bubble {
  max-width: 86%; padding: 11px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.5;
  animation: ts-bubble-in .26s cubic-bezier(.22,.61,.36,1);
}
@keyframes ts-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#tutor-stage .ts-bubble.is-legend { align-self: flex-start; background: rgba(20, 22, 28, 0.05); color: var(--ts-ink); border-bottom-left-radius: 5px; }
#tutor-stage .ts-bubble.is-you { align-self: flex-end; background: var(--ts-accent); color: #fff; border-bottom-right-radius: 5px; }
#tutor-stage .ts-bubble-who {
  display: block; margin-bottom: 2px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ts-accent);
}
#tutor-stage .ts-bubble-text { display: block; }

/* ---------- overlay (behind completion / unlock screens) ---------- */
#tutor-stage .ts-overlay {
  position: absolute; inset: 0; z-index: 6; pointer-events: auto;
  background: rgba(18, 16, 12, 0.45);
}
#tutor-stage .ts-overlay[hidden] { display: none; }

/* ---------- dark parity ---------- */
body[data-mode="dark"] #tutor-stage .ts-hud .ts-exit { background: rgba(255, 255, 255, 0.08); color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-hud .ts-exit:hover { background: rgba(255, 255, 255, 0.14); }
body[data-mode="dark"] #tutor-stage .ts-segbar .ts-seg { background: rgba(255, 255, 255, 0.12); }
body[data-mode="dark"] #tutor-stage .ts-feedback { background: #1c1d22; border-color: rgba(255, 255, 255, 0.08); color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-feedback.is-correct { background: rgba(47, 174, 102, 0.16); color: #7fe0a6; }
body[data-mode="dark"] #tutor-stage .ts-feedback.is-wrong { background: rgba(217, 138, 43, 0.16); color: #f0b878; }
body[data-mode="dark"] #tutor-stage .ts-feedback.is-strict { background: rgba(214, 69, 47, 0.16); color: #f0937f; }
body[data-mode="dark"] #tutor-stage .ts-feedback.is-review { background: rgba(31, 155, 142, 0.16); color: #6fd6c8; }
body[data-mode="dark"] #tutor-stage .ts-speech { background: #1c1d22; border-color: rgba(255, 255, 255, 0.08); }
body[data-mode="dark"] #tutor-stage .ts-tutorbar > button { background: #26272d; color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-tutorbar > button:hover { background: #303138; }
body[data-mode="dark"] #tutor-stage .ts-chatpanel { background: #1c1d22; border-color: rgba(255, 255, 255, 0.08); }
body[data-mode="dark"] #tutor-stage .ts-chatpanel .ts-ask-input { background: #26272d; color: var(--ts-ink); border-color: rgba(255, 255, 255, 0.1); }
body[data-mode="dark"] #tutor-stage .ts-chat-close { background: rgba(255, 255, 255, 0.08); color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-bubble.is-legend { background: rgba(255, 255, 255, 0.06); }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  #tutor-stage .ts-stage-board,
  #tutor-stage[data-focus="board"] .ts-stage-board,
  #tutor-stage[data-focus="tutor"] .ts-stage-board {
    left: 12px; right: 12px; width: auto; transform: none;
    top: 70px; bottom: 150px;
  }
  #tutor-stage .ts-hud { padding: 12px 14px; gap: 10px; }
  #tutor-stage .ts-xp { font-size: 14px; }
  #tutor-stage .ts-speech { left: 12px; right: 12px; max-width: none; bottom: 184px; }
  #tutor-stage .ts-chatpanel { width: 100%; }
  #tutor-stage .ts-tutorbar { bottom: 18px; left: 140px; }
}

/* Continue must be a centered pill, not a full-width bar: override the
   .ts-btn-primary { flex: 1 } it inherits (it carries .ts-btn-primary). */
#tutor-stage .ts-actionbar .ts-continue { flex: 0 0 auto; min-width: 320px; }
@media (max-width: 720px) {
  #tutor-stage .ts-actionbar .ts-continue { min-width: 0; width: calc(100vw - 48px); }
}

/* ==================================================================
   Skill-check mode (Task #251) — the tutor stands down: hide the
   narration bubble + caption so it reads as a graded, on-your-own check.
   ================================================================== */
#tutor-stage[data-skillcheck="1"] .ts-speech,
#tutor-stage[data-skillcheck="1"] .ts-caption { display: none !important; }
#tutor-stage[data-skillcheck="1"] .ts-card-problem .ts-kicker {
  color: var(--ts-red-ink);
}

/* ==================================================================
   Number-tile equation primitive (Task #251)
   ================================================================== */
#tutor-stage .ts-fw-tile { align-items: center; gap: 28px; }
#tutor-stage .ts-tile-eq {
  display: flex; align-items: center; justify-content: center;
  gap: 22px; margin: 8px 0 4px;
  /* Wide equations scroll instead of clipping (same idiom as .ts-equation,
     Task #251). `safe center` keeps the start reachable when overflowing;
     plain `center` stays as the fallback for engines without `safe`.
     Caught by goldframe (Task #349): 4-term tile rows clipped both edges
     at 9:16 mobile. */
  justify-content: safe center;
  max-width: 100%; overflow-x: auto;
}
#tutor-stage .ts-tile-frac {
  display: inline-flex; flex-direction: column; align-items: center;
  font: 800 40px "Fraunces", Georgia, serif; color: var(--ts-ink);
  line-height: 1.05;
}
#tutor-stage .ts-tile-bar {
  width: 64px; height: 4px; border-radius: 4px;
  background: var(--ts-ink); margin: 6px 0;
}
#tutor-stage .ts-tile-eq-sign {
  font: 700 36px "Fraunces", Georgia, serif; color: var(--ts-muted);
}
#tutor-stage .ts-tile-blank {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; min-height: 56px; padding: 2px 10px;
  border: 3px dashed var(--ts-line); border-radius: 14px;
  color: var(--ts-muted);
}
#tutor-stage .ts-tile-blank.filled {
  border-style: solid; border-color: var(--ts-accent); color: var(--ts-ink);
}
#tutor-stage .ts-tile-blank.is-answer {
  border-color: var(--ts-green); color: var(--ts-green-ink);
}
#tutor-stage .ts-tile-tray {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
}
#tutor-stage .ts-tile {
  width: 60px; height: 60px; border-radius: 16px;
  border: 1px solid var(--ts-line); background: #fff;
  font: 800 26px "Fraunces", Georgia, serif; color: var(--ts-ink);
  cursor: pointer; transition: transform .08s ease, border-color .15s ease,
    box-shadow .15s ease;
}
#tutor-stage .ts-tile:hover { border-color: var(--ts-accent); transform: translateY(-2px); }
#tutor-stage .ts-tile.chosen {
  border-color: var(--ts-accent); color: #fff; background: var(--ts-accent);
  box-shadow: 0 10px 22px -12px rgba(181, 101, 29, 0.7);
}
#tutor-stage .ts-tile.is-answer {
  border-color: var(--ts-green); background: var(--ts-green); color: #fff;
}
#tutor-stage .ts-tile.used {
  opacity: 0.32; cursor: default; transform: none;
  border-color: var(--ts-line); box-shadow: none;
}

/* --- tiles widget: multi-cell equation with op cells + tappable slots --- */
#tutor-stage .ts-tile-row {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; min-height: 56px;
}
#tutor-stage .ts-tile-op {
  display: inline-flex; align-items: center; gap: 8px;
}
#tutor-stage .ts-tile-opbase {
  font: 800 40px "Fraunces", Georgia, serif; color: var(--ts-ink);
}
#tutor-stage .ts-tile-opsign {
  font: 700 30px "Fraunces", Georgia, serif; color: var(--ts-muted);
}
#tutor-stage .ts-tile-slot.ts-tappable { cursor: pointer; }
#tutor-stage .ts-tile-slot.filled.ts-tappable:hover {
  border-color: var(--ts-accent); transform: translateY(-1px);
}
/* Compact tile-equation metrics on phones so typical 4-term rows FIT the
   414px card instead of scrolling (goldframe Task #349 baseline fix). */
@media (max-width: 720px) {
  #tutor-stage .ts-tile-eq { gap: 10px; }
  #tutor-stage .ts-tile-frac { font-size: 26px; }
  #tutor-stage .ts-tile-bar { width: 40px; height: 3px; margin: 4px 0; }
  #tutor-stage .ts-tile-eq-sign { font-size: 22px; }
  #tutor-stage .ts-tile-blank {
    min-width: 42px; min-height: 42px; border-width: 2px; border-radius: 11px;
  }
  #tutor-stage .ts-tile-row { gap: 5px; min-height: 44px; }
  #tutor-stage .ts-tile-opbase { font-size: 26px; }
  #tutor-stage .ts-tile-opsign { font-size: 20px; }
  #tutor-stage .ts-tile { width: 48px; height: 48px; font-size: 21px; }
}

/* --- pick widget: multiple-choice shape-diagram cards --- */
#tutor-stage .ts-fw-pick {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: center;
  align-items: stretch;
}
#tutor-stage .ts-fw-pick-prompt {
  font: 600 17px "Fraunces", Georgia, serif; color: var(--ts-ink);
  text-align: center; margin-bottom: 4px;
}
#tutor-stage .ts-fw-pickopt {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px; border-radius: 18px; cursor: pointer;
  border: 2px solid var(--ts-line); background: #fff;
  transition: transform .1s ease, border-color .15s ease, box-shadow .15s ease;
}
#tutor-stage .ts-fw-pickopt:hover {
  border-color: var(--ts-accent); transform: translateY(-2px);
  box-shadow: 0 12px 24px -16px rgba(181, 101, 29, 0.6);
}
#tutor-stage .ts-fw-pickvis {
  width: 120px; height: 120px; display: flex; align-items: center;
  justify-content: center;
}
#tutor-stage .ts-fw-pickvis svg { width: 100%; height: 100%; }
#tutor-stage .ts-fw-pick-cap {
  font: 600 14px "Fraunces", Georgia, serif; color: var(--ts-muted);
}
#tutor-stage .ts-fw-pickopt.chosen {
  border-color: var(--ts-accent);
  box-shadow: 0 12px 24px -14px rgba(181, 101, 29, 0.7);
}
#tutor-stage .ts-fw-pick-val {
  font: 700 15px "Fraunces", Georgia, serif; color: var(--ts-muted);
  opacity: 0; height: 0; overflow: hidden; transition: opacity .15s ease;
}
#tutor-stage .ts-fw-pickopt.show-val .ts-fw-pick-val {
  opacity: 1; height: auto;
}
#tutor-stage .ts-fw-pickopt.is-answer {
  border-color: var(--ts-green);
  box-shadow: 0 12px 24px -14px rgba(45, 122, 62, 0.5);
}
#tutor-stage .ts-fw-pickopt.is-answer .ts-fw-pick-val { color: var(--ts-green-ink); }

/* ==================================================================
   Completion board — "Practice complete!" (Task #251)
   ================================================================== */
#tutor-stage .ts-complete {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 6px;
}
#tutor-stage .ts-complete-badge {
  width: 92px; height: 92px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 8px;
  background: var(--ts-green-soft);
  box-shadow: 0 0 0 8px rgba(47, 174, 102, 0.12);
  animation: tsPop .5s cubic-bezier(.2, 1.3, .5, 1) both;
}
#tutor-stage .ts-complete-badge svg {
  width: 46px; height: 46px; fill: none;
  stroke: var(--ts-green); stroke-width: 3.4;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: tsCheck .5s .25s ease forwards;
}
#tutor-stage .ts-complete-title { font-size: 36px; margin: 4px 0 18px; }
#tutor-stage .ts-complete-stats {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
}
#tutor-stage .ts-stat {
  display: flex; flex-direction: column; align-items: center;
  min-width: 104px; padding: 18px 14px; border-radius: 18px;
  background: rgba(20, 22, 28, 0.04); border: 1px solid var(--ts-line);
}
#tutor-stage .ts-stat-num {
  font: 800 32px "Fraunces", Georgia, serif; color: var(--ts-accent);
}
#tutor-stage .ts-stat-label {
  font-size: 13px; color: var(--ts-muted); margin-top: 4px;
  letter-spacing: .02em;
}
@keyframes tsPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes tsCheck { to { stroke-dashoffset: 0; } }

/* ==================================================================
   Leagues board — leaderboard reveal (Task #251)
   ================================================================== */
#tutor-stage .ts-leagues {
  list-style: none; margin: 8px auto 0; padding: 0;
  max-width: 460px; width: 100%; display: flex; flex-direction: column; gap: 8px;
}
#tutor-stage .ts-league-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: 14px;
  background: rgba(20, 22, 28, 0.03); border: 1px solid var(--ts-line);
  opacity: 0; transform: translateY(8px);
  animation: tsRowIn .4s ease forwards; animation-delay: calc(var(--d) * 90ms);
  transition: background .3s ease, box-shadow .3s ease, transform .45s cubic-bezier(.2,1,.4,1);
}
#tutor-stage .ts-league-rank {
  width: 28px; text-align: center; font-weight: 800; color: var(--ts-muted);
}
#tutor-stage .ts-league-name { flex: 1; text-align: left; font-weight: 600; }
#tutor-stage .ts-league-xp { font-weight: 700; color: var(--ts-accent); }
#tutor-stage .ts-league-row.is-you {
  background: var(--ts-accent); border-color: var(--ts-accent);
  box-shadow: 0 14px 30px -16px rgba(181, 101, 29, 0.7);
}
#tutor-stage .ts-league-row.is-you .ts-league-rank,
#tutor-stage .ts-league-row.is-you .ts-league-name,
#tutor-stage .ts-league-row.is-you .ts-league-xp { color: #fff; }
#tutor-stage .ts-league-row.is-you.rise { transform: translateY(-4px) scale(1.03); }
@keyframes tsRowIn { to { opacity: 1; transform: translateY(0); } }

/* dark theme parity for the new boards */
body[data-mode="dark"] #tutor-stage .ts-tile { background: #26272d; color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-fw-pickopt { background: #26272d; }
body[data-mode="dark"] #tutor-stage .ts-fw-pick-cap,
body[data-mode="dark"] #tutor-stage .ts-fw-pick-val { color: #d9c6a8; }
body[data-mode="dark"] #tutor-stage .ts-stat { background: rgba(255, 255, 255, 0.05); }
body[data-mode="dark"] #tutor-stage .ts-league-row { background: rgba(255, 255, 255, 0.04); }

/* ==================================================================
   Premium checkout gate + "Premium Unlocked!" celebration (Task #251)
   These cards are appended to <body> (siblings of the inline .stage-gate
   in tutor_stage.html), so — unlike #tutor-stage boards — they theme off
   html[data-theme="dark"], matching those inline gate styles.
   ================================================================== */
.stage-paygate-card {
  max-width: 460px; width: 100%; text-align: center;
  background: rgba(255, 252, 245, 0.94);
  border: 1px solid rgba(60, 42, 20, 0.12);
  border-radius: 24px; padding: 34px 30px 26px;
  box-shadow: 0 34px 90px -34px rgba(40, 28, 12, 0.55);
}
html[data-theme="dark"] .stage-paygate-card {
  background: rgba(26, 26, 33, 0.94);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 34px 90px -34px rgba(0, 0, 0, 0.75);
}
.stage-paygate-crown {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 50%; font-size: 26px; color: #fff;
  background: linear-gradient(180deg, #c79a55, #a8742f);
  box-shadow: 0 16px 30px -14px rgba(168, 116, 47, 0.8);
}
.stage-paygate-eyebrow {
  margin: 0 0 8px; font: 600 12px/1.4 "Manrope", sans-serif;
  letter-spacing: .14em; text-transform: uppercase; color: #a8742f;
}
html[data-theme="dark"] .stage-paygate-eyebrow { color: #d9b46a; }
.stage-paygate-title {
  margin: 0 0 10px; font: 600 26px/1.18 "Fraunces", serif; color: #2b2218;
}
html[data-theme="dark"] .stage-paygate-title { color: #f0e7d6; }
.stage-paygate-sub {
  margin: 0 auto 18px; max-width: 380px;
  font: 500 14px/1.5 "Manrope", sans-serif; color: rgba(43, 34, 24, 0.66);
}
html[data-theme="dark"] .stage-paygate-sub { color: rgba(240, 231, 214, 0.6); }
.stage-paygate-feats {
  list-style: none; margin: 0 auto 20px; padding: 0;
  max-width: 320px; text-align: left;
  display: flex; flex-direction: column; gap: 9px;
}
.stage-paygate-feats li {
  position: relative; padding-left: 28px;
  font: 500 14px/1.4 "Manrope", sans-serif; color: #3a2f22;
}
html[data-theme="dark"] .stage-paygate-feats li { color: #e6dcc9; }
.stage-paygate-feats li::before {
  content: "\2713"; position: absolute; left: 0; top: -1px;
  display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, #5aab6b, #3f9354);
}
.stage-paygate-plans {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px;
}
.stage-plan {
  position: relative; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  padding: 16px 14px 14px; border-radius: 16px;
  border: 2px solid rgba(60, 42, 20, 0.16);
  background: #fff; color: #2b2218;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
html[data-theme="dark"] .stage-plan {
  background: #15151d; color: #f0e7d6; border-color: rgba(255, 255, 255, 0.14);
}
.stage-plan:hover { transform: translateY(-1px); }
.stage-plan.is-active {
  border-color: #c08a3e;
  box-shadow: 0 0 0 3px rgba(192, 138, 62, 0.22), 0 16px 30px -18px rgba(168, 116, 47, 0.6);
}
.stage-plan-badge {
  position: absolute; top: -10px; right: 10px;
  padding: 3px 9px; border-radius: 999px;
  font: 700 10px/1 "Manrope", sans-serif; letter-spacing: .04em; color: #fff;
  background: linear-gradient(180deg, #5aab6b, #3f9354);
  box-shadow: 0 6px 14px -6px rgba(63, 147, 84, 0.8);
}
.stage-plan-name {
  font: 600 12px/1 "Manrope", sans-serif; letter-spacing: .06em;
  text-transform: uppercase; color: rgba(43, 34, 24, 0.55);
}
html[data-theme="dark"] .stage-plan-name { color: rgba(240, 231, 214, 0.5); }
.stage-plan-amt { font: 700 24px/1.1 "Manrope", sans-serif; }
.stage-plan-amt small { font-size: 13px; font-weight: 600; opacity: .6; }
.stage-plan-note {
  font: 500 11px/1.35 "Manrope", sans-serif; color: rgba(43, 34, 24, 0.55);
}
html[data-theme="dark"] .stage-plan-note { color: rgba(240, 231, 214, 0.5); }
.stage-paygate-go {
  width: 100%; padding: 15px 22px;
  font: 700 16px "Manrope", sans-serif;
  border: none; border-radius: 14px;
  background: linear-gradient(180deg, #c79a55, #a8742f);
  color: #fff; cursor: pointer;
  box-shadow: 0 16px 30px -12px rgba(168, 116, 47, 0.7);
  transition: filter .15s ease, opacity .15s ease;
}
.stage-paygate-go:hover { filter: brightness(1.05); }
.stage-paygate-go:disabled { opacity: .7; cursor: default; }
.stage-paygate-err {
  margin: 12px 0 0; font: 500 13px "Manrope", sans-serif; color: #c0392b;
}
html[data-theme="dark"] .stage-paygate-err { color: #ef8d80; }
.stage-paygate-back {
  display: inline-block; margin-top: 14px;
  font: 600 13px "Manrope", sans-serif; text-decoration: none;
  color: rgba(43, 34, 24, 0.5);
}
.stage-paygate-back:hover { color: rgba(43, 34, 24, 0.75); }
html[data-theme="dark"] .stage-paygate-back { color: rgba(240, 231, 214, 0.45); }
html[data-theme="dark"] .stage-paygate-back:hover { color: rgba(240, 231, 214, 0.7); }

/* ---- "Premium Unlocked!" celebration ---- */
.stage-unlock-card {
  position: relative; overflow: hidden;
  max-width: 460px; width: 100%; text-align: center;
  background: rgba(255, 252, 245, 0.95);
  border: 1px solid rgba(60, 42, 20, 0.12);
  border-radius: 24px; padding: 44px 34px 34px;
  box-shadow: 0 34px 90px -34px rgba(40, 28, 12, 0.55);
}
html[data-theme="dark"] .stage-unlock-card {
  background: rgba(26, 26, 33, 0.95);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 34px 90px -34px rgba(0, 0, 0, 0.75);
}
.stage-unlock-badge {
  display: inline-grid; place-items: center;
  width: 78px; height: 78px; margin: 0 auto 16px;
  border-radius: 50%; font-size: 38px; color: #fff;
  background: linear-gradient(180deg, #5aab6b, #3f9354);
  box-shadow: 0 18px 36px -16px rgba(63, 147, 84, 0.85);
  animation: tsPop .5s cubic-bezier(.2, 1, .4, 1) both;
}
.stage-unlock-eyebrow {
  margin: 0 0 8px; font: 600 12px/1.4 "Manrope", sans-serif;
  letter-spacing: .14em; text-transform: uppercase; color: #a8742f;
}
html[data-theme="dark"] .stage-unlock-eyebrow { color: #d9b46a; }
.stage-unlock-title {
  margin: 0 0 10px; font: 600 32px/1.12 "Fraunces", serif; color: #2b2218;
}
html[data-theme="dark"] .stage-unlock-title { color: #f0e7d6; }
.stage-unlock-sub {
  margin: 0 auto 24px; max-width: 360px;
  font: 500 14px/1.55 "Manrope", sans-serif; color: rgba(43, 34, 24, 0.66);
}
html[data-theme="dark"] .stage-unlock-sub { color: rgba(240, 231, 214, 0.6); }
.stage-unlock-go {
  min-width: 220px; padding: 15px 26px;
  font: 700 16px "Manrope", sans-serif; border: none; border-radius: 14px;
  background: linear-gradient(180deg, #c79a55, #a8742f);
  color: #fff; cursor: pointer;
  box-shadow: 0 16px 30px -12px rgba(168, 116, 47, 0.7);
}
.stage-unlock-go:hover { filter: brightness(1.05); }
.stage-confetti {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.stage-confetti-bit {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px;
  opacity: 0; animation: tsConfetti 1.5s ease-in forwards;
}
.stage-confetti-bit:nth-child(7n+1) { left: 8%;  background: #e0b15a; animation-delay: .02s; }
.stage-confetti-bit:nth-child(7n+2) { left: 22%; background: #5aab6b; animation-delay: .12s; }
.stage-confetti-bit:nth-child(7n+3) { left: 36%; background: #c08a3e; animation-delay: .06s; }
.stage-confetti-bit:nth-child(7n+4) { left: 52%; background: #6fa8dc; animation-delay: .18s; }
.stage-confetti-bit:nth-child(7n+5) { left: 67%; background: #d98c8c; animation-delay: .09s; }
.stage-confetti-bit:nth-child(7n+6) { left: 81%; background: #a8742f; animation-delay: .15s; }
.stage-confetti-bit:nth-child(7n)   { left: 93%; background: #5aab6b; animation-delay: .04s; }
@keyframes tsConfetti {
  0%   { opacity: 0; transform: translateY(0) rotate(0deg); }
  12%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(360px) rotate(420deg); }
}
@media (max-width: 720px) {
  .stage-paygate-plans { grid-template-columns: 1fr; }
}

/* =====================================================================
   Brilliant-style split layout (Task #251): when the chat opens, the
   screen SPLITS — tutor conversation on the LEFT (same side as the
   resident legend portrait), the lesson card on the RIGHT, with a
   draggable vertical divider between them. Desktop only; on phones the
   chat stays a full-width overlay.
   ===================================================================== */
/* divider is hidden by default; the desktop split layout below reveals it only
   while the chat is open. On phones it never appears (chat is a full overlay). */
#tutor-stage .ts-divider { display: none; }

@media (min-width: 721px) {
  #tutor-stage { --ts-split: 27%; }

  /* default (chat closed): center the lesson with transform-free centering
     so it can smoothly animate-slide to the right when the chat opens */
  #tutor-stage .ts-stage-board,
  #tutor-stage[data-focus="board"] .ts-stage-board,
  #tutor-stage[data-focus="tutor"] .ts-stage-board {
    left: 0; right: 0; margin: 0 auto; transform: none;
    width: min(880px, calc(100vw - 220px)); /* Task #284: wider lesson card */
    transition: left var(--ts-anim-dur) var(--ts-anim-ease),
                right var(--ts-anim-dur) var(--ts-anim-ease),
                width var(--ts-anim-dur) var(--ts-anim-ease);
    will-change: left, right, width;
  }

  /* chat open: the lesson card docks to the RIGHT of the divider */
  #tutor-stage.ts-chat-open .ts-stage-board,
  #tutor-stage.ts-chat-open[data-focus="board"] .ts-stage-board,
  #tutor-stage.ts-chat-open[data-focus="tutor"] .ts-stage-board {
    left: calc(var(--ts-split) + 18px); right: 24px;
    width: auto; margin: 0; max-width: none;
  }

  /* Stage-presence teacher (/learn player only — body.learn-player): while
     the chat is CLOSED the teacher owns the left column, so the lesson card
     centers in the space to his RIGHT instead of the full viewport. /lab's
     tutor overlay has no resident corner box and keeps the full-width
     centering above. Endpoints stay animatable: when the chat opens this
     rule stops matching and the dock rule above takes over mid-transition. */
  body.learn-player #tutor-stage:not(.ts-chat-open) .ts-stage-board,
  body.learn-player #tutor-stage:not(.ts-chat-open)[data-focus="board"] .ts-stage-board,
  body.learn-player #tutor-stage:not(.ts-chat-open)[data-focus="tutor"] .ts-stage-board {
    left: calc(var(--legend-w, 250px) + 20px);
    right: 20px;
    width: min(880px, calc(100vw - var(--legend-w, 250px) - 88px));
  }

  /* Stage-presence bubble (Task #394, /learn player only): the box top sits
     much higher now, and the page vars reserve a fixed ~180px band above it
     for the bubble. Let long spoken lines run a little wider there so they
     wrap to fewer lines and always fit inside that band. Chat-open (docked
     compact teacher) keeps the classic width so no more of the bubble peeks
     past the left chat panel than before; /lab never defines the vars and
     keeps the classic 320px bubble everywhere. */
  body.learn-player #tutor-stage:not(.ts-chat-open) .ts-speech {
    max-width: min(380px, 32vw);
  }

  /* the conversation panel docks LEFT (slides in from the left edge).
     Task #284 ROOT-CAUSE FIX for the janky open animation: these rules used
     to hang off `.ts-chat-open` (the ROOT class), which lands in the SAME
     frame as `.show`. The browser then transitioned from the last PAINTED
     state — the panel's BASE position, off-screen at the RIGHT edge
     (right:0 + translateX(100%), kept rendered by `[hidden]{display:flex}`)
     — so the panel visibly flew ACROSS the whole stage. They now hang off a
     panel-level `dock-left` class that the JS applies one flushed frame
     BEFORE `.show`, so the slide starts from off-screen LEFT as designed. */
  #tutor-stage .ts-chatpanel.dock-left {
    left: 0; right: auto;
    width: var(--ts-split);
    background: var(--ts-paper);
    border-left: none; border-right: 1px solid var(--ts-line);
    box-shadow: 10px 0 40px -34px rgba(20, 22, 40, 0.32);
    transform: translateX(-100%);
  }
  #tutor-stage .ts-chatpanel.dock-left.show { transform: translateX(0); }

  /* keep the chat input clear of the bottom-left resident portrait */
  #tutor-stage .ts-chatpanel.dock-left .ts-ask { padding-left: 18px; }
  #tutor-stage .ts-chatpanel.dock-left .ts-chat { padding-bottom: 24px; }

  /* draggable vertical divider — fades in with the split instead of snapping in */
  #tutor-stage .ts-divider {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 0; bottom: 0;
    left: var(--ts-split); width: 18px; margin-left: -9px;
    cursor: col-resize; z-index: 9; touch-action: none; background: transparent;
    opacity: 0; pointer-events: none;
    transition: opacity var(--ts-anim-dur) var(--ts-anim-ease);
  }
  #tutor-stage.ts-chat-open .ts-divider { opacity: 1; pointer-events: auto; }
  #tutor-stage .ts-divider-grip {
    width: 4px; height: 64px; border-radius: 999px; background: var(--ts-line);
    transition: background .15s ease, height .15s ease;
  }
  #tutor-stage .ts-divider:hover .ts-divider-grip,
  #tutor-stage .ts-divider.is-dragging .ts-divider-grip {
    background: var(--ts-accent); height: 104px;
  }
}
body[data-mode="dark"] #tutor-stage .ts-chatpanel.dock-left {
  border-right-color: rgba(255, 255, 255, 0.08);
  background: #1c1d22;
}

/* ============================================================
   Lesson modals (exit confirm · flag report) · toast · highlight
   ============================================================ */
#tutor-stage .ts-modal {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#tutor-stage .ts-modal-card {
  width: min(420px, 92vw);
  background: var(--ts-paper); color: var(--ts-ink);
  border: 1px solid var(--ts-line); border-radius: 18px;
  box-shadow: 0 40px 90px -40px rgba(20, 22, 40, 0.5);
  padding: 22px 22px 18px;
  animation: tsModalIn .22s cubic-bezier(.22,.61,.36,1);
}
@keyframes tsModalIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; }
}
#tutor-stage .ts-modal-title { margin: 0 0 8px; font: 700 19px "Fraunces", Georgia, serif; color: var(--ts-ink); }
#tutor-stage .ts-modal-body { font-size: 14.5px; line-height: 1.5; color: var(--ts-muted); }
#tutor-stage .ts-modal-opts { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
#tutor-stage .ts-modal-opt {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--ts-line); border-radius: 12px;
  font-size: 14px; color: var(--ts-ink);
}
#tutor-stage .ts-modal-opt:hover { background: rgba(20, 22, 28, 0.04); }
#tutor-stage .ts-modal-opt input { accent-color: var(--ts-accent); }
#tutor-stage .ts-modal-text {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 64px;
  border: 1px solid var(--ts-line); border-radius: 12px; padding: 10px 12px;
  font: 400 14px "Manrope", sans-serif; color: var(--ts-ink); background: #fff;
}
#tutor-stage .ts-modal-text:focus { outline: none; border-color: var(--ts-accent); }
#tutor-stage .ts-modal-input {
  width: 100%; box-sizing: border-box; margin-top: 10px;
  border: 1px solid var(--ts-line); border-radius: 12px; padding: 10px 12px;
  font: 400 14px "Manrope", sans-serif; color: var(--ts-ink); background: #fff;
}
#tutor-stage .ts-modal-input:focus { outline: none; border-color: var(--ts-accent); }
#tutor-stage .ts-modal-btn:disabled { opacity: 0.6; cursor: default; }
#tutor-stage .ts-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
#tutor-stage .ts-modal-btn {
  border: none; cursor: pointer; border-radius: 12px; padding: 11px 18px;
  font: 700 14px "Manrope", sans-serif;
}
#tutor-stage .ts-modal-solid { background: var(--ts-ink); color: #fff; }
#tutor-stage .ts-modal-solid:hover { filter: brightness(1.08); }
#tutor-stage .ts-modal-ghost { background: rgba(20, 22, 28, 0.06); color: var(--ts-ink); }
#tutor-stage .ts-modal-ghost:hover { background: rgba(20, 22, 28, 0.12); }

#tutor-stage .ts-toast {
  position: absolute; left: 50%; bottom: 96px; transform: translate(-50%, 12px);
  z-index: 8; pointer-events: none;
  background: var(--ts-ink); color: #fff; font: 600 13.5px "Manrope", sans-serif;
  padding: 10px 16px; border-radius: 999px; opacity: 0;
  box-shadow: 0 18px 40px -22px rgba(20, 22, 40, 0.6);
  transition: opacity .2s ease, transform .2s ease;
}
#tutor-stage .ts-toast.show { opacity: 1; transform: translate(-50%, 0); }

#tutor-stage .ts-card.ts-hl-pulse { animation: tsHlPulse 1.3s ease; }
@keyframes tsHlPulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 174, 102, 0); }
  22% { box-shadow: 0 0 0 3px rgba(47, 174, 102, .9), 0 0 28px 4px rgba(47, 174, 102, .35); }
  100% { box-shadow: 0 0 0 0 rgba(47, 174, 102, 0); }
}

body[data-mode="dark"] #tutor-stage .ts-modal-card { background: #1c1d22; border-color: rgba(255, 255, 255, 0.08); }
body[data-mode="dark"] #tutor-stage .ts-modal-text { background: #26272d; color: var(--ts-ink); border-color: rgba(255, 255, 255, 0.1); }
body[data-mode="dark"] #tutor-stage .ts-modal-opt { border-color: rgba(255, 255, 255, 0.1); color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .ts-modal-ghost { background: rgba(255, 255, 255, 0.08); }
body[data-mode="dark"] #tutor-stage .ts-modal-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* ----------------------------------------------------------------------------
   Skill-check arc (Task #254 / T6): transition gate, per-question dots, and
   the X/total result screen. Synthesized by TutorStageController (not authored
   beats), styled to match the surrounding paper-card lesson surface.
---------------------------------------------------------------------------- */
#tutor-stage .ts-scdots {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin: 0 0 14px;
}
#tutor-stage .ts-scdot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--ts-line);
  transition: background .2s ease, transform .2s ease;
}
#tutor-stage .ts-scdot.done { background: var(--ts-green); }
#tutor-stage .ts-scdot.on {
  background: var(--ts-accent);
  transform: scale(1.25);
}

/* Transition gate before the first skill-check question */
#tutor-stage .ts-skillintro {
  text-align: center;
  padding: 26px 22px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#tutor-stage .ts-skillintro-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ts-accent-soft);
}
#tutor-stage .ts-skillintro-title {
  margin: 2px 0 0;
  font-family: var(--ts-display, "Fraunces", serif);
  font-size: 26px;
  color: var(--ts-ink);
}
#tutor-stage .ts-skillintro-sub {
  margin: 0 0 8px;
  color: var(--ts-muted);
  font-size: 15px;
}
#tutor-stage .ts-skillintro-go { min-width: 150px; }

/* Result screen after the last skill-check question */
#tutor-stage .ts-scresult {
  text-align: center;
  padding: 26px 22px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#tutor-stage .ts-scresult-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ts-accent-soft);
}
#tutor-stage .ts-scresult-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 6px 0 2px;
}
#tutor-stage .ts-scresult-num {
  font-family: var(--ts-display, "Fraunces", serif);
  font-size: 58px;
  line-height: 1;
  font-weight: 600;
  color: var(--ts-green);
}
#tutor-stage .ts-scresult-of {
  font-size: 24px;
  font-weight: 600;
  color: var(--ts-muted);
}
#tutor-stage .ts-scresult-headline {
  margin: 2px 0 12px;
  font-family: var(--ts-display, "Fraunces", serif);
  font-size: 22px;
  color: var(--ts-ink);
}
#tutor-stage .ts-scresult-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
#tutor-stage .ts-scresult-actions .ts-btn { min-width: 140px; }

body[data-mode="dark"] #tutor-stage .ts-scdot { background: rgba(255, 255, 255, 0.16); }
body[data-mode="dark"] #tutor-stage .ts-scdot.done { background: var(--ts-green); }

/* ==================================================================
   NEW FRACTION WIDGETS (rebuild) — whole-number terms in tiles,
   multi-option compare cards, and the overlap-grid area model.
   ================================================================== */

/* --- tiles: a whole-number term (e.g. "2 = 2/1 read as 2 wholes") --- */
/* A single big cell that vertically centers to the fraction midline beside
   it so "2 × 1/3" and "2/3" both sit on one baseline. */
#tutor-stage .ts-tile-whole {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 0 4px;
  font: 800 40px "Fraunces", Georgia, serif; color: var(--ts-ink);
  line-height: 1.05;
}

/* --- compare: abstract fraction shown inside an option card --- */
#tutor-stage .ts-cmp-frac {
  display: inline-flex; flex-direction: column; align-items: center;
  font: 800 34px "Fraunces", Georgia, serif; color: var(--ts-ink);
  line-height: 1.05;
}
#tutor-stage .ts-cmp-n,
#tutor-stage .ts-cmp-d { padding: 0 6px; }
#tutor-stage .ts-cmp-bar {
  width: 46px; height: 4px; border-radius: 4px;
  background: var(--ts-ink); margin: 5px 0;
}
/* figure-based option (bar/pie/regions) rendered as SVG inside the card */
#tutor-stage .ts-fw-opt-vis {
  width: 100%; max-width: 150px; display: flex; justify-content: center;
}
#tutor-stage .ts-fw-opt-vis svg { width: 100%; height: auto; display: block; }

/* >2 options wrap into a responsive grid instead of a single row */
#tutor-stage .ts-fw-compare-multi {
  flex-flow: row wrap; gap: 12px; max-width: 520px;
}
#tutor-stage .ts-fw-compare-multi .ts-fw-opt {
  flex: 0 1 140px; max-width: 160px;
}

/* --- overlapGrid: rows×cols area model, tap cells to shade --- */
#tutor-stage .ts-fw-overlap .ts-frac-grid { max-width: 300px; }
#tutor-stage .ts-gridcell {
  fill: #ffffff;
  stroke: var(--ts-shade-stroke); stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  transition: fill .15s ease;
}
#tutor-stage .ts-gridcell.on { fill: var(--ts-shade-blue); }
#tutor-stage .ts-gridcell.ts-tappable { cursor: pointer; }
#tutor-stage .ts-gridcell.ts-tappable:hover { fill: #e7edfd; }
#tutor-stage .ts-gridcell.ts-tappable.on:hover { fill: #5b7ce8; }
/* faint tint guides that hint the a-columns / b-rows behind the cells */
#tutor-stage .ts-grid-guide { pointer-events: none; }
#tutor-stage .ts-grid-guide.guide-a { fill: rgba(181, 101, 29, 0.14); }
#tutor-stage .ts-grid-guide.guide-b { fill: rgba(109, 140, 240, 0.16); }

/* --- dark mode --- */
body[data-mode="dark"] #tutor-stage .ts-tile-whole,
body[data-mode="dark"] #tutor-stage .ts-cmp-frac { color: #f3e7d3; }
body[data-mode="dark"] #tutor-stage .ts-cmp-bar { background: #f3e7d3; }
body[data-mode="dark"] #tutor-stage .ts-gridcell {
  fill: #2b2c33; stroke: rgba(255, 255, 255, 0.22);
}
body[data-mode="dark"] #tutor-stage .ts-gridcell.on { fill: var(--ts-shade-blue); }
body[data-mode="dark"] #tutor-stage .ts-gridcell.ts-tappable:hover { fill: rgba(109, 140, 240, 0.28); }
body[data-mode="dark"] #tutor-stage .ts-grid-guide.guide-a { fill: rgba(181, 101, 29, 0.22); }
body[data-mode="dark"] #tutor-stage .ts-grid-guide.guide-b { fill: rgba(109, 140, 240, 0.24); }

/* =============================================================
 * CALCULUS / NEGATIVE-NUMBERS WIDGETS: signedTiles, intTiles, pick-text,
 * line-graph figure, graphTrace, curveTrace, tangentSeek, regionPick, slopeFit
 * ============================================================= */
#tutor-stage .ts-st-row { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0 4px; }
#tutor-stage .ts-st-col { display: flex; flex-direction: column; align-items: center; min-width: 56px; }
#tutor-stage .ts-st-val { font-weight: 700; font-size: 20px; margin-bottom: 6px; color: #2f2a25; font-variant-numeric: tabular-nums; }
#tutor-stage .ts-st-box { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 10px; border-radius: 12px; background: rgba(0,0,0,0.035); min-height: 46px; }
#tutor-stage .ts-st-col.is-slot .ts-st-box { outline: 2px dashed rgba(0,0,0,0.18); outline-offset: 2px; background: rgba(255,255,255,0.65); }
#tutor-stage .ts-st-stack { display: flex; flex-direction: column; gap: 4px; }
#tutor-stage .ts-st-tile { width: 30px; height: 24px; border-radius: 6px; border: 1.5px solid; font-size: 15px; font-weight: 800; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
#tutor-stage .ts-st-tile.is-plus  { background: #e9f7ee; border-color: #3aa564; color: #22713f; }
#tutor-stage .ts-st-tile.is-minus { background: #fdedec; border-color: #d15b52; color: #a53c34; }
#tutor-stage .ts-st-tile.is-paired { opacity: 0.38; }
#tutor-stage .ts-st-col:not(.is-slot) .ts-st-tile { cursor: default; }
#tutor-stage .ts-st-op { font-size: 22px; font-weight: 700; color: #4b453f; padding: 0 2px; margin-top: 22px; }
#tutor-stage .ts-st-handle { width: 34px; height: 22px; border-radius: 11px; border: 1.5px dashed rgba(0,0,0,0.3); background: #fff; font-weight: 800; cursor: grab; touch-action: none; display: flex; align-items: center; justify-content: center; }
#tutor-stage .ts-st-handle.is-plus  { color: #22713f; }
#tutor-stage .ts-st-handle.is-minus { color: #a53c34; }
#tutor-stage .ts-st-handle:active { cursor: grabbing; background: #f3efe9; }
#tutor-stage .ts-it-eq { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 22px; font-weight: 700; color: #2f2a25; padding: 10px 0 14px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
#tutor-stage .ts-it-text { white-space: pre; }
#tutor-stage .ts-it-blank { min-width: 52px; height: 40px; border-radius: 10px; border: 2px dashed rgba(0,0,0,0.28); background: rgba(255,255,255,0.7); font-size: 20px; font-weight: 800; cursor: pointer; }
#tutor-stage .ts-it-blank.filled { border-style: solid; border-color: #b98a4e; background: #fff7ec; }
#tutor-stage .ts-it-blank.is-answer { border-color: #3aa564; background: #e9f7ee; }
#tutor-stage .ts-it-tray { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
#tutor-stage .ts-it-tile { min-width: 56px; height: 42px; border-radius: 10px; border: 1.5px solid rgba(0,0,0,0.25); background: #fff; font-size: 19px; font-weight: 800; cursor: pointer; padding: 0 12px; }
#tutor-stage .ts-it-tile.used { opacity: 0.35; cursor: default; }
#tutor-stage .ts-fw-pick-text { font-size: 22px; font-weight: 800; color: #2f2a25; padding: 18px 8px; text-align: center; font-variant-numeric: tabular-nums;
  /* long option labels wrap instead of widening the grid track (Task #349) */
  max-width: 100%; overflow-wrap: break-word; }
@media (max-width: 720px) {
  #tutor-stage .ts-fw-pick-text { font-size: 18px; padding: 12px 4px; }
  #tutor-stage .ts-fw-pick.ts-fw-pick-2col { gap: 10px; }
  #tutor-stage .ts-fw-pick.ts-fw-pick-3col { gap: 8px; }
}

/* --- graph widgets: line-graph figure, graphTrace, curveTrace, tangentSeek, slopeFit --- */
#tutor-stage .ts-gr-fig { display: flex; justify-content: center; margin: 2px 0 10px; }
#tutor-stage .ts-gr-svg { width: min(380px, 88%); height: auto; display: block; margin: 0 auto; user-select: none; }
#tutor-stage .ts-gt { touch-action: none; }
#tutor-stage .ts-gt-handle { cursor: grab; }
#tutor-stage .ts-gt-handle:active { cursor: grabbing; }
#tutor-stage .ts-gt-readout { text-align: center; font-size: 15px; color: #565c66; font-family: "SF Mono", ui-monospace, monospace; margin-bottom: 2px; }
#tutor-stage .ts-rp-region { cursor: pointer; }
#tutor-stage .ts-sf-eq { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 20px; }
#tutor-stage .ts-sf-text { color: var(--ts-ink, #20242a); }
#tutor-stage .ts-sf-input { width: 84px; height: 48px; border: 1.5px solid #c9ced6; border-radius: 10px; font-size: 20px; text-align: center; outline: none; background: #fff; color: inherit; font-family: inherit; }
#tutor-stage .ts-sf-input:focus { border-color: #4f6ef7; box-shadow: 0 0 0 3px rgba(79,110,247,.15); }
#tutor-stage .ts-sf-input.is-answer { border-color: #2f9e63; color: #2f9e63; background: #f0faf4; }

/* dark-mode text legibility for the new widgets (figures keep light plot ink) */
body[data-mode="dark"] #tutor-stage .ts-st-val { color: #ece7df; }
body[data-mode="dark"] #tutor-stage .ts-st-op { color: #d8d2c8; }
body[data-mode="dark"] #tutor-stage .ts-it-eq { color: #ece7df; }
body[data-mode="dark"] #tutor-stage .ts-fw-pick-text { color: #ece7df; }

/* --- board figures: illustrations ON teach cards (1:1 with Brilliant intro pages) --- */
#tutor-stage .ts-board-fig { display: flex; justify-content: center; margin: 4px 0 12px; }
#tutor-stage .ts-scene-fill { display: flex; align-items: center; justify-content: center; gap: 30px; margin: 4px 0 16px; }
#tutor-stage .ts-scene-fill .ts-gr-svg { width: min(320px, 58%); }
#tutor-stage .ts-bottle { width: 74px; height: auto; flex: 0 0 auto; }
#tutor-stage .ts-heading-sub { font-size: 16px; color: #565c66; margin: 12px auto 0; max-width: 46ch; line-height: 1.55; text-align: center; }
body[data-mode="dark"] #tutor-stage .ts-heading-sub { color: #c9c2b8; }
#tutor-stage .ts-fw-pickthumb .ts-gr-svg { width: 170px; height: auto; }
/* equation boards: Brilliant-scale math type, never clip */
#tutor-stage .ts-equation { max-width: 100%; overflow-x: auto; }
#tutor-stage .ts-equation .katex { font-size: 24px; }
#tutor-stage .ts-board .ts-equation .katex, #tutor-stage .ts-card .ts-equation .katex { font-size: 24px !important; }
#tutor-stage .ts-ps-point { cursor: pointer; }
#tutor-stage .ts-board-fig-stack { flex-direction: column; gap: 6px; }
#tutor-stage .ts-board-fig-stack .ts-gr-svg { width: min(300px, 78%); }

/* ---- dual-panel figure toggle (f' / f'' switcher) ---- */
#tutor-stage .ts-fig-toggle { text-align: center; }
#tutor-stage .ts-fig-panel[hidden] { display: none; }
#tutor-stage .ts-fig-tabs { display: flex; justify-content: center; gap: 12px; margin-top: 8px; }
#tutor-stage .ts-fig-tab {
  min-width: 48px; padding: 9px 13px; border-radius: 10px;
  border: 1.5px solid #d6d9e0; background: #fff; color: #20242a;
  font-weight: 700; font-size: 14px; cursor: pointer;
  box-shadow: 0 2.5px 0 #d6d9e0; font-family: inherit;
}
#tutor-stage .ts-fig-tab.active { background: #20242a; color: #fff; border-color: #20242a; box-shadow: 0 2.5px 0 #000; }
#tutor-stage .ts-fw-stage .ts-gr-fig.ts-board-fig-stack svg, #tutor-stage .ts-board-fig-stack .ts-fig-panel svg { display: block; margin: 0 auto; }

/* bug fix (v2 handoff #3): big tile banks (4+) wrap into a tidy 2-col grid */
#tutor-stage .ts-it-tray.is-grid { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 10px; max-width: 340px; margin: 0 auto; }
#tutor-stage .ts-it-tray.is-grid .ts-it-tile { width: 100%; }

/* ---------------------------------------------------------------------------
   Calculus v3 handoff — 2 genuinely new widget classes (numFill formula line +
   riemann/generic range slider). Every other new widget (secantSlider,
   tangentSign, areaSweep, seqSlider, seqFill, deltaSeek, endpointSeek,
   poleSlider, taylorSlider) reuses existing graph/slider/slopeFit primitives
   already styled above. Prefixed #tutor-stage to match prod scoping.
--------------------------------------------------------------------------- */
#tutor-stage .ts-nf-formula { text-align: center; font-size: 25px; color: var(--ts-ink, #20242a); margin: 6px 0 20px; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
#tutor-stage .ts-rs-slider { display: block; width: 62%; max-width: 340px; margin: 16px auto 4px; accent-color: #4f6ef7; cursor: pointer; height: 22px; }

/* =================================================================
 * VECTORS & MATRICES WIDGETS — ported verbatim from the audited
 * handoff (LGA-1 GO). Vector/matrix widget styles + polish pass.
 * ================================================================= */
/* vecFill — vector component fill-in (Vectors & Matrices) */
.ts-vf-row { display: flex; align-items: center; justify-content: center; margin-top: 16px;
  /* Wide vector sums scroll instead of clipping (goldframe Task #349). */
  justify-content: safe center; max-width: 100%; overflow-x: auto; }
.ts-vf-mat { position: relative; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 8px 16px; }
.ts-vf-mat::before, .ts-vf-mat::after { content: ""; position: absolute; top: 0; bottom: 0; width: 9px; border: 2.5px solid #3d434c; }
.ts-vf-mat::before { left: 0; border-right: none; border-radius: 2px 0 0 2px; }
.ts-vf-mat::after { right: 0; border-left: none; border-radius: 0 2px 2px 0; }
.ts-vf-input { width: 64px; text-align: center; }
.ts-vf-fixed { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 40px; font-size: 17px; font-weight: 600; color: #20242a; }

/* vecTiles — drag number tiles into a [x/y] column vector */
.ts-vt-brk { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 16px 0 6px;
  /* Wide bracket equations scroll instead of clipping (goldframe Task #349 —
     same idiom as .ts-equation; `safe center` keeps the start reachable). */
  justify-content: safe center; max-width: 100%; overflow-x: auto; }
.ts-vt-bracket { font-size: 68px; font-weight: 200; color: #20242a; line-height: 0.7; }
.ts-vt-col { display: flex; flex-direction: column; gap: 8px; }
.ts-vt-slot { width: 52px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; color: #20242a; border-radius: 8px; box-sizing: border-box; }
.ts-vt-slot.is-empty { border: 2px dashed #c2c8d2; }
.ts-vt-slot.is-filled { border: 2px solid #4f6ef7; background: #eef1fe; cursor: pointer; }
.ts-vt-slot.is-fixed { border: 2px solid #dfe3e9; background: #f4f6f9; }
.ts-vt-slot.is-answer { border-color: #4a9e5c; background: #eaf6ec; }
.ts-vt-pal { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px auto 0; max-width: 430px; }
.ts-vt-tile { min-width: 40px; height: 40px; padding: 0 8px; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; color: #20242a; background: #fff; border: 1.5px solid #dfe3e9; border-radius: 8px; cursor: grab; user-select: none; touch-action: none; box-sizing: border-box; }
.ts-vt-tile:hover { border-color: #4f6ef7; }
.ts-vt-tile:active { cursor: grabbing; }
.ts-vt-sbrk { display: inline-flex; align-items: center; gap: 6px; }
/* Compact vector/matrix bracket metrics on phones so typical rows FIT the
   414px card instead of scrolling (goldframe Task #349 baseline fix). */
@media (max-width: 720px) {
  .ts-vt-brk { gap: 4px; }
  .ts-vt-bracket { font-size: 48px; }
  .ts-vt-slot { width: 40px; height: 38px; font-size: 17px; }
  .ts-vt-static { width: 32px; font-size: 16px; }
  .ts-vt-op { font-size: 19px; margin: 0 2px; }
  .ts-vt-scalar { font-size: 19px; margin: 0 4px 0 2px; }
  .ts-cr-scal { font-size: 18px; }
}
/* L17 systems-of-equations line widget (sysLines) */
.ts-sl { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ts-sl-legend { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.ts-sl-row { display: flex; align-items: center; gap: 8px; max-width: 100%; overflow-x: auto; }
.ts-sl-slash { width: 18px; height: 18px; flex: none; }
.ts-sl-eq { font-size: 17px; font-weight: 600; color: #2a2f37; letter-spacing: 0.2px; }
.ts-sl-point { display: flex; align-items: center; gap: 4px; }
.ts-sl-paren { font-size: 30px; font-weight: 400; color: #3a3f47; line-height: 1; }
/* L17 matrices-as-systems / solving-systems widget (sysSolve) */
.ts-ss { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ts-ss-top { margin-bottom: 2px; }
.ts-ss-connect { font-size: 14px; color: #565c66; font-style: italic; margin: 2px 0; }
.ts-ss-sys { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.ts-ss-row { display: flex; align-items: center; gap: 5px; max-width: 100%; overflow-x: auto; }
.ts-ss-var { font-size: 20px; font-style: italic; font-weight: 600; color: #20242a; }
.ts-ss-static { min-width: 24px; text-align: center; font-size: 20px; font-weight: 600; color: #20242a; }
.ts-ss-cslot { width: 44px; height: 40px; }
.ts-ss-and { font-size: 16px; color: #565c66; margin: 0 6px; }
.ts-ss-solrow { margin-top: 6px; }
.ts-vt-static { width: 46px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 600; color: #20242a; }
.ts-vt-op { font-size: 24px; font-weight: 500; color: #20242a; margin: 0 4px; }
.ts-vt-scalar { font-size: 24px; font-weight: 600; color: #20242a; margin: 0 6px 0 2px; display: inline-flex; align-items: center; }
.ts-vf-scalar { width: 40px; margin-right: 6px; }
.ts-vt-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: 18px; line-height: 1.05; }
.ts-vt-frac-num { border-bottom: 1.6px solid #20242a; padding: 0 4px; }
.ts-vt-frac-den { padding: 0 4px; }
/* combResult: fixed scalar coefficient before a bracket (tight to the bracket) */
.ts-cr-scal { font-size: 22px; font-weight: 600; margin: 0 2px 0 4px; }
/* symFill: symbolic / statement tile-fill (L9.2) */
.ts-sf2 { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ts-sf2-board { max-width: 500px; margin: 6px auto 2px; }
.ts-sf2-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 3px; font-size: 20px; line-height: 1.9; color: #20242a; margin: 8px 0; }
.ts-sf2-txt { white-space: pre; }
.ts-sf2-vec { position: relative; font-style: italic; font-weight: 600; padding: 0 1px; }
.ts-sf2-vec::after { content: "→"; position: absolute; left: -1px; right: 1px; top: -0.62em; font-size: 0.62em; font-style: normal; font-weight: 700; text-align: center; line-height: 1; letter-spacing: -0.04em; pointer-events: none; }
.ts-sf2-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: 15px; line-height: 1.02; margin: 0 2px; }
.ts-sf2-frac .ts-sf2-num { border-bottom: 1.5px solid #20242a; padding: 0 4px; }
.ts-sf2-frac .ts-sf2-den { padding: 0 4px; }
.ts-sf2-slot { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 34px; padding: 0 6px; border-radius: 8px; vertical-align: middle; box-sizing: border-box; font-size: 18px; font-weight: 600; }
.ts-sf2-slot.is-empty { border: 2px dashed #c2c8d2; }
.ts-sf2-slot.is-filled { border: 2px solid #4f6ef7; background: #eef1fe; cursor: pointer; }
.ts-sf2-slot.is-answer { border-color: #4a9e5c; background: #eaf6ec; }
.ts-sf2-pal { max-width: 470px; }
.ts-sf2-tile { min-width: 46px; padding: 0 10px; }
/* symFill column-vector token (e.g. [a;b], [1;0]) — compact, inline with the row */
.ts-sf2-col { vertical-align: middle; margin: 0 2px; }
.ts-sf2-col .ts-vt-bracket { font-size: 40px; font-weight: 200; }
.ts-sf2-col .ts-vt-col { gap: 0; }
.ts-sf2-col .ts-vt-static { width: auto; min-width: 20px; height: 26px; padding: 0 6px; font-size: 17px; }

/* Transforming Vectors (L10): rows of "op conn [slot]" + cascading tile palette */
.ts-xf-rows { display: flex; flex-direction: column; gap: 10px; margin: 16px auto 4px; width: fit-content; }
.ts-xf-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.ts-xf-num { font-size: 13px; font-weight: 600; color: #98a0ac; min-width: 14px; text-align: right; }
.ts-xf-verb { font-size: 18px; font-weight: 700; color: #4f6ef7; margin: 0; }
.ts-xf-verb.ts-xf-chosen { cursor: pointer; border-bottom: 1.5px dashed #b9c2d6; }
.ts-xf-conn { font-size: 16px; font-weight: 500; color: #6b7280; margin: 0 1px; }
.ts-xf-opslot, .ts-xf-pslot { min-width: 46px; width: auto; height: 40px; padding: 0 12px; font-size: 16px; font-weight: 600; }
.ts-xf-opslot.is-empty, .ts-xf-pslot.is-empty { min-width: 64px; }
.ts-xf-pal { min-height: 40px; }
.ts-xf-tile { min-width: 44px; padding: 0 12px; font-size: 15px; }

/* Transforming Basis Vectors (L10.2): [1,0] ↦ [_,_] typed image rows */
.ts-bm-rows { display: flex; flex-direction: column; gap: 14px; margin: 18px auto 4px; width: fit-content; }
.ts-bm-row { display: flex; align-items: center; gap: 10px; }
.ts-bm-arrow { font-size: 22px; color: #6b7280; margin: 0 4px; }
.ts-bm-input { width: 44px; height: 34px; text-align: center; font-size: 17px; font-weight: 600; color: #20242a; border: 2px dashed #c2c8d2; border-radius: 7px; background: #fff; box-sizing: border-box; margin: 2px 0; }
.ts-bm-input:focus { outline: none; border-style: solid; border-color: #4f6ef7; background: #f5f7ff; }
.ts-bm-input.is-answer { border-style: solid; border-color: #4a9e5c; background: #eaf6ec; }
/* Transforming Basis Vectors (L10.2) tile mode: basis-image slots + surd tile palette */
.ts-bm-slot { width: 54px; height: 46px; margin: 2px 0; }
.ts-bm-pal { max-width: 460px; margin-top: 14px; }
.ts-bm-tile { min-width: 46px; height: 46px; padding: 0 8px; }
.ts-bm-val { display: inline-flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; }
.ts-bm-rad { display: inline-flex; align-items: flex-start; }
.ts-bm-radn { border-top: 1.6px solid currentColor; padding: 0 1px; margin-left: 1px; line-height: 1.15; }
.ts-bm-frac { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.02; font-size: 14px; }
.ts-bm-frac .ts-bm-fnum { border-bottom: 1.6px solid currentColor; padding: 0 3px 1px; }
.ts-bm-frac .ts-bm-fden { padding: 1px 3px 0; }
/* Linear Transformations (L10.3): given-mapping rows above the solve row */
.ts-lm-given { opacity: 0.92; }
.ts-lm-given .ts-vt-static { font-size: 16px; }
.ts-lm-solve { margin-top: 4px; padding-top: 12px; border-top: 1.5px solid #eceef2; }
/* Transforming Combinations (L10.4): symbolic T(e₁)/T(e₂) combination fill */
.ts-cm-given { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 14px 0 2px; font-size: 15px; }
.ts-cm-eq { flex-wrap: wrap; }
.ts-cm-tlab { font-size: 17px; font-weight: 700; margin: 0 3px; white-space: nowrap; }
.ts-cm-input { width: 54px; text-align: center; margin: 0 4px; }
/* Matrices as Transformations (L11): 2×2 matrix bracket with tile-fill cells */
.ts-mg-mat { display: flex; align-items: stretch; justify-content: center; gap: 4px; margin: 16px 0 6px; }
.ts-mg-brk { font-size: 64px; font-weight: 300; line-height: 1; display: flex; align-items: center; color: #20242a; }
.ts-mg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; align-items: center; justify-items: center; padding: 4px 6px; }
.ts-mg-cell { width: 48px; height: 44px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.ts-mg-static { font-size: 22px; font-weight: 600; color: #20242a; }
/* Transforming via Matrices (L11.2): stacked "M·v = [result]" equations */
.ts-mv-eqs { display: flex; flex-direction: column; gap: 16px; align-items: center; margin: 16px 0 6px; max-width: 100%; }
.ts-mv-eq { display: flex; align-items: center; gap: 3px;
  /* Wide matrix-vector equations scroll instead of clipping (Task #349). */
  max-width: 100%; overflow-x: auto; }
.ts-mv-brk { font-size: 46px; font-weight: 300; line-height: 1; display: flex; align-items: center; color: #20242a; }
.ts-mv-mat, .ts-mv-vec { display: inline-flex; align-items: stretch; }
.ts-mv-mgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 12px; align-items: center; justify-items: center; padding: 0 3px; }
.ts-mv-vcol { display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; padding: 0 2px; }
.ts-mv-num { min-width: 20px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 600; color: #20242a; }
.ts-mv-slot { width: 40px; height: 34px; font-size: 18px; }
.ts-mv-input { width: 46px; height: 34px; text-align: center; font-size: 18px; font-weight: 600; color: #20242a; border: 2px dashed #c2c8d2; border-radius: 7px; background: #fff; box-sizing: border-box; margin: 2px 0; }
.ts-mv-input:focus { outline: none; border-style: solid; border-color: #4f6ef7; background: #f5f7ff; }
.ts-mv-input.is-answer { border-style: solid; border-color: #4a9e5c; background: #eaf6ec; }
/* Matrix as Multiple Vectors (L12.2): [matrix] ↦ [result matrix] */
.ts-mc-eq { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 6px;
  /* Wide matrix equations scroll instead of clipping (goldframe Task #349). */
  justify-content: safe center; max-width: 100%; overflow-x: auto; }
.ts-mc-mat { display: inline-flex; align-items: stretch; }
.ts-mc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; align-items: center; justify-items: center; padding: 3px 4px; }
.ts-mc-cell { width: 38px; height: 36px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; border-radius: 6px; }
.ts-mc-static { font-size: 18px; font-weight: 600; color: #20242a; }
.ts-mc-slot { font-size: 17px; }
/* Compact matrix-equation metrics on phones so a [2×2]+[2×2]=[2×2] row FITS
   the 414px card instead of scrolling (goldframe Task #349 baseline fix). */
@media (max-width: 720px) {
  .ts-mc-eq { gap: 5px; }
  .ts-mv-brk { font-size: 36px; }
  .ts-mc-cell { width: 30px; height: 32px; }
  .ts-mc-slot { font-size: 15px; }
  .ts-mc-grid { gap: 3px; padding: 2px 3px; }
  /* vecFill / matrix-vector / dot-product compaction (Task #349) */
  .ts-vf-input { width: 46px; }
  .ts-vf-fixed { width: 46px; height: 36px; font-size: 15px; }
  .ts-vf-mat { padding: 6px 10px; gap: 6px; }
  .ts-mv-num { font-size: 16px; height: 26px; }
  .ts-mv-mgrid { gap: 2px 8px; }
  .ts-ss-cslot { width: 38px; height: 36px; }
  /* symFill statement text may wrap on phones (desktop keeps exact pre) */
  .ts-sf2-txt { white-space: pre-wrap; }
}
.ts-mc-arrow { font-size: 24px; color: #6b7280; margin: 0 4px; }
/* Matrix arithmetic (L12.3 A±B, L12.4 k·A) */
.ts-mo-op { font-size: 24px; font-weight: 500; color: #20242a; margin: 0 4px; }
.ts-mo-scalar { font-size: 22px; font-weight: 700; color: #20242a; margin: 0 4px 0 0; }
.ts-mo-input { width: 40px; height: 34px; text-align: center; font-size: 17px; font-weight: 600; color: #20242a; border: 2px dashed #c2c8d2; border-radius: 6px; background: #fff; box-sizing: border-box; }
.ts-mo-input:focus { outline: none; border-style: solid; border-color: #4f6ef7; background: #f5f7ff; }
.ts-mo-input.is-answer { border-style: solid; border-color: #4a9e5c; background: #eaf6ec; }
/* Matrix multiplication (L13): highlight the row of A and column of B feeding the active result cell */
.ts-mm-eq { gap: 6px; }
.ts-mm-src { transition: background 0.15s ease, color 0.15s ease; }
.ts-mm-hl { background: #e6ecff; color: #3352d8; }
/* Border-drawn brackets stretch to any row count (matMul handles non-square matrices) */
.ts-mm-brk { width: 7px; align-self: stretch; box-sizing: border-box; }
.ts-mm-brk-l { border: 2.4px solid #20242a; border-right: none; border-radius: 4px 0 0 4px; margin-right: 3px; }
.ts-mm-brk-r { border: 2.4px solid #20242a; border-left: none; border-radius: 0 4px 4px 0; margin-left: 3px; }
/* Sizing a matrix product (L13.3): drag handles resize the empty result grid to m×p */
.ts-sz-wrap { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 20px 0 26px; flex-wrap: wrap; }
.ts-sz-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ts-sz-dim { font-size: 15px; font-weight: 700; color: #6b7280; letter-spacing: 0.03em; }
.ts-sz-dim.is-live { color: #3352d8; }
.ts-sz-mat { display: inline-flex; align-items: stretch; position: relative; }
.ts-sz-grid { display: grid; gap: 5px; padding: 5px 6px; }
.ts-sz-cell { width: 26px; height: 26px; background: #e5e8ef; border-radius: 5px; }
.ts-sz-result .ts-sz-cell { background: #eaeefb; }
.ts-sz-op { font-size: 22px; font-weight: 500; color: #20242a; }
.ts-sz-handle { position: absolute; background: #b9c2da; border-radius: 9px; cursor: grab; touch-action: none; transition: background 0.12s; }
.ts-sz-handle:hover { background: #97a6ce; }
.ts-sz-handle:active { cursor: grabbing; background: #6f83b8; }
.ts-sz-h-r { width: 9px; height: 32px; right: -14px; top: 50%; transform: translateY(-50%); }
.ts-sz-h-b { height: 9px; width: 32px; bottom: -14px; left: 50%; transform: translateX(-50%); }
.ts-sz-result.is-answer .ts-sz-cell { background: #d7ecdb; }
/* Determinants — transformed areas (L15): det( [matrix] ) = [input] under a shaded parallelogram */
.ts-da-eq { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.ts-da-det { font-size: 18px; font-style: italic; font-weight: 600; color: #20242a; }
.ts-da-input { width: 52px; height: 36px; text-align: center; font-size: 17px; font-weight: 600; color: #20242a; border: 2px dashed #c2c8d2; border-radius: 6px; background: #fff; box-sizing: border-box; }
.ts-da-input:focus { outline: none; border-style: solid; border-color: #4f6ef7; background: #f5f7ff; }
.ts-da-input.is-answer { border-style: solid; border-color: #4a9e5c; background: #eaf6ec; }
.ts-da-slot { width: 52px; height: 36px; font-size: 17px; }
/* Computing the inverse (L16.4): (1/[det]) · [adj] · [A] = [I] */
.ts-if-eq { flex-wrap: wrap; gap: 6px; }
.ts-if-frac { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; margin-right: 2px; }
.ts-if-num { font-size: 17px; font-weight: 600; color: #20242a; line-height: 1; }
.ts-if-bar { width: 46px; height: 2px; background: #20242a; }
.ts-if-detslot { width: 40px; height: 32px; font-size: 16px; }

/* Raster lesson figures (e.g. Higgsfield-generated 3D visuals) */
.ts-board-img { display: flex; justify-content: center; margin: 0 auto 4px; }
.ts-board-img img {
  max-width: 100%;
  max-height: 300px;
  height: auto;
  border-radius: 16px;
  display: block;
  mix-blend-mode: multiply;   /* white image bg blends into white card; full detail preserved */
}

/* Pseudocode block in a problem */
.ts-code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.55;
  text-align: left; white-space: pre-wrap;
  background: #2a2520; color: #e9e2d4;
  border-radius: 12px; padding: 16px 18px; margin: 4px auto 6px;
  max-width: 520px; overflow-x: auto;
  box-shadow: 0 2px 10px rgba(42,37,32,0.12);
}

/* pick: 2x2 grid for 4 short options (matches Brilliant's numeric MCQ layout) */
#tutor-stage .ts-fw-pick.ts-fw-pick-2col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
#tutor-stage .ts-fw-pick.ts-fw-pick-2col .ts-fw-pickopt { width: auto; min-width: 0; min-height: 64px; justify-content: center; }
/* pick: single-row 3-across for a 3-way categorical MCQ (Brilliant's Negative/Zero/Positive) */
#tutor-stage .ts-fw-pick.ts-fw-pick-3col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
#tutor-stage .ts-fw-pick.ts-fw-pick-3col .ts-fw-pickopt { width: auto; min-width: 0; min-height: 56px; justify-content: center; }

.ts-vt-coeffslot { align-self: center; margin: 0 3px; }

.ts-md-rows { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 14px; }
.ts-md-row { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.ts-md-label { font-family: "KaTeX_Math", serif; font-style: italic; color: #20242a; }
.ts-md-input { width: 72px; text-align: center; }

.ts-md-wide { width: 160px; }

.ts-md-brk { display: inline-flex; align-items: center; justify-content: center; margin: 4px auto 10px; }

/* Components from an angle (polarComp): v_x = r·cos(θ°), v_y = r·sin(θ°) */
.ts-pc-rows { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; margin: 16px auto 4px; width: max-content; }
.ts-pc-row { display: flex; align-items: center; gap: 4px; font-size: 21px; }
.ts-pc-lab { font-family: "KaTeX_Math", serif; font-style: italic; color: #20242a; white-space: nowrap; }
.ts-pc-lab sub { font-style: normal; }
.ts-pc-slot { min-width: 50px; height: 42px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 600; color: #20242a; border-radius: 8px; box-sizing: border-box; }
.ts-pc-slot.is-empty { border: 2px dashed #c2c8d2; }
.ts-pc-slot.is-filled { border: 2px solid #4f6ef7; background: #eef1fe; cursor: pointer; }
.ts-pc-slot.is-answer { border-color: #4a9e5c; background: #eaf6ec; }
.ts-pc-pal { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px auto 0; max-width: 430px; }
.ts-pc-tile { min-width: 42px; height: 40px; padding: 0 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; color: #20242a; background: #fff; border: 1.5px solid #dfe3e9; border-radius: 8px; cursor: grab; user-select: none; touch-action: none; box-sizing: border-box; }
.ts-pc-tile:hover { border-color: #4f6ef7; }
.ts-pc-tile:active { cursor: grabbing; }
.ts-pc-input { width: 66px; height: 44px; }
.ts-pc-colwrap { display: inline-flex; align-items: center; justify-content: center; gap: 2px; margin: 16px auto 6px; }
.ts-pc-col { display: flex; flex-direction: column; gap: 10px; padding: 4px 6px; }
.ts-pc-ccell { display: flex; align-items: center; justify-content: center; }
.ts-pc-cinput { width: 148px; height: 46px; font-size: 18px; }
.ts-pc-cinput::placeholder { color: #b6bcc6; font-size: 14px; font-style: italic; }
.ts-vb-eslot { min-width: 128px; height: 44px; font-size: 18px; font-weight: 600; padding: 0 10px; }

/* Scale to a target magnitude (vecScale) */
.ts-vs-row { display: inline-flex; align-items: center; gap: 10px; margin: 16px auto 6px; justify-content: center;
  /* Wide dot-product rows scroll instead of clipping (Task #349). */
  max-width: 100%; overflow-x: auto; }
.ts-vs-slot { min-width: 48px; height: 46px; align-self: center; }
.ts-vs-res { color: #3aa76d; }
.ts-vs-input { width: 66px; height: 46px; align-self: center; }

/* ── Polish pass (supervisor QA): motion, drag affordance, ≥44px tap targets ── */
.ts-vt-tile, .ts-pc-tile { height: 44px; transition: border-color .12s ease, box-shadow .12s ease, transform .08s ease, background .12s ease; }
.ts-vt-tile:hover, .ts-pc-tile:hover { border-color: #4f6ef7; box-shadow: 0 2px 7px rgba(31,42,68,.13); transform: translateY(-1px); }
.ts-vt-tile:active, .ts-pc-tile:active { transform: translateY(0) scale(.95); box-shadow: 0 1px 2px rgba(31,42,68,.10); }
.ts-vt-slot, .ts-pc-slot { transition: border-color .14s ease, background .14s ease, box-shadow .14s ease; }
.ts-pc-slot { min-height: 44px; }
.ts-vt-slot.is-filled, .ts-pc-slot.is-filled { animation: tsSlotPop .17s ease; }
.ts-vt-slot.is-droptarget, .ts-pc-slot.is-droptarget { border-color: #4f6ef7 !important; background: #e3e9ff !important; box-shadow: 0 0 0 3px rgba(79,110,247,.18); transform: scale(1.04); }
.ts-bm-input { height: 44px; }
@keyframes tsSlotPop { 0% { transform: scale(.82); } 60% { transform: scale(1.07); } 100% { transform: scale(1); } }
@media (max-width: 720px) {
  .ts-vt-tile, .ts-pc-tile { height: 48px; min-width: 48px; font-size: 18px; }
  .ts-vt-slot, .ts-pc-slot { height: 48px; min-height: 48px; }
  .ts-bm-input { height: 48px; width: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .ts-vt-tile, .ts-pc-tile, .ts-vt-slot, .ts-pc-slot { transition: none; }
  .ts-vt-slot.is-filled, .ts-pc-slot.is-filled { animation: none; }
}

/* =====================================================================
   Task #302 — LECTURE STAGE: teacher visible & alive (hall split stage).
   Appended LAST on purpose: later rules win the layers above.
   - ONE SURFACE: body.tutor-stage-open stands ALL hall chrome down.
   - Desktop hall (#tutor-stage.ts-hall, >720px): the board docks RIGHT and
     the legend keeps a real column on the LEFT (the camera recenters him in
     that column via TutorStageController._applyStageCamera / setViewOffset).
     ≤720px keeps the existing overlay treatment untouched.
   ===================================================================== */

/* ---------- one clean surface (all widths; /learn pages lack these) ---- */
body.tutor-stage-open .top-bar,
body.tutor-stage-open .chat-zone,
body.tutor-stage-open .right-rail,
body.tutor-stage-open #switcher-hint,
body.tutor-stage-open .mic-button-container,
body.tutor-stage-open #mic-status {
  display: none !important;
}

/* ---------- split stage: legend column + docked board (desktop hall) --- */
@media (min-width: 721px) {
  #tutor-stage.ts-hall { --ts-legend-col: clamp(340px, 40vw, 620px); }

  #tutor-stage.ts-hall .ts-stage-board,
  #tutor-stage.ts-hall[data-focus="board"] .ts-stage-board,
  #tutor-stage.ts-hall[data-focus="tutor"] .ts-stage-board {
    left: var(--ts-legend-col); right: 24px;
    width: auto; transform: none;
    top: 76px; bottom: 128px;
  }

  /* Continue rail + assist + feedback center under the BOARD, not the page,
     so they can never collide with the transcript strip or checkpoint bar
     living in the legend column. */
  #tutor-stage.ts-hall .ts-actionbar { left: var(--ts-legend-col); right: 24px; }
  #tutor-stage.ts-hall .ts-assist,
  #tutor-stage.ts-hall .ts-feedback {
    left: calc(50vw + var(--ts-legend-col) / 2 - 12px);
  }

  /* transcript strip — docked in the legend's corner, never over the board.
     NO backdrop-filter here: it would re-blur the live canvas every frame. */
  #tutor-stage.ts-hall .ts-speech {
    left: 24px; right: auto; bottom: 24px;
    width: calc(var(--ts-legend-col) - 64px);
    max-width: none; max-height: 192px; overflow-y: auto;
    background: rgba(24, 16, 10, 0.84); color: #f7efe2;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px; border-bottom-left-radius: 14px;
    padding: 12px 16px 13px;
    box-shadow: 0 18px 44px -20px rgba(0, 0, 0, 0.55);
  }
  #tutor-stage.ts-hall .ts-speech-text { color: #f2e9da; }
  #tutor-stage.ts-hall .ts-speech-who {
    color: #e2b07a; display: flex; align-items: baseline; gap: 6px;
  }
  #tutor-stage.ts-hall .ts-speech-who::before {
    content: "●"; font-size: 8px; color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
  }
  #tutor-stage.ts-hall.is-speaking .ts-speech-who::before {
    color: var(--ts-green, #2fae66);
    animation: tsWhoPulse 1.3s ease-in-out infinite;
  }
  #tutor-stage.ts-hall.is-speaking .ts-speech-who::after {
    content: "— speaking"; font-weight: 700; letter-spacing: 0.08em;
    color: rgba(247, 239, 226, 0.55);
  }
  /* calm: no green ring floating over the legend while he talks */
  #tutor-stage.ts-hall.is-speaking .ts-speech {
    box-shadow: 0 18px 44px -20px rgba(0, 0, 0, 0.55);
  }

  /* checkpoint + resume dock ABOVE the strip, inside the legend column */
  #tutor-stage.ts-hall .ts-checkpoint,
  #tutor-stage.ts-hall .ts-resume {
    left: 24px; right: auto; transform: none;
    bottom: 232px;
    max-width: calc(var(--ts-legend-col) - 64px);
  }
  #tutor-stage.ts-hall .ts-checkpoint { flex-wrap: wrap; }

  /* stage chat/mic controls: top of the legend column (under the HUD) */
  #tutor-stage.ts-hall .ts-tutorbar {
    left: 24px; right: auto; top: 84px; bottom: auto;
  }
}

@keyframes tsWhoPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- alive opening: shimmering board skeleton ------------------- */
#tutor-stage .ts-skel-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
}
#tutor-stage .ts-skel {
  border-radius: 10px;
  background: linear-gradient(100deg,
    rgba(122, 86, 46, 0.10) 30%, rgba(122, 86, 46, 0.20) 50%,
    rgba(122, 86, 46, 0.10) 70%);
  background-size: 220% 100%;
  animation: tsSkelShimmer 1.5s ease-in-out infinite;
}
@keyframes tsSkelShimmer {
  from { background-position: 130% 0; }
  to { background-position: -130% 0; }
}
#tutor-stage .ts-skel-kicker { width: 130px; height: 12px; }
#tutor-stage .ts-skel-title { width: min(430px, 72%); height: 34px; }
#tutor-stage .ts-skel-line { width: min(520px, 84%); height: 15px; }
#tutor-stage .ts-skel-line.is-short { width: min(340px, 58%); }
#tutor-stage .ts-skel-fig {
  width: min(320px, 58%); height: 148px; border-radius: 18px; margin-top: 6px;
}
#tutor-stage .ts-skel-note {
  margin-top: 8px; font: 600 14px "Manrope", sans-serif; color: var(--ts-muted);
}
body[data-mode="dark"] #tutor-stage .ts-skel {
  background: linear-gradient(100deg,
    rgba(255, 255, 255, 0.06) 30%, rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.06) 70%);
  background-size: 220% 100%;
}

/* ---------- generation failure: the professor pauses ------------------- */
#tutor-stage .ts-error-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 8px;
}
#tutor-stage .ts-retry {
  margin-top: 14px; min-width: 220px; padding: 14px 26px;
  font: 700 16px "Manrope", sans-serif; border: none; border-radius: 14px;
  cursor: pointer; background: var(--ts-ink); color: var(--ts-paper);
  box-shadow: 0 14px 30px -14px rgba(20, 22, 40, 0.55);
  transition: transform .08s ease, filter .15s ease;
}
#tutor-stage .ts-retry:hover { filter: brightness(1.08); }
#tutor-stage .ts-retry:active { transform: translateY(1px); }
body[data-mode="dark"] #tutor-stage .ts-retry { background: #f1efe9; color: #16171b; }

/* ---------- template problems: slider (was unstyled on this surface) ---
   Fixes the jammed "0%100%" min/max labels and styles the new live
   consequence readout. Scoped to #tutor-stage; the practice overlay keeps
   its own lesson-mode.css styling. */
#tutor-stage .pl-instruction {
  font: 600 17px/1.5 "Manrope", sans-serif; color: var(--ts-ink);
  text-align: center; margin: 0 0 6px;
}
#tutor-stage .pl-slider-wrap {
  display: flex; flex-direction: column; gap: 10px;
  width: min(460px, 100%); margin: 6px auto 0;
}
#tutor-stage .pl-slider-readout {
  font: 800 26px "Fraunces", serif; color: var(--ts-ink);
  text-align: center; font-variant-numeric: tabular-nums;
}
#tutor-stage .pl-slider {
  width: 100%; height: 34px; cursor: pointer; accent-color: var(--ts-accent);
}
#tutor-stage .pl-slider-ends {
  display: flex; justify-content: space-between; gap: 12px;
  font: 600 12.5px "Manrope", sans-serif; color: var(--ts-muted);
}
#tutor-stage .pl-consequence {
  text-align: center; font: 600 14.5px/1.45 "Manrope", sans-serif;
  color: var(--ts-teal-ink, #17665e);
  background: var(--ts-teal-soft, rgba(31, 155, 142, 0.12));
  border-radius: 10px; padding: 9px 12px;
}
#tutor-stage .pl-slider-wrap.right .pl-slider-readout { color: var(--ts-green-ink, #1e7a46); }
#tutor-stage .pl-slider-wrap.wrong .pl-slider-readout { color: var(--ts-amber-ink, #9a5b12); }
body[data-mode="dark"] #tutor-stage .pl-consequence {
  background: rgba(31, 155, 142, 0.16); color: #6fd6c8;
}

/* =====================================================================
   Task #348 — THE BOARD WRITES ITSELF (fragment staging + reveal verbs,
   captions, film capture). Appended LAST on purpose: the reveal classes
   must win the entry-animation layers above.
   - .ts-frag-staged hides a fragment until its cue fires (visibility, not
     display: layout is FINAL from first paint — the board never reflows
     while he speaks, the words simply appear in place).
   - .ts-fx-* are the closed reveal verbs (runtime-owned styling; authors
     only ever pick the verb). The class STAYS after the animation (fill
     both) — removing it would swap `animation` back to the legacy entry
     animation and re-run it; see TutorStageController._revealFrag.
   ===================================================================== */
#tutor-stage .ts-frag-staged { visibility: hidden !important; }

#tutor-stage .ts-fx-write {
  animation: tsFxWrite 0.42s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
#tutor-stage .ts-fx-draw {
  animation: tsFxDraw 0.65s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
#tutor-stage .ts-fx-fade {
  animation: tsFxFade 0.38s ease both;
}
@keyframes tsFxWrite {
  from { clip-path: inset(-4% 104% -4% -4%); opacity: 0.4; }
  to   { clip-path: inset(-4% -4% -4% -4%); opacity: 1; }
}
@keyframes tsFxDraw {
  from { clip-path: inset(-4% 104% -4% -4%); opacity: 0.25; filter: blur(1.4px); }
  to   { clip-path: inset(-4% -4% -4% -4%); opacity: 1; filter: blur(0); }
}
@keyframes tsFxFade {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

/* Degradation law — reduced motion jumps straight to the final state: the
   controller never stages, and even a mid-flight fx resolves instantly. */
@media (prefers-reduced-motion: reduce) {
  #tutor-stage .ts-frag-staged { visibility: visible !important; }
  #tutor-stage .ts-fx-write,
  #tutor-stage .ts-fx-draw,
  #tutor-stage .ts-fx-fade { animation: none !important; filter: none; }
}

/* Captions primitive (Trap 7): bottom-center bar mirroring the narration.
   Word-paced (karaoke) lines dim the not-yet-spoken words; whole-line
   captions (no alignment) show at full strength — degradation law. */
#tutor-stage .ts-captions {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  max-width: min(760px, 88vw); z-index: 60; pointer-events: none;
  background: rgba(22, 17, 11, 0.86); color: #f7f0e4;
  padding: 9px 16px; border-radius: 12px; text-align: center;
  font: 600 18px/1.5 "Manrope", sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
#tutor-stage .ts-captions[hidden] { display: none; }
#tutor-stage .ts-captions.is-karaoke .ts-cap-word { opacity: 0.42; transition: opacity 0.12s ease; }
#tutor-stage .ts-captions.is-karaoke .ts-cap-word.is-said { opacity: 1; }
@media (max-width: 720px) {
  #tutor-stage .ts-captions {
    font-size: 15.5px; max-width: 92vw;
    bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  }
}

/* CC toggle — matches the round HUD buttons (flag/sound). */
#tutor-stage .ts-hud .ts-cc {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 50%; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(20, 22, 28, 0.06); color: var(--ts-muted);
  font: 800 11px/1 "Manrope", sans-serif; letter-spacing: 0.4px;
}
#tutor-stage .ts-hud .ts-cc:hover { background: rgba(20, 22, 28, 0.12); }
#tutor-stage .ts-hud .ts-cc.is-on { background: var(--ts-accent); color: #fff; }

/* Film capture mode v1 (?film=1) — clean feed: ALL UI chrome stands down;
   the stage, the legend, the board and the captions remain. */
#tutor-stage.ts-film .ts-hud,
#tutor-stage.ts-film .ts-actionbar,
#tutor-stage.ts-film .ts-tutorbar,
#tutor-stage.ts-film .ts-chatpanel,
#tutor-stage.ts-film .ts-divider,
#tutor-stage.ts-film .ts-feedback,
#tutor-stage.ts-film .ts-speech,
#tutor-stage.ts-film .ts-resume,
#tutor-stage.ts-film .ts-checkpoint,
#tutor-stage.ts-film .ts-endnote { display: none !important; }

/* =====================================================================
   Task #350 — MARK: THE LECTURER'S HAND (inline emphasis on declared
   targets). Authors declare {mark, target, at} — the runtime owns every
   color and coordinate (Law 2). The palette is FIXED and semantic:
     hl   — the circled word (chalk sienna ellipse)
     term — a term being defined (teal underline)
     warn — caution (amber underline)
     dim  — de-emphasis (the stamped span recedes)
   Stamped .ts-mark-t spans are INERT until their cue fires — legacy render
   and admin preview are unchanged by the stamps alone. ===================================================================== */
#tutor-stage {
  --ts-mark-hl: #b3541e;
  --ts-mark-term: #17665e;
  --ts-mark-warn: #9a5b12;
  --ts-mark-dim-opacity: 0.38;
}
body[data-mode="dark"] #tutor-stage {
  --ts-mark-hl: #ff9d6b;
  --ts-mark-term: #6fd6c8;
  --ts-mark-warn: #f0b35e;
}

#tutor-stage .ts-mark-t.ts-mks-dim { transition: opacity 0.45s ease; }
#tutor-stage .ts-mark-t.ts-mks-dim.is-on { opacity: var(--ts-mark-dim-opacity); }
#tutor-stage .ts-mark-t.ts-mks-dim.is-instant { transition: none; }

/* The overlay layer lives at its host's CONTENT origin (width/height 0 +
   overflow visible), so strokes are drawn in content coordinates and scroll
   WITH the text; it never affects layout and never inherits the card's
   centered-child measure. Hosts: the beat card, or the .ts-equation
   scroller for KaTeX targets (position:relative added below). */
#tutor-stage .ts-card > .ts-mark-layer,
#tutor-stage .ts-equation > .ts-mark-layer {
  position: absolute; top: 0; left: 0;
  max-width: none; margin: 0;
  overflow: visible; pointer-events: none; z-index: 3;
  display: block;
  /* width/height are set inline per draw to the host's scroll extent —
     Chrome refuses to paint a zero-size SVG root even with overflow:visible */
}
#tutor-stage .ts-equation { position: relative; }

#tutor-stage .ts-mark-stroke {
  fill: none;
  stroke-width: 2.5px;
  stroke-linecap: round;
  opacity: 0.92;
}
#tutor-stage .ts-mkp-hl { stroke: var(--ts-mark-hl); stroke-width: 3px; }
#tutor-stage .ts-mkp-term { stroke: var(--ts-mark-term); }
#tutor-stage .ts-mkp-warn { stroke: var(--ts-mark-warn); stroke-width: 3px; }
/* Live draw-on: the path starts fully dash-offset (set inline by the
   runtime) and this transition pulls the chalk stroke across. */
#tutor-stage .ts-mark-stroke.is-drawn {
  transition: stroke-dashoffset 0.45s cubic-bezier(0.33, 0, 0.2, 1);
}
#tutor-stage .ts-mark-stroke.is-instant { transition: none; }

/* Degradation law — reduced motion jumps to the final marked state. */
@media (prefers-reduced-motion: reduce) {
  #tutor-stage .ts-mark-stroke,
  #tutor-stage .ts-mark-t.ts-mks-dim { transition: none !important; }
}

/* ============================================================
   Task #352 — the plate (primary sources on the board).
   An archival paper frame over the chalkboard: the legend teaches over
   their own notebook page. The runtime camera pans/zooms the img inside
   the clipped viewport on narration anchors (percentage transform —
   reflow-proof); authors only ever name curated manifest rects.
   ============================================================ */
#tutor-stage .ts-plate {
  box-sizing: border-box; /* file convention: per-element, no global reset */
  max-width: 100%;
  margin: 14px 0 0;
  padding: 12px;
  background: linear-gradient(180deg, #fdf8ee 0%, #f6ecd9 100%);
  border: 1px solid rgba(122, 90, 44, 0.28);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(58, 36, 12, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}
#tutor-stage .ts-plate-viewport {
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #241a10;
  aspect-ratio: var(--plate-ar, 1.5);
  width: min(100%, calc(46vh * var(--plate-ar, 1.5)));
  margin: 0 auto;
  box-shadow: inset 0 0 18px rgba(20, 12, 4, 0.35);
}
#tutor-stage .ts-plate-img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 0 0;
  will-change: transform;
  transition: transform 1100ms cubic-bezier(0.22, 0.8, 0.24, 1);
  user-select: none;
  -webkit-user-drag: none;
}
#tutor-stage .ts-plate-img.is-instant { transition: none; }
#tutor-stage .ts-plate-cap {
  margin: 10px 6px 0;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  font-style: italic;
  color: #5a3d1c;
}

/* Degradation ladder: no resolution at serve time (.is-missing) or the
   image failed to LOAD at play (.is-broken, via inline onerror) → the
   caption card. The lesson never breaks (spec law). */
#tutor-stage .ts-plate .ts-plate-fallback { display: none; }
#tutor-stage .ts-plate.is-missing .ts-plate-fallback,
#tutor-stage .ts-plate.is-broken .ts-plate-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 18px;
  border: 1.5px dashed rgba(122, 90, 44, 0.4);
  border-radius: 6px;
  text-align: center;
}
#tutor-stage .ts-plate.is-broken .ts-plate-viewport { display: none; }
#tutor-stage .ts-plate-emblem {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: rgba(122, 90, 44, 0.65);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#tutor-stage .ts-plate-fb-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(122, 90, 44, 0.75);
}
#tutor-stage .ts-plate-fb-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  color: #3a2a14;
  text-transform: capitalize;
}
#tutor-stage .ts-plate-fb-cap {
  font-size: 14px;
  line-height: 1.5;
  font-style: italic;
  color: #5a3d1c;
  max-width: 46ch;
}

/* Dark mode — the paper mat warms down instead of glowing. */
body[data-mode="dark"] #tutor-stage .ts-plate {
  background: linear-gradient(180deg, #2b241a 0%, #221b12 100%);
  border-color: rgba(214, 178, 122, 0.22);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
body[data-mode="dark"] #tutor-stage .ts-plate-cap,
body[data-mode="dark"] #tutor-stage .ts-plate-fb-cap { color: #cdb489; }
body[data-mode="dark"] #tutor-stage .ts-plate-fb-title { color: #ecd9b4; }
body[data-mode="dark"] #tutor-stage .ts-plate-fb-kicker { color: rgba(214, 178, 122, 0.75); }
body[data-mode="dark"] #tutor-stage .ts-plate-emblem { stroke: rgba(214, 178, 122, 0.6); }
body[data-mode="dark"] #tutor-stage .ts-plate.is-missing .ts-plate-fallback,
body[data-mode="dark"] #tutor-stage .ts-plate.is-broken .ts-plate-fallback {
  border-color: rgba(214, 178, 122, 0.3);
}

/* Small screens: keep the plate from swallowing the stage. */
@media (max-width: 720px) {
  #tutor-stage .ts-plate { padding: 8px; }
  #tutor-stage .ts-plate-viewport {
    width: min(100%, calc(38vh * var(--plate-ar, 1.5)));
  }
}

/* Degradation law — reduced motion cuts to the focus state, never pans. */
@media (prefers-reduced-motion: reduce) {
  #tutor-stage .ts-plate-img { transition: none !important; }
}

/* ══ Task #353 — the HOLD beat: the ungraded predict-pause ══════════════
   A prompt, 2–5 predictions, one commit. No verdict chrome anywhere: the
   chosen option keeps a neutral amber tint through the reveal (predictions
   are never punished). The reveal panel lands only after commit (Trap 5). */
#tutor-stage .ts-card-hold .ts-hold-opts {
  display: flex; flex-direction: column; gap: 10px; margin: 14px 0 16px;
  width: 100%; max-width: 460px;
}
#tutor-stage .ts-hold-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 12px 16px;
  border: 1.5px solid var(--ts-line);
  border-radius: 14px;
  background: var(--ts-paper);
  color: var(--ts-ink);
  font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1.4;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
#tutor-stage .ts-hold-opt:hover { border-color: var(--ts-amber); transform: translateY(-1px); }
#tutor-stage .ts-hold-opt-dot {
  flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--ts-line); background: transparent;
  transition: border-color .15s ease, background .15s ease;
}
#tutor-stage .ts-hold-opt.is-chosen {
  border-color: var(--ts-amber); background: var(--ts-amber-soft);
}
#tutor-stage .ts-hold-opt.is-chosen .ts-hold-opt-dot {
  border-color: var(--ts-amber); background: var(--ts-amber);
}
/* after commit: unchosen predictions recede; the chosen one keeps its tint */
#tutor-stage .ts-hold-opts.is-committed .ts-hold-opt { cursor: default; }
#tutor-stage .ts-hold-opts.is-committed .ts-hold-opt:hover { transform: none; }
#tutor-stage .ts-hold-opts.is-committed .ts-hold-opt:not(.is-chosen) { opacity: .45; }
#tutor-stage .ts-hold-reveal {
  /* tutor-stage.css has no global box-sizing reset — without border-box the
     16px side padding rides OUTSIDE width:100% and the goldframe escape gate
     flags the reveal spilling past the card edge (Task #353). */
  box-sizing: border-box;
  width: 100%; max-width: 460px;
  margin: 4px 0 14px; padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px dashed var(--ts-amber);
  background: var(--ts-amber-soft);
  animation: tsHoldReveal .5s ease both;
}
#tutor-stage .ts-hold-reveal-kicker {
  display: block;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ts-amber-ink); margin-bottom: 6px;
}
#tutor-stage .ts-hold-reveal-text {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 17px; font-weight: 600; line-height: 1.45;
  color: var(--ts-ink);
}
@keyframes tsHoldReveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #tutor-stage .ts-hold-reveal { animation: none; }
}
/* dark mode warms down with the rest of the card */
body[data-mode="dark"] #tutor-stage .ts-hold-opt { background: rgba(255, 255, 255, 0.03); }
body[data-mode="dark"] #tutor-stage .ts-hold-opt.is-chosen,
body[data-mode="dark"] #tutor-stage .ts-hold-reveal { background: rgba(214, 178, 122, 0.12); }

/* ---------- Task #354 — memory: the pin rail, remedy detour, pin summary ----------
   The rail is the lesson's MARGIN: at most 6 text-only facts that accumulate
   across beats (append/erase/dim only — layout is runtime-owned). It hangs off
   the left edge of the stage board like a chalk sidebar. NOTE: tutor-stage.css
   has no global box-sizing reset — the padded rail declares border-box itself
   or the goldframe harness flags phantom escapes. */
#tutor-stage .ts-pinrail {
  position: absolute;
  top: 0;
  right: calc(100% + 16px);
  width: min(220px, 24vw);
  max-height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  padding: 12px 14px;
  background: var(--ts-paper);
  border: 1px solid var(--ts-line);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(64, 41, 18, 0.10);
  pointer-events: auto;
}
#tutor-stage .ts-pinrail-title {
  margin: 0 0 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ts-accent-soft);
}
#tutor-stage .ts-pinrail-list {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 7px;
}
#tutor-stage .ts-pinrail .ts-pin {
  position: relative;
  box-sizing: border-box;
  padding-left: 14px;
  font-size: 13px; line-height: 1.35;
  color: var(--ts-ink);
  transition: opacity .3s ease;
  overflow-wrap: break-word;
}
#tutor-stage .ts-pinrail .ts-pin::before {
  content: "";
  position: absolute; left: 0; top: .48em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ts-accent);
}
#tutor-stage .ts-pinrail .ts-pin.is-dim { opacity: 0.42; }
/* Narrow stage (the same 720px break the rest of /learn uses): the rail
   collapses to a count chip above the board — the margin no longer exists,
   so the memory recedes to a tally instead of overlapping the card. */
@media (max-width: 720px) {
  #tutor-stage .ts-pinrail {
    top: -10px; right: 0;
    transform: translateY(-100%);
    width: auto; max-width: 60vw;
    padding: 5px 12px;
    border-radius: 999px;
    display: inline-flex; align-items: center; gap: 6px;
  }
  #tutor-stage .ts-pinrail-list { display: none; }
  #tutor-stage .ts-pinrail-title { margin: 0; }
  #tutor-stage .ts-pinrail::after {
    content: attr(data-count);
    font-size: 12px; font-weight: 700; color: var(--ts-accent);
  }
}

/* The depth-1 remedy card — the legend's "one more look" detour after a wrong
   answer. Same paper as every card, with a quiet amber spine so it reads as
   an aside, not a new lesson beat. */
#tutor-stage .ts-card-remedy { border-left: 3px solid var(--ts-accent-soft); }
#tutor-stage .ts-remedy-kicker {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ts-accent-soft);
  margin-bottom: 10px;
}

/* End-of-lesson summary assembled from the rail (dim facts stay, receded). */
#tutor-stage .ts-pin-summary {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--ts-line);
}
#tutor-stage .ts-pin-summary-title {
  margin: 0 0 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ts-accent-soft);
}
#tutor-stage .ts-pin-summary-list {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 6px;
  text-align: left;
}
#tutor-stage .ts-pin-summary-list .ts-pin {
  position: relative; box-sizing: border-box; padding-left: 14px;
  font-size: 13.5px; line-height: 1.4; color: var(--ts-ink);
}
#tutor-stage .ts-pin-summary-list .ts-pin::before {
  content: "";
  position: absolute; left: 0; top: .48em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ts-accent);
}
#tutor-stage .ts-pin-summary-list .ts-pin.is-dim { opacity: 0.42; }
/* dark mode warms down with the rest of the stage */
body[data-mode="dark"] #tutor-stage .ts-pinrail { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }

/* =====================================================================
   Task #383 — TEMPLATE PROBLEM WIDGETS: full .pl-* parity on the stage.
   The six ProblemTemplates renderers (tap / slider / number line /
   fill-blank / sort / drag) emit `.pl-*` markup whose styles live in
   lesson-mode.css — but that sheet is scoped to #problem-lesson-overlay
   (the /lab practice overlay) and never loads on the standalone stage
   page, so tap options rendered as one bare run-together text strip.
   This block ports every remaining widget primitive (the slider was
   already ported above), scoped to #tutor-stage and recolored with the
   stage's own calm tokens — lesson-mode geometry, stage palette.
   Pages that load BOTH sheets (the review room) cannot double-apply:
   lesson-mode rules only match inside #problem-lesson-overlay, these
   only inside #tutor-stage; no element ever sits inside both.
   ===================================================================== */

/* ---- tap_the_right_one: distinct, tappable option cards ---- */
#tutor-stage .pl-options {
  display: flex; flex-direction: column; gap: 10px;
  width: min(460px, 100%); margin: 4px auto 0;
}
#tutor-stage .pl-option {
  display: block; width: 100%;
  text-align: left;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--ts-line);
  background: var(--ts-paper);
  color: var(--ts-ink);
  font-family: inherit; font-size: 15px; font-weight: 500; line-height: 1.4;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
#tutor-stage .pl-option:hover { border-color: var(--ts-accent); }
#tutor-stage .pl-option:active { transform: translateY(1px); }
#tutor-stage .pl-option.sel {
  border-color: var(--ts-accent);
  background: rgba(181, 101, 29, 0.12);
  font-weight: 600;
}
#tutor-stage .pl-option.right {
  border-color: var(--ts-green);
  background: rgba(47, 174, 102, 0.14);
}
#tutor-stage .pl-option.wrong {
  border-color: var(--ts-red);
  background: rgba(214, 69, 47, 0.12);
}

/* ---- number_line (same family as the ported slider above) ---- */
#tutor-stage .pl-numline-wrap {
  width: min(460px, 100%); margin: 6px auto 0; padding: 6px 4px;
}
#tutor-stage .pl-numline-readout {
  font: 800 26px "Fraunces", serif; color: var(--ts-ink);
  text-align: center; font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}
#tutor-stage .pl-numline-track {
  position: relative; height: 4px; border-radius: 2px;
  background: rgba(20, 22, 28, 0.18);
  margin: 26px 6px 6px;
}
#tutor-stage .pl-numline-tick {
  position: absolute; top: -5px; width: 2px; height: 14px;
  background: rgba(20, 22, 28, 0.28);
  transform: translateX(-1px);
}
#tutor-stage .pl-numline-lbl {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  font: 600 10.5px "Manrope", sans-serif; color: var(--ts-muted);
  white-space: nowrap;
}
#tutor-stage .pl-numline-input {
  width: 100%; height: 34px; cursor: pointer; accent-color: var(--ts-accent);
  margin-top: 14px; /* clears the tick labels hanging below the track */
}
#tutor-stage .pl-numline-wrap.right .pl-numline-readout { color: var(--ts-green-ink, #1e7a46); }
#tutor-stage .pl-numline-wrap.wrong .pl-numline-readout { color: var(--ts-amber-ink, #9a5b12); }

/* ---- fill_the_blank: sentence + underlined slots + chip banks ---- */
#tutor-stage .pl-fill-sentence {
  font-size: 17px; line-height: 1.9; margin-bottom: 16px;
}
#tutor-stage .pl-fill-slot {
  display: inline-block; min-width: 64px; text-align: center;
  border-bottom: 2px solid var(--ts-accent);
  padding: 0 8px; margin: 0 2px;
  color: var(--ts-accent); font-weight: 600;
}
#tutor-stage .pl-fill-slot.done {
  background: rgba(181, 101, 29, 0.12);
  border-radius: 6px 6px 0 0;
  color: var(--ts-ink);
}
#tutor-stage .pl-fill-slot.right { color: var(--ts-green-ink, #1c8a4e); border-color: var(--ts-green); }
#tutor-stage .pl-fill-slot.wrong { color: var(--ts-red-ink, #b3331f); border-color: var(--ts-red); }
#tutor-stage .pl-fill-banks { display: flex; flex-direction: column; gap: 12px; }
#tutor-stage .pl-fill-bank { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#tutor-stage .pl-fill-bank-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ts-muted); margin-right: 4px;
}
#tutor-stage .pl-chip {
  padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--ts-line);
  background: var(--ts-paper); color: var(--ts-ink);
  font-family: inherit; font-size: 14px; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
#tutor-stage .pl-chip:hover { border-color: var(--ts-accent); }
#tutor-stage .pl-chip.sel {
  border-color: var(--ts-accent); background: rgba(181, 101, 29, 0.12); font-weight: 600;
}

/* ---- sort_order: numbered rows with up/down controls ---- */
#tutor-stage .pl-sort-list {
  list-style: none; counter-reset: pl;
  margin: 0 auto; padding: 0;
  width: min(460px, 100%);
  display: flex; flex-direction: column; gap: 8px;
}
#tutor-stage .pl-sort-item {
  counter-increment: pl;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-radius: 11px;
  border: 1.5px solid var(--ts-line);
  background: var(--ts-paper);
  transition: border-color .15s ease, background .15s ease;
}
#tutor-stage .pl-sort-item::before {
  content: counter(pl);
  font-family: "Fraunces", Georgia, serif; font-weight: 600;
  color: var(--ts-accent); margin-right: 6px;
}
#tutor-stage .pl-sort-label { flex: 1; font-size: 15px; color: var(--ts-ink); }
#tutor-stage .pl-sort-ctrls { display: flex; gap: 4px; }
#tutor-stage .pl-sort-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--ts-line);
  background: rgba(20, 22, 28, 0.05); color: var(--ts-muted);
  cursor: pointer; font-size: 11px;
}
#tutor-stage .pl-sort-btn:hover:not([disabled]) { background: rgba(20, 22, 28, 0.1); color: var(--ts-ink); }
#tutor-stage .pl-sort-btn[disabled] { opacity: .3; cursor: default; }
#tutor-stage .pl-sort-list.right .pl-sort-item {
  border-color: var(--ts-green); background: rgba(47, 174, 102, 0.10);
}
#tutor-stage .pl-sort-list.wrong .pl-sort-item { border-color: rgba(214, 69, 47, 0.45); }

/* ---- drag_tiles: tray + tiles + buckets ---- */
#tutor-stage .pl-drag-tray {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px; border-radius: 12px;
  border: 1.5px dashed rgba(20, 22, 28, 0.28);
  min-height: 56px; margin-bottom: 14px;
  background: rgba(20, 22, 28, 0.03);
}
#tutor-stage .pl-drag-tray-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ts-muted); width: 100%;
}
#tutor-stage .pl-tile {
  padding: 9px 14px; border-radius: 10px;
  border: 1.5px solid var(--ts-line);
  background: var(--ts-paper); color: var(--ts-ink);
  font-family: inherit; font-size: 14px; cursor: grab;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
#tutor-stage .pl-tile.picked {
  border-color: var(--ts-accent); background: rgba(181, 101, 29, 0.12);
  box-shadow: 0 0 0 2px rgba(181, 101, 29, 0.3);
}
#tutor-stage .pl-tile.placed { cursor: pointer; background: rgba(20, 22, 28, 0.04); }
#tutor-stage .pl-buckets {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px;
}
#tutor-stage .pl-bucket {
  border: 1.5px solid var(--ts-line); border-radius: 12px;
  background: var(--ts-paper);
  min-height: 84px; cursor: pointer; overflow: hidden;
  transition: border-color .15s ease, background .15s ease;
}
#tutor-stage .pl-bucket.over { border-color: var(--ts-accent); background: rgba(181, 101, 29, 0.08); }
#tutor-stage .pl-bucket.right { border-color: var(--ts-green); }
#tutor-stage .pl-bucket.wrong { border-color: var(--ts-red); }
#tutor-stage .pl-bucket-head {
  font-size: 12.5px; font-weight: 700; padding: 8px 12px;
  background: rgba(20, 22, 28, 0.05); color: var(--ts-muted);
}
#tutor-stage .pl-bucket-body { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }

/* ---- gaze / positional hint pulse. Keyframes are declared locally under a
        stage-unique name: lesson-mode.css (which owns plGaze) never loads on
        the standalone stage page. ---- */
#tutor-stage .pl-gaze-pulse { animation: tsPlGaze 1.5s ease; }
@keyframes tsPlGaze {
  0%, 100% { box-shadow: 0 0 0 0 rgba(181, 101, 29, 0); }
  30% { box-shadow: 0 0 0 4px rgba(181, 101, 29, 0.55); }
  60% { box-shadow: 0 0 0 8px rgba(181, 101, 29, 0); }
}

/* ---- dark theme: widget surfaces warm down with the stage. NOTE: these
        base rules (id+attr+class) out-specify the light state rules
        (id+2 classes), so every state needs its own dark override. ---- */
body[data-mode="dark"] #tutor-stage .pl-option,
body[data-mode="dark"] #tutor-stage .pl-chip,
body[data-mode="dark"] #tutor-stage .pl-tile,
body[data-mode="dark"] #tutor-stage .pl-sort-item,
body[data-mode="dark"] #tutor-stage .pl-bucket {
  background: rgba(255, 255, 255, 0.03);
}
body[data-mode="dark"] #tutor-stage .pl-option.sel,
body[data-mode="dark"] #tutor-stage .pl-chip.sel,
body[data-mode="dark"] #tutor-stage .pl-tile.picked,
body[data-mode="dark"] #tutor-stage .pl-fill-slot.done,
body[data-mode="dark"] #tutor-stage .pl-bucket.over { background: rgba(214, 178, 122, 0.12); }
body[data-mode="dark"] #tutor-stage .pl-option.right { background: rgba(47, 174, 102, 0.16); }
body[data-mode="dark"] #tutor-stage .pl-option.wrong { background: rgba(214, 69, 47, 0.16); }
body[data-mode="dark"] #tutor-stage .pl-sort-list.right .pl-sort-item { background: rgba(47, 174, 102, 0.12); }
body[data-mode="dark"] #tutor-stage .pl-tile.placed { background: rgba(255, 255, 255, 0.05); }
body[data-mode="dark"] #tutor-stage .pl-sort-btn { background: rgba(255, 255, 255, 0.06); }
body[data-mode="dark"] #tutor-stage .pl-sort-btn:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.12); color: var(--ts-ink);
}
body[data-mode="dark"] #tutor-stage .pl-bucket-head { background: rgba(255, 255, 255, 0.06); }
body[data-mode="dark"] #tutor-stage .pl-drag-tray {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.03);
}
body[data-mode="dark"] #tutor-stage .pl-fill-slot.done { color: var(--ts-ink); }
body[data-mode="dark"] #tutor-stage .pl-numline-track { background: rgba(255, 255, 255, 0.2); }
body[data-mode="dark"] #tutor-stage .pl-numline-tick { background: rgba(255, 255, 255, 0.3); }

/* ── Custom authored widgets (v9) — the sandboxed activity card ──────────
   The iframe is the SACRED boundary (sandbox="allow-scripts", null origin);
   these styles only dress the card around it. */
#tutor-stage .ts-custom-wrap { display: flex; flex-direction: column; gap: 14px; }
#tutor-stage .ts-custom-title { font-weight: 700; font-size: 1.05rem; }
#tutor-stage .ts-custom-mount { width: 100%; }
#tutor-stage .ts-custom-frame { width: 100%; border: 0; display: block; border-radius: 12px; background: #fff; }
#tutor-stage .ts-custom-fallback { font-size: .95rem; opacity: .8; font-style: italic; }
#tutor-stage .ts-custom-continue { align-self: flex-end; }
