:root {
  color-scheme: dark;
  --bg: #050507;
  --fg: #f5f5f7;
  --dim: #8e939e;
  --soft: #b6b7ba;
  --hair: rgb(255 255 255 / 0.12);
  --hair-strong: rgb(255 255 255 / 0.2);
  --faint: rgb(255 255 255 / 0.06);
  --glass: rgb(255 255 255 / 0.04);
  --glass-strong: rgb(14 16 26 / 0.78);
  --accent: #5b8cff;
  --accent-soft: rgb(91 140 255 / 0.16);
  --violet: #8b5cf6;
  --mint: #4ade80;
  --gold: #fac86e;
  --sky: #78b4ff;
  --danger: #ff6b6b;
  --sans: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 18px;
  --radius-small: 12px;
  --pill: 999px;
  --gutter: 16px;
  --bar-height: 52px;
  --side-width: 360px;
  --panel-width: 360px;
  --orb-landing: 200px;
  --orb-side: 168px;
  --figure-accent: #6f9bff;
  --hand: "Caveat", "Segoe Print", cursive;
  --gold-glow: rgb(250 200 110 / 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 var(--sans);
  color: var(--fg);
  background:
    radial-gradient(1100px 700px at 50% -12%, rgb(91 140 255 / 0.14), transparent 60%),
    radial-gradient(900px 640px at 88% 112%, rgb(139 92 246 / 0.11), transparent 60%),
    radial-gradient(700px 520px at -6% 82%, rgb(74 222 128 / 0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}
#cosmos { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }

button, input, textarea, select { font: inherit; color: inherit; }
button {
  background: var(--glass);
  border: 1px solid var(--hair);
  border-radius: var(--pill);
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.25s var(--out), opacity 0.2s;
}
button:hover:not(:disabled) { background: rgb(255 255 255 / 0.09); }
button:active:not(:disabled) { transform: scale(0.96); }
button:disabled { opacity: 0.4; cursor: default; }
button.ghost { background: transparent; border-color: transparent; color: var(--soft); }
button.ghost:hover { color: var(--fg); background: var(--glass); }
button.accent { background: var(--accent-soft); border-color: rgb(91 140 255 / 0.55); white-space: nowrap; }
button.icon { display: inline-grid; place-items: center; padding: 7px; }
button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#voice[aria-pressed="true"] .mute, #voice[aria-pressed="false"] .waves { display: none; }
#side-toggle[aria-pressed="true"] { color: var(--fg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--glass);
  border: 1px solid var(--hair);
  border-radius: var(--radius-small);
  padding: 11px 14px;
  resize: vertical;
}
textarea::placeholder, input::placeholder { color: var(--dim); }

.eyebrow { display: block; margin-bottom: 6px; font: 500 11px/1 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }

.bar {
  position: fixed; inset: 0 0 auto; z-index: 4; height: var(--bar-height);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px 0 18px;
  background: linear-gradient(rgb(5 5 7 / 0.9), transparent);
}
.bar-start, .bar-actions { display: flex; align-items: center; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 6px; font-weight: 500; letter-spacing: 0.02em; }
.brand-logo { width: 28px; height: 28px; margin: -2px -2px -2px -4px; }
.timer { font: 500 13px var(--mono); color: var(--dim); font-variant-numeric: tabular-nums; margin-right: 6px; }

main { position: relative; z-index: 1; height: 100dvh; padding: var(--bar-height) var(--gutter) var(--gutter); }

.presence { display: flex; flex-direction: column; align-items: center; text-align: center; }
.orb { width: var(--orb-landing); aspect-ratio: 1; flex: none; margin: -24px 0 -34px; }
.voiceline { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.state { margin: 0; font: 500 11px/1 var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); }
.caption { margin: 0; min-height: 1.45em; font-size: clamp(17px, 2vw, 21px); font-weight: 300; line-height: 1.45; text-wrap: pretty; }
.caption.fresh { animation: rise 0.6s var(--out); }
.heard { margin: 0; min-height: 1.3em; color: var(--dim); font-size: 14px; font-style: italic; line-height: 1.4; }
.teacher-only { display: none !important; }
body.teacher .teacher-only:not([hidden]) { display: revert !important; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.orb.orb-fallback { border-radius: 50%; transform: scale(0.55); background: radial-gradient(circle at 34% 28%, #fff 0 4%, var(--accent) 34%, var(--violet) 66%, #0b0820); box-shadow: 0 0 60px rgb(91 140 255 / 0.5); }
.orb.orb-fallback[data-state="speaking"] { background: radial-gradient(circle at 34% 28%, #fff 0 4%, var(--gold) 34%, #ff7ab6 66%, #2a0d1c); }
.orb.orb-fallback[data-state="listening"] { background: radial-gradient(circle at 34% 28%, #fff 0 4%, var(--sky) 34%, #22d3ee 66%, #04202a); }

.landing { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0fr); gap: 0; transition: grid-template-columns 0.7s var(--out), gap 0.7s var(--out); }
.landing.has-preview { grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr); gap: 28px; }
.compose { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 4px 6px 12px; text-align: center; }
.compose::before, .compose::after { content: ""; flex: 1 0 0; }
.landing-slot .orb { margin: -26px 0 -34px; }
.landing-slot .caption:empty, .landing-slot .heard:empty { display: none; }
.compose h1 { margin: 4px 0 0; font-size: clamp(28px, 3vw, 40px); font-weight: 500; line-height: 1.12; letter-spacing: -0.025em; text-wrap: balance; }
.glow { background: linear-gradient(100deg, #9db8ff 10%, #c3a6ff 55%, var(--gold) 95%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.describe {
  width: min(100%, 620px); display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 10px 12px; text-align: left;
  border: 1px solid var(--hair-strong); border-radius: 20px; background: var(--glass-strong); backdrop-filter: blur(16px);
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.4), inset 0 1px 0 rgb(255 255 255 / 0.06); transition: border-color 0.2s, box-shadow 0.2s;
}
.describe textarea { border: none; background: transparent; padding: 4px; font-size: 17px; line-height: 1.5; resize: none; field-sizing: content; min-height: 4.6em; max-height: 11em; }
.describe textarea:focus-visible { outline: none; }
.describe:focus-within { border-color: rgb(91 140 255 / 0.6); box-shadow: 0 24px 70px rgb(0 0 0 / 0.4), 0 0 0 4px rgb(91 140 255 / 0.14); }
.talk-row:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.describe-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.build, .primary { display: inline-flex; align-items: center; gap: 8px; }
.build { padding: 9px 14px 9px 18px; font-weight: 500; }
.build svg, .primary svg { width: 18px; height: 18px; }
.describe.is-busy .build { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
article.preview {
  min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; text-align: left;
  visibility: hidden; opacity: 0; translate: 56px 0;
  transition: opacity 0.5s 0.2s, translate 0.7s var(--out) 0.1s, visibility 0s 0.7s;
  border: 1px solid var(--hair); border-radius: 24px; background: rgb(10 12 20 / 0.7); backdrop-filter: blur(18px);
  box-shadow: 0 40px 100px rgb(0 0 0 / 0.5), inset 0 1px 0 rgb(255 255 255 / 0.05);
}
.landing.has-preview article.preview { visibility: visible; opacity: 1; translate: 0 0; transition: opacity 0.5s 0.2s, translate 0.7s var(--out) 0.1s, visibility 0s; }
.preview-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--hair); }
.chip { padding: 3px 10px; border: 1px solid var(--hair); border-radius: var(--pill); background: var(--glass); color: var(--soft); font-size: 12px; }
#share { margin-left: auto; padding: 4px 10px; font-size: 12px; border-color: var(--hair); }
.preview-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px; scrollbar-color: var(--hair-strong) transparent; }
.preview .block { padding: 12px 14px; background: var(--glass); backdrop-filter: none; }
.preview .block-canvas { padding: 0; background: none; }
.preview .board-placeholder { min-height: 220px; }
.note { margin: 0; color: var(--gold); font-size: 13px; }
.preview-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--hair); background: rgb(10 12 20 / 0.55); }
.primary { padding: 12px 22px 12px 30px; border: none; font-weight: 500; font-size: 16px; background: linear-gradient(135deg, var(--accent), var(--violet)); box-shadow: 0 10px 40px rgb(91 140 255 / 0.35); }
.primary:hover:not(:disabled) { background: linear-gradient(135deg, #6d9bff, #9a70ff); }
#access { width: 150px; text-align: center; border-radius: var(--pill); }
.fine { margin: 0; color: var(--dim); font-size: 13px; }

body.working main { height: 100dvh; padding-bottom: var(--gutter); }
.studio { height: 100%; display: grid; grid-template-columns: var(--side-width) minmax(0, 1fr); gap: var(--gutter); transition: grid-template-columns 0.5s var(--out); }
body.focus .studio { grid-template-columns: 0 minmax(0, 1fr); gap: 0; }
body.focus .side { opacity: 0; pointer-events: none; }
.side { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding: 2px; transition: opacity 0.3s; }
.presence-slot .presence { padding-bottom: 4px; }
.presence-slot .orb { width: var(--orb-side); margin: -20px 0 -26px; }
.presence-slot { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--hair-strong) transparent; }
.presence-slot .caption { font-size: 17px; }
.workspace { min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.question-bar { flex: none; padding: 10px 16px 12px; border: 1px solid var(--hair); border-radius: var(--radius); background: var(--glass-strong); backdrop-filter: blur(16px); }
.question-bar .eyebrow { margin-bottom: 4px; }
.question-text { margin: 0; max-height: 6.6em; overflow-y: auto; font-size: 17px; font-weight: 500; line-height: 1.45; white-space: pre-wrap; }
.katex { font-size: 1.06em; }
.workspace { position: relative; }
.done {
  position: absolute; z-index: 4; left: 50%; bottom: 22px; translate: -50% 0; width: max-content; max-width: calc(100% - 32px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 20px; padding: 12px 12px 12px 22px;
  border: 1px solid rgb(74 222 128 / 0.35); border-radius: 22px; background: rgb(12 16 22 / 0.9); backdrop-filter: blur(18px);
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.55), 0 0 0 6px rgb(74 222 128 / 0.06); animation: done-in 0.6s var(--out);
}
.done-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 18px; font-weight: 500; }
.done-check { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #052e16; background: var(--mint); box-shadow: 0 0 18px rgb(74 222 128 / 0.55); font-size: 16px; font-weight: 700; }
.done-stats { color: var(--dim); font: 400 13px var(--mono); }
.done-stats:not(:empty)::before { content: "· "; }
.done-actions { display: flex; align-items: center; gap: 8px; }
.done-actions .primary { padding: 10px 18px 10px 24px; font-size: 15px; }
.done-actions button.is-busy { animation: pulse 1.2s ease-in-out infinite; }
@keyframes done-in { from { opacity: 0; translate: -50% 24px; } }

.talk { display: flex; flex-direction: column; gap: 8px; }
.talk-row { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--hair); border-radius: var(--pill); background: var(--glass-strong); backdrop-filter: blur(16px); }
.talk-input { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.talk-input input { border: none; background: transparent; padding: 2px 4px 4px; }
.talk-input input:focus-visible { outline: none; }
.mic-label { padding: 0 4px; font: 500 10px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.send { color: var(--soft); }
.talk-help { display: flex; gap: 8px; }
.talk-help .chip { flex: 1; font-size: 13px; padding: 8px 10px; }
.mic {
  --mic-level: 0;
  flex: none; width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--hair); color: var(--soft); background: var(--glass);
}
.mic .slash { display: none; }
.mic[aria-pressed="false"] .slash { display: inline; }
.mic[aria-pressed="true"] {
  border: none; color: #fff;
  background: radial-gradient(circle at 35% 30%, #a8c1ff, var(--accent) 55%, var(--violet));
  box-shadow: 0 0 0 calc(3px + var(--mic-level) * 16px) rgb(91 140 255 / 0.22), 0 0 22px rgb(91 140 255 / 0.45);
}

.activity { display: flex; flex-direction: column; gap: 12px; }
.studio .activity { flex: 1; min-height: 0; overflow-y: auto; padding: 2px; scrollbar-color: var(--hair-strong) transparent; }
.studio .activity.only-canvas { overflow: hidden; }
.block { position: relative; padding: 14px 16px; border: 1px solid var(--hair); border-radius: var(--radius); background: var(--glass-strong); backdrop-filter: blur(16px); }
.block-title { margin: 0 0 10px; font-size: 15px; font-weight: 500; line-height: 1.4; }
.block-text { margin: 0; font-size: 16px; line-height: 1.55; white-space: pre-line; }
.block.block-text, .preview .block.block-text { padding: 2px 4px; border: none; background: none; backdrop-filter: none; }
.figure { margin: 0; color: var(--fg); }
.figure svg { display: block; width: 100%; max-width: 520px; height: auto; max-height: min(340px, 45vh); margin: 0 auto; }
.block-canvas { display: flex; flex-direction: column; padding: 0; border: none; background: none; backdrop-filter: none; }
.block-canvas > .block-title { margin: 0 0 6px 4px; font-size: 13px; color: var(--soft); }
.block-canvas .canvas-area { flex: none; height: min(70vh, 640px); }
.only-canvas .block-canvas { flex: 1; min-height: 0; }
.only-canvas .block-canvas .canvas-area { flex: 1; height: auto; }
.board-placeholder { position: relative; min-height: 110px; display: grid; place-items: center; padding: 16px; color: var(--soft); border: 1px dashed var(--hair-strong); border-radius: var(--radius); background: radial-gradient(rgb(255 255 255 / 0.07) 1px, transparent 1px) 0 0 / 28px 28px; }
.board-placeholder svg { width: min(100%, 420px); height: auto; max-height: 220px; }
.answer { width: 100%; }
.answer.number, .answer.expression { font-family: var(--mono); font-size: 14px; }
.fields { display: grid; grid-template-columns: fit-content(55%) minmax(140px, 320px) auto; justify-content: start; align-items: center; gap: 10px 14px; }
.field { display: contents; }
.field-label { grid-column: 1; }
.given { font-family: var(--mono); color: var(--soft); }
.unit { color: var(--soft); }
.choices { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.choice { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--hair); border-radius: var(--pill); cursor: pointer; transition: background 0.2s, border-color 0.2s; }
.choice input { margin: 0; accent-color: var(--accent); }
.choice:has(input:checked) { background: var(--accent-soft); border-color: rgb(91 140 255 / 0.55); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.table-wrap { overflow-x: auto; }
.grid { border-collapse: collapse; font-size: 14px; }
.grid th { padding: 6px 8px; text-align: left; font-weight: 500; color: var(--soft); border-bottom: 1px solid var(--hair); }
.grid td { padding: 4px; border-bottom: 1px solid var(--faint); }
.grid td:not(:has(input)) { padding: 6px 8px; }
.grid .answer { width: 12em; padding: 7px 10px; border-radius: 8px; }
button.add { margin-top: 8px; padding: 5px 12px; font-size: 13px; border-color: var(--hair); }
.order { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: step; }
.order-item { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; border: 1px solid var(--hair); border-radius: var(--radius-small); background: var(--glass); cursor: grab; counter-increment: step; }
.order-item::before { content: counter(step); min-width: 1.2em; font: 500 12px var(--mono); color: var(--dim); }
.order-item.dragging { opacity: 0.45; }
.grip { color: var(--dim); letter-spacing: -0.2em; }
.order-text { flex: 1; }
button.move { padding: 4px 9px; }
.entries { margin: 0; padding-left: 1.7em; display: grid; gap: 6px; }
.entries li::marker { font: 12px var(--mono); color: var(--dim); }
.code-wrap { position: relative; border: 1px solid var(--hair); border-radius: var(--radius-small); background: rgb(4 5 9 / 0.75); }
.code-wrap:focus-within { border-color: rgb(91 140 255 / 0.6); }
.code-wrap .cm-editor { min-height: 12em; border-radius: inherit; font: 14px/1.6 var(--mono); }
.code-wrap .cm-editor.cm-focused { outline: none; }
.code-wrap .cm-scroller { font-family: var(--mono); min-height: 12em; }
.code-wrap .cm-content[contenteditable="false"] { opacity: 0.75; }
.code-wrap .cm-tooltip { border: 1px solid var(--hair-strong); border-radius: 8px; background: rgb(16 18 30); font-family: var(--mono); }
.code-wrap .cm-tooltip-autocomplete ul li[aria-selected] { background: var(--accent-soft); color: var(--fg); }
.code-wrap .cm-panels { background: rgb(16 18 30); color: var(--fg); }
.cm-tutor-line { background: rgb(250 200 110 / 0.12) !important; box-shadow: inset 3px 0 0 var(--gold); }
.tutor-note.on-code { position: absolute; right: 12px; z-index: 2; padding: 1px 8px; font-size: 20px; border: 1px solid var(--gold-glow); background: rgb(14 16 26 / 0.94); }
.code-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.code-language { font: 500 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
button.test { padding: 6px 18px; font-size: 13px; }
button.test.is-busy { animation: pulse 1.2s ease-in-out infinite; }
.examples { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.example { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--glass); font-size: 13px; }
.example code { font-family: var(--mono); }
.example .arrow { color: var(--dim); }
.example .result { margin-left: auto; font: 12px var(--mono); }
.example.passed { box-shadow: inset 3px 0 0 var(--mint); }
.example.passed .result { color: var(--mint); }
.example.failed { box-shadow: inset 3px 0 0 var(--danger); }
.example.failed .result { color: var(--danger); }
.doc-paper { padding: 4px 6px 10px; border: 1px solid var(--hair); border-radius: var(--radius-small); background: rgb(4 5 9 / 0.55); }
.doc-heading { margin: 14px 12px 6px; font-weight: 600; font-size: 15px; color: var(--soft); letter-spacing: 0.01em; }
.doc { border: 1px solid transparent; border-radius: var(--radius-small); transition: border-color 0.15s, background 0.15s; }
.doc:focus-within { border-color: rgb(91 140 255 / 0.5); background: rgb(91 140 255 / 0.04); }
.doc .milkdown {
  --crepe-color-background: transparent;
  --crepe-color-on-background: var(--fg);
  --crepe-color-surface: rgb(16 18 30);
  --crepe-color-surface-low: rgb(22 25 40);
  --crepe-color-on-surface: var(--fg);
  --crepe-color-on-surface-variant: var(--dim);
  --crepe-color-outline: var(--dim);
  --crepe-color-primary: var(--accent);
  --crepe-color-secondary: var(--accent-soft);
  --crepe-color-on-secondary: var(--fg);
  --crepe-color-inverse: var(--fg);
  --crepe-color-on-inverse: var(--bg);
  --crepe-color-inline-code: var(--gold);
  --crepe-color-error: var(--danger);
  --crepe-color-hover: rgb(255 255 255 / 0.07);
  --crepe-color-selected: var(--accent-soft);
  --crepe-color-inline-area: rgb(255 255 255 / 0.06);
  --crepe-base-font-size: 15px;
  --crepe-font-title: var(--sans);
  --crepe-font-default: var(--sans);
  --crepe-font-code: var(--mono);
  --crepe-shadow-1: 0 2px 10px rgb(0 0 0 / 0.45);
  --crepe-shadow-2: 0 8px 28px rgb(0 0 0 / 0.55);
  border-radius: inherit;
}
.doc .milkdown .ProseMirror { min-height: 4.2em; padding: 10px 14px 12px 40px; line-height: 1.6; }
@media (hover: none) { .doc .milkdown .ProseMirror { padding-left: 14px; } }
.doc .milkdown .milkdown-top-bar { min-height: 38px; padding: 0 6px; border-radius: var(--radius-small) var(--radius-small) 0 0; background: rgb(10 12 22 / 0.96); }
.doc:not(:focus-within) .milkdown-top-bar { display: none; }
.doc .milkdown .katex { font-size: 1.05em; }
.preview .doc .milkdown .ProseMirror, .doc .milkdown .ProseMirror[contenteditable="false"] { opacity: 0.75; padding-left: 14px; }
:disabled.answer { opacity: 0.55; }
.widget-instruction { margin: -4px 0 8px; color: var(--soft); font-size: 14px; }
.widget { position: relative; border: 1px solid var(--hair); border-radius: var(--radius-small); background: rgb(13 16 32 / 0.6); overflow: hidden; }
.widget-frame { display: block; width: 100%; height: 320px; border: 0; background: transparent; }
.widget.is-repairing::after { content: "Fixing this part…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--soft); background: rgb(5 5 7 / 0.7); }

.canvas-area { position: relative; min-height: 0; display: flex; }
.board {
  position: relative; flex: 1; min-height: 0; overflow: hidden; overscroll-behavior: contain;
  border: 1px solid var(--hair); border-radius: var(--radius);
  background: rgb(255 255 255 / 0.02) radial-gradient(rgb(255 255 255 / 0.07) 1px, transparent 1px) var(--grid-x, 0) var(--grid-y, 0) / var(--grid, 28px) var(--grid, 28px);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 30px 80px rgb(0 0 0 / 0.35);
}
#pad { position: relative; z-index: 1; display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#pad:is([data-tool="hand"], .grab) { cursor: grab; }
#pad.panning { cursor: grabbing; }
#pad-figure { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board-hint { position: absolute; left: 24px; top: 22px; margin: 0; color: var(--dim); line-height: 1.6; pointer-events: none; }
.toolbar {
  position: absolute; z-index: 2; top: 12px; right: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px;
  border: 1px solid var(--hair); border-radius: var(--pill); background: var(--glass-strong); backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.35);
}
.tool { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-color: transparent; background: transparent; color: var(--soft); }
.tool:hover { color: var(--fg); }
.tool.on { background: var(--accent-soft); border-color: rgb(91 140 255 / 0.55); color: var(--fg); }
.tool-gap { width: 22px; height: 1px; margin: 4px 0; background: var(--hair); }
.pens { position: relative; }
.swatch { width: 18px; height: 18px; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px rgb(255 255 255 / 0.16), 0 0 10px var(--swatch); }
.palette {
  position: absolute; top: 50%; right: calc(100% + 12px); translate: 0 -50%; display: flex; gap: 6px; padding: 6px;
  border: 1px solid var(--hair); border-radius: var(--pill); background: var(--glass-strong); backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.35);
}
.swatch-button { width: 34px; height: 34px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: var(--swatch); }
.swatch-button:hover:not(:disabled) { background: var(--swatch); filter: brightness(1.15); }
.swatch-button[aria-pressed="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.55); }
.tutor-layer { position: absolute; z-index: 1; top: 0; left: 0; width: 0; height: 0; transform-origin: 0 0; }
.view-home { position: absolute; z-index: 2; right: 16px; bottom: 16px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font: 500 12px var(--mono); background: var(--glass-strong); backdrop-filter: blur(14px); }
.view-home svg { width: 16px; height: 16px; }
.tutor-note {
  position: absolute; width: max-content; max-width: 240px; padding: 0 6px; border: none; border-radius: 8px;
  font: 600 23px/1.15 var(--hand); color: var(--gold); text-align: left; text-shadow: 0 0 12px var(--gold-glow);
  background: rgb(5 5 7 / 0.55); cursor: pointer; animation: write-in 0.7s linear both;
}
.tutor-note:hover:not(:disabled) { background: rgb(5 5 7 / 0.8); }
.tutor-note .katex { font-size: 0.78em; }
.tutor-layer .tutor-note { pointer-events: none; background: none; cursor: default; }
.tutor-note.on-input { z-index: 2; padding: 2px 8px; font-size: 21px; border: 1px solid var(--gold-glow); background: rgb(14 16 26 / 0.94); }
.tutor-mark { position: absolute; overflow: visible; pointer-events: none; }
.tutor-mark :is(ellipse, path) {
  fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1;
  filter: drop-shadow(0 0 4px var(--gold-glow)); animation: draw 0.6s var(--out) forwards;
}
.tutor-mark rect { fill: rgb(250 200 110 / 0.22); stroke: none; mix-blend-mode: screen; animation: write-in 0.5s var(--out) both; }
.tutor-highlight { background-color: rgb(250 200 110 / 0.16) !important; }
.tutor-layer .fading { opacity: 0; transition: opacity 0.6s ease; }
.tutor-marked { outline: 2px solid var(--gold) !important; outline-offset: 3px; box-shadow: 0 0 18px var(--gold-glow); }
@keyframes write-in { from { clip-path: inset(0 100% 0 0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.typed-card { position: absolute; z-index: 2; left: 16px; right: 76px; bottom: 16px; }
.typed-card textarea { font-family: var(--mono); font-size: 14px; background: var(--glass-strong); backdrop-filter: blur(14px); border-color: var(--hair-strong); }

.panel {
  position: fixed; z-index: 5; top: calc(var(--bar-height) + 4px); right: var(--gutter); bottom: var(--gutter); width: var(--panel-width);
  display: flex; flex-direction: column; gap: 18px; padding: 16px; overflow-y: auto;
  border: 1px solid var(--hair-strong); border-radius: var(--radius);
  background: rgb(12 14 22 / 0.92); backdrop-filter: blur(20px);
  box-shadow: -20px 0 60px rgb(0 0 0 / 0.45);
  animation: slide-in 0.35s var(--out);
}
@keyframes slide-in { from { opacity: 0; translate: 24px 0; } }
.panel h3, .panel summary { margin: 0 0 10px; font: 500 11px var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.panel summary { cursor: pointer; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 92%; padding: 8px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; }
.msg.from-tutor { align-self: flex-start; background: rgb(91 140 255 / 0.14); border: 1px solid rgb(91 140 255 / 0.25); border-bottom-left-radius: 4px; }
.msg.from-student { align-self: flex-end; background: var(--faint); border: 1px solid var(--hair); border-bottom-right-radius: 4px; }
.msg.from-student.quiet { opacity: 0.6; font-style: italic; }
.msg.from-system { align-self: center; color: var(--dim); font-size: 12px; text-align: center; }
.msg .meta { display: block; margin-top: 2px; font: 11px var(--mono); color: var(--dim); }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.summary dt { color: var(--dim); }
.summary dd { margin: 0; }
.panel-chat .chat { max-height: 32vh; overflow-y: auto; }
.panel-log .fine { margin: -4px 0 10px; font-size: 12px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.entry { padding: 8px 10px; border: 1px solid var(--faint); border-radius: var(--radius-small); background: rgb(255 255 255 / 0.025); font-size: 13px; }
.entry-head { display: flex; align-items: baseline; gap: 8px; }
.entry-head time, .entry-head .aside { font: 11px var(--mono); color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-head strong { font-weight: 600; white-space: nowrap; }
.entry-head .reason { flex: 1; color: var(--soft); }
.entry-line { margin: 4px 0 0; color: var(--soft); }
.entry-line.quote { color: var(--fg); font-style: italic; }
.entry-line.said { color: var(--gold); }
.entry.spoke { border-color: var(--gold-glow); }
.entry.spoke strong { color: var(--gold); }
.entry.looked strong { color: var(--sky); }
.entry:is(.waited, .note) { padding: 3px 10px; border-color: transparent; background: none; }
.entry:is(.waited, .note) :is(strong, .reason) { color: var(--dim); }
.entry details { margin-top: 6px; }
.panel .entry summary { margin: 0; letter-spacing: 0.1em; }
.entry dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 6px 0 0; }
.entry dt { color: var(--dim); }
.entry dd { margin: 0; white-space: pre-wrap; font: 12px/1.45 var(--mono); color: var(--soft); }

@media (max-width: 1100px) {
  :root { --side-width: 310px; --orb-side: 140px; }
}
@media (max-height: 800px) {
  :root { --orb-side: 112px; --orb-landing: 150px; }
  .presence-slot .presence { flex-direction: row; gap: 2px; text-align: left; }
  .presence-slot .orb { margin: -14px -8px -14px -16px; }
  .presence-slot .voiceline { align-items: flex-start; }
  .presence-slot .caption { font-size: 16px; }
  .compose { gap: 10px; }
  .compose h1 { font-size: 30px; }
}
@media (max-width: 980px) {
  main { height: auto; min-height: 100dvh; }
  .landing, .landing.has-preview { height: auto; grid-template-columns: 1fr; gap: 18px; }
  .landing:not(.has-preview) article.preview { display: none; }
  .compose { overflow: visible; }
  article.preview { overflow: visible; }
  .preview-body { flex: none; overflow: visible; }
  body.shared article.preview { order: -1; }
  .preview-foot { position: sticky; bottom: 0; z-index: 3; border-radius: 0 0 24px 24px; backdrop-filter: blur(16px); }
}
@media (max-width: 860px) {
  body.working main { height: auto; min-height: 100dvh; }
  .studio { grid-template-columns: minmax(0, 1fr); height: auto; }
  body.focus .studio { grid-template-columns: minmax(0, 1fr); }
  body.focus .side { display: none; }
  .side { overflow: visible; }
  .presence-slot .presence { flex-direction: row; gap: 4px; text-align: left; }
  .presence-slot .orb { width: 112px; margin: -16px -8px -16px -16px; }
  .presence-slot .voiceline { align-items: flex-start; }
  .studio .activity, .studio .activity.only-canvas { overflow: visible; }
  .block-canvas .canvas-area, .only-canvas .block-canvas .canvas-area { flex: none; height: 68vh; }
  .talk { position: sticky; bottom: 8px; z-index: 3; margin-top: 0; }
  .question-bar { position: sticky; top: calc(var(--bar-height) + 2px); z-index: 3; }
  .done { position: sticky; left: auto; bottom: 12px; translate: none; margin: 12px auto 0; animation: none; }
  .panel { left: var(--gutter); width: auto; top: auto; height: 70vh; }
}
@media (max-width: 600px) {
  :root { --orb-landing: 170px; }
  .chip, #share { white-space: nowrap; }
  .preview-foot .primary { flex: 1; justify-content: center; }
  .fields { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .field-label, .choices { grid-column: 1 / -1; }
  .field:not(:first-child) .field-label { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.widget-frame.tutor-marked { outline-offset: -3px; }
.lab-tag { margin-left: 6px; padding: 1px 8px; border: 1px solid var(--gold-glow); border-radius: var(--pill); color: var(--gold); font: 11px/1.6 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
