/* "Blue book" exam paper: cool ruled paper, navy ink, a cobalt pen for the student, red only for the margin
   rule and the subskill under focus. */
:root {
  --paper: #f3f6f9;
  --sheet: #ffffff;
  --rule: #d5dfea;
  --rule-soft: #ebf0f6;
  --ink: #1c2748;
  --ink-2: #5a6684;
  --pen: #2a47c4;
  --margin-red: #d2574a;
  --focus-ring: #2a47c4;
  --fill: #1c2748;
  --empty: #dfe6ef;
  --serif: "Literata", Georgia, serif;
  --sans: "Public Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1525; --sheet: #141d33; --rule: #26334f; --rule-soft: #1b2640;
    --ink: #e2e8f3; --ink-2: #94a0bb; --pen: #93a9ff; --margin-red: #e8776b;
    --focus-ring: #93a9ff; --fill: #e2e8f3; --empty: #26334f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1525; --sheet: #141d33; --rule: #26334f; --rule-soft: #1b2640;
  --ink: #e2e8f3; --ink-2: #94a0bb; --pen: #93a9ff; --margin-red: #e8776b;
  --focus-ring: #93a9ff; --fill: #e2e8f3; --empty: #26334f; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr) 288px; height: 100dvh; }
.sessions, .ledger { background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.sessions { border-right: 1px solid var(--rule); padding: 20px 14px 14px; }
.ledger { border-left: 1px solid var(--rule); padding: 20px 20px 16px; overflow-y: auto; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--sheet); }

.wordmark { font: 600 1.25rem/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.sessions-head, .ledger-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.new-btn { width: 100%; margin-bottom: 14px; }
.session-list { flex: 1; overflow-y: auto; margin: 0 -6px; }
.session-item { display: flex; align-items: center; gap: 4px; border-radius: 6px; }
.session-item a { flex: 1; min-width: 0; padding: 7px 8px; color: var(--ink); text-decoration: none; font-size: 0.9rem; line-height: 1.3; }
.session-item a span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item a small { color: var(--ink-2); font-size: 0.75rem; }
.session-item:hover { background: var(--rule-soft); }
.session-item.active { background: var(--rule-soft); box-shadow: inset 2px 0 0 var(--margin-red); }
.session-item .del { opacity: 0; border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 6px 8px; border-radius: 4px; }
.session-item:hover .del, .session-item .del:focus-visible { opacity: 1; }
.session-empty { color: var(--ink-2); font-size: 0.875rem; padding: 4px 8px; }
.sessions-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--rule); }
.mode-pill { font-size: 0.75rem; color: var(--ink-2); }

/* ---------- buttons */
.btn { appearance: none; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); padding: 9px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 0.95rem; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.btn-primary:hover { background: var(--pen); border-color: var(--pen); }
.btn:disabled { opacity: 0.5; cursor: default; }
.link-btn { border: 0; background: none; padding: 4px 2px; color: var(--ink-2); cursor: pointer; font-size: 0.9rem; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }
.icon-btn { border: 0; background: none; padding: 6px 8px; cursor: pointer; color: var(--ink-2); font-size: 0.95rem; border-radius: 4px; }

/* ---------- start screen: a ruled sheet with a red margin */
.start {
  flex: 1; overflow-y: auto; padding: 12vh 40px 40px 120px; position: relative;
  background:
    linear-gradient(to right, transparent 86px, var(--margin-red) 86px, var(--margin-red) 88px, transparent 88px),
    repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--rule-soft) 31px, var(--rule-soft) 32px);
}
.start-form { max-width: 640px; }
.start-q { font: 500 clamp(2rem, 4.5vw, 3.1rem)/1.1 var(--serif); letter-spacing: -0.02em; margin: 0 0 28px; text-wrap: balance; }
.start-row { display: flex; gap: 10px; }
.start-row input { flex: 1; min-width: 0; padding: 13px 14px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); font-size: 1.05rem; color: var(--pen); }
.start-row input::placeholder { color: var(--ink-2); opacity: 0.7; }
.start-go { margin-top: 16px; }
.start-go .btn { padding: 13px 22px; font-size: 1.05rem; }
.start-blurb { color: var(--ink-2); max-width: 60ch; margin: 14px 0 36px; font-size: 0.95rem; }
.book-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 12px 0 2px; }
.book-row label { font-weight: 600; font-size: 0.9rem; }
.book-row select { flex: 1 1 260px; min-width: 0; max-width: 100%; padding: 9px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); color: var(--ink); font: inherit; font-size: 0.95rem; }
/* Textbook figures the tutor shows with [[fig <id>]] */
.book-fig { margin: 12px 0; }
.book-fig img { display: block; max-width: 100%; max-height: 360px; height: auto; border: 1px solid var(--rule); border-radius: 6px; background: #fff; }
.book-fig figcaption { margin-top: 4px; font-size: 0.82rem; color: var(--ink-2); }
.board-body .book-fig img { max-height: 46vh; }
.lang-pick { border: 0; padding: 0; margin: 14px 0 0; }
.lang-pick legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 10px; padding: 0; }
.lang-options { display: flex; gap: 8px; flex-wrap: wrap; }
.lang-opt { flex: 1 1 0; min-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); cursor: pointer; text-align: center; }
.lang-opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.lang-opt:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.lang-opt input { position: absolute; opacity: 0; pointer-events: none; }
.lang-opt strong { font-weight: 600; }
.lang-opt span { color: var(--ink-2); font-size: 0.8rem; }
.book-mode { margin-top: 12px; }
.skill-pick { border: 0; padding: 0; margin: 0; }
.skill-pick legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 10px; padding: 0; }
.skill-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); cursor: pointer; }
.skill-opt:has(input:checked) { border-color: var(--ink); }
.skill-opt input { margin-top: 4px; accent-color: var(--ink); }
.skill-opt strong { font-weight: 600; }
.skill-desc { display: block; color: var(--ink-2); font-size: 0.875rem; margin-top: 2px; }
.custom-skill { margin: 8px 0 0 0; }
.custom-row { display: flex; gap: 8px; margin-bottom: 8px; }
.custom-row input, .custom-skill textarea { flex: 1; width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); }
.custom-skill textarea { font: 0.82rem/1.5 var(--mono); resize: vertical; }
.hint { color: var(--ink-2); font-size: 0.82rem; margin: 6px 0 0; }
.credit { color: var(--ink-2); font-size: 0.8rem; margin: 48px 0 0; max-width: 640px; }
.credit a { color: inherit; }

/* ---------- dialogue: a script, speaker in the margin */
.convo { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; }
.dialogue {
  list-style: none; margin: 0; padding: 40px 32px 24px 0; max-width: 820px;
  background: linear-gradient(to right, transparent 102px, var(--margin-red) 102px, var(--margin-red) 104px, transparent 104px);
  min-height: 100%;
}
.turn { display: grid; grid-template-columns: 104px minmax(0, 1fr); margin-bottom: 26px; }
.speaker { text-align: right; padding: 3px 16px 0 0; font-size: 0.78rem; font-weight: 600; color: var(--ink-2); letter-spacing: 0.01em; }
.turn .body { padding-left: 22px; min-width: 0; max-width: 68ch; }
.turn.user .speaker { color: var(--pen); }
.turn.user .body { color: var(--pen); white-space: pre-wrap; font-size: 1rem; }
.turn.assistant .body { font: 1.03rem/1.65 var(--serif); }
.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p { margin: 0 0 0.8em; }
.body h1, .body h2, .body h3 { font: 600 1.1rem/1.3 var(--serif); margin: 1.2em 0 0.4em; }
.body ul, .body ol { padding-left: 1.3em; margin: 0 0 0.8em; }
.body li { margin: 0.2em 0; }
.body code { font: 0.86em var(--mono); background: var(--rule-soft); padding: 0.1em 0.35em; border-radius: 3px; }
.body pre { font: 0.82rem/1.45 var(--mono); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 12px 14px; overflow-x: auto; margin: 0 0 0.9em; }
.body pre code { background: none; padding: 0; font-size: inherit; }
.body blockquote { margin: 0 0 0.8em; padding-left: 14px; border-left: 2px solid var(--rule); color: var(--ink-2); }
.body a { color: var(--pen); }
.body table { border-collapse: collapse; font-size: 0.9rem; margin-bottom: 0.9em; }
.body th, .body td { border: 1px solid var(--rule); padding: 4px 8px; }
.cursor::after { content: ""; display: inline-block; width: 0.5em; height: 1.05em; background: var(--ink-2); vertical-align: text-bottom; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.thinking { color: var(--ink-2); font: italic 1rem var(--serif); }
.turn-error { color: var(--margin-red); font-size: 0.92rem; }
.turn-error .btn { margin-left: 8px; padding: 4px 10px; font-size: 0.85rem; }

/* ---------- composer */
.composer-wrap { border-top: 1px solid var(--rule); padding: 12px 32px 14px 126px; background: var(--sheet); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; max-width: 694px; }
.chip { border: 1px solid var(--rule); background: var(--sheet); color: var(--ink-2); border-radius: 999px; padding: 3px 11px; font-size: 0.8rem; cursor: pointer; }
.chip:hover { color: var(--ink); border-color: var(--ink-2); }
.composer { display: flex; gap: 8px; align-items: flex-end; max-width: 694px; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; background: var(--sheet); color: var(--pen); max-height: 40vh; line-height: 1.45; }
.composer textarea:focus { border-color: var(--ink-2); outline: none; }
.composer-hint { margin: 6px 0 0; font-size: 0.72rem; color: var(--ink-2); }

/* ---------- ledger (skill map) */
.ledger h2 { font: 600 1.05rem/1 var(--serif); margin: 0; }
.ledger-topic { font: 500 1rem/1.3 var(--serif); margin: 0 0 4px; }
.ledger-overall { display: flex; align-items: baseline; gap: 8px; margin-bottom: 18px; color: var(--ink-2); font-size: 0.85rem; }
.ledger-overall b { font: 500 1.9rem/1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.skill-rows { list-style: none; margin: 0 0 20px; padding: 0; }
.skill-row { border-bottom: 1px solid var(--rule-soft); }
.skill-go { display: block; width: 100%; padding: 9px 6px; margin: 0; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.skill-go:hover { background: var(--rule-soft); }
.skill-go:focus-visible { outline: 2px solid var(--margin-red); outline-offset: -2px; }
.skill-row:first-child { border-top: 1px solid var(--rule-soft); }
.skill-row-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.88rem; line-height: 1.3; margin-bottom: 6px; }
.skill-row-top span:last-child { font-variant-numeric: tabular-nums; color: var(--ink-2); flex: none; }
.pips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.pip { height: 6px; border-radius: 1px; background: var(--empty); }
.pip.on { background: var(--fill); }
.skill-row.focus .skill-row-top span:first-child { color: var(--margin-red); font-weight: 600; }
.skill-row.focus .pip.on { background: var(--margin-red); }
.skill-note { display: block; font-size: 0.75rem; color: var(--ink-2); margin-top: 4px; }
.ledger-empty { color: var(--ink-2); font-size: 0.88rem; margin: 0 0 20px; }
.ledger-updated { font-size: 0.75rem; color: var(--ink-2); margin: -10px 0 20px; }
.scale { margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 0.78rem; color: var(--ink-2); display: grid; gap: 3px; }
.scale div { display: flex; gap: 8px; }
.scale dt { font-family: var(--mono); color: var(--ink); width: 1ch; }
.scale dd { margin: 0; }

/* ---------- settings */
.settings { border: 1px solid var(--rule); border-radius: 10px; padding: 24px; width: min(460px, calc(100vw - 32px)); background: var(--sheet); color: var(--ink); }
.settings::backdrop { background: rgb(14 21 37 / 0.45); }
.settings h2 { font: 600 1.3rem/1.2 var(--serif); margin: 0 0 6px; }
.settings-lede { color: var(--ink-2); font-size: 0.92rem; margin: 0 0 18px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 5px; }
.field input { width: 100%; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.field small { display: block; color: var(--ink-2); font-size: 0.78rem; margin-top: 5px; line-height: 1.4; }
.check-result { min-height: 1.4em; font-size: 0.88rem; margin: 0 0 12px; }
.check-result.ok { color: var(--pen); }
.check-result.bad { color: var(--margin-red); }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; }
.acct-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 16px; }
.acct-links:empty { display: none; }
.acct-links .link-btn { color: var(--pen); padding: 0; }
.acct-links .link-btn.danger { color: var(--margin-red); }
.code-input { font-family: var(--mono); font-size: 1.25rem; letter-spacing: 0.35em; }
.acct-hint { margin: 28px 0 0; max-width: 640px; }
.acct-hint .link-btn { font-size: inherit; color: var(--pen); padding: 0; }
.acct-hint + .credit { margin-top: 14px; }

/* ---------- responsive */
.only-mobile { display: none; }
.scrim { display: none; }
@media (max-width: 1100px) {
  .shell { grid-template-columns: 232px minmax(0, 1fr); }
  .ledger { position: fixed; inset: 0 0 0 auto; width: min(320px, 88vw); z-index: 20; transform: translateX(100%); transition: transform 0.2s ease; box-shadow: none; }
  .shell.map-open .ledger { transform: none; box-shadow: -8px 0 30px rgb(0 0 0 / 0.12); }
  .shell.map-open .scrim { display: block; }
  .only-mobile.ledger-only, #open-map { display: inline-block; }
  .topbar { display: flex !important; }
  #open-sessions { visibility: hidden; }
  #close-map { display: inline-block; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sessions { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
  .shell.sessions-open .sessions { transform: none; box-shadow: 8px 0 30px rgb(0 0 0 / 0.12); }
  .shell.sessions-open .scrim { display: block; }
  .only-mobile { display: inline-block; }
  #open-sessions { visibility: visible; }
  .start { padding: 48px 16px 32px 16px; background: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--rule-soft) 31px, var(--rule-soft) 32px); }
  .start-row { flex-direction: column; }
  .start-go .btn { width: 100%; }
  .dialogue { padding: 20px 16px 16px 0; background: linear-gradient(to right, transparent 15px, var(--margin-red) 15px, var(--margin-red) 16px, transparent 16px); }
  .turn { grid-template-columns: 16px minmax(0, 1fr); }
  .speaker { grid-column: 2; padding: 0 0 4px 14px; text-align: left; }
  .turn .body { grid-column: 2; padding-left: 14px; }
  .composer-wrap { padding: 10px 16px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
}
.topbar { display: none; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--rule); background: var(--sheet); }
.topbar-title { font: 600 1rem/1 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { position: fixed; inset: 0; background: rgb(14 21 37 / 0.35); z-index: 10; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- voice call
   A call is the one dark surface in the app: navy like the ink, with the tutor as a monogram that rings
   when it speaks, the board beside it, captions underneath. */
.main { position: relative; }
.start-alt { margin: 12px 0 0; color: var(--ink-2); font-size: 0.92rem; }
.start-alt .link-btn { font-size: inherit; color: var(--pen); padding: 0; }
.call-btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.call-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.shell.in-call { grid-template-columns: 0 minmax(0, 1fr) 288px; }
.shell.in-call .sessions { overflow: hidden; padding: 0; border: 0; }
.call {
  --c-bg: #131b30; --c-surface: #1b2541; --c-line: #2c3a5e; --c-text: #e6ebf5; --c-dim: #9aa6c2;
  --c-pen: #9fb3ff; --c-red: #ee7d70;
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
  background: var(--c-bg); color: var(--c-text); padding: 16px 24px 18px;
}
.call-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.88rem; color: var(--c-dim); }
.call-topic { font: 500 1rem/1.3 var(--serif); color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-timer { font-variant-numeric: tabular-nums; }
.call-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 40px; padding: 12px 0; }
/* With something on the board, the board is the stage: as big as fits, with the teacher small (a quarter of
   his usual size) in a row under it. */
.call-stage.has-board { flex-direction: column; gap: 10px; justify-content: flex-start; padding: 8px 0 6px; }
.call-stage.has-board .board { order: 1; flex: 1 1 auto; width: min(1040px, 100%); height: auto; min-height: 0; }
.call-stage.has-board .presence { order: 2; flex: 0 0 auto; width: auto; flex-direction: row; gap: 10px; }
.call-stage.has-board .face { width: 40px; height: 40px; font-size: 1.2rem; border-width: 2px; }
.call-stage.has-board .rings { top: 0; left: 0; width: 40px; height: 40px; transform: none; }
.call-stage.has-board .nametag { margin-top: 0; text-align: left; display: flex; gap: 8px; align-items: baseline; }
.call-stage.has-board .nametag strong { font-size: 0.92rem; }

.presence { position: relative; width: 240px; display: flex; flex-direction: column; align-items: center; }
.face {
  position: relative; z-index: 1; width: 148px; height: 148px; border-radius: 50%;
  display: grid; place-items: center; background: var(--c-surface); border: 2px solid var(--c-line);
  font: italic 500 4.4rem/1 var(--serif); color: var(--c-text); transition: border-color 0.25s, transform 0.12s;
}
.face.has-avatar { overflow: hidden; background: #25335c; }
.face.has-avatar .avatar { width: 100%; height: 100%; display: block; }
.avatar .av-head { transition: transform 0.08s linear; }
.avatar .av-eyes { transform-box: fill-box; transform-origin: center; transition: transform 0.07s; }
.avatar .av-eyes.blink { transform: scaleY(0.12); }
.avatar .av-brows, .avatar .av-pupils { transition: transform 0.3s ease; }
.avatar[data-state="listening"] .av-brows { transform: translateY(-1.6px); }            /* attentive */
.avatar[data-state="thinking"] .av-pupils { transform: translate(1.4px, -1.2px); }     /* looks up, thinking */
.presence[data-state="listening"] .face.has-avatar .avatar { transform: rotate(-3deg); transition: transform 0.4s ease; }
.face.has-avatar .avatar { transition: transform 0.4s ease; }
.rings { position: absolute; top: 0; left: 50%; width: 148px; height: 148px; transform: translateX(-50%); }
.rings span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--c-red); opacity: 0; }
.presence[data-state="speaking"] .face { border-color: var(--c-red); }
.presence[data-state="speaking"] .rings span { animation: ring 1.8s ease-out infinite; }
.presence[data-state="speaking"] .rings span:nth-child(2) { animation-delay: 0.6s; }
.presence[data-state="speaking"] .rings span:nth-child(3) { animation-delay: 1.2s; }
.presence.pulse .face { transform: scale(1.03); }
@keyframes ring { from { transform: scale(1); opacity: 0.55; } to { transform: scale(1.75); opacity: 0; } }
.presence[data-state="listening"] .face { border-color: var(--c-pen); }
.presence[data-state="listening"] .rings span:first-child { border-color: var(--c-pen); opacity: 0.35; transform: scale(1.14); transition: transform 0.15s; }
.presence[data-state="listening"].heard .rings span:first-child { transform: scale(1.24); opacity: 0.6; }
.presence[data-state="thinking"] .rings span:first-child { opacity: 0.8; border-color: transparent; border-top-color: var(--c-dim); transform: scale(1.12); animation: spin 1s linear infinite; }
@keyframes spin { from { rotate: 0deg; } to { rotate: 360deg; } }
.nametag { margin-top: 22px; text-align: center; display: grid; gap: 2px; }
.nametag strong { font: 600 1.05rem/1.2 var(--serif); }
.nametag span { font-size: 0.82rem; color: var(--c-dim); }
.presence[data-state="listening"] .nametag span { color: var(--c-pen); }
.presence[data-state="speaking"] .nametag span { color: var(--c-red); }

/* The board is a classroom chalkboard: green slate in a wooden frame with a chalk ledge, written on in chalk.
   Comic Mono (self-hosted, MIT, see comic-mono-LICENSE.txt) is a fixed-width Comic Sans look-alike, so skill maps
   and diagrams still line up; Kalam writes the Hindi. */
@font-face { font-family: "Comic Mono"; src: url("comic-mono.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Comic Mono"; src: url("comic-mono-bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
/* The board keeps one size whatever is written on it (longer work scrolls inside), so the call doesn't jump. */
.board {
  --chalk: #f4f1e6; --chalk-dim: #c9d6c5; --chalk-yellow: #f2e394; --chalk-pink: #f2a99a;
  --chalk-font: "Comic Mono", "Comic Sans MS", "Kalam", "Chalkboard SE", cursive;
  flex: 0 0 auto; width: min(560px, 100%); height: min(440px, 100%); min-width: 0; overflow: hidden auto; color-scheme: dark;
  color: var(--chalk); font-family: var(--chalk-font);
  background-color: #2c4a37;
  background-image:
    radial-gradient(ellipse 60% 45% at 22% 18%, rgb(255 255 255 / 0.08), transparent 70%),  /* old chalk smudges */
    radial-gradient(ellipse 50% 40% at 78% 80%, rgb(255 255 255 / 0.06), transparent 70%),
    radial-gradient(ellipse 80% 70% at 50% 50%, transparent 40%, rgb(0 0 0 / 0.28));        /* darker towards the frame */
  border: 10px solid #7a4e2b; border-bottom-width: 16px;                                     /* frame, deeper ledge at the bottom */
  border-radius: 6px; padding: 14px 18px 16px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.35), inset 0 2px 14px rgb(0 0 0 / 0.4), 0 8px 22px rgb(0 0 0 / 0.35);
}
.board-head { margin: 0 0 10px; font: 700 0.85rem/1.2 var(--chalk-font); letter-spacing: 0.02em; color: var(--chalk-yellow); text-shadow: 0 0 6px rgb(242 227 148 / 0.25); }
.board-body { font-size: 1.02rem; line-height: 1.55; text-shadow: 0 0 1px rgb(255 255 255 / 0.55), 0 0 7px rgb(255 255 255 / 0.12); }
/* Long lines wrap onto the next line: a student never has to scroll the board sideways. */
.board-body pre { font: 1.02rem/1.55 var(--chalk-font); background: none; border: 0; border-radius: 0; padding: 2px 0; margin: 0 0 1em; color: var(--chalk); white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: visible; }
.board-body pre + pre { border-top: 1px dashed rgb(244 241 230 / 0.22); padding-top: 12px; }
.board-body code { font-family: var(--chalk-font); background: rgb(255 255 255 / 0.08); color: var(--chalk); }
.board-body pre code { background: none; }
.board-body pre:has(> code.language-question) { border-left: 3px solid var(--chalk-yellow); padding-left: 12px; }
.board-body .katex { font-size: 1.18em; line-height: 1.9; }
.board-body .katex-display { margin: 0.4em 0; text-align: left; }
.board-body .katex-display > .katex { text-align: left; }
.board-body h1, .board-body h2, .board-body h3, .board-body strong { color: var(--chalk-yellow); font-family: var(--chalk-font); }
.board-body a { color: var(--chalk-yellow); }
.board-body th, .board-body td { border-color: rgb(244 241 230 / 0.35); }
.board-body blockquote { border-left-color: rgb(244 241 230 / 0.35); color: var(--chalk-dim); }
.board-body .book-fig img { border: 5px solid #fbfaf5; border-radius: 2px; box-shadow: 0 4px 12px rgb(0 0 0 / 0.4); transform: rotate(-0.6deg); }
.board-body .book-fig figcaption { color: var(--chalk-dim); font-size: 0.85rem; margin-top: 8px; text-shadow: none; }

.captions { min-height: 4.6em; max-width: 760px; width: 100%; margin: 0 auto; text-align: center; }
.cap-tutor { margin: 0 0 6px; font: 1.2rem/1.45 var(--serif); text-wrap: balance; }
/* Karaoke captions: words not yet said are dim, the word being said is lit, said words are full white. */
.cap-tutor .w { border-radius: 4px; transition: color 0.12s, background-color 0.12s, box-shadow 0.12s; }
.cap-tutor.karaoke .w { color: rgb(230 235 245 / 0.42); }
.cap-tutor.karaoke .w.said { color: var(--c-text); }
.cap-tutor.karaoke .w.now { color: #fff; background: rgb(238 125 112 / 0.32); box-shadow: 0 0 0 3px rgb(238 125 112 / 0.32); }
.cap-you { margin: 0; color: var(--c-pen); font-size: 1rem; min-height: 1.5em; }
.cap-you .interim { opacity: 0.6; }
.call-notice { max-width: 640px; margin: 6px auto 0; text-align: center; font-size: 0.85rem; color: var(--c-red); }
.call-type { display: flex; gap: 8px; max-width: 640px; width: 100%; margin: 10px auto 0; }
.call-type input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-text); }
.call .btn-primary { background: var(--c-text); border-color: var(--c-text); color: var(--c-bg); }
.call-answers { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 12px auto 0; }
.call-answers[hidden] { display: none; }
.call-answers .answer-choice { min-width: 110px; padding: 12px 22px; border-radius: 999px; border: 2px solid var(--c-pen); background: var(--c-surface); color: var(--c-text); font: 600 1.05rem/1.2 var(--sans, inherit); cursor: pointer; }
.call-answers .answer-choice:hover, .call-answers .answer-choice:focus-visible { background: var(--c-pen); color: var(--c-bg); outline: none; }
.answer-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.answer-choices .answer-choice { padding: 8px 18px; border-radius: 999px; }
.q-groups .q-group details > summary { list-style: none; cursor: pointer; padding: 9px 6px 6px; margin: 0; }
.q-groups .q-group details > summary::-webkit-details-marker { display: none; }
.q-groups .q-group details > summary span:first-child::before { content: "▸ "; color: var(--ink-2); }
.q-groups .q-group details[open] > summary span:first-child::before { content: "▾ "; }
.q-groups .q-group.complete .skill-row-top span:last-child { color: var(--margin-red); font-weight: 600; }
.q-bar { height: 4px; margin: 0 6px 8px; border-radius: 2px; background: var(--rule-soft); overflow: hidden; }
.q-bar span { display: block; height: 100%; background: var(--pen, #1d2a4d); }
.q-group.focus .q-bar span { background: var(--margin-red); }
.q-list { list-style: none; margin: 0 0 8px; padding: 0; }
.q-item { display: grid; grid-template-columns: 14px auto minmax(0, 1fr); gap: 6px; align-items: baseline; width: 100%; padding: 5px 6px; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; font-size: 0.82rem; line-height: 1.35; text-align: left; cursor: pointer; }
.q-item:hover { background: var(--rule-soft); }
.q-item:focus-visible { outline: 2px solid var(--margin-red); outline-offset: -2px; }
.q-item .q-mark { color: var(--margin-red); font-weight: 700; }
.q-item .q-label { font-weight: 600; font-variant-numeric: tabular-nums; }
.q-item .q-text { color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.q-item.done .q-text { text-decoration: line-through; text-decoration-color: rgb(0 0 0 / 0.25); }
.q-item.now { background: var(--rule-soft); }
.q-item.now .q-label, .q-item.now .q-text { color: var(--margin-red); }
.call-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 12px auto 0; }
.call-chips .chip { background: transparent; border-color: var(--c-line); color: var(--c-dim); }
.call-chips .chip:hover { color: var(--c-text); border-color: var(--c-dim); }

.call-bar { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.cbtn { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; padding: 10px 8px 8px; border: 0; border-radius: 10px; background: var(--c-surface); color: var(--c-text); cursor: pointer; font-size: 0.75rem; }
.cbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cbtn:hover { background: var(--c-line); }
.cbtn:disabled { opacity: 0.4; cursor: default; }
.cbtn .slash { display: none; }
/* Raise hand: stop the tutor mid-explanation and ask a doubt */
.cbtn .hand-ico { font-size: 20px; line-height: 22px; height: 22px; }
.cbtn-hand.up { background: #f6c64a; color: #1c2748; }
.cbtn[aria-pressed="false"]#c-mic { background: var(--c-text); color: var(--c-bg); }
.cbtn[aria-pressed="false"]#c-mic .slash { display: inline; }
.cbtn[aria-pressed="true"]#c-type, .cbtn[aria-expanded="true"] { background: var(--c-line); }
.cbtn.end { background: var(--c-red); color: #1a0f0e; }
.cbtn.end:hover { background: #f39488; }
.call :focus-visible { outline-color: var(--c-pen); }
.voice-pop { position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%); width: min(360px, calc(100% - 32px)); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; font-size: 0.85rem; }
.voice-pop label { display: grid; gap: 4px; color: var(--c-dim); }
.voice-pop select { padding: 7px; border-radius: 6px; background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-line); }
.voice-pop .link-btn { color: var(--c-pen); justify-self: start; }

@media (max-width: 1100px) { .shell.in-call { grid-template-columns: 0 minmax(0, 1fr); } }
@media (max-width: 760px) {
  .shell.in-call { grid-template-columns: minmax(0, 1fr); }
  .call { padding: 12px 16px max(14px, env(safe-area-inset-bottom)); }
  .call-stage { flex-direction: column; gap: 14px; justify-content: flex-start; }
  .call-stage:not(.has-board) { justify-content: center; }
  .board { border-width: 7px 7px 11px; padding: 10px 12px 12px; }
  /* A skill map line is about 42 characters: shrink the chalk so it fits a phone's width (longer lines wrap). */
  .board-body, .board-body pre { font-size: clamp(0.7rem, 3vw, 1.02rem); }
  .cap-tutor { font-size: 1.05rem; }
  .call-bar { gap: 6px; flex-wrap: nowrap; }
  .cbtn { min-width: 0; flex: 1 1 0; max-width: 64px; padding: 8px 4px 6px; }
  .cbtn span { font-size: 0.7rem; }
}
.call-sound { max-width: 640px; margin: 8px auto 0; text-align: center; font-size: 0.85rem; color: var(--c-dim); }
.call-sound .btn { margin-left: 6px; padding: 6px 12px; font-size: 0.85rem; vertical-align: middle; }
.voice-pop .voice-help { margin: 0; color: var(--c-dim); font-size: 0.8rem; line-height: 1.4; }

/* ---------- side panel tabs */
.tabs { display: flex; gap: 2px; margin: -4px 0 0 -8px; min-width: 0; }
.tab { border: 0; background: none; padding: 6px 8px; border-radius: 5px; cursor: pointer; color: var(--ink-2); font: 600 0.86rem/1 var(--sans); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--rule-soft); }
.tab-count { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel .link-btn { color: var(--pen); }

/* ---------- command controls, saved state, resume */
.turn-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; font-family: var(--sans); }
.turn-actions .btn { padding: 6px 12px; font-size: 0.85rem; }
.resume-from { margin: -22px 0 30px; }
.resume-from > .link-btn { color: var(--pen); padding: 0; font-size: 0.9rem; }
#resume-box { margin-top: 10px; display: grid; gap: 8px; justify-items: start; }
#resume-box textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); font: 0.82rem/1.5 var(--mono); resize: vertical; }
#resume-box .hint { margin: 0; }

/* ---------- break */
.break { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 24px;
  background: repeating-linear-gradient(to bottom, var(--sheet) 0, var(--sheet) 31px, var(--rule-soft) 31px, var(--rule-soft) 32px); }
.break-card { max-width: 440px; text-align: center; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 34px 32px 30px; }
.break-eyebrow { margin: 0; font: 600 0.78rem/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--margin-red); }
.break-time { margin: 10px 0 6px; font: 500 3.4rem/1 var(--serif); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.break-lede { margin: 0 0 22px; color: var(--ink-2); font-size: 0.95rem; }
.break-where { text-align: left; border-left: 2px solid var(--margin-red); padding: 2px 0 2px 14px; margin: 0 0 24px; }
.break-label { margin: 0 0 3px; font-size: 0.75rem; font-weight: 600; color: var(--ink-2); }
.break-left { margin: 0; font: 1rem/1.5 var(--serif); }
.btn-label { margin-left: 0; }
#break-btn svg { stroke-width: 2.4; }
.cbtn .when-on { display: none; fill: currentColor; stroke: none; }
.cbtn[aria-pressed="true"]#c-pause { background: var(--c-text); color: var(--c-bg); }
.cbtn[aria-pressed="true"]#c-pause .when-on { display: inline; }
.cbtn[aria-pressed="true"]#c-pause .when-off { display: none; }
.call.paused .face { opacity: 0.45; }
.call.paused .cap-tutor { color: var(--c-dim); font-size: 1.05rem; }

/* ---------- notebook */
.notes-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.notes-head .ledger-topic { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-tools { display: flex; gap: 10px; flex: none; }
.notes-tools .link-btn { padding: 0; font-size: 0.82rem; }
.note-add { display: grid; gap: 6px; justify-items: end; margin-bottom: 16px; }
.note-add textarea, .note-edit { width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); color: var(--pen); font: 0.9rem/1.45 var(--sans); resize: vertical; }
.note-add .btn { padding: 6px 12px; font-size: 0.85rem; }
.note-list, .note-books { list-style: none; margin: 0; padding: 0; }
.note { padding: 12px 0; border-top: 1px solid var(--rule-soft); }
.note-quote { display: block; width: 100%; text-align: left; border: 0; border-left: 2px solid #e8b339; background: none; padding: 1px 0 1px 10px; margin: 0 0 6px; cursor: pointer;
  font: 0.88rem/1.5 var(--serif); color: var(--ink); white-space: pre-wrap; max-height: 9em; overflow: hidden; }
.note-text { margin: 0; color: var(--pen); font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-foot { display: flex; gap: 12px; align-items: center; margin-top: 6px; font-size: 0.74rem; color: var(--ink-2); }
.note-foot span { margin-right: auto; }
.note-foot .link-btn { padding: 0; font-size: 0.74rem; color: var(--ink-2); }
.note-foot .link-btn:hover { color: var(--ink); }
.note-book { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--rule-soft); background: none; padding: 9px 0; cursor: pointer; font-size: 0.9rem; color: var(--ink); }
.note-book span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-book small { flex: none; color: var(--ink-2); }
.note-books { margin-bottom: 14px; }
mark.hl { background: #fbe9a9; color: inherit; border-radius: 2px; padding: 0.08em 0; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark.hl.flash { animation: hlflash 1.2s ease; }
@keyframes hlflash { 0%, 60% { background: #f3c84a; } 100% { background: #fbe9a9; } }
.sel-save { position: fixed; z-index: 40; border: 0; border-radius: 6px; background: var(--ink); color: var(--sheet); padding: 7px 12px; font: 600 0.82rem/1 var(--sans); cursor: pointer; box-shadow: 0 4px 14px rgb(14 21 37 / 0.25); }
.sel-save::before { content: ""; display: inline-block; width: 0.7em; height: 0.7em; margin-right: 7px; background: #f3c84a; border-radius: 2px; }

/* ---------- wins: streak, goal, XP, badges */
.wins-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 100%; margin: 0 0 14px; padding: 9px 6px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); color: var(--ink-2); cursor: pointer; font: 0.7rem/1.2 var(--sans); }
.wins-strip:hover { border-color: var(--ink-2); }
.ws { display: grid; justify-items: center; gap: 2px; position: relative; }
.ws b { font: 600 1.05rem/1.1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.ws b { display: flex; align-items: center; gap: 5px; }
.ws .ring { width: 15px; height: 15px; }
.ring circle { fill: none; stroke: var(--empty); stroke-width: 3.5; }
.ring .ring-fill { stroke: var(--pen); stroke-linecap: round; transition: stroke-dasharray 0.5s ease; }
.wins-strip.at-risk .ws:first-child b { color: var(--margin-red); }
.wins-strip.bump { animation: bump 0.45s ease; }
@keyframes bump { 35% { transform: scale(1.04); border-color: var(--pen); } }
.new-btn { margin-bottom: 12px; }
.wins-hello { margin: 0 0 14px; font-size: 0.9rem; font-weight: 500; color: var(--pen); }

.wins-streak { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 12px; color: var(--ink-2); font-size: 0.9rem; }
.wins-streak b { font: 500 3rem/0.95 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.wins-streak.at-risk b { color: var(--margin-red); }
.wins-week { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 0 0 8px; padding: 0; }
.wins-week li { display: grid; justify-items: center; gap: 5px; }
.wins-week .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--empty); }
.wins-week li.on .dot { background: var(--fill); }
.wins-week li.today .dot { outline: 2px solid var(--pen); outline-offset: 2px; }
.wins-week small { font-size: 0.7rem; color: var(--ink-2); }
.wins-note { margin: 0 0 6px; font-size: 0.8rem; color: var(--margin-red); }
.wins-block { padding: 14px 0 0; margin-top: 12px; border-top: 1px solid var(--rule-soft); }
.wins-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.wins-label { font-weight: 600; font-size: 0.88rem; }
.wins-head { margin: 22px 0 8px; padding-top: 14px; border-top: 1px solid var(--rule-soft); }
.wins-xp { font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.wins-goal { font: inherit; font-size: 0.8rem; color: var(--ink-2); background: var(--sheet); border: 1px solid var(--rule); border-radius: 5px; padding: 2px 4px; }
.wins-bar { height: 8px; border-radius: 2px; background: var(--empty); overflow: hidden; }
.wins-bar span { display: block; height: 100%; background: var(--fill); border-radius: 2px; transition: width 0.6s ease; }
.wins-bar.pen span { background: var(--pen); }
.wins-sub { margin: 6px 0 0; font-size: 0.76rem; color: var(--ink-2); }
.wins-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 18px; }
.wins-tiles div { display: grid; gap: 2px; padding: 10px 4px; text-align: center; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); font-size: 0.72rem; color: var(--ink-2); }
.wins-tiles b { font: 500 1.35rem/1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.wins-certs, .wins-badges { list-style: none; margin: 0; padding: 0; }
.wins-certs li { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 0.88rem; }
.wins-certs a { color: var(--pen); }
.wins-certs small { color: var(--ink-2); flex: none; }
.wins-certs .link-btn { padding: 0; text-align: left; }
.wins-badges li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: start; padding: 6px 0; opacity: 0.55; }
.wins-badges li.got { opacity: 1; }
.badge-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--empty); color: var(--ink-2); font-size: 0.8rem; }
.wins-badges li.got .badge-mark { background: #e8b339; color: #1c2748; }
.wins-badges strong { display: block; font-size: 0.86rem; font-weight: 600; }
.wins-badges small { display: block; font-size: 0.75rem; color: var(--ink-2); }

.toasts { position: fixed; z-index: 60; top: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px;
  background: var(--ink); color: var(--sheet); box-shadow: 0 10px 30px rgb(14 21 37 / 0.28); cursor: pointer; animation: toast-in 0.42s cubic-bezier(0.2, 1.4, 0.4, 1); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: opacity 0.35s, transform 0.35s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-18px) scale(0.94); } }
.toast-mark { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #e8b339; color: #1c2748; font: 600 1.05rem/1 var(--serif); }
.toast.levelup .toast-mark { background: var(--margin-red); color: #fff; animation: pop 0.6s 0.15s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes pop { from { transform: scale(0.3); } }
.toast-body { display: grid; gap: 1px; }
.toast-body strong { font: 600 0.98rem/1.25 var(--serif); }
.toast-body span { font-size: 0.82rem; opacity: 0.82; line-height: 1.35; }
.toast .btn { padding: 6px 10px; font-size: 0.8rem; }
.xp-pop { position: fixed; z-index: 55; left: 50%; bottom: 132px; transform: translateX(-50%); padding: 4px 10px; border-radius: 999px; background: var(--pen); color: var(--sheet);
  font: 600 0.82rem/1.2 var(--sans); pointer-events: none; animation: xp-rise 1.25s ease-out forwards; }
@keyframes xp-rise { 0% { opacity: 0; transform: translate(-50%, 8px) scale(0.8); } 18% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -46px); } }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 58; pointer-events: none; display: none; }
.confetti.on { display: block; }
.cert-eyebrow { margin: 0 0 6px; font: 600 0.74rem/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--margin-red); }
.check-result a { color: var(--pen); }

@media (max-width: 760px) {
  .btn-label { display: none; }
  .composer .call-btn { padding: 9px 11px; }
  .break-time { font-size: 2.8rem; }
  .resume-from { margin-top: -18px; }
}

.board.stale { opacity: 0.55; }
.board.stale .board-head { color: var(--chalk-pink); }

/* ---------- teacher switch */
.teacher-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-2); margin-right: 4px; }
.teacher-pick select { font: inherit; color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 999px; padding: 3px 8px; cursor: pointer; }
.teacher-note { margin: 0 0 8px; font-size: 0.82rem; color: var(--pen); }

/* ---------- sound and mic check */
.vcheck { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.vc-device { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--ink-2); }
.vc-steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 14px; }
.vc-step { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--rule); border-radius: 8px; }
.vc-main { flex: 1; min-width: 0; }
.vc-dot { flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--rule); display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; }
.vc-step[data-state="busy"] .vc-dot { border-color: var(--pen); border-top-color: transparent; animation: vc-spin 0.9s linear infinite; }
.vc-step[data-state="ok"] { border-color: var(--pen); }
.vc-step[data-state="ok"] .vc-dot { border-color: var(--pen); background: var(--pen); color: var(--sheet); }
.vc-step[data-state="ok"] .vc-dot::after { content: "✓"; }
.vc-step[data-state="bad"] .vc-dot { border-color: var(--margin-red); color: var(--margin-red); }
.vc-step[data-state="bad"] .vc-dot::after { content: "!"; }
@keyframes vc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .vc-step[data-state="busy"] .vc-dot { animation: none; } }
.vc-msg { margin: 4px 0 10px; font-size: 0.92rem; color: var(--ink-2); }
.vc-msg:empty { display: none; }
.vc-say { color: var(--ink); font-weight: 600; }
.vc-heard { margin: 0 0 8px; font-size: 0.92rem; color: var(--pen); }
.vc-heard:empty { display: none; }
.vc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vc-meter { height: 8px; border-radius: 4px; background: var(--empty); overflow: hidden; margin: 0 0 10px; }
.vc-meter span { display: block; height: 100%; width: 0; background: var(--pen); transition: width 80ms linear; }
.vc-help { margin-top: 12px; padding: 12px 14px; border-radius: 6px; background: var(--paper); font-size: 0.9rem; }
.vc-help-title { margin: 0 0 6px; font-weight: 600; }
.vc-help ol { margin: 0; padding-left: 1.2em; display: grid; gap: 5px; }
.vc-foot { justify-content: space-between; align-items: center; }
.call-notice .link-btn { font-size: inherit; color: inherit; }
#vc-skip { white-space: nowrap; }
/* The book's question, written by the app from the tutor's [[q ...]] marker: wrap it, never scroll sideways. */
pre:has(> code.language-question), pre:has(> code.language-question) code { white-space: pre-wrap; overflow-wrap: anywhere; }
/* A diagram the tutor drew (an SVG block): chalk lines on the board, ink in the chat. */
.diagram { margin: 10px 0; color: var(--ink); }
.diagram svg { display: block; width: 100%; max-width: 560px; height: auto; max-height: 46vh; overflow: visible; font-family: var(--sans); }
.board-body .diagram { color: var(--chalk); }
.board-body .diagram svg { max-width: 720px; font-family: var(--chalk-font); }
.diagram svg text:not([fill]) { fill: currentColor; }
/* The board is written as the tutor speaks: a waiting block takes its space but is not yet written; then its
   lines are wiped in left to right, one after another, like chalk. */
.board-body .bb.wait { visibility: hidden; }
.board-body .bb .ln { display: inline-block; max-width: 100%; vertical-align: top; line-height: 1.5; }
@keyframes chalk-write { from { clip-path: inset(-4px 100% -4px 0); } to { clip-path: inset(-4px -4px -4px 0); } }
/* Captions: two lines at most, whatever happens. */
.cap-tutor { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cap-tutor .chunk[hidden] { display: none; }

/* The API key box is a plain text field drawn as dots: a password field gets the saved account password filled in by the browser. */
input.secret { -webkit-text-security: disc; }

/* Tables written on the board or in a reply as "a | b" rows: ruled, columns lined up, fitted to the width. */
.tbl { overflow-x: auto; margin: 0 0 0.9em; }
.tbl table { border-collapse: collapse; margin: 0; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.tbl caption { caption-side: top; text-align: left; font-weight: 600; padding: 0 0 6px; }
.tbl th, .tbl td { border: 1px solid var(--rule); padding: 4px 10px; text-align: center; vertical-align: middle; line-height: 1.3; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td:first-child { white-space: nowrap; }
.tbl th { font-weight: 600; }
.tbl tr.total td { font-weight: 700; border-top-width: 2px; }
.tbl code { font: inherit; background: none; padding: 0; color: inherit; }
.tbl .katex { font-size: 1em; line-height: 1.2; }
.board-body .tbl { margin-bottom: 1em; }
.board-body .tbl table { font: 1em/1.3 var(--chalk-font); color: var(--chalk); }
.board-body .tbl th, .board-body .tbl td { border-color: rgb(244 241 230 / 0.4); }
.board-body .tbl caption, .board-body .tbl th { color: var(--chalk-yellow); }
.board-body .tbl tr.total td { border-top-color: rgb(244 241 230 / 0.8); }
@media (max-width: 640px) { .tbl th, .tbl td { padding: 3px 6px; } }
@keyframes chalk-row { from { opacity: 0; } to { opacity: 1; } }
/* On the board a long table scrolls as rows are written: its column headings stay in view above the data. */
.board-body .tbl { overflow: visible; }
.board-body .tbl thead th { position: sticky; top: -14px; z-index: 1; background: #2c4a37; box-shadow: 0 0 0 1px rgb(244 241 230 / 0.4); }
