:root {
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --tutor:        #7c3aed;
  --student:      #0891b2;
  --bg:           #f1f5f9;
  --panel:        #ffffff;
  --ink:          #1e293b;
  --muted:        #64748b;
  --border:       #e2e8f0;
  --ok:           #10b981;
  --danger:       #ef4444;
  --shadow:       0 6px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
/* The `hidden` attribute must win over display rules (.tool-group/.panel-sec use display:flex). */
[hidden] { display: none !important; }

/* ---------- Landing ---------- */
.landing {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: min(460px, 100%);
}
.brand-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.brand-title span { color: var(--brand); }
.subtitle { color: var(--muted); margin: 6px 0 24px; line-height: 1.5; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; outline: none;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.btn {
  width: 100%; padding: 12px 16px; border: none; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 15px;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f8fafc; }
.divider { display:flex; align-items:center; gap:12px; color:var(--muted); font-size:13px; margin:22px 0; }
.divider::before, .divider::after { content:""; height:1px; background:var(--border); flex:1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.5; }

/* ---------- Whiteboard ---------- */
.board-app { display: flex; flex-direction: column; height: 100vh; }
/* -webkit-fill-available: iPadOS < 15.4 has no dvh — plain 100vh leaves the
   bottom toolbar hidden under Safari's chrome on an unscrollable page.
   --vvh (set by board.js from visualViewport) beats them all: Safari
   16.0–16.3 dvh tracks the LARGE viewport and clips the toolbar. */
.board-body { height: 100vh; height: -webkit-fill-available; height: 100dvh; height: var(--vvh, 100dvh); overflow: hidden; overscroll-behavior: none; }
.board-body .board-app { height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.board-body .topbar { flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px; gap: 10px }
.board-body .topbar > * { flex: 0 0 auto }
.topbar .logo { font-weight: 800; font-size: 18px; }
.topbar .logo span { color: var(--brand); }
.room-pill {
  font-size: 13px; background: #eff6ff; color: var(--brand-dark);
  padding: 5px 10px; border-radius: 999px; font-weight: 600;
}
.spacer { flex: 1; }
.status { font-size: 13px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }

.roster { display: flex; align-items: center; gap: 6px; }
.chip {
  font-size: 12px; padding: 4px 9px; border-radius: 999px; font-weight: 600;
  background: #f1f5f9; color: var(--ink); border: 1px solid var(--border);
}
.chip.tutor { background: #f5f3ff; color: var(--tutor); border-color: #ddd6fe; }
.chip.student { background: #ecfeff; color: var(--student); border-color: #cffafe; }

.workspace { flex: 1; display: flex; min-height: 0; }
.canvas-wrap {
  flex: 1; position: relative; display: grid; place-items: center;
  padding: 16px; min-width: 0;
}
.canvas-frame {
  position: relative; width: 100%; max-width: min(100%, 1100px);
  aspect-ratio: 4 / 3; background: #fff; border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
#board, #cursors { position: absolute; inset: 0; width: 100%; height: 100%; }
#board { touch-action: none; cursor: crosshair; }
#cursors { pointer-events: none; }
/* Dot only, centered EXACTLY on the ink point — a name label here covered the
   writing and pulled the dot off the point (the writer shows in #writerInd). */
.remote-cursor { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.remote-cursor .nib { display: block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--border);
}
/* board: tools docked at the TOP (border flips) — iPad Safari's dynamic
   chrome clips the bottom edge, so nothing essential lives there */
.board-body .toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px; gap: 10px;
  border-top: none; border-bottom: 1px solid var(--border) }
.board-body .toolbar .tbtn { padding: 6px 10px; font-size: 13px; white-space: nowrap }
.board-body .toolbar .tool-group { flex: 0 0 auto }
/* one scrollable row on narrow screens — wrapped rows made the bar tall
   enough to fall off the bottom of an iPad viewport */
.board-body .toolbar .inktools { flex-wrap: nowrap }
.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-group .label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--brand); transform: scale(1.08); }
.tbtn {
  border: 1px solid var(--border); background: #fff; border-radius: 9px;
  padding: 7px 11px; font-size: 14px; font-weight: 600; color: var(--ink);
}
.tbtn:hover { background: #f8fafc; }
.tbtn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.width-dot { display:inline-block; background: var(--ink); border-radius: 50%; }

/* ---------- Recognition panel ---------- */
/* The board's fixed side panel ONLY (board.html <aside class="panel">).
   Content pages (/progress, /students, /classes) define their own .panel look —
   an unscoped rule here squeezed those to 320px for months. */
aside.panel {
  width: 320px; border-left: 1px solid var(--border); background: var(--panel);
  display: flex; flex-direction: column; padding: 16px; gap: 12px;
}
/* On the board the panel is a slide-in drawer (#panelBtn, tutors + peer
   rooms): the canvas keeps the SAME size for tutor and student — iPad screen
   space is tight, so the pane overlays from the right instead of docking. */
.board-body .workspace { position: relative; }
.board-body aside.panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(340px, 85%); flex: none;
  transform: translateX(103%); transition: transform .22s ease;
  z-index: 30; box-shadow: -12px 0 28px rgba(15,23,42,.14);
  overflow-y: auto; padding: 14px; gap: 10px;
}
body.panel-open aside.panel { transform: none; }
/* Students in a lesson room: no side panel at all — its sections (worksheet,
   lesson mode, handwriting→text) are tutor tools. Peer study rooms keep it. */
body.student-view aside.panel { display: none; }
.panel h3 { margin: 0; font-size: 15px; }
.panel .out {
  flex: 1; border: 1px dashed var(--border); border-radius: 10px; padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  white-space: pre-wrap; word-break: break-word; color: var(--ink); overflow: auto;
}
.panel .muted { color: var(--muted); font-size: 12px; line-height: 1.5; }
@media (max-width: 820px) { body:not(.board-body) aside.panel { display: none; } }

.panel-sec { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.panel-sec:last-child { flex: 1; min-height: 0; border-bottom: none; padding-bottom: 0; }
.panel-sec h3 { margin: 0; font-size: 15px; }
.ws-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ws-field select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; color: var(--ink); background: #fff; }
.tbtn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.tbtn.primary:hover { background: var(--brand-dark); }
.ws-sel { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; max-width: 160px; background: #fff; color: var(--ink); }
.toggle { font-size: 13px; display: flex; align-items: center; gap: 7px; cursor: pointer; color: var(--ink); }
.toggle input { width: 16px; height: 16px; cursor: pointer; }

/* ---------- Worksheet background layer (behind the ink canvas) ---------- */
/* #worksheetPage is a fixed 1000×750 "page" in the same logical space as the
   strokes; JS scales it to the frame so ink lands on the questions exactly. */
#worksheet { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#worksheetPage {
  position: absolute; top: 0; left: 0; width: 1000px; height: 750px;
  transform-origin: top left;
  display: flex; flex-direction: column;
  font-family: 'Helvetica Neue', Arial, sans-serif; color: #2c3e50;
}
.ws-rule {
  flex: 0 0 auto; text-align: center; color: #7f8c8d;
  font-size: 15px; line-height: 1.35; padding: 12px 40px 8px;
}
.ws-grid {
  flex: 1 1 auto; display: grid; grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr; min-height: 0;
}
.ws-cell {
  border-right: 1px dashed #e6eaec; border-bottom: 1px dashed #e6eaec;
  padding: 16px 30px; position: relative;
}
.ws-cell.col-last { border-right: none; }
.ws-cell.row-last { border-bottom: none; }
.ws-qlabel { font-size: 18px; font-weight: 700; color: #16a085; margin-bottom: 6px; }
.ws-setout {
  display: inline-block; width: 6.5em; text-align: right;
  font-family: 'Times New Roman', Times, serif;
  font-size: 34px; font-weight: bold; font-variant-numeric: tabular-nums; letter-spacing: 1px;
}
.ws-setout .ws-bot { display: flex; justify-content: space-between; }
.ws-setout .ws-bot .op { color: #7f8c8d; }
.ws-setout .ws-line { border-top: 2px solid #2c3e50; margin: 6px 0; }
.ws-setout .ws-ans { color: #16a085; min-height: 30px; }
.ws-setout .ws-ans .dp { display: block; font-size: 0.5em; font-weight: 600; letter-spacing: 0; }

/* Revealable answers / notes (shared by all topics; tutor toggles "Show answers") */
.ws-ans, .ws-note { visibility: hidden; }
#worksheetPage.show-ans .ws-ans,
#worksheetPage.show-ans .ws-note { visibility: visible; }
.ws-note { font-size: 15px; font-weight: 600; color: #7f8c8d; margin-top: 8px; min-height: 1.2em; }
.ws-note strong { color: #16a085; }

/* Auto-marking ✓/✗ badges (drawn into each question cell) + panel status */
.ws-mark { position: absolute; top: 2px; right: 6px; font-size: 26px; font-weight: 800; line-height: 1; }
.ws-mark.ok { color: #16a085; }
.ws-mark.no { color: #e74c3c; }
.ws-mark-status { font-size: 12px; color: var(--muted); line-height: 1.45; }
.ws-mark-status code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Single-question (practice) layout ---------- */
.ws-one { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px 30px; text-align: center; }
.ws-one-expr { font-size: 60px; font-weight: bold; color: #2c3e50; letter-spacing: 1px; line-height: 1.2; }
.ws-one-expr .op { color: #7f8c8d; margin: 0 14px; }
.ws-one-expr .ws-ans { color: #16a085; display: none; visibility: visible; }
#worksheetPage.show-ans .ws-one-expr .ws-ans { display: inline; }
.ws-one-expr .dp { display: block; font-size: 0.3em; font-weight: 600; color: #16a085; letter-spacing: 0; margin-top: 6px; }
.ws-one-expr .ws-q { color: #bdc3c7; }
#worksheetPage.show-ans .ws-one-expr .ws-q { display: none; }
.ws-one-prompt { font-size: 22px; font-weight: 700; color: #2c3e50; }
.ws-one-note { font-size: 18px; }
.ws-one-shape { gap: 12px; }
.ws-shape-big { align-self: stretch; display: flex; align-items: center; justify-content: center; }
/* Full-width box + fixed height; the SVG's default preserveAspectRatio scales the
   diagram up to fill it, centred and undistorted. */
.ws-shape-big svg { width: 100%; height: 380px; display: block; }
.ws-ldiv-big { font-size: 54px; }
.ws-ans-box { font-size: 20px; font-weight: bold; color: #16a085; background: #eafaf3; border: 2px solid #abe3cd; border-radius: 10px; padding: 8px 18px; line-height: 1.5; }
.ws-ans-box b, .ws-ans-box strong { color: #16a085; }

/* Sequences & Series — one-big-question topics: instruction, the sequence/series
   shown big, and a revealable worked solution. Pinned to the top so the lower
   half of the page stays free to write the working out. */
.ws-one-seq { justify-content: flex-start; gap: 14px; padding: 16px 38px; }
.seq-prompt { max-width: 880px; font-size: 21px; font-weight: 700; color: #2c3e50; line-height: 1.4; }
.seq-prompt sub, .seq-prompt sup { font-size: 0.72em; }
.seq-body { font-size: 32px; font-weight: 800; color: var(--brand); letter-spacing: 0.5px; line-height: 1.25; }
.seq-body sub, .seq-body sup { font-size: 0.72em; }
.seq-ans {
  max-width: 880px; text-align: left; color: #2c3e50;
  font-size: 16px; font-weight: 600; line-height: 1.7;
  max-height: 470px; overflow: auto;
}
.seq-ans b, .seq-ans strong { color: #16a085; }
.seq-ans sub, .seq-ans sup { font-size: 0.72em; }
/* Bank question pushed to a room (bank_q worksheet module) */
.bq-one { justify-content: flex-start; gap: 10px; padding: 14px 36px; }
.bq-prompt { max-width: 880px; font-size: 19px; font-weight: 700; color: #2c3e50;
  line-height: 1.45; white-space: pre-wrap; }
.bq-img { max-width: 82%; max-height: 300px; border: 1px solid #e2e8f0; border-radius: 8px; }
.bq-choices { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; max-width: 900px; }
.bq-choice { font-size: 16px; color: #2c3e50; }
.bq-choice b { color: #2563eb; }
.bq-ans { max-width: 860px; text-align: left; font-size: 14px; font-weight: 600;
  white-space: pre-wrap; max-height: 230px; overflow: auto; }

/* Grid fallback (multi-question sheets) */
.ws-seq-list { flex: 1 1 auto; min-height: 0; overflow: auto; }
.ws-seq-item { border-bottom: 1px dashed #e6eaec; }
.ws-seq-item .seq-prompt { font-size: 18px; }
.ws-seq-item .seq-body { font-size: 24px; margin-top: 4px; }

/* ---------- Practice & Record page ---------- */
.practice-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.practice-bar { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.practice-bar .divider { width: 1px; height: 26px; background: var(--border); }
.practice-body .canvas-wrap { flex: 1; min-height: 0; padding: 12px 16px; display: grid; place-items: center; }
.practice-body .canvas-frame { max-width: none; }   /* JS sizes it to the largest 4:3 that fits */
.lvl-tabs { display: inline-flex; }
.lvl-tab { border: 1px solid var(--border); background: #fff; color: var(--muted); font-weight: 600; font-size: 13px; padding: 7px 13px; cursor: pointer; }
.lvl-tab:first-child { border-radius: 8px 0 0 8px; }
.lvl-tab:last-child { border-radius: 0 8px 8px 0; }
.lvl-tab:not(:first-child) { border-left: none; }
.lvl-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.lvl-tab:disabled { opacity: 0.55; cursor: default; }

/* Dividing — long-division set-out (quotient above the bracket) */
.ws-ldiv {
  display: inline-grid; grid-template-columns: auto auto;
  font-family: 'Times New Roman', Times, serif; font-size: 30px; font-weight: bold;
  text-align: left; font-variant-numeric: tabular-nums;
}
.ws-ldiv .ws-ans { color: #16a085; padding: 0 0.15em 0.08em 0.22em; min-height: 1.05em; }
.ws-ldiv .dvr { justify-self: end; align-self: start; padding: 0.08em 0.18em 0 0; }
.ws-ldiv .dvd {
  border-top: 3px solid #2c3e50; border-left: 3px solid #2c3e50;
  border-top-left-radius: 0.45em 0.9em; padding: 0.08em 0.15em 0.05em 0.22em;
}
.ws-ldiv .ch { display: inline-block; width: 0.62em; text-align: center; }
.ws-ldiv .ch.pt { width: 0.3em; }

/* Word-style worksheet questions (inverse ops, primes, story problems) */
.ws-word { font-size: 18px; font-weight: 600; color: #2c3e50; line-height: 1.5; }
.ws-word .ws-ans { color: #16a085; }

/* Powers of ten — inline expression */
.ws-inline { font-size: 34px; font-weight: bold; color: #2c3e50; letter-spacing: 1px; }
.ws-inline .op { color: #7f8c8d; margin: 0 8px; }
.ws-inline .ws-ans { color: #16a085; }

/* Shape topics (Area / Volume) — SVG diagram + answer, centred in the cell.
   The shape flexes to fill the height left after the label/answer, so the same
   cell fits 4, 6 or 8 questions without clipping. */
.ws-cell-shape { display: flex; flex-direction: column; align-items: center; text-align: center; overflow: hidden; }
.ws-cell-shape .ws-qlabel { align-self: flex-start; }
.ws-shape { flex: 1 1 auto; min-height: 0; margin: 2px 0; display: flex; align-items: center; justify-content: center; }
.ws-shape svg { display: block; max-width: 100%; max-height: 100%; height: auto; width: auto; }
.ws-note b, .ws-note strong { color: #16a085; }

/* ---------- Top nav (community pages) ---------- */
.nav {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.nav-logo { font-weight: 800; font-size: 20px; text-decoration: none; color: var(--ink); }
.nav-logo span { color: var(--brand); }
.nav-links { display: flex; gap: 14px; }
.nav-links a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.nav-links a.active, .nav-links a:hover { color: var(--brand); }
.auth-slot { display: flex; align-items: center; gap: 10px; }
.me { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.me-av svg, .rec-av svg, .watch-av svg, .me-av { border-radius: 8px; display: block; }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 9px; text-decoration: none; display: inline-flex; align-items: center; }
.rec-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }

/* ---------- Page + library grid ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.page-title { font-size: 26px; font-weight: 800; margin: 8px 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip-btn { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip-btn.active, .chip-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.rec-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .12s; }
.rec-card:hover { transform: translateY(-3px); }
.rec-thumb { height: 110px; background: linear-gradient(135deg, #eff6ff, #f5f3ff); display: flex; align-items: flex-start; justify-content: space-between; padding: 10px; }
.rec-subject { font-size: 11px; font-weight: 700; background: #fff; color: var(--brand-dark); padding: 3px 8px; border-radius: 999px; }
.rec-dur { font-size: 11px; font-weight: 700; background: rgba(15,23,42,.7); color: #fff; padding: 3px 7px; border-radius: 6px; align-self: flex-end; }
.rec-body { padding: 12px; }
.rec-title { font-weight: 700; font-size: 15px; line-height: 1.3; margin-bottom: 8px; }
.rec-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot-sep { opacity: .5; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- Auth tabs/forms ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab { flex: 1; padding: 9px; border: 1px solid var(--border); background: #fff; border-radius: 9px; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.authform .field select, .authform textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; }
.honor { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 6px 0 16px; }
.honor input { margin-top: 3px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------- Recorder ---------- */
.tbtn.rec { color: var(--danger); font-weight: 800; }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 16px; }
.modal-card { background: #fff; border-radius: 16px; padding: 24px; width: min(460px, 100%); box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 6px; }
.modal-actions { display: flex; gap: 10px; margin-top: 10px; }
.modal-actions .btn { width: auto; flex: 1; }
.modal-card textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font: inherit; resize: vertical; }

/* ---------- Watch / player ---------- */
.watch { max-width: 900px; margin: 0 auto; padding: 22px 20px 60px; }
.watch-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.watch-title { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.watch-meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.watch-frame { aspect-ratio: 4 / 3; width: 100%; }
.watch-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.player { display: flex; align-items: center; gap: 12px; margin-top: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.play-btn { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--brand); color: #fff; font-size: 16px; }
.play-btn:hover { background: var(--brand-dark); }
.ptime { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.seek { flex: 1; accent-color: var(--brand); }
.watch-desc { color: var(--ink); margin-top: 18px; white-space: pre-wrap; }
.watch-note { color: var(--muted); font-size: 13px; margin-top: 8px; }

.report-link { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 6px; }
.report-link:hover { color: var(--danger); }

/* ---------- Q&A ---------- */
.qlist { display: flex; flex-direction: column; gap: 10px; }
.qrow { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); }
.qrow:hover { border-color: var(--brand); }
.qrow-main { flex: 1; min-width: 0; }
.qrow-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.qrow-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.qrow-side { display: flex; align-items: center; gap: 10px; }
.qrow-answers { font-size: 12px; color: var(--muted); white-space: nowrap; }
.bounty { font-size: 12px; font-weight: 700; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.solved { font-size: 12px; font-weight: 700; color: var(--ok); background: #ecfdf5; border: 1px solid #a7f3d0; padding: 2px 8px; border-radius: 999px; }
.flag-banner { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.qbox { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.qbox-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.qbox-title { font-size: 22px; font-weight: 800; margin: 0 0 8px; }
.qbox-body { color: var(--ink); white-space: pre-wrap; margin: 0 0 12px; }
.qbox-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.answers-h { font-size: 16px; margin: 24px 0 12px; }
.answer { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.answer.accepted { border-color: var(--ok); background: #f0fdf4; }
.answer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.answer-author { font-weight: 600; font-size: 14px; }
.answer-body { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.answer-rec { display: inline-block; margin-top: 8px; font-weight: 600; text-decoration: none; color: var(--brand); }
.accept-btn { color: var(--ok); border-color: var(--ok); }
.accepted-badge { color: var(--ok); font-weight: 700; font-size: 13px; }

/* ---------- Premium ---------- */
.perks { list-style: none; padding: 0; margin: 16px 0; }
.perks li { padding: 7px 0; color: var(--ink); font-size: 14px; border-bottom: 1px solid var(--border); }
#actions .btn { width: 100%; margin-top: 6px; }

/* ---------- Welcome banner (logged-out home) ---------- */
.welcome-banner { display: flex; align-items: center; gap: 16px; justify-content: space-between; background: linear-gradient(135deg, #eff6ff, #f5f3ff); border: 1px solid #dbeafe; border-radius: 14px; padding: 16px 20px; margin-bottom: 22px; flex-wrap: wrap; }
.welcome-banner div { line-height: 1.5; }
.welcome-banner .btn { width: auto; white-space: nowrap; }

/* ---------- Profile ---------- */
.prof { display: flex; align-items: center; gap: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 8px; }
.prof-av svg { border-radius: 16px; display: block; }
.prof-name { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.prof-sub { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prof-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.prof-actions .btn { width: auto; }
.rec-manage { padding: 0 12px 12px; }
.rec-thumb-link { text-decoration: none; color: inherit; display: block; }
.author-link { color: inherit; text-decoration: none; }
.author-link:hover { color: var(--brand); text-decoration: underline; }
a.me { text-decoration: none; color: inherit; }

/* ---------- Recorder split-pane (answering a question) ---------- */
.q-pane { width: 30%; min-width: 220px; max-width: 380px; border-right: 1px solid var(--border); background: var(--panel); padding: 18px 20px; overflow: auto; }
.q-pane-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.q-pane-title { font-size: 18px; font-weight: 800; margin: 6px 0 10px; line-height: 1.3; }
.q-pane-body { color: var(--ink); white-space: pre-wrap; font-size: 14px; line-height: 1.55; }
.q-pane-note { color: var(--muted); font-size: 12px; margin-top: 16px; }
@media (max-width: 760px) {
  .workspace { flex-direction: column; }
  .q-pane { width: auto; max-width: none; max-height: 30vh; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ---------- Record page: fit one screen (no scroll), responsive ---------- */
.record-body { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.record-body .board-app { flex: 1; min-height: 0; height: auto; }
.record-body .workspace { flex: 1; min-height: 0; }
.record-body .canvas-wrap { padding: 8px 12px; }
.record-body .canvas-frame { max-width: none; }   /* JS sizes this to contain a 4:3 box */
.record-body .toolbar { flex: 0 0 auto; }
.record-body .toolbar .tbtn { padding: 6px 9px; }  /* tighter so the bar fits one row */

/* ---------- Pinned Soapbox question on the recording canvas (sb_q) ---------- */
.sbq-pin { text-align: left; width: 38%; max-width: 400px; margin: 10px;
  background: rgba(255, 255, 255, 0.94); border: 1.5px solid #cbd5e1;
  border-radius: 10px; padding: 10px 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.sbq-pin-label { font-size: 10px; font-weight: 800; letter-spacing: 1px;
  color: var(--muted); }
.sbq-pin-title { font-size: 14.5px; font-weight: 700; margin: 2px 0 4px;
  line-height: 1.3; }
.sbq-pin-body { font-size: 12px; color: #334155; white-space: pre-wrap;
  max-height: 130px; overflow: hidden; }
.sbq-pin-img { max-width: 100%; max-height: 330px; object-fit: contain;
  border: 1px solid #e2e8f0; border-radius: 6px; margin-top: 6px; }

/* Collapsible question pane + photo lightbox (recorder P0) */
.q-pane-actions { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.q-pane-tab { position: absolute; left: 0; top: 90px; z-index: 30;
  writing-mode: vertical-rl; padding: 12px 6px; background: var(--brand);
  color: #fff; border-radius: 0 8px 8px 0; cursor: pointer; font-size: 12.5px;
  font-weight: 700; user-select: none; }
.q-lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(15,23,42,.88);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.q-lightbox img { max-width: 96vw; max-height: 94vh; object-fit: contain;
  background: #fff; border-radius: 6px; }
