*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body.teach {
  --fg: #f5f1e9;
  --fg-dim: #c8bfb3;
  --fg-faint: #988f86;
  --ground: #100f0e;
  --panel: #181716;
  --panel-hi: #22201e;
  --line: rgb(222 214 203 / 0.15);
  --line-2: rgb(222 214 203 / 0.42);
  --accent: var(--rook);
  --radius-sm: 4px;
  --radius: 6px;
  --shadow-control: 0 3px 10px rgb(0 0 0 / 0.24), inset 0 1px 0 rgb(255 255 255 / 0.04);
  --shadow-panel: 0 10px 26px rgb(0 0 0 / 0.2), inset 0 1px 0 rgb(255 255 255 / 0.025);
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--ground);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.mono { font-family: var(--mono); letter-spacing: 0; text-transform: uppercase; font-size: 0.64rem; font-weight: 500; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease; }
button:disabled { cursor: not-allowed; opacity: 0.36; }
button:not(:disabled):active { transform: translateY(0) scale(0.98); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
#t-top {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px 16px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: #161514;
  flex-wrap: wrap;
  position: relative;
  z-index: 10;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.16);
}
.t-back { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 1.05rem; }
.t-back .mark { width: 20px; height: 20px; display: block; background: var(--fg); -webkit-mask: url('/assets/monogram.png') center/contain no-repeat; mask: url('/assets/monogram.png') center/contain no-repeat; mask-mode: luminance; -webkit-mask-mode: luminance; }
.t-back:hover { color: var(--accent); }
.t-id { min-width: 220px; flex: 1 1 280px; }
.t-crumb { margin: 0; color: var(--fg-faint); }
.t-crumb b { color: var(--accent); font-weight: 500; }
.t-title { margin: 2px 0 0; font-size: 0.96rem; line-height: 1.2; font-weight: 550; letter-spacing: 0; color: #fff; overflow-wrap: anywhere; }
.t-session-time { min-width: 112px; display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 7px; padding: 5px 8px; border-left: 1px solid var(--line-2); }
.t-session-time span { color: var(--fg-faint); }
.t-session-time b { font-size: 1rem; font-weight: 500; }
.t-session-time small { grid-column: 2; color: var(--fg-faint); font-size: 0.54rem; }
.t-pick { width: 100%; min-width: 0; max-width: 180px; min-height: 34px; background: var(--ground); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 5px 24px 5px 8px; font-family: var(--mono); font-size: 0.58rem; box-shadow: var(--shadow-control); }
.t-track { max-width: 128px; min-height: 34px; background: var(--ground); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 5px 20px 5px 8px; font-family: var(--mono); font-size: 0.58rem; box-shadow: var(--shadow-control); }
.t-load-state { position: fixed; inset: 0; z-index: 1000; width: 100%; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: clamp(22px, 6vw, 64px); border: 0; background: radial-gradient(ellipse at 50% 43%, #25211e 0%, #100f0e 68%); color: var(--fg); font-family: var(--sans); box-shadow: none; text-align: center; }
.t-load-film { display: block; width: min(52vw, 260px); aspect-ratio: 1; object-fit: contain; mix-blend-mode: screen; }
.t-load-state:not([data-state='loading']) .t-load-film { display: none; }
.t-load-message { width: min(100%, 40rem); color: #fff; font-size: clamp(1.1rem, 2.4vw, 1.6rem); line-height: 1.45; text-wrap: balance; }
@media (prefers-reduced-motion: reduce) { .t-load-film { display: none; } }
.t-load-state[data-state='error'], .t-load-state[data-state='access'], .t-load-state[data-state='review'] { color: #fff; }
.t-load-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; }
.t-load-state button, .t-load-state .t-load-actions a { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); color: var(--fg); font: 500 0.72rem var(--mono); text-decoration: none; }
.t-load-state button:hover, .t-load-state .t-load-actions a:hover { border-color: var(--accent); color: #fff; }
.t-load-state .t-load-login, .t-load-state .t-load-plans { background: var(--accent); border-color: var(--accent); color: #120f0e; }
.t-load-state .t-load-login:hover, .t-load-state .t-load-plans:hover { color: #120f0e; filter: brightness(1.08); }
.t-load-state .t-load-free { background: transparent; }
.t-views { display: flex; gap: 3px; }
.t-views button { min-height: 34px; background: #171615; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 5px 9px; font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase; box-shadow: var(--shadow-control); }
.t-views button:hover { border-color: var(--accent); color: #fff; transform: translateY(-1px); }
.t-views button[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: #120f0e; box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 20%, transparent); }
.t-feedback { justify-self: start; color: var(--fg-dim); font: 500 0.62rem var(--mono); text-decoration: underline; text-underline-offset: 0.2em; white-space: nowrap; }
.t-feedback:hover { color: #fff; }

/* Desktop shell */
#t-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
#t-main:focus { outline: 0; }
#t-class-context { grid-row: 1; }
#t-teach, #t-prep { grid-row: 2; }
.t-class-context { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 5px 16px; border-bottom: 1px solid var(--line); background: #252321; font-size: 0.72rem; }
.t-class-context label { color: var(--fg-dim); }
.t-class-context select { min-width: 100px; max-width: 160px; min-height: 32px; padding: 3px 6px; border: 1px solid var(--line-2); background: var(--ground); border-radius: 4px; font-size: 0.72rem; }
.t-class-context button, .t-return { min-height: 32px; display: inline-flex; align-items: center; padding: 4px 9px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--ground); font-size: 0.72rem; }
.t-class-context button:not(:disabled):hover, .t-return:hover { border-color: var(--accent); }
#t-context-status { color: var(--fg-dim); overflow-wrap: anywhere; }
.t-grid {
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(218px, 0.72fr) minmax(470px, 1.7fr) minmax(310px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
}
.t-rail, .t-stage { min-width: 0; min-height: 0; background: var(--ground); }
.t-left { grid-column: 1; grid-row: 1; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; padding: 12px; }
.t-outline-head { display: grid; gap: 4px; }
.t-outline-head p { margin: 0; }
.t-pacing { color: var(--fg-faint); line-height: 1.4; }
.t-flow { list-style: none; margin: 0; padding: 0; min-width: 0; display: grid; grid-auto-rows: minmax(42px, auto); gap: 2px; align-content: start; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.t-flow button { width: 100%; min-height: 42px; border: 0; border-left: 2px solid transparent; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: transparent; color: var(--fg-dim); padding: 9px 8px; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 5px; align-items: center; text-align: left; }
.t-flow button:hover { background: var(--panel); color: var(--fg); }
.t-flow li.on button { border-left-color: var(--accent); background: var(--panel-hi); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.035); }
.t-flow .n, .t-flow .m { font-family: var(--mono); font-size: 0.56rem; color: var(--fg-faint); }
.t-flow .l { font-size: 0.84rem; line-height: 1.25; overflow-wrap: anywhere; }
.t-flow li.on .n, .t-flow li.on .m { color: var(--accent); }

.t-stage { grid-column: 2; grid-row: 1; padding: 12px 14px; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; overflow: hidden; container: teach-stage / inline-size; }
.t-stage:not(.is-prose) { gap: 14px; }
.t-stage-head { display: grid; gap: 5px; }
.t-beat-h { margin: 0; color: var(--fg-faint); }
.t-beat-title { margin: 0; font-family: var(--display); font-size: clamp(1.08rem, 1.55vw, 1.55rem); line-height: 1.18; font-weight: 450; letter-spacing: 0; }
.t-beat-title.long { font-family: var(--sans); font-size: 0.94rem; line-height: 1.34; }
.t-beats { min-height: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.t-beats:empty { display: none; }
.t-beats button { min-width: 30px; min-height: 28px; background: #171615; border: 1px solid var(--line-2); border-radius: var(--radius-sm); color: var(--fg-dim); font-family: var(--mono); font-size: 0.6rem; box-shadow: var(--shadow-control); }
.t-beats button:hover { border-color: var(--accent); color: #fff; transform: translateY(-1px); }
.t-beats button[aria-current='true'] { background: var(--accent); border-color: var(--accent); color: #120f0e; box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 22%, transparent); }

.t-board-workspace { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px; }
.t-board-tools { display: flex; justify-content: flex-end; align-items: center; gap: 4px; min-height: 30px; }
.t-board-tools button, .t-line-btns button, .t-reset { width: 32px; height: 30px; display: grid; place-items: center; background: #171615; border: 1px solid var(--line-2); border-radius: var(--radius-sm); color: var(--fg-dim); font-family: var(--mono); font-size: 0.62rem; box-shadow: var(--shadow-control); }
.t-board-tools button[data-copy] { width: 42px; }
.t-board-tools button:hover:not(:disabled), .t-line-btns button:hover:not(:disabled), .t-reset:hover { border-color: var(--accent); color: #fff; transform: translateY(-1px); box-shadow: 0 5px 14px rgb(0 0 0 / 0.34), inset 0 1px 0 rgb(255 255 255 / 0.06); }
.t-board-tools button[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: #110f0e; box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 22%, transparent); }
.t-copy-status { margin-left: auto; color: var(--accent); white-space: nowrap; }
.t-copy-status:empty { display: none; }
.t-board-wrap { min-width: 0; min-height: 0; display: grid; place-items: start center; container-type: size; }
.t-board-frame { position: relative; width: min(100cqw, 100cqh); aspect-ratio: 1; border-radius: var(--radius-sm); box-shadow: 0 14px 34px rgb(0 0 0 / 0.36), 0 0 0 1px rgb(238 228 214 / 0.16); animation: t-surface-in 180ms ease-out both; }
.t-board { width: 100%; height: 100%; }
.board2d { position: relative; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.board2d .sq { position: relative; }
.board2d .sq.l { background: #e7dcc7; }
.board2d .sq.d { background: #9d805f; }
.board2d .sq.from::after, .board2d .sq.to::after { content: ''; position: absolute; inset: 0; outline: 3px solid #17120e; outline-offset: -3px; z-index: 2; }
.board2d .sq.to::after { box-shadow: inset 0 0 0 5px var(--accent); }
.board2d .sq.coach-mark::before { content: ''; position: absolute; inset: 9%; border: 4px solid #2f8f83; border-radius: 50%; z-index: 3; pointer-events: none; }
.board2d .sq .co { position: absolute; font-family: var(--mono); font-size: 0.54rem; color: rgb(24 16 10 / 0.9); z-index: 4; }
.board2d .sq .co.f { right: 3px; bottom: 1px; }
.board2d .sq .co.r { left: 3px; top: 1px; }
.board2d img { position: absolute; inset: 5%; width: 90%; height: 90%; filter: drop-shadow(0 2px 5px rgb(0 0 0 / 0.4)); }
.t-board-frame.is-annotating .board2d { cursor: crosshair; }
.t-board-frame.is-dragging .board2d { cursor: grabbing; }
.t-arrows { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.t-arrow { position: absolute; height: 5px; background: #2f8f83; transform-origin: 0 50%; opacity: 0.92; animation: t-arrow-in 140ms ease-out both; }
.t-arrow::after { content: ''; position: absolute; right: -1px; top: 50%; width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 13px solid #2f8f83; transform: translateY(-50%); }
.t-caption { margin: 0; min-height: 1.3em; color: var(--fg-faint); font-size: 0.72rem; text-align: center; }

/* Prose teaching surfaces */
.t-stage.is-prose { overflow: hidden; }
.t-prose { min-width: 0; min-height: 0; overflow-y: auto; padding: 2px clamp(2px, 2vw, 26px) 16px; display: grid; align-content: start; gap: 18px; scrollbar-width: thin; }
.t-prose-lead { margin: 0; max-width: 70ch; font-family: var(--display); font-size: clamp(1.05rem, 1.65vw, 1.42rem); line-height: 1.45; }
.t-prose-meta { margin: -8px 0 0; color: var(--accent); }
.t-prose-section { max-width: 74ch; border-top: 1px solid var(--line-2); padding-top: 10px; }
.t-prose-section h3, .t-run-steps h3 { margin: 0 0 7px; color: var(--accent); }
.t-prose-section p { margin: 0; color: var(--fg-dim); line-height: 1.55; }
.t-prose-section ul { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.t-prose-section li { color: var(--fg-dim); line-height: 1.48; }
.t-run-card { max-width: 68ch; border: 1px solid var(--line-2); border-left: 1px solid var(--accent); border-radius: var(--radius); padding: 16px 16px 16px 18px; background: var(--panel); display: grid; gap: 12px; box-shadow: var(--shadow-panel); }
.t-run-card > p { margin: 0; }
.t-run-card > p:not(.mono) { font-size: clamp(1.05rem, 1.4vw, 1.3rem); line-height: 1.45; }
.t-card-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.t-card-controls button, .t-related button { min-height: 38px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #171615; color: var(--fg-dim); box-shadow: var(--shadow-control); }
.t-card-controls button:hover:not(:disabled), .t-related button:hover { border-color: var(--accent); color: #fff; transform: translateY(-1px); }
.t-run-steps { max-width: 76ch; }
.t-run-steps ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; counter-reset: runstep; }
.t-run-steps li { counter-increment: runstep; display: grid; grid-template-columns: 30px 1fr; align-items: stretch; }
.t-run-steps li::before { content: counter(runstep, decimal-leading-zero); display: grid; place-items: center; border: 1px solid var(--line-2); border-right: 0; color: var(--accent); font-family: var(--mono); font-size: 0.58rem; }
.t-run-steps button { min-height: 44px; padding: 9px 11px; border: 1px solid var(--line-2); background: transparent; text-align: left; line-height: 1.4; }
.t-run-steps li.done { opacity: 0.56; }
.t-run-steps li.done button { text-decoration: line-through; }
.t-related { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.t-related span { margin-right: 4px; color: var(--fg-faint); }
.t-related button { padding: 6px 10px; }

/* Coach rail */
.t-right { grid-column: 3; grid-row: 1; padding: 12px 12px 148px; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; overflow: hidden; }
.t-coach-cue, .t-solution { min-width: 0; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel); padding: 11px; box-shadow: var(--shadow-panel); animation: t-surface-in 180ms ease-out both; }
.t-coach-cue { display: grid; gap: 7px; max-height: 168px; overflow-y: auto; }
.t-coach-cue header, .t-solution > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.t-coach-cue header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; }
.t-coach-cue h3, .t-solution h3 { margin: 0; color: var(--fg-faint); }
.t-coach-cue header b { color: var(--accent); font-weight: 500; }
.t-cue-body, .t-hintline { margin: 0; color: var(--fg-dim); font-size: 0.82rem; line-height: 1.42; }
.t-hintline { border-left: 2px solid #2f8f83; padding-left: 8px; }
.t-solution { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 9px; overflow: hidden; }
.t-right.solution-collapsed { grid-template-rows: auto auto; align-content: start; }
.t-right.cue-collapsed.solution-collapsed { grid-template-rows: auto auto; }
.t-coach-cue.is-collapsed, .t-solution.is-collapsed { grid-template-rows: auto; align-content: start; }
.t-coach-cue.is-collapsed > :not(header), .t-solution.is-collapsed > :not(header) { display: none; }
.t-collapse { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #121110; color: var(--fg-dim); font-family: var(--mono); font-size: 0.8rem; line-height: 1; box-shadow: var(--shadow-control); }
.t-collapse:hover { border-color: var(--accent); color: #fff; transform: translateY(-1px); }
.t-sol-body { min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 12px; padding-right: 3px; scrollbar-width: thin; }
.t-sol-body > .san { margin: 0; color: var(--accent); font-family: var(--mono); font-size: 0.88rem; line-height: 1.5; }
.t-muted { margin: 0; color: var(--fg-faint); font-size: 0.78rem; }
.t-mini { border-top: 1px solid var(--line); padding-top: 8px; }
.t-mini:first-child { border-top: 0; padding-top: 0; }
.t-mini h4 { margin: 0 0 5px; color: var(--accent); }
.t-mini p { margin: 0; color: var(--fg-dim); font-size: 0.8rem; line-height: 1.45; }
.t-mini ul { margin: 0; padding-left: 16px; display: grid; gap: 5px; }
.t-mini li { color: var(--fg-dim); font-size: 0.78rem; line-height: 1.4; }
.t-line { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 7px; }
.t-line-head { display: flex; justify-content: space-between; color: var(--fg-faint); }
.t-line-head b { color: var(--accent); font-weight: 500; }
.t-plies { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; max-height: 58px; overflow-y: auto; }
.t-plies button { min-height: 28px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #121110; color: var(--fg-dim); font-family: var(--mono); font-size: 0.62rem; box-shadow: var(--shadow-control); }
.t-plies button[aria-current='step'] { border-color: var(--accent); color: #fff; background: var(--panel-hi); }
.t-line-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.t-line-btns button { width: auto; }

/* Persistent navigation and clock */
.t-dock { grid-column: 3; grid-row: 1; align-self: end; z-index: 4; min-width: 0; margin: 0 12px 12px; background: #171615; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'prev next' 'clock clock'; gap: 6px; align-items: stretch; box-shadow: 0 12px 30px rgb(0 0 0 / 0.34), inset 0 1px 0 rgb(255 255 255 / 0.035); }
.t-prev, .t-next { min-width: 0; min-height: 50px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #121110; display: grid; align-content: center; gap: 2px; text-align: left; box-shadow: var(--shadow-control); }
.t-next { text-align: right; border-color: var(--accent); }
.t-prev { grid-area: prev; }
.t-next { grid-area: next; }
.t-prev span, .t-next span { font-size: 0.74rem; color: var(--fg); }
.t-prev small, .t-next small { color: var(--fg-faint); font-family: var(--mono); font-size: 0.52rem; line-height: 1.25; overflow-wrap: anywhere; }
.t-prev:hover:not(:disabled), .t-next:hover:not(:disabled) { border-color: var(--accent); background: var(--panel-hi); transform: translateY(-1px); }
.t-clock { grid-area: clock; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 4px; gap: 5px 8px; align-items: center; }
.t-clock-readout { min-width: 0; display: flex; align-items: baseline; gap: 7px; }
.t-clock-readout > span { color: var(--fg-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-clock-readout b { font-size: 1.18rem; font-weight: 500; white-space: nowrap; }
.t-clock-readout small { color: var(--fg-faint); font-size: 0.52rem; white-space: nowrap; }
.t-clock-actions { display: flex; gap: 4px; grid-column: 2; grid-row: 1 / 3; }
.t-play { min-width: 88px; height: 36px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: #121110; color: var(--fg); font-size: 0.72rem; box-shadow: var(--shadow-control); }
.t-play:hover { background: var(--accent); color: #120f0e; transform: translateY(-1px); box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 22%, transparent); }
.t-reset { height: 36px; }
.t-bar { position: relative; height: 4px; background: rgb(244 239 228 / 0.12); overflow: hidden; }
.t-bar i { position: absolute; inset: 0; width: 100%; transform: scaleX(0); transform-origin: left center; background: var(--accent); transition: transform 240ms linear, background-color 140ms ease; }
.t-bar.over i { background: #df6f5c; }

/* Keep nested scrollbars quiet and consistent with the dark console. */
.t-flow, .t-prose, .t-coach-cue, .t-sol-body, .t-plies {
  scrollbar-color: var(--line-2) transparent;
  scrollbar-width: thin;
}
.t-flow::-webkit-scrollbar, .t-prose::-webkit-scrollbar, .t-coach-cue::-webkit-scrollbar, .t-sol-body::-webkit-scrollbar, .t-plies::-webkit-scrollbar { width: 7px; height: 7px; }
.t-flow::-webkit-scrollbar-track, .t-prose::-webkit-scrollbar-track, .t-coach-cue::-webkit-scrollbar-track, .t-sol-body::-webkit-scrollbar-track, .t-plies::-webkit-scrollbar-track { background: transparent; }
.t-flow::-webkit-scrollbar-thumb, .t-prose::-webkit-scrollbar-thumb, .t-coach-cue::-webkit-scrollbar-thumb, .t-sol-body::-webkit-scrollbar-thumb, .t-plies::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 2px; }

/* Prep document */
.t-prep { height: 100%; min-height: 0; overflow-y: auto; background: #f6f2e9; color: #1c1c1a; padding: clamp(22px, 4vw, 58px) clamp(16px, 5vw, 76px) 70px; }
.t-prep .doc { max-width: 78ch; margin: 0 auto; display: grid; gap: 20px; }
.t-prep h2 { margin: 0; font-family: var(--display); font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.08; font-weight: 450; letter-spacing: 0; }
.t-prep h3, .t-prep h4 { margin: 0; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0; color: #51645e; }
.t-prep h3 { font-size: 0.66rem; }
.t-prep h4 { font-size: 0.6rem; margin-top: 7px; }
.t-prep p { margin: 0; line-height: 1.58; color: #34322e; }
.t-prep .kick { color: #51645e; }
.t-prep section { border-top: 1px solid #d3ccc0; padding-top: 11px; display: grid; gap: 7px; }
.t-prep ul, .t-prep ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.t-prep li { line-height: 1.5; color: #34322e; }
.t-prep .facts { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.t-prep .facts li { border-top: 1px solid #d3ccc0; padding-top: 5px; display: grid; }
.t-prep .facts .k { font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase; color: #6b675f; }
.t-prep .facts .v { font-family: var(--mono); color: #1c1c1a; }
.t-prep .routine { border-left: 3px solid #51645e; padding-left: 12px; display: grid; gap: 5px; }

/* Presentation */
body[data-teach-view='present'] .t-left,
body[data-teach-view='present'] .t-right { display: none; }
body[data-teach-view='present'] .t-grid { grid-template-rows: minmax(0, 1fr) auto; }
body[data-teach-view='present'] .t-stage { grid-column: 1 / -1; }
body[data-teach-view='present'] .t-dock { grid-column: 1 / -1; grid-row: 2; align-self: stretch; margin: 0; padding: 7px 10px; grid-template-columns: minmax(145px, 1fr) minmax(300px, 1.35fr) minmax(145px, 1fr); grid-template-areas: 'prev clock next'; gap: 8px; }
body[data-teach-view='present'] .t-board-tools { opacity: 0.22; transition: opacity 160ms; }
body[data-teach-view='present'] .t-board-tools:hover,
body[data-teach-view='present'] .t-board-tools:focus-within { opacity: 1; }
.t-stage:fullscreen { width: 100vw; height: 100vh; height: 100dvh; background: var(--ground); padding: 18px; }

/* Once the stage has enough room, move tools into balanced side gutters. */
@container teach-stage (min-width: 540px) {
  .t-board-workspace {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 6px;
  }
  .t-board-tools {
    grid-column: 3;
    grid-row: 1;
    min-height: 0;
    align-self: start;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
  }
  .t-board-tools button,
  .t-board-tools button[data-copy] { width: 42px; height: 34px; }
  .t-board-tools button[data-copy='fen'] { margin-top: 6px; }
  .t-board-wrap { grid-column: 2; grid-row: 1; }
  .t-caption { grid-column: 2; grid-row: 2; }
  .t-copy-status {
    width: 44px;
    margin: 2px 0 0;
    padding: 5px 2px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: #171615;
    box-shadow: var(--shadow-control);
    font-size: 0.5rem;
    line-height: 1.3;
    text-align: center;
    white-space: normal;
  }
}

/* Keep the desktop header balanced: identity stays left, controls stay right. */
@media (min-width: 900px) {
  #t-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(120px, 180px) minmax(100px, 128px) auto; flex-wrap: nowrap; }
  .t-id { min-width: 0; }
  .t-views { justify-content: flex-end; }
}

@media (min-width: 700px) and (max-height: 620px) {
  .t-stage:not(.is-prose) .t-beat-title.long { font-size: 0.84rem; line-height: 1.16; }
}

/* Tablet: outline strip plus workspace and coach rail. */
@media (min-width: 900px) and (max-width: 1199px) {
  #t-top { gap: 7px 10px; padding: 7px 12px; }
  .t-session-time { display: none; }
  .t-pick { max-width: 150px; }
  .t-track { max-width: 120px; }
  .t-grid { grid-template-columns: minmax(175px, 0.62fr) minmax(380px, 1.55fr) minmax(280px, 1fr); }
  .t-left, .t-stage { padding: 10px; }
  .t-right { padding: 10px 10px 144px; }
  .t-dock { margin: 0 10px 10px; }
  .t-flow button { padding: 7px 6px; }
  .t-coach-cue { max-height: 130px; }
  #t-top { grid-template-columns: auto minmax(0, 1fr) minmax(110px, 150px) minmax(95px, 120px) auto; }
  .t-views { grid-column: 5; }
}

@media (min-width: 700px) and (max-width: 899px) {
  body.teach { height: 100vh; height: 100dvh; overflow: hidden; }
  #t-top { padding: 7px 12px; gap: 7px 10px; }
  .t-id { flex-basis: 300px; }
  .t-grid { grid-template-columns: minmax(0, 1.45fr) minmax(290px, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .t-left { grid-column: 1 / -1; grid-row: 1; padding: 7px 10px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .t-outline-head { min-width: 165px; }
  .t-flow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); grid-auto-rows: auto; align-content: initial; overflow-x: auto; overflow-y: hidden; }
  .t-flow { scrollbar-width: none; }
  .t-flow::-webkit-scrollbar { display: none; }
  .t-flow button { min-height: 52px; border-left: 0; border-bottom: 2px solid transparent; padding: 6px; grid-template-columns: 20px minmax(0, 1fr); }
  .t-flow .m { grid-column: 2; }
  .t-flow li.on button { border-bottom-color: var(--accent); }
  .t-stage { grid-column: 1; grid-row: 2; padding: 9px 10px; }
  .t-right { grid-column: 2; grid-row: 2; padding: 9px; }
  .t-dock { grid-column: 1 / -1; grid-row: 3; align-self: stretch; margin: 0; padding: 7px 10px; grid-template-columns: minmax(145px, 1fr) minmax(300px, 1.35fr) minmax(145px, 1fr); grid-template-areas: 'prev clock next'; gap: 8px; }
}

/* Phone: the strip and active workspace lead; controls remain reachable. */
@media (max-width: 699px) {
  .t-class-context { padding: 6px 10px; }
  .t-class-context select { max-width: 125px; }
  body.teach { display: block; min-height: 100dvh; height: auto; overflow: visible; padding-bottom: 0; }
  #t-top { position: sticky; top: 0; z-index: 30; padding: 8px 10px; gap: 7px; }
  .t-back { font-size: 0.96rem; }
  .t-id { order: 3; flex: 1 0 100%; min-width: 0; }
  .t-session-time { margin-left: auto; min-width: 100px; }
  .t-pick { max-width: 45vw; display: block; }
  .t-track { max-width: 35vw; }
  .t-views { order: 2; margin-left: auto; }
  .t-views button { padding-inline: 7px; }
  .t-grid { height: auto; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; }
  .t-left { grid-column: 1; grid-row: 1; padding: 8px 10px; display: grid; grid-template-rows: auto auto; }
  .t-outline-head { display: flex; justify-content: space-between; gap: 4px 10px; align-items: baseline; flex-wrap: wrap; }
  .t-outline-head .t-feedback { flex-basis: 100%; }
  .t-pacing { text-align: right; }
  .t-flow { min-height: 64px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 64vw); grid-auto-rows: auto; align-content: initial; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
  .t-flow { scrollbar-width: none; }
  .t-flow::-webkit-scrollbar { display: none; }
  .t-flow button { min-height: 58px; border-left: 0; border-bottom: 2px solid transparent; padding: 6px; grid-template-columns: 18px minmax(0, 1fr); align-content: center; }
  .t-flow .m { grid-column: 2; }
  .t-flow li.on button { border-bottom-color: var(--accent); }
  .t-stage { grid-column: 1; grid-row: 2; padding: 10px; overflow: visible; min-height: 0; }
  .t-board-workspace { min-height: 0; grid-template-rows: auto auto auto; }
  .t-board-wrap { container-type: inline-size; }
  .t-board-frame { width: min(100%, clamp(250px, calc(100dvh - 540px), 360px)); }
  .t-board-tools button { min-width: 36px; min-height: 36px; }
  .t-prose { max-height: none; overflow: visible; padding: 2px 0 124px; }
  .t-right { grid-column: 1; grid-row: 3; padding: 10px 10px 124px; overflow: visible; grid-template-rows: auto auto; }
  .t-coach-cue { max-height: none; overflow: visible; }
  .t-solution { min-height: 90px; overflow: visible; grid-template-rows: auto auto auto; }
  .t-sol-body { max-height: none; overflow: visible; }
  /* Phone controls follow the guidance in normal flow; a bottom-sticky dock
     covered the cue/solution actions while their row entered the viewport. */
  .t-dock { position: static; bottom: auto; z-index: 25; grid-column: 1; grid-row: 4; align-self: stretch; margin: 0; padding: 7px; border-top: 0; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; grid-template-areas: 'clock clock' 'prev next'; box-shadow: 0 -8px 22px rgb(0 0 0 / 0.45); }
  .t-collapse { min-width: 44px; min-height: 44px; }
  .t-clock { grid-column: 1 / -1; grid-row: 1; }
  .t-prev { grid-column: 1; grid-row: 2; }
  .t-next { grid-column: 2; grid-row: 2; }
  .t-prev, .t-next { min-height: 48px; }
  body[data-teach-view='present'] .t-grid { min-height: calc(100dvh - 116px); grid-template-rows: minmax(0, 1fr) auto; }
  body[data-teach-view='present'] .t-stage { grid-row: 1; overflow: auto; }
  body[data-teach-view='present'] .t-dock { grid-row: 2; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; grid-template-areas: 'clock clock' 'prev next'; }
  .t-prep { min-height: calc(100dvh - 116px); height: auto; }
}

@media (max-width: 420px) {
  .t-session-time { display: none; }
  .t-title { font-size: 0.9rem; }
  .t-pacing { max-width: 220px; }
  .t-board-tools { justify-content: flex-start; flex-wrap: wrap; }
  .t-copy-status { order: 3; flex-basis: 100%; }
  .t-clock-readout > span { max-width: 92px; }
}

@media (max-width: 699px) and (max-height: 739px) {
  .t-dock { position: static; }
}

@keyframes t-surface-in {
  from { opacity: 0.72; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes t-arrow-in {
  from { opacity: 0; }
  to { opacity: 0.92; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
