/* =============================================================
   tools.css: the study tools dock (index-card tabs + Win98 windows),
   floating sticky notes, the paint program (draw.js) and the
   Accessibility tool's page-wide settings. Loaded on every page.
   Everything here is static until used: no running animations, and the
   only moving parts (drag, cursor ring, reading ruler) use transforms.
   ============================================================= */

/* ---------- Accessibility settings (classes set on <html> by the head script) ---------- */
html { font-size: calc(100% * var(--a11y-scale, 1)); }
html.a11y-font { --font: "Atkinson Hyperlegible", "Poppins", system-ui, sans-serif; --font-display: "Atkinson Hyperlegible", system-ui, sans-serif; --font-ui: "Atkinson Hyperlegible", system-ui, sans-serif; --font-pixel: "Atkinson Hyperlegible", system-ui, sans-serif; --font-crt: "Atkinson Hyperlegible", ui-monospace, monospace; }
html.a11y-font body, html.a11y-font button, html.a11y-font input, html.a11y-font textarea, html.a11y-font select { font-family: var(--font) !important; }
html.a11y-spacing body { letter-spacing: 0.03em; word-spacing: 0.14em; }
html.a11y-spacing p, html.a11y-spacing li, html.a11y-spacing .prose, html.a11y-spacing .card-face { line-height: 1.9 !important; }
html.a11y-links a { text-decoration: underline !important; text-underline-offset: 3px; text-decoration-thickness: 2px; }
html.a11y-reduce-motion *, html.a11y-reduce-motion *::before, html.a11y-reduce-motion *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important; scroll-behavior: auto !important;
}
html.a11y-contrast {
  --ink: #000; --ink-soft: #111; --ink-muted: #2a2a2a; --line: #3a3a3a; --line-strong: #000;
  --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f0f0f0; --header-bg: #fff;
  --brand: #063b30; --brand-strong: #000; --btn-bg: #000; --btn-ink: #fff; --focus: #000;
}
html.a11y-contrast[data-theme="dark"] {
  --ink: #fff; --ink-soft: #f2f2f2; --ink-muted: #dedede; --line: #cfcfcf; --line-strong: #fff;
  --bg: #000; --surface: #000; --surface-2: #0b0b0b; --surface-3: #161616; --header-bg: #000;
  --brand: #ffe08a; --brand-strong: #fff; --btn-bg: #ffe08a; --btn-ink: #000; --focus: #ffe08a;
}
html.a11y-contrast body, html.a11y-contrast body.app { background: var(--bg) !important; }
html.a11y-contrast .bg-photo, html.a11y-contrast .lamp-grid, html.a11y-contrast .idea-net { display: none !important; }
html.a11y-contrast .bg-scrim { background: #000 !important; opacity: 1 !important; }
html.a11y-contrast :focus-visible { outline: 3px solid var(--focus) !important; outline-offset: 3px; }

.a11y-ruler {
  position: fixed; left: 0; right: 0; top: 0; height: 2.8em; z-index: 99999970; pointer-events: none;
  border-block: 2px solid rgba(233, 196, 106, 0.85);
  box-shadow: 0 0 0 100vmax rgba(7, 21, 18, 0.42);
  will-change: transform;
}

/* ---------- Dock: index-card tabs on the right edge ---------- */
.dock {
  position: fixed; right: 0; top: 50%; z-index: 99999989;
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  transform: translateY(-50%);
  pointer-events: none;
}
.dock > * { pointer-events: auto; }
.dock-tab {
  --tab: 42px;
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 12px 0 10px;
  background: #fbf3d5; color: #1b2a25;
  border: 1px solid #6b6548; border-right: 0; border-radius: 7px 0 0 7px;
  box-shadow: inset 1px 1px 0 #fff, -2px 2px 0 rgba(18, 48, 43, 0.2);
  font: 600 0.84rem/1 var(--font-ui); white-space: nowrap;
  cursor: pointer;
  transform: translateX(calc(100% - var(--tab)));
  transition: transform 0.16s var(--ease, ease), background 0.16s;
}
.dock-tab img.px { width: 20px; height: 20px; flex-shrink: 0; }
.dock-tab:hover, .dock-tab:focus-visible { transform: translateX(0); }
.dock-tab.open { background: #ead9a0; border-color: #4d4630; }
.dock-tab.open::before, .dock-tab.min::before {
  content: ""; position: absolute; left: 3px; top: 50%; width: 4px; height: 14px; margin-top: -7px; border-radius: 2px;
  background: #2f6559;
}
.dock-tab.min::before { background: #c9a227; height: 6px; margin-top: -3px; }
.dock-tab { position: relative; }
.dock-tuck {
  width: 22px; height: 26px; margin-top: 2px;
  display: grid; place-items: center;
  background: #12302b; color: #f2e6bd; border: 1px solid #0b1d19; border-right: 0; border-radius: 5px 0 0 5px;
  font: 700 0.9rem/1 var(--font-ui); cursor: pointer;
}
.dock.tucked .dock-tab { transform: translateX(100%); visibility: hidden; }
.dock.tucked .dock-tuck { width: 26px; height: 64px; writing-mode: vertical-rl; font-size: 0.72rem; letter-spacing: 0.08em; }
html[data-theme="dark"] .dock-tab { background: #12302b; color: #f2e6bd; border-color: #3d6e5f; box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.08), -2px 2px 0 rgba(0, 0, 0, 0.45); }
html[data-theme="dark"] .dock-tab.open { background: #1f4a40; }
html[data-theme="dark"] .dock-tuck { background: #c2b78e; color: #0c1f1b; border-color: #6b6548; }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .dock-tab { background: #12302b; color: #f2e6bd; border-color: #3d6e5f; box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.08), -2px 2px 0 rgba(0, 0, 0, 0.45); }
  html[data-theme="system"] .dock-tab.open { background: #1f4a40; }
}

/* ---------- Tool windows ---------- */
.dock-win {
  position: fixed; left: 0; top: 0; z-index: 99999990;
  width: var(--w, 340px); max-width: calc(100vw - 16px);
  max-height: calc(100vh - var(--header-h, 74px) - 20px);
  display: flex; flex-direction: column;
  box-shadow: inset 1px 1px 0 var(--bevel-light), 5px 5px 0 rgba(7, 21, 18, 0.22) !important;
  outline: none;
}
.dock-win.front { z-index: 99999991; }
.dock-win.min { visibility: hidden; pointer-events: none; }
.dock-win .win-bar { cursor: grab; touch-action: none; }
.dock-win.dragging .win-bar { cursor: grabbing; }
.dock-win.dragging { opacity: 0.94; }
.dock-win button.win-x { cursor: pointer; padding: 0; border-radius: 0; }
.dock-win button.win-x:hover { background: #e6ddc0; }
.dock-win button.win-x:active { border-color: #4d4630 #fff #fff #4d4630; }
.dock-body { padding: 12px; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; min-height: 0; color: var(--ink); }
.dock-body .input, .dock-body .select, .dock-body .textarea { font-size: 0.88rem; }
.dock-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dock-row.between { justify-content: space-between; }
.dock-label { font: 700 0.7rem/1.2 var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.dock-hint { font-size: 0.78rem; color: var(--ink-muted); line-height: 1.45; }
.dock-win.resizable { resize: both; overflow: hidden; min-width: 360px; min-height: 300px; }
.dock-win.resizable .dock-body { flex: 1; }
.dock-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.dock-seg button { padding: 5px 10px; background: var(--surface); color: var(--ink); border: 0; border-left: 1px solid var(--line); font: 600 0.8rem var(--font); cursor: pointer; }
.dock-seg button:first-child { border-left: 0; }
.dock-seg button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-ink); }

/* Music */
.music-player { min-height: 80px; border-radius: 12px; overflow: hidden; background: #0e211c; }
.music-embed { display: block; width: 100%; border: 0; }
.music-load, .music-away {
  width: 100%; min-height: 80px; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: linear-gradient(90deg, #12302b, #2f6559); color: #f2e6bd; border: 0; text-align: left; cursor: pointer;
  font: inherit;
}
.music-load img.px, .music-away img.px { width: 40px; height: 40px; }
.music-load strong, .music-away strong { display: block; font: 700 0.95rem var(--font-ui); }
.music-load small, .music-away small { display: block; opacity: 0.8; font-size: 0.78rem; }
.music-load:hover { filter: brightness(1.08); }
.music-rack { display: flex; flex-direction: column; gap: 3px; max-height: 196px; overflow: auto; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.music-station {
  display: grid; grid-template-columns: 20px 1fr; column-gap: 9px; align-items: center;
  padding: 6px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink);
  text-align: left; cursor: pointer; font: inherit;
}
.music-station img.px { width: 18px; height: 18px; grid-row: span 2; }
.music-station .music-name { font: 600 0.86rem/1.2 var(--font-ui); }
.music-station .music-note { font-size: 0.74rem; color: var(--ink-muted); }
.music-station:hover { background: var(--surface); border-color: var(--line); }
.music-station.on { background: var(--btn-bg); color: var(--btn-ink); }
.music-station.on .music-note { color: inherit; opacity: 0.8; }
.music-remote { border-top: 1px dashed var(--line-strong); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.sp-now { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; }
.sp-art { width: 56px; height: 56px; border-radius: 4px; background: var(--surface-3) center / cover; border: 1px solid var(--line); }
.sp-title { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-artist { font-size: 0.78rem; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-controls { display: flex; align-items: center; gap: 6px; }
.sp-controls .ui-btn.icon { width: 34px; height: 32px; min-height: 32px; padding: 0; }
.sp-list { display: flex; flex-direction: column; gap: 2px; max-height: 160px; overflow: auto; }
.sp-list button { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border: 0; border-radius: 4px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; font-size: 0.82rem; }
.sp-list button:hover { background: var(--surface-3); }
.sp-list img { width: 28px; height: 28px; border-radius: 3px; object-fit: cover; }
body.popout-player { min-height: 100vh; padding: 0; background: var(--bg); }
body.popout-player main { padding: 0; }
.popout-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.popout-shell .win { border-radius: 0; border-left: 0; border-right: 0; flex: 1; display: flex; flex-direction: column; }
.popout-shell .dock-body { flex: 1; }

/* Sticky notes */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.note-card, .sticky-pin {
  --c: #f7e48b;
  position: relative; display: flex; flex-direction: column;
  background: var(--c); color: #2a2616;
  box-shadow: 1px 2px 0 rgba(60, 52, 28, 0.25), 3px 5px 10px -6px rgba(60, 52, 28, 0.5);
}
.note-card { min-height: 128px; border-radius: 2px; }
.note-card textarea, .sticky-pin textarea {
  flex: 1; width: 100%; min-height: 84px; resize: none; border: 0; outline: none; background: transparent; color: inherit;
  padding: 8px 10px 6px; font: 0.92rem/1.4 "Comic Sans MS", "Chalkboard SE", "Comic Neue", "Segoe Print", cursive;
}
html.a11y-font .note-card textarea, html.a11y-font .sticky-pin textarea { font-family: var(--font) !important; }
.note-card textarea:focus-visible, .sticky-pin textarea:focus-visible { box-shadow: inset 0 0 0 2px rgba(42, 38, 22, 0.35); }
.note-tools { display: flex; align-items: center; gap: 2px; padding: 2px 4px 4px; }
.note-tools .grow { flex: 1; }
.note-btn {
  width: 26px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 3px;
  background: transparent; color: rgba(42, 38, 22, 0.75); cursor: pointer; font-size: 0.95rem;
}
.note-btn:hover, .note-btn[aria-pressed="true"] { background: rgba(42, 38, 22, 0.1); color: #2a2616; }
.note-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 1px solid rgba(42, 38, 22, 0.45); }
.note-add {
  min-height: 128px; display: grid; place-items: center; gap: 4px; padding: 10px;
  border: 2px dashed var(--line-strong); border-radius: 2px; background: transparent; color: var(--ink-muted);
  font: 600 0.82rem var(--font-ui); cursor: pointer;
}
.note-add:hover { color: var(--ink); background: var(--surface-2); }
.sticky-pin {
  position: fixed; left: 0; top: 0; z-index: 99999980;
  width: 210px; min-height: 150px; border-radius: 1px;
  transform: translate(var(--x, 0), var(--y, 0)) rotate(var(--r, -1deg));
}
.sticky-tape {
  height: 22px; cursor: grab; touch-action: none; display: flex; align-items: center; justify-content: flex-end; padding: 0 2px;
}
.sticky-tape::before {
  content: ""; position: absolute; left: 50%; top: -9px; width: 74px; height: 20px; margin-left: -37px;
  background: rgba(253, 249, 236, 0.62); border: 1px solid rgba(160, 150, 115, 0.35); transform: rotate(-2deg);
}
.sticky-pin.dragging { cursor: grabbing; box-shadow: 4px 8px 0 rgba(60, 52, 28, 0.2); }

/* Read aloud */
.read-btn.speaking { color: var(--brand) !important; border-color: var(--brand) !important; background: var(--brand-tint, rgba(47, 101, 89, 0.12)) !important; }
.read-btn ion-icon { font-size: 1.1rem; }
.dock-meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.dock-meter i { display: block; height: 100%; background: var(--brand); transform-origin: left; }
.dictate-btn.busy { opacity: 0.75; cursor: progress; }

/* Accessibility */
.a11y-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dotted var(--line); }
.a11y-row:last-of-type { border-bottom: 0; }
.a11y-row > span { font-size: 0.88rem; }
.a11y-row small { display: block; color: var(--ink-muted); font-size: 0.74rem; }
.a11y-size { display: inline-flex; align-items: center; gap: 4px; }
.a11y-size output { min-width: 48px; text-align: center; font: 700 0.95rem/1 var(--font-ui); font-variant-numeric: tabular-nums; }

/* ---------- Paint program (draw.js) ---------- */
.draw-app { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.draw-bar, .draw-colors {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 5px 6px; border-radius: var(--r-sm);
  background: #e9e0c4; border: 1px solid; border-color: #fff #8f8763 #8f8763 #fff;
  color: #1b2a25;
}
.draw-bar .grow { flex: 1; }
.draw-sep { width: 1px; align-self: stretch; background: #8f8763; box-shadow: 1px 0 0 #fff; margin: 0 2px; }
.draw-btn {
  width: 30px; height: 28px; display: grid; place-items: center; padding: 0;
  background: #d9cfae; color: #1b2a25; border: 1px solid; border-color: #fff #4d4630 #4d4630 #fff; border-radius: 2px;
  box-shadow: inset -1px -1px 0 #8f8763; cursor: pointer; font-size: 1rem;
}
.draw-btn:hover { background: #e6ddc0; }
.draw-btn:active { border-color: #4d4630 #fff #fff #4d4630; box-shadow: inset 1px 1px 0 #8f8763; }
.draw-btn:disabled { color: #9a958a; cursor: default; }
.draw-range { display: inline-flex; align-items: center; gap: 5px; font: 600 0.74rem var(--font-ui); }
.draw-range input { width: 76px; accent-color: #2f6559; }
.draw-range input:disabled { opacity: 0.4; }
.draw-val { min-width: 30px; font: 600 0.78rem/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.draw-select { height: 28px; padding: 0 6px; border: 1px solid #8f8763; border-radius: 2px; background: #fffdf6; color: #1b2a25; font: 0.8rem var(--font); }
/* Shape fill / font share one fixed slot so switching tools never reflows the bar (and moves the canvas). */
.draw-ctx { position: relative; width: 112px; height: 28px; flex-shrink: 0; }
.draw-ctx select { position: absolute; inset: 0; width: 100%; visibility: hidden; }
.draw-app[data-tool="rect"] .ctx-shape, .draw-app[data-tool="ellipse"] .ctx-shape, .draw-app[data-tool="text"] .ctx-text { visibility: visible; }
.draw-main { display: grid; grid-template-columns: auto 1fr; gap: 6px; align-items: start; min-width: 0; }
.draw-tools {
  display: grid; grid-template-columns: repeat(2, 34px); gap: 2px; padding: 4px;
  background: #e9e0c4; border: 1px solid; border-color: #fff #8f8763 #8f8763 #fff; border-radius: var(--r-sm);
}
.draw-tool {
  width: 34px; height: 34px; display: grid; place-items: center; padding: 0;
  background: #d9cfae; border: 1px solid; border-color: #fff #4d4630 #4d4630 #fff; border-radius: 2px; cursor: pointer;
}
.draw-tool:hover { background: #e6ddc0; }
.draw-tool.on { background: #fffdf6; border-color: #4d4630 #fff #fff #4d4630; box-shadow: inset 1px 1px 0 #8f8763; }
.draw-sprite {
  width: 24px; height: 24px; image-rendering: pixelated;
  background: url("../img/icons/paint-tools.png") calc(var(--i) * -24px) 0 / 336px 24px no-repeat;
}
.draw-tool .draw-sprite { background-position: calc(var(--i, 0) * -24px) 0; }
.draw-stage {
  --u: 1px;
  position: relative; width: 100%; min-width: 0; overflow: hidden; outline: none;
  background-color: #fffdf6; border: 1px solid; border-color: #4d4630 #fff #fff #4d4630;
  box-shadow: inset 1px 1px 0 #8f8763;
  touch-action: none; cursor: crosshair;
}
.draw-stage:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.draw-stage[data-paper="ruled"] {
  background-image: linear-gradient(90deg, transparent calc(var(--u) * 63), rgba(194, 65, 59, 0.35) calc(var(--u) * 63), rgba(194, 65, 59, 0.35) calc(var(--u) * 64), transparent calc(var(--u) * 64)),
    linear-gradient(180deg, transparent calc(var(--u) * 31), rgba(47, 109, 181, 0.22) calc(var(--u) * 31));
  background-size: 100% 100%, 100% calc(var(--u) * 32);
  background-position: 0 0, 0 calc(var(--u) * 9);
}
.draw-stage[data-paper="graph"] {
  background-image: linear-gradient(rgba(47, 101, 89, 0.16) 1px, transparent 1px), linear-gradient(90deg, rgba(47, 101, 89, 0.16) 1px, transparent 1px);
  background-size: calc(var(--u) * 25) calc(var(--u) * 25);
}
.draw-stage[data-paper="dots"] {
  background-image: radial-gradient(rgba(92, 90, 82, 0.4) 1px, transparent 1.4px);
  background-size: calc(var(--u) * 25) calc(var(--u) * 25);
}
.draw-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.draw-app[data-tool="text"] .draw-stage { cursor: text; }
.draw-app[data-tool="fill"] .draw-stage, .draw-app[data-tool="eyedropper"] .draw-stage { cursor: cell; }
.draw-app[data-tool="eraser"] .draw-stage, .draw-app[data-tool="highlighter"] .draw-stage, .draw-app[data-tool="marker"] .draw-stage, .draw-app[data-tool="spray"] .draw-stage { cursor: none; }
.draw-cursor {
  position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none; display: none;
  border: 1px solid rgba(27, 42, 37, 0.8); box-shadow: 0 0 0 1px rgba(255, 253, 246, 0.85);
  will-change: transform;
}
.draw-cursor.show { display: block; }
.draw-app[data-tool="highlighter"] .draw-cursor { border-radius: 2px; }
.draw-textbox {
  position: absolute; z-index: 2; min-width: 140px; max-width: 70%;
  padding: 0 2px; margin: 0; border: 1px dashed #2f6559; background: rgba(255, 253, 246, 0.9);
  outline: none; resize: none; overflow: hidden; line-height: 1.25; white-space: pre;
}
.draw-colors { gap: 8px; }
.draw-current {
  width: 30px; height: 30px; flex-shrink: 0; background: var(--c);
  border: 1px solid; border-color: #4d4630 #fff #fff #4d4630; box-shadow: inset 0 0 0 2px #fffdf6;
}
.draw-palette { display: grid; grid-template-columns: repeat(8, 16px); gap: 2px; }
.draw-swatch, .draw-recent .draw-swatch {
  width: 16px; height: 14px; padding: 0; background: var(--c); cursor: pointer;
  border: 1px solid; border-color: #4d4630 #fff #fff #4d4630;
}
.draw-swatch.on { outline: 2px solid #12302b; outline-offset: 1px; }
.draw-recent { display: inline-flex; gap: 2px; }
.draw-custom { width: 30px; height: 28px; padding: 0; border: 1px solid #8f8763; background: #fffdf6; cursor: pointer; }
.draw-app.compact .draw-range input { width: 60px; }
html[data-theme="dark"] .draw-bar, html[data-theme="dark"] .draw-colors, html[data-theme="dark"] .draw-tools { background: #c9bf9a; }

@media (max-width: 640px) {
  .dock { top: auto; bottom: 88px; transform: none; gap: 4px; }
  .dock-tab { --tab: 40px; height: 38px; }
  .dock-tab:hover { transform: translateX(calc(100% - var(--tab))); }
  .dock-win {
    left: 0 !important; right: 0; top: auto !important; bottom: 0;
    width: auto !important; max-width: none; max-height: 78vh;
    transform: none !important; border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
  }
  .dock-win .win-bar { cursor: default; }
  .dock-win.resizable { resize: none; min-width: 0; }
  .sticky-pin { width: 170px; min-height: 120px; }
  .draw-main { grid-template-columns: 1fr; }
  .draw-tools { grid-template-columns: repeat(7, 34px); justify-content: start; overflow-x: auto; }
  .draw-range input { width: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .dock-tab { transition: none; }
}
@media print {
  .dock, .dock-win, .sticky-pin, .a11y-ruler { display: none !important; }
}

/* ---------- Tutor (session dock tool) ---------- */
.tutor-log { display: flex; flex-direction: column; gap: 8px; min-height: 160px; max-height: 300px; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.tutor-msg { max-width: 88%; padding: 8px 10px; border-radius: 10px; font-size: 0.88rem; line-height: 1.45; white-space: pre-wrap; }
.tutor-msg.student { align-self: flex-end; background: var(--btn-bg); color: var(--btn-ink); border-bottom-right-radius: 3px; }
.tutor-msg.tutor { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.tutor-msg.error { border-color: var(--bad); color: var(--bad); }
.tutor-msg.thinking { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-muted); }
.tutor-tools { display: flex; gap: 4px; margin-top: 6px; white-space: normal; }
.tutor-tools .ui-btn { min-height: 26px; padding: 2px 8px; }
.tutor-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.tutor-chips .chip { cursor: pointer; font-size: 0.76rem; padding: 3px 9px; }

/* ---------- Coach's debrief (recap) ---------- */
.debrief-headline { font: 700 1.15rem/1.4 var(--font-display); margin: 0; }
.debrief-focus { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.debrief-focus p { margin: 2px 0 0; }
.debrief-n { flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--btn-bg); color: var(--btn-ink); font: 700 0.85rem/1 var(--font-ui); }

/* ---------- Study room window (dock, while you're in a room) ---------- */
.room-mini-timer { display: flex; align-items: baseline; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.room-mini-clock { font-size: 1.6rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.room-mini-phase { font-size: 0.8rem; color: var(--ink-soft); }
.room-on-break .room-mini-timer { background: var(--ok-tint); }
.room-mini-quiz { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: var(--r-sm); background: var(--warn-tint); color: var(--ink); font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.room-mini-quiz[hidden] { display: none; }
.room-mini-people { display: flex; flex-wrap: wrap; gap: 6px; }
.room-person { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; padding: 2px 8px 2px 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.room-person.away { opacity: 0.55; }
.avatar.sm { width: 22px; height: 22px; font-size: 0.7rem; }
.room-chat-log { display: flex; flex-direction: column; gap: 4px; overflow: auto; font-size: 0.86rem; line-height: 1.4; }
.room-chat-log.mini { max-height: 150px; min-height: 60px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.room-msg { overflow-wrap: anywhere; }
.room-msg.mine strong { color: var(--brand-strong); }
.room-msg.system { color: var(--ink-muted); font-size: 0.8rem; font-style: italic; }
.room-msg.system strong { font-weight: 600; }
