/* ==========================================================================
   Agora AI Learning Companion — Design system + studio layout
   Tokens documented in docs/DESIGN_SYSTEM.md
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Surfaces */
  --bg-0: #070B17;
  --bg-1: #0B1020;
  --bg-2: #111827;
  --surface: #151D2E;
  --surface-2: #1A2335;
  --surface-3: #222D43;
  --glass: rgba(21, 29, 46, 0.72);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --highlight: rgba(255, 255, 255, 0.05);

  /* Brand + semantic */
  --accent: #6366F1;
  --accent-hi: #818CF8;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --cyan: #22D3EE;
  --cyan-soft: rgba(34, 211, 238, 0.14);
  --success: #34D399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --grad-brand: linear-gradient(135deg, #818CF8 0%, #6366F1 50%, #22D3EE 100%);

  /* Text */
  --text: #F8FAFC;
  --text-2: #94A3B8;
  --text-3: #64748B;

  /* Whiteboard (light canvas) */
  --paper: #FBFCFE;
  --paper-dot: #D5DCE7;
  --ink: #0F172A;
  --ink-2: #475569;
  --ink-accent: #4F46E5;
  --ink-mistake: #E2554F;
  --ink-success: #059669;

  /* Type */
  --font-ui: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-math: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --font-hand: 'Caveat', 'Bradley Hand', cursive;

  --fs-xs: 0.6875rem;  /* 11 */
  --fs-sm: 0.8125rem;  /* 13 */
  --fs-md: 0.875rem;   /* 14 */
  --fs-lg: 1rem;       /* 16 */
  --fs-xl: 1.25rem;    /* 20 */

  /* Space (4px grid) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;

  /* Radius */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 999px;

  /* Elevation */
  --shadow-panel: inset 0 1px 0 var(--highlight), 0 24px 48px -28px rgba(0, 0, 0, 0.7);
  --shadow-float: 0 1px 0 var(--highlight) inset, 0 20px 50px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border-strong);
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.45);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 140ms;
  --t-med: 260ms;
  --t-slow: 420ms;

  /* Layout */
  --topbar-h: 64px;
  --side-w: 384px;
  --gutter: 16px;
  --dock-h: 64px;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg-1);
  background-image:
    radial-gradient(1100px 600px at 12% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, rgba(34, 211, 238, 0.09), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
img, video { display: block; max-width: 100%; }
kbd {
  font-family: var(--font-mono); font-size: 0.72em;
  padding: 1px 6px; border-radius: var(--r-xs);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  box-shadow: 0 1px 0 rgba(0,0,0,.4);
}
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: rgba(99, 102, 241, 0.4); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 3. App shell ---------- */
.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
}

.topbar {
  display: flex; align-items: center; gap: var(--s-6);
  padding: 0 var(--s-6);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.brand__mark { border-radius: 10px; box-shadow: 0 6px 20px -6px rgba(99, 102, 241, 0.7); }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__name { font-weight: 650; font-size: 0.95rem; letter-spacing: -0.01em; }
.brand__by { font-size: var(--fs-xs); color: var(--text-3); }

.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-2); min-width: 0; }
.crumb { white-space: nowrap; }
.crumb--subject {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px; border-radius: var(--r-full);
  background: var(--accent-soft); color: #C7D2FE; font-weight: 550;
  border: 1px solid rgba(129, 140, 248, 0.25);
}
.crumb--subject .ico { width: 14px; height: 14px; }
.crumb--muted { color: var(--text-3); }
.crumbs__sep { color: var(--text-3); opacity: .6; }

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

/* ---------- 4. Primitives ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px; border-radius: var(--r-full);
  font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap;
  background: rgba(148, 163, 184, 0.06); border: 1px solid var(--border);
}
.pill--sm { height: 24px; padding: 0 9px; font-size: var(--fs-xs); gap: 6px; font-weight: 550; }
.pill--phase { color: var(--text-3); font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .02em; }
.pill__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.pill[data-tone="success"] { color: #A7F3D0; border-color: rgba(52, 211, 153, 0.25); background: var(--success-soft); }
.pill[data-tone="success"] .pill__dot { background: var(--success); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2); }
.pill[data-tone="live"] { color: #A5F3FC; border-color: rgba(34, 211, 238, 0.3); background: var(--cyan-soft); }
.pill[data-tone="live"] .pill__dot { background: var(--cyan); animation: pulse-dot 1.8s var(--ease) infinite; }
.pill[data-tone="warning"] { color: #FDE68A; border-color: rgba(251, 191, 36, 0.3); background: var(--warning-soft); }
.pill[data-tone="warning"] .pill__dot { background: var(--warning); }
.pill[data-tone="danger"] { color: #FECACA; border-color: rgba(248, 113, 113, 0.3); background: var(--danger-soft); }
.pill[data-tone="danger"] .pill__dot { background: var(--danger); }
.pill[data-tone="busy"] .pill__dot { background: var(--accent-hi); animation: pulse-dot 1s ease infinite; }

.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: var(--r-xs); font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap;
}
.tag--soon { color: #C7D2FE; background: var(--accent-soft); border: 1px dashed rgba(129, 140, 248, 0.4); }

.tile {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none;
  border: 1px solid var(--border);
}
.tile .ico { width: 16px; height: 16px; }
.tile--indigo { background: var(--accent-soft); color: var(--accent-hi); border-color: rgba(129, 140, 248, .25); }
.tile--cyan { background: var(--cyan-soft); color: var(--cyan); border-color: rgba(34, 211, 238, .25); }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none;
  color: var(--text-2); border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover:not(:disabled) { background: rgba(148, 163, 184, 0.1); color: var(--text); }
.icon-btn:active:not(:disabled) { transform: scale(0.94); }
.icon-btn[aria-pressed="true"] { color: var(--cyan); background: var(--cyan-soft); border-color: rgba(34, 211, 238, .25); }
.icon-btn--sm { width: 30px; height: 30px; border-radius: var(--r-xs); }
.icon-btn--sm .ico { width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r-sm);
  font-size: var(--fs-md); font-weight: 550; white-space: nowrap; text-decoration: none;
  border: 1px solid var(--border-strong); color: var(--text); background: var(--surface-2);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.btn .ico { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn--primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(180deg, #7376F4, #5B5EE8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 8px 20px -8px rgba(99, 102, 241, 0.8);
}
.btn--primary:hover:not(:disabled) { background: linear-gradient(180deg, #8083F6, #6366F1); }
.btn--ghost { background: rgba(148, 163, 184, 0.06); }
.btn--sm { height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn--block { width: 100%; }
.btn--danger:hover:not(:disabled) { color: #FECACA; border-color: rgba(248, 113, 113, .4); background: var(--danger-soft); }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid rgba(148, 163, 184, 0.2); border-top-color: var(--cyan);
  animation: spin .8s linear infinite;
}

.empty-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(148, 163, 184, 0.08); border: 1px solid var(--border); color: var(--text-2);
}
.empty-icon .ico { width: 22px; height: 22px; }
.empty-icon--danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(248, 113, 113, .25); }
.empty-icon--warn { color: var(--warning); background: var(--warning-soft); border-color: rgba(251, 191, 36, .25); }

/* Tooltip (CSS only) */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  padding: 5px 9px; border-radius: var(--r-xs);
  font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0; text-transform: none; white-space: nowrap; color: var(--text);
  background: #0A0F1D; border: 1px solid var(--border-strong);
  box-shadow: 0 8px 20px -6px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: 350ms; }
.topbar [data-tip]::after, .panel__head [data-tip]::after { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -4px); }
.topbar [data-tip]:hover::after, .panel__head [data-tip]:hover::after { transform: translate(-50%, 0); }
.topbar__right [data-tip]::after { left: auto; right: 0; transform: translate(0, -4px); }
.topbar__right [data-tip]:hover::after { transform: translate(0, 0); }

/* ---------- 5. Studio grid ---------- */
.studio {
  min-height: 0;
  display: grid;
  gap: var(--gutter);
  padding: var(--gutter) calc(var(--gutter) + 4px) calc(var(--gutter) + 4px);
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  grid-template-rows: auto minmax(180px, 1fr);
  grid-template-areas:
    "main camera"
    "main context";
}
.board { grid-area: main; position: relative; }
.camera { grid-area: camera; position: relative; }
.context { grid-area: context; }

/* Camera focus: camera becomes the main stage, board docks to the side */
.app[data-focus="camera"] .studio {
  grid-template-areas:
    "camera main"
    "camera context";
  grid-template-rows: auto minmax(160px, 1fr);
}
.app[data-focus="camera"] .board { max-height: 260px; }

.panel {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(26, 35, 53, 0.78), rgba(17, 24, 39, 0.78));
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  container-type: inline-size;
  animation: rise var(--t-slow) var(--ease) both;
}
.camera { animation-delay: 120ms; }
.context { animation-delay: 180ms; }

.panel__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  min-height: 58px;
}
.panel__title { display: flex; align-items: center; gap: var(--s-3); min-width: 0; flex: 1; }
.panel__title > div { min-width: 0; }
.panel__title h2 { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; }
.panel__sub { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel__actions { display: flex; align-items: center; gap: 2px; }
.panel__actions .pill { margin-right: 6px; }

/* ---------- 6. Whiteboard ---------- */
.board__tools {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: var(--r-md); background: rgba(7, 11, 23, 0.5); border: 1px solid var(--border);
}
.board__tools .tag { margin: 0 6px 0 4px; }
.tool { width: 32px; height: 30px; border-radius: var(--r-xs); display: grid; place-items: center; color: var(--text-3); }
.tool .ico { width: 16px; height: 16px; }
.board__restore { display: none; }
.app[data-focus="camera"] .board__restore { display: grid; }
.app[data-focus="camera"] .board__tools { display: none; }

.board__canvas {
  position: relative; flex: 1; min-height: 0;
  margin: 0 var(--s-3) var(--s-3);
  border-radius: var(--r-lg);
  background-color: var(--paper);
  background-image: radial-gradient(var(--paper-dot) 1.1px, transparent 1.2px);
  background-size: 22px 22px;
  background-position: 11px 11px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06), 0 12px 40px -20px rgba(0, 0, 0, 0.8);
  color: var(--ink);
  overflow: auto;
  /* leave room for the floating dock */
  padding-bottom: calc(var(--dock-h) + var(--s-8));
}
.board__ribbon {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 8px; width: fit-content;
  margin: var(--s-4) var(--s-4) 0 auto;
  padding: 6px 10px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 500; color: #4338CA;
  background: rgba(238, 242, 255, 0.92); border: 1px dashed rgba(99, 102, 241, 0.45);
  backdrop-filter: blur(6px);
}
.board__ribbon .ico { width: 14px; height: 14px; }

/* Live lesson board (Excalidraw engine, Phase 4) */
.board__live {
  position: relative; flex: 1; min-height: 0;
  margin: 0 var(--s-3) var(--s-3);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06), 0 12px 40px -20px rgba(0, 0, 0, 0.8);
}
.board__live[hidden], .board__canvas[hidden] { display: none; }
.board__surface { position: absolute; inset: 0 0 calc(var(--dock-h) + var(--s-6)) 0; }
.board__surface .excalidraw { --color-primary: #4f46e5; }
/* Empty-board placeholder */
.board__empty {
  position: absolute; inset: 0 0 calc(var(--dock-h) + var(--s-6)) 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: var(--s-6); text-align: center; pointer-events: none;
  background: radial-gradient(#e2e8f0 1.1px, transparent 1.2px) 0 0 / 22px 22px, #ffffff;
}
.board__empty[hidden] { display: none; }
.board__empty-art { width: min(240px, 50%); height: auto; margin-bottom: 6px; }
.board__empty-art .be-frame { fill: #f8fafc; stroke: #c7d2fe; stroke-width: 2; }
.board__empty-art .be-line { stroke: #94a3b8; stroke-width: 4; stroke-linecap: round; fill: none; }
.board__empty-art .be-line--soft { stroke: #cbd5e1; }
.board__empty-art .be-chart { stroke: #6366f1; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.board__empty-art .be-dot { fill: #22d3ee; }
.board__empty-art .be-leg { stroke: #cbd5e1; stroke-width: 4; stroke-linecap: round; }
.board__empty-title { margin: 0; font-size: 18px; font-weight: 650; color: #1e293b; }
.board__empty-text { margin: 0; max-width: 420px; font-size: 14px; color: #475569; }
.board__empty-hint { margin: 6px 0 0; font-size: 12.5px; color: #6366f1; }
.lesson-card__empty { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--text-2); }

/* Aria's surface: hide the engine's own menus/toolbars (desktop and its narrow "mobile" layout).
   Pan and pinch-zoom on the canvas still work; the camera follows new content automatically. */
.board__surface .layer-ui__wrapper,
.board__surface .App-bottom-bar,
.board__surface .App-toolbar-content,
.board__surface .mobile-misc-tools-container { display: none !important; }
.board__caption {
  position: absolute; left: 50%; bottom: calc(var(--dock-h) + var(--s-8)); transform: translateX(-50%);
  max-width: min(720px, 86%); margin: 0; padding: 10px 16px;
  border-radius: var(--r-md); background: rgba(15, 23, 42, 0.86); color: #F8FAFC;
  font-size: var(--fs-sm); line-height: 1.45; text-align: center;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 5;
}
.board__surface { z-index: 0; isolation: isolate; }
.board__demo { position: relative; }
.board__btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: var(--r-xs); color: var(--text-2); font-size: var(--fs-xs); font-weight: 550;
}
.board__btn .ico { width: 14px; height: 14px; }
.board__btn:hover:not(:disabled), .board__btn[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.board__btn:disabled { opacity: .45; cursor: default; }
.board__btn[data-playing="true"] { color: #A5F3FC; }
.board__menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 260px;
  padding: 6px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-panel);
}
.board__menu button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-xs); text-align: left; color: var(--text); font-size: var(--fs-sm);
}
.board__menu button small { color: var(--text-3); font-size: var(--fs-xs); }
.board__menu button:hover, .board__menu button:focus-visible { background: var(--surface-3); }

.lesson { max-width: 820px; margin: 0 auto; padding: var(--s-4) clamp(20px, 5cqi, 56px) 0; }
.lesson__eyebrow {
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-accent);
}
.lesson__title { font-family: var(--font-math); font-weight: 600; font-size: clamp(1.5rem, 3.2cqi, 2rem); letter-spacing: -0.01em; margin: 4px 0 clamp(16px, 3cqi, 28px); }
var { font-family: var(--font-math); font-style: italic; font-weight: 500; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(10px, 1.6cqi, 16px); }
.step {
  display: grid; grid-template-columns: 30px minmax(max-content, auto) 1fr; align-items: center;
  column-gap: clamp(14px, 2.5cqi, 28px);
  padding: 6px 0;
  animation: write-in var(--t-slow) var(--ease) both;
}
.step:nth-child(2) { animation-delay: 120ms; } .step:nth-child(3) { animation-delay: 240ms; } .step:nth-child(4) { animation-delay: 360ms; }
.step__n {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--ink-2); background: #EEF2F7; border: 1px solid #E2E8F0;
}
.math { font-family: var(--font-math); font-size: clamp(1.45rem, 3.6cqi, 2.25rem); line-height: 1.25; white-space: nowrap; font-variant-numeric: lining-nums; }
.step__note { font-size: var(--fs-sm); color: var(--ink-2); }
.step__hand { font-family: var(--font-hand); font-size: clamp(1.1rem, 2.2cqi, 1.45rem); line-height: 1.1; color: var(--ink-mistake); transform: rotate(-2deg); }
.step--mistake .step__n { color: var(--ink-mistake); background: #FEF2F2; border-color: #FECACA; }
.step--mistake .math { color: #334155; }
.mark-mistake { position: relative; display: inline-block; padding: 0 4px; }
.mark-mistake::after {
  content: ''; position: absolute; inset: -6px -8px -4px -6px;
  border: 2.5px solid var(--ink-mistake); border-radius: 50% 46% 52% 44% / 56% 50% 48% 52%;
  transform: rotate(-4deg); opacity: .9;
}
.mark-hl { background: linear-gradient(transparent 38%, rgba(99, 102, 241, 0.2) 38%, rgba(99, 102, 241, 0.2) 80%, transparent 80%); padding: 0 4px; border-radius: 3px; }
.step--done .step__n { color: #fff; background: var(--ink-success); border-color: var(--ink-success); }
.step__check {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content;
  font-size: var(--fs-sm); font-weight: 550; color: var(--ink-success);
  padding: 4px 10px; border-radius: var(--r-full); background: #ECFDF5; border: 1px solid #A7F3D0;
}
.step__check .ico { width: 14px; height: 14px; stroke-width: 2.4; }

.hint {
  display: flex; gap: var(--s-3); align-items: flex-start;
  margin-top: clamp(20px, 4cqi, 36px); padding: var(--s-4);
  border-radius: var(--r-md); background: #fff;
  border: 1px solid #E0E7FF; box-shadow: 0 10px 30px -18px rgba(79, 70, 229, 0.45);
  max-width: 560px;
}
.hint__icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: #EEF2FF; color: var(--ink-accent); }
.hint__icon .ico { width: 16px; height: 16px; }
.hint__label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-accent); }
.hint__text { font-size: var(--fs-md); color: #334155; margin-top: 2px; }

/* Compact board (camera focus or narrow container) */
@container (max-width: 520px) {
  .board__canvas { padding-bottom: var(--s-4); }
  .board__ribbon { margin: var(--s-2) var(--s-2) 0 auto; font-size: 10px; }
  .lesson { padding-top: var(--s-2); }
  .step { grid-template-columns: 24px auto; }
  .step__n { width: 22px; height: 22px; font-size: 11px; }
  .step__note, .step__hand, .step__check, .hint { display: none; }
  .math { font-size: 1.25rem; }
  .lesson__title { font-size: 1.15rem; margin-bottom: 8px; }
}

/* ---------- 7. Aria (orb states — top-bar chip, see 16) ---------- */
/* Picture-in-picture video of Aria (Anam) */
.pip {
  --pip-w: 240px; --pip-h: 180px;
  --state: var(--text-3);
  position: absolute; z-index: 30;
  width: var(--pip-w); height: var(--pip-h);
  border-radius: var(--r-lg); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 30%, #1e293b, #0b1020);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.75), 0 0 0 2px color-mix(in srgb, var(--state) 55%, transparent);
  transition: box-shadow var(--t-med) var(--ease), width var(--t-med) var(--ease), height var(--t-med) var(--ease), border-radius var(--t-med) var(--ease);
  cursor: grab; touch-action: none; user-select: none;
}
.pip[hidden] { display: none; }
.pip.is-dragging { cursor: grabbing; transition: none; box-shadow: 0 24px 60px -14px rgba(0, 0, 0, 0.85), 0 0 0 2px var(--accent-hi); }
/* corners (inside the host panel; bottom corners clear the floating dock) */
.pip[data-corner="br"] { right: var(--s-5); bottom: calc(var(--dock-h) + var(--s-8)); }
.pip[data-corner="bl"] { left: var(--s-5); bottom: calc(var(--dock-h) + var(--s-8)); }
.pip[data-corner="tr"] { right: var(--s-5); top: 72px; }
.pip[data-corner="tl"] { left: var(--s-5); top: 72px; }
/* camera as main view: stay clear of the device row + shutter at the bottom of the camera panel */
.camera > .pip[data-corner^="b"] { bottom: calc(var(--dock-h) + 96px); }
.pip__video, .pip__video > div, .pip__video video { position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; }
.pip__video video { object-fit: cover; }
.pip__wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.pip[data-live="true"] .pip__wait { display: none; }
.pip__bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px;
  padding: 18px 8px 8px 12px; background: linear-gradient(180deg, transparent, rgba(7, 11, 23, 0.82));
  font-size: var(--fs-xs); color: #e2e8f0;
}
.pip__name { font-weight: 650; }
.pip__state { flex: 1; display: inline-flex; align-items: center; gap: 6px; color: color-mix(in srgb, var(--state) 70%, #e2e8f0); }
.pip__state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--state); }
.pip__btn { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: #e2e8f0; background: rgba(15, 23, 42, 0.55); }
.pip__btn:hover { background: rgba(99, 102, 241, 0.45); }
.pip__btn .ico { width: 14px; height: 14px; }
.pip[data-state="listening"] { --state: var(--cyan); }
.pip[data-state="thinking"], .pip[data-state="connecting"] { --state: var(--accent-hi); }
.pip[data-state="speaking"] { --state: var(--success); }
.pip[data-state="disconnected"] { --state: var(--warning); }
/* minimised: a small round face with the state ring; click to restore */
.pip[data-min="true"] { --pip-w: 64px; --pip-h: 64px; border-radius: 50%; box-shadow: 0 10px 26px -10px rgba(0, 0, 0, 0.8), 0 0 0 3px var(--state); }
.pip[data-min="true"] .pip__bar, .pip[data-min="true"] .pip__wait span:last-child { display: none; }

.orb { position: relative; width: 92px; height: 92px; flex: none; display: grid; place-items: center; }
.orb__core {
  position: relative; z-index: 2; width: 66px; height: 66px; border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.55), transparent 38%),
    radial-gradient(circle at 70% 80%, rgba(34, 211, 238, .8), transparent 55%),
    linear-gradient(140deg, #818CF8, #4F46E5 60%, #0E7490);
  box-shadow: 0 10px 30px -6px rgba(99, 102, 241, 0.7), inset 0 -6px 14px rgba(7, 11, 23, .35);
  transition: filter var(--t-med), transform var(--t-med) var(--ease);
  animation: breathe 5s ease-in-out infinite;
}
.orb__initial { font-weight: 650; font-size: 1.5rem; color: rgba(255,255,255,.92); letter-spacing: -0.02em; text-shadow: 0 2px 8px rgba(30, 27, 75, .5); }
.orb__ring {
  position: absolute; inset: 6px; border-radius: 50%;
  border: 1.5px solid var(--state); opacity: 0;
}
.orb__spin {
  position: absolute; inset: 2px; border-radius: 50%; opacity: 0;
  background: conic-gradient(from 0deg, transparent 0 65%, var(--accent-hi) 85%, var(--cyan));
  -webkit-mask: radial-gradient(circle, transparent 41px, #000 42px);
          mask: radial-gradient(circle, transparent 41px, #000 42px);
}
.aria-chip[data-state="idle"] .wave, .aria-chip[data-state="disconnected"] .wave { opacity: 0; }

.state-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600;
  color: var(--state); background: rgba(148, 163, 184, 0.08); border: 1px solid var(--border);
}
.state-chip__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--state); }

.wave { display: flex; align-items: center; gap: 3px; height: 18px; margin-top: 4px; opacity: .25; transition: opacity var(--t-med); }
.wave i { width: 3px; height: 4px; border-radius: 2px; background: var(--state); transition: height var(--t-med); }

/* States */
.aria-chip[data-state="idle"] .orb__core { filter: saturate(.55) brightness(.8); }
.aria-chip[data-state="connecting"] { --state: var(--accent-hi); }
.aria-chip[data-state="connecting"] .orb__spin { opacity: 1; animation: spin 1.1s linear infinite; }
.aria-chip[data-state="listening"] { --state: var(--cyan); }
.aria-chip[data-state="listening"] .orb__ring { animation: ripple 2.2s var(--ease) infinite; }
.aria-chip[data-state="listening"] .orb__ring--2 { animation-delay: 1.1s; }
.aria-chip[data-state="thinking"] { --state: var(--accent-hi); }
.aria-chip[data-state="thinking"] .orb__spin { opacity: .7; animation: spin 2.6s linear infinite; }
.aria-chip[data-state="thinking"] .orb__core { animation: breathe 1.6s ease-in-out infinite; }
.aria-chip[data-state="speaking"] { --state: var(--success); }
.aria-chip[data-state="speaking"] .orb__core { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(52, 211, 153, .12), 0 10px 40px -4px rgba(52, 211, 153, .5); }
.aria-chip[data-state="speaking"] .wave { opacity: 1; }
.aria-chip[data-state="speaking"] .wave i { animation: eq 900ms ease-in-out infinite; }
.aria-chip[data-state="listening"] .wave { opacity: .7; }
.aria-chip[data-state="listening"] .wave i { animation: eq 1.4s ease-in-out infinite; animation-duration: 1.6s; }
.wave i:nth-child(2) { animation-delay: -.2s !important; } .wave i:nth-child(3) { animation-delay: -.5s !important; }
.wave i:nth-child(4) { animation-delay: -.1s !important; } .wave i:nth-child(5) { animation-delay: -.7s !important; }
.wave i:nth-child(6) { animation-delay: -.35s !important; } .wave i:nth-child(7) { animation-delay: -.6s !important; }
.aria-chip[data-state="disconnected"] { --state: var(--warning); }
.aria-chip[data-state="disconnected"] .orb__core { filter: grayscale(1) brightness(.6); animation: none; }

/* ---------- 8. Camera ---------- */
.camera__body { display: flex; flex-direction: column; gap: var(--s-3); padding: 0 var(--s-3) var(--s-3); min-height: 0; flex: 1; }
.camera[data-collapsed="true"] .camera__body { display: none; }
.app[data-focus="camera"] .camera__body { padding-bottom: calc(var(--dock-h) + 30px); }
.camera[data-collapsed="true"] .ico--chev { transform: rotate(-90deg); }
.ico--chev { transition: transform var(--t-med) var(--ease); }

.cam-stage {
  position: relative; overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 50% 40%, rgba(34, 211, 238, 0.06), transparent 60%),
    repeating-linear-gradient(135deg, rgba(148,163,184,.035) 0 10px, transparent 10px 20px),
    #0A0F1C;
  border: 1px solid var(--border);
  isolation: isolate;
}
.app[data-focus="camera"] .cam-stage { aspect-ratio: auto; flex: 1; min-height: 0; }
@media (min-width: 1121px) and (max-height: 960px) {
  .app[data-focus="board"] .cam-stage { aspect-ratio: 16 / 9; }
  .ghost-chat { display: none; }
}
.cam-stage video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
  opacity: 0; transition: opacity var(--t-slow) var(--ease), transform var(--t-med) var(--ease);
}
.cam-stage[data-state="live"] video { opacity: 1; }
.cam-stage[data-rotated="true"] video { transform: rotate(180deg); }

.cam-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: var(--s-6); text-align: center;
  animation: fade var(--t-med) var(--ease);
}
.cam-overlay__title { font-weight: 600; font-size: var(--fs-md); margin-top: 4px; }
.cam-overlay__text { font-size: var(--fs-sm); color: var(--text-2); max-width: 290px; }
.cam-overlay .btn { margin-top: 6px; }
.cam-overlay__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; }
.cam-stage[data-state="idle"] .cam-overlay--idle,
.cam-stage[data-state="requesting"] .cam-overlay--requesting,
.cam-stage[data-state="error"] .cam-overlay--error,
.cam-stage[data-state="disconnected"] .cam-overlay--disconnected { display: flex; }
.cam-stage[data-state="requesting"]::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(100deg, transparent 30%, rgba(148, 163, 184, .07) 50%, transparent 70%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}

.cam-live, .cam-meta {
  position: absolute; z-index: 3; top: 10px;
  display: none; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-xs); font-size: 10.5px; font-weight: 600;
  background: rgba(7, 11, 23, 0.62); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.08);
}
.cam-live { left: 10px; letter-spacing: .08em; text-transform: uppercase; color: #fff; }
.cam-live span { width: 6px; height: 6px; border-radius: 50%; background: #F43F5E; animation: pulse-dot 1.6s ease infinite; }
.cam-meta { right: 10px; font-family: var(--font-mono); font-weight: 500; color: var(--text-2); }
.cam-stage[data-state="live"] .cam-live,
.cam-stage[data-state="live"] .cam-meta { display: inline-flex; }

/* Corner brackets: framing guide */
.cam-frame { position: absolute; inset: 14px; z-index: 2; pointer-events: none; opacity: 0; transition: opacity var(--t-med); }
.cam-stage[data-state="live"] .cam-frame { opacity: .7; }
.cam-frame i { position: absolute; width: 18px; height: 18px; border-color: rgba(255,255,255,.75); border-style: solid; border-width: 0; }
.cam-frame i:nth-child(1) { top: 22px; left: 0; border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 6px; }
.cam-frame i:nth-child(2) { top: 22px; right: 0; border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 6px; }
.cam-frame i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; border-bottom-left-radius: 6px; }
.cam-frame i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 6px; }

.cam-flash { position: absolute; inset: 0; z-index: 4; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.is-firing { animation: flash 420ms var(--ease); }
.cam-stage.is-capturing video { animation: snap 380ms var(--ease); }

.cam-controls { display: flex; align-items: center; gap: var(--s-2); }
.select {
  position: relative; flex: 1; min-width: 0; display: flex; align-items: center;
  height: 40px; border-radius: var(--r-sm);
  background: rgba(7, 11, 23, 0.45); border: 1px solid var(--border);
  transition: border-color var(--t-fast);
}
.select:hover { border-color: var(--border-strong); }
.select:focus-within { box-shadow: var(--ring); border-color: transparent; }
.select select {
  appearance: none; -webkit-appearance: none; width: 100%; height: 100%;
  padding: 0 32px 0 36px; background: transparent; border: 0; outline: none;
  font-size: var(--fs-sm); color: var(--text); text-overflow: ellipsis; cursor: pointer;
}
.select select:disabled { color: var(--text-3); cursor: not-allowed; }
.select select option { background: var(--bg-2); color: var(--text); }
.select__lead { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.select__chev { position: absolute; right: 10px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.select--block select { padding-left: 12px; }

.last-shot {
  width: 40px; height: 40px; border-radius: var(--r-sm); overflow: hidden; flex: none;
  border: 1px solid var(--border-strong); background: var(--surface-3);
  transition: transform var(--t-fast);
  animation: pop var(--t-slow) var(--ease-spring);
}
.last-shot:hover { transform: scale(1.06); }
.last-shot img { width: 100%; height: 100%; object-fit: cover; }

.shutter {
  width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(from 210deg, #818CF8, #22D3EE, #818CF8);
  padding: 3px;
  box-shadow: 0 8px 22px -8px rgba(34, 211, 238, 0.7);
  transition: transform var(--t-fast) var(--ease), opacity var(--t-fast), filter var(--t-fast);
}
.shutter__inner { width: 100%; height: 100%; border-radius: 50%; background: var(--bg-2); display: grid; place-items: center; }
.shutter__inner::after { content: ''; width: 30px; height: 30px; border-radius: 50%; background: #F8FAFC; transition: transform var(--t-fast) var(--ease); }
.shutter:hover:not(:disabled) .shutter__inner::after { transform: scale(0.92); }
.shutter:active:not(:disabled) { transform: scale(0.92); }
.shutter:disabled { filter: grayscale(1); opacity: .35; box-shadow: none; }

/* ---------- 9. Context tabs ---------- */
.tabs {
  display: flex; gap: 2px; padding: 6px; margin: var(--s-3) var(--s-3) 0;
  border-radius: var(--r-md); background: rgba(7, 11, 23, 0.45); border: 1px solid var(--border);
}
.tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 550; color: var(--text-3);
  transition: color var(--t-fast), background var(--t-fast);
}
.tab .ico { width: 15px; height: 15px; }
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface-3); box-shadow: inset 0 1px 0 var(--highlight), 0 2px 8px -2px rgba(0,0,0,.5); }
.tab__count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  font-size: 10.5px; font-weight: 650; display: grid; place-items: center;
  background: rgba(148, 163, 184, .14); color: var(--text-2);
}
.tab__count.is-bumped { animation: pop var(--t-slow) var(--ease-spring); background: var(--cyan-soft); color: var(--cyan); }

.pane { flex: 1; min-height: 0; overflow: auto; padding: var(--s-4); animation: fade var(--t-med) var(--ease); }

.empty { height: 100%; min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: var(--s-2); }
.empty__title { font-weight: 600; font-size: var(--fs-md); margin-top: 6px; }
.empty__text { font-size: var(--fs-sm); color: var(--text-3); max-width: 280px; }

.ghost-chat { width: 200px; display: grid; gap: 7px; margin-bottom: 4px; }
.ghost { height: 12px; border-radius: var(--r-full); background: linear-gradient(90deg, rgba(148,163,184,.1), rgba(148,163,184,.18), rgba(148,163,184,.1)); background-size: 200% 100%; animation: shimmer 2.4s linear infinite; }
.ghost--ai { width: 78%; }
.ghost--me { width: 56%; justify-self: end; background: linear-gradient(90deg, rgba(99,102,241,.16), rgba(99,102,241,.3), rgba(99,102,241,.16)); background-size: 200% 100%; }
.ghost--short { width: 44%; }

.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s-2); }
.gallery li { animation: pop var(--t-slow) var(--ease-spring) both; }
.thumb {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--border-strong); background: var(--surface-3);
  transition: transform var(--t-fast), border-color var(--t-fast);
}
.thumb:hover { transform: translateY(-2px); border-color: rgba(34, 211, 238, .5); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__time {
  position: absolute; left: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 9.5px; color: #E2E8F0; background: rgba(7,11,23,.7);
}

.lesson-card {
  padding: var(--s-4); border-radius: var(--r-md);
  background: linear-gradient(160deg, rgba(99, 102, 241, 0.14), rgba(34, 211, 238, 0.05));
  border: 1px solid rgba(129, 140, 248, 0.2);
}
.lesson-card__eyebrow { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-hi); }
.lesson-card__eyebrow .ico { width: 14px; height: 14px; }
.lesson-card__title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; margin: 6px 0 10px; }
.objectives { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.objectives li { position: relative; padding-left: 20px; font-size: var(--fs-sm); color: var(--text-2); }
.objectives li::before { content: ''; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 2px; background: var(--cyan); transform: rotate(45deg); opacity: .8; }
.section-label { margin: var(--s-5) 0 var(--s-2); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.loop { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; counter-reset: loop; }
.loop li {
  counter-increment: loop; display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px 0 6px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 550; color: var(--text-2);
  background: rgba(148, 163, 184, 0.07); border: 1px solid var(--border);
}
.loop li::before { content: counter(loop); width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; color: var(--text); background: var(--accent-soft); }
.note { display: flex; align-items: center; gap: 6px; margin-top: var(--s-4); font-size: var(--fs-xs); color: var(--text-3); }
.note .ico { width: 14px; height: 14px; }

/* ---------- 10. Dock ---------- */
.dock {
  position: fixed; z-index: 20;
  bottom: calc(var(--gutter) + 22px);
  left: calc((100vw - var(--side-w) - var(--gutter)) / 2);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  height: var(--dock-h); padding: 0 10px;
  border-radius: 22px;
  background: rgba(13, 19, 36, 0.82);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-float);
  animation: dock-in 600ms var(--ease) 200ms both;
}
.dock__btn {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.dock__btn .ico { width: 20px; height: 20px; }
.dock__btn:hover:not(:disabled) { background: rgba(148, 163, 184, 0.12); color: var(--text); }
.dock__btn:active:not(:disabled) { transform: scale(0.92); }
.dock__btn:disabled { color: var(--text-3); opacity: .55; }
.dock__btn[aria-pressed="true"] { color: var(--cyan); background: var(--cyan-soft); }
.dock__sep { width: 1px; height: 26px; background: var(--border-strong); margin: 0 6px; }
.dock__primary {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px 0 16px;
  border-radius: 14px; font-weight: 600; color: #fff; white-space: nowrap;
  background: linear-gradient(135deg, #6366F1, #4F46E5 55%, #0891B2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 10px 24px -10px rgba(99, 102, 241, 0.9);
  transition: filter var(--t-fast), transform var(--t-fast);
}
.dock__primary:hover { filter: brightness(1.08); }
.dock__primary:active { transform: scale(0.97); }
.dock__primary .ico { width: 18px; height: 18px; }
.dock__soon { font-size: 10px; font-weight: 650; letter-spacing: .04em; padding: 3px 7px; border-radius: 8px; background: rgba(255,255,255,.16); text-transform: uppercase; }

/* ---------- 11. Drawer ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(3, 6, 15, 0.55); backdrop-filter: blur(2px); animation: fade var(--t-med) var(--ease); }
.drawer {
  position: fixed; z-index: 41; top: 12px; right: 12px; bottom: 12px;
  width: min(380px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  border-radius: var(--r-xl);
  background: rgba(17, 24, 39, 0.96); border: 1px solid var(--border-strong);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  transform: translateX(calc(100% + 24px)); visibility: hidden;
  transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
}
.drawer.is-open { transform: none; visibility: visible; transition: transform var(--t-slow) var(--ease); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.drawer__head h2 { font-size: var(--fs-lg); font-weight: 600; }
.drawer__body { flex: 1; overflow: auto; padding: var(--s-2) var(--s-5) var(--s-6); }
.setting-group { padding: var(--s-4) 0; border-bottom: 1px solid var(--border); display: grid; gap: var(--s-3); }
.setting-group:last-child { border-bottom: 0; }
.setting-group__title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.field { display: grid; gap: 6px; }
.field--row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.field__label { font-size: var(--fs-sm); font-weight: 550; color: var(--text); }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }

.segmented { display: flex; padding: 3px; gap: 2px; border-radius: var(--r-sm); background: rgba(7, 11, 23, 0.5); border: 1px solid var(--border); }
.segmented--wrap { flex-wrap: wrap; }
.segmented button {
  flex: 1; min-width: max-content; height: 30px; padding: 0 10px; border-radius: 6px;
  font-size: var(--fs-xs); font-weight: 550; color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface-3); color: var(--text); box-shadow: inset 0 1px 0 var(--highlight), 0 2px 6px -2px rgba(0,0,0,.6); }

.switch { position: relative; width: 40px; height: 24px; flex: none; border-radius: var(--r-full); background: var(--surface-3); border: 1px solid var(--border-strong); transition: background var(--t-fast); }
.switch span { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #CBD5E1; transition: transform var(--t-med) var(--ease-spring), background var(--t-fast); }
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-checked="true"] span { transform: translateX(16px); background: #fff; }

.kv { margin: 0; display: grid; gap: 8px; }
.kv > div { display: flex; justify-content: space-between; gap: var(--s-4); font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text-2); text-align: right; font-family: var(--font-mono); font-size: var(--fs-xs); }
.kv--keys dd { font-family: var(--font-ui); }

/* ---------- 12. Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  background: rgba(3, 6, 15, 0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fade var(--t-med) var(--ease);
}
.lightbox__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.lightbox__meta { display: flex; gap: var(--s-4); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-2); flex-wrap: wrap; }
.lightbox__meta strong { color: var(--text); font-weight: 500; }
.lightbox__actions { display: flex; align-items: center; gap: var(--s-2); }
.lightbox__stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: var(--s-6) 72px; }
.lightbox__stage img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); box-shadow: 0 30px 80px -20px rgba(0,0,0,.9); animation: zoom-in var(--t-slow) var(--ease); }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(148,163,184,.1); border: 1px solid var(--border); }
.lightbox__nav--prev { left: var(--s-4); } .lightbox__nav--next { right: var(--s-4); }
.lightbox__nav:disabled { opacity: .25; }

/* ---------- 13. Toasts ---------- */
.toasts { position: fixed; z-index: 70; top: calc(var(--topbar-h) + 12px); right: 16px; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  background: rgba(21, 29, 46, 0.96); border: 1px solid var(--border-strong);
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.7);
  font-size: var(--fs-sm);
  animation: toast-in var(--t-slow) var(--ease-spring);
}
.toast.is-leaving { animation: toast-out var(--t-med) var(--ease) forwards; }
.toast .ico { width: 18px; height: 18px; margin-top: 1px; color: var(--accent-hi); }
.toast[data-tone="success"] .ico { color: var(--success); }
.toast[data-tone="warning"] .ico { color: var(--warning); }
.toast[data-tone="danger"] .ico { color: var(--danger); }
.toast__title { font-weight: 600; }
.toast__text { color: var(--text-2); font-size: var(--fs-xs); margin-top: 1px; }

/* ---------- 13b. Voice session (Phase 2) ---------- */
.dock__primary { padding-right: 16px; }
.dock__primary[data-state="live"], .dock__primary[data-state="ending"] {
  background: linear-gradient(135deg, #F43F5E, #E11D48 60%, #BE123C);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 10px 24px -10px rgba(244, 63, 94, 0.8);
}
.dock__primary:disabled { cursor: progress; filter: saturate(.8); }
.dock__spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
.dock__primary[data-state="starting"] .dock__spinner, .dock__primary[data-state="ending"] .dock__spinner { display: block; }
.dock__primary[data-state="starting"] .ico, .dock__primary[data-state="ending"] .ico { display: none; }
.dock__btn.is-muted, .dock__btn.is-muted:hover:not(:disabled) { color: #FECACA; background: var(--danger-soft); }

.pane--transcript { position: relative; padding-top: var(--s-3); }
.metric-chip {
  position: sticky; top: 0; z-index: 1; float: right; margin: 0 0 6px 8px;
  height: 22px; padding: 0 8px; border-radius: var(--r-full); display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-2);
  background: rgba(7, 11, 23, 0.8); border: 1px solid var(--border); backdrop-filter: blur(6px);
}
.transcript { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; clear: both; }
.msg { display: grid; gap: 3px; max-width: 88%; }
.msg.is-new { animation: rise var(--t-med) var(--ease); }
.msg__flag[hidden], .caret[hidden] { display: none; }
.msg--teacher, .msg--other { justify-self: start; }
.msg--student { justify-self: end; }
.msg__who { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.msg--student .msg__who { justify-content: flex-end; }
.msg--teacher .msg__who { color: var(--accent-hi); }
.msg__flag { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--warning); }
.msg__text { font-size: var(--fs-md); line-height: 1.45; padding: 9px 12px; border-radius: 14px; overflow-wrap: anywhere; }
.msg--teacher .msg__text, .msg--other .msg__text { background: var(--surface-3); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg--student .msg__text { background: linear-gradient(160deg, rgba(99,102,241,.32), rgba(79,70,229,.22)); border: 1px solid rgba(129,140,248,.3); border-top-right-radius: 4px; }
.msg--live .msg__text { opacity: .85; }
.msg--system { justify-self: center; max-width: 100%; }
.msg--system .msg__who { display: none; }
.msg--system .msg__text { padding: 4px 10px; font-size: var(--fs-xs); color: #A5F3FC; background: var(--cyan-soft); border: 1px dashed rgba(34, 211, 238, .35); border-radius: var(--r-full); }
.caret { display: inline-block; width: 2px; height: 1em; margin-left: 3px; vertical-align: -2px; background: currentColor; animation: pulse-dot 1s steps(2) infinite; }
.tab__live { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,.2); animation: pulse-dot 1.6s ease infinite; }

.aria-chip[data-state="ready"] { --state: var(--accent-hi); }
/* Camera off in the side column: compact stage so the transcript gets the room */
.app[data-focus="board"] .cam-stage:not([data-state="live"]) { aspect-ratio: auto; height: 150px; }
.app[data-focus="board"] .cam-stage:not([data-state="live"]) .cam-overlay__text { display: none; }
.app[data-focus="board"] .cam-stage:not([data-state="live"]) .cam-overlay { gap: 6px; padding: var(--s-4); }
.app[data-focus="board"] .cam-stage:not([data-state="live"]) .empty-icon { width: 40px; height: 40px; }
body[data-session="live"] #set-agent-state, body[data-session="starting"] #set-agent-state { pointer-events: none; opacity: .4; }

/* ---------- 13c. Vision (Phase 3) ---------- */
.tab { font-size: 12.5px; }
.cam-scan { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity var(--t-med) var(--ease); overflow: hidden; }
.cam-stage.is-scanning .cam-scan { opacity: 1; }
.cam-scan::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px rgba(34, 211, 238, .55), inset 0 0 40px rgba(34, 211, 238, .18); border-radius: inherit; }
.cam-scan__line {
  position: absolute; left: 0; right: 0; height: 28%; top: -28%;
  background: linear-gradient(180deg, transparent, rgba(34, 211, 238, .22) 70%, rgba(34, 211, 238, .75) 98%, transparent);
  animation: scan 1.6s cubic-bezier(.45, 0, .55, 1) infinite;
}
.cam-scan__label {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; color: #CFFAFE; background: rgba(7, 11, 23, .7); border: 1px solid rgba(34, 211, 238, .35);
  backdrop-filter: blur(8px);
}
.cam-scan__label .ico { width: 14px; height: 14px; }
@keyframes scan { to { top: 100%; } }

.spinner--sm { width: 14px; height: 14px; border-width: 2px; }
.vision-busy { display: flex; align-items: center; gap: 8px; margin-bottom: var(--s-3); padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: #A5F3FC; background: var(--cyan-soft); border: 1px solid rgba(34, 211, 238, .25); }

.obs { display: grid; gap: 10px; animation: rise var(--t-med) var(--ease); }
.obs__head { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; }
.obs__head-text { display: grid; gap: 4px; min-width: 0; }
.obs__media { border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border-strong); background: #000; aspect-ratio: 4 / 3; }
.obs__media img { width: 100%; height: 100%; object-fit: cover; }
.obs__badge { justify-self: start; height: 20px; padding: 0 8px; display: inline-flex; align-items: center; border-radius: var(--r-full); font-size: 10.5px; font-weight: 600; color: var(--text-2); background: rgba(148, 163, 184, .08); border: 1px solid var(--border-strong); }
.obs__badge[data-tone="live"] { color: #A5F3FC; border-color: rgba(34, 211, 238, .35); }
.obs__meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--fs-xs); color: var(--text-3); }
.obs__verdict { font-size: var(--fs-sm); font-weight: 600; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: rgba(148, 163, 184, .06); color: var(--text-2); }
.obs__verdict[data-tone="success"] { color: #A7F3D0; background: var(--success-soft); border-color: rgba(52, 211, 153, .3); }
.obs__verdict[data-tone="danger"] { color: #FECACA; background: var(--danger-soft); border-color: rgba(248, 113, 113, .3); }
.obs__verdict[data-tone="warning"] { color: #FDE68A; background: var(--warning-soft); border-color: rgba(251, 191, 36, .3); }
.obs__problem { font-family: var(--font-math); font-size: 1.05rem; line-height: 1.3; color: var(--text); }
.obs__steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 4px; }
.obs__steps li {
  counter-increment: step; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--r-sm);
  background: rgba(148, 163, 184, .05); border: 1px solid transparent;
}
.obs__steps li::before { content: counter(step); width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 650; color: var(--text-2); background: var(--surface-3); }
.obs__steps li::after { margin-left: auto; font-size: 12px; font-weight: 700; }
.obs__steps li[data-state="ok"]::after { content: '✓'; color: var(--success); }
.obs__steps li[data-state="error"] { border-color: rgba(248, 113, 113, .35); background: var(--danger-soft); }
.obs__steps li[data-state="error"]::before { color: #fff; background: var(--danger); }
.obs__steps li[data-state="error"]::after { content: 'first mistake'; color: #FECACA; font-weight: 600; font-size: 10.5px; }
.obs__steps li[data-state="carried"]::after { content: '↳ carried'; color: var(--text-3); font-weight: 500; font-size: 10.5px; }
.obs__expr { font-family: var(--font-math); font-size: 1rem; }
.obs__summary { font-size: var(--fs-sm); color: var(--text-2); }
.obs__foot { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); }

.follow-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px 0 9px; margin-right: 6px;
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600; color: #A5F3FC; max-width: 150px;
  background: var(--cyan-soft); border: 1px solid rgba(34, 211, 238, .3); transition: background var(--t-fast);
}
.follow-chip:hover { background: rgba(34, 211, 238, .22); }
.follow-chip #follow-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-chip .ico { width: 12px; height: 12px; opacity: .7; }
.follow-chip__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); flex: none; animation: pulse-dot 1.8s ease infinite; }

/* ---------- 14. Keyframes ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes write-in { from { opacity: 0; transform: translateX(-8px); } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
@keyframes zoom-in { from { opacity: 0; transform: scale(.96); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse-dot { 50% { opacity: .35; } }
@keyframes breathe { 50% { transform: scale(1.035); } }
@keyframes ripple { 0% { opacity: .8; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
@keyframes snap { 40% { transform: scale(.975); } }
@keyframes dock-in { from { opacity: 0; transform: translate(-50%, 24px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- 15. Responsive ---------- */
@media (max-width: 1360px) {
  :root { --side-w: 352px; }
  .crumb--muted, .crumbs__sep:last-of-type { display: none; }
}
@media (max-width: 1120px) {
  .crumbs { display: none; }
  .app { height: auto; min-height: 100dvh; }
  .studio, .app[data-focus="camera"] .studio {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "main main"
      "context camera";
    padding-bottom: calc(var(--dock-h) + 48px);
  }
  .app[data-focus="camera"] .studio { grid-template-areas: "camera camera" "context main"; }
  .board { min-height: 560px; }
  .app[data-focus="camera"] .board { max-height: none; min-height: 0; }
  .context { min-height: 300px; }
  .dock { left: 50%; }
}
@media (max-width: 720px) {
  :root { --gutter: 12px; --topbar-h: 58px; }
  .topbar { padding: 0 var(--s-4); gap: var(--s-3); }
  .brand__by, .pill--phase { display: none; }
  #server-pill .pill__text { display: none; }
  #server-pill { width: 30px; padding: 0; justify-content: center; }
  .aria-chip__sub { display: none; }
  .studio, .app[data-focus="camera"] .studio {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "camera" "main" "context";
  }
  .board { min-height: 480px; }
  .board__tools .tool:nth-child(n+3) { display: none; }
  .dock { bottom: 12px; padding: 0 6px; gap: 2px; }
  .dock__btn { width: 40px; height: 40px; }
  .dock__sep { margin: 0 2px; }
  .dock__soon { display: none; }
  .lightbox__stage { padding: var(--s-4); }
  .lightbox__nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- 15. Progress (Phase 6.3) ---------- */
.tab { flex: 1 1 auto; min-width: 0; padding: 0 6px; }
.progress { display: flex; flex-direction: column; min-height: 100%; }
.pg-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); margin-bottom: var(--s-3); }
.pg-stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.pg-stat__value { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-stat__label { font-size: var(--fs-xs); color: var(--text-3); }
.pg-last__summary { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--text); line-height: 1.5; }
.pg-next { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--text-2); }
.pg-next strong { color: var(--accent-hi); font-weight: 600; }
.pg-group { margin-bottom: var(--s-3); }
.pg-group__title { margin: 0 0 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.pg-skills { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pg-skill { --lv: var(--warning); }
.pg-skill--strong { --lv: var(--success); }
.pg-skill--getting { --lv: var(--cyan); }
.pg-skill__row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.pg-skill__name { font-size: var(--fs-sm); min-width: 0; }
.pg-chip { flex: none; font-size: 10.5px; font-weight: 650; padding: 2px 7px; border-radius: var(--r-full); color: var(--lv); background: color-mix(in srgb, var(--lv) 14%, transparent); }
.pg-bar { height: 6px; border-radius: var(--r-full); background: rgba(148, 163, 184, .14); overflow: hidden; }
.pg-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--lv); transition: width var(--t-slow) var(--ease); }
.pg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pg-list li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); background: var(--surface-2); border: 1px solid var(--border); }
.pg-list--watch li { border-left: 3px solid var(--danger); }
.pg-list--fixed li { flex-direction: row; align-items: center; gap: 8px; color: var(--text-2); }
.pg-list--fixed .ico { width: 14px; height: 14px; color: var(--success); flex: none; }
.pg-meta { font-size: var(--fs-xs); color: var(--text-3); margin: 4px 0 0; }
.pg-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pg-history details { border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.pg-history summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.pg-history summary::-webkit-details-marker { display: none; }
.pg-history__when { font-size: var(--fs-xs); color: var(--text-3); }
.pg-history__topics { font-size: var(--fs-sm); font-weight: 550; }
.pg-history__body { padding: 0 10px 10px; font-size: var(--fs-sm); color: var(--text-2); }
.pg-history__body p { margin: 0; }
.btn--danger.is-armed { color: #FECACA; border-color: rgba(248, 113, 113, .5); background: var(--danger-soft); }

/* ---------- 16. Aria status chip (top bar) + compact camera ---------- */
.app[data-focus="board"] .cam-stage { aspect-ratio: 16 / 9; }  /* side column: shorter; video is "contain", never cropped */
.aria-chip {
  --state: var(--text-3);
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px 0 6px;
  border-radius: var(--r-full); border: 1px solid var(--border);
  background: radial-gradient(120px 60px at 18% 50%, rgba(99, 102, 241, 0.16), transparent 70%), rgba(21, 29, 46, 0.6);
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: border-color var(--t-med);
}
.aria-chip[data-state="speaking"], .aria-chip[data-state="listening"] { border-color: color-mix(in srgb, var(--state) 40%, transparent); }
.orb--mini { width: 36px; height: 36px; }
.orb--mini .orb__core { width: 28px; height: 28px; box-shadow: 0 4px 12px -3px rgba(99, 102, 241, 0.7), inset 0 -3px 6px rgba(7, 11, 23, .35); }
.orb--mini .orb__initial { font-size: .8rem; }
.orb--mini .orb__ring { inset: 2px; }
.orb--mini .orb__spin { inset: 0; -webkit-mask: radial-gradient(circle, transparent 15px, #000 16px); mask: radial-gradient(circle, transparent 15px, #000 16px); }
.aria-chip[data-state="speaking"] .orb--mini .orb__core { box-shadow: 0 0 0 3px rgba(52, 211, 153, .18), 0 4px 16px -2px rgba(52, 211, 153, .5); }
.aria-chip__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.aria-chip__row { display: flex; align-items: center; gap: 8px; }
.aria-chip__name { font-weight: 650; font-size: var(--fs-sm); }
.aria-chip__state { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 600; color: var(--state); }
.aria-chip .wave { height: 12px; margin: 0; gap: 2px; }
.aria-chip .wave i { width: 2px; }
.aria-chip__sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.aria-chip__sub[data-tone="live"] { color: var(--success); font-variant-numeric: tabular-nums; }
.aria-chip__sub[data-tone="busy"] { color: var(--accent-hi); }
.aria-chip__sub[data-tone="warning"] { color: var(--warning); }
.aria-chip__sub[data-tone="danger"] { color: var(--danger); }

/* ---------- 17. Practice card (Phase 6.4) ---------- */
.pg-practice { margin-bottom: var(--s-3); padding: 12px; border-radius: var(--r-md); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(34, 211, 238, 0.06)); }
.pg-practice:empty { display: none; }
.pg-practice__head { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 650; }
.pg-practice__head .ico { width: 16px; height: 16px; color: var(--accent-hi); }
.pg-practice__head .spinner { margin-left: auto; }
.pg-practice .pg-meta { margin: 4px 0 10px; }
.pg-practice__btns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.pg-practice__btn { display: flex; flex-direction: column; align-items: stretch; gap: 1px; height: auto; min-width: 0; max-width: 100%; box-sizing: border-box; padding: 8px 10px; text-align: left; width: 100%; white-space: normal; overflow: hidden; }
.pg-practice__kind { font-size: 10.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-hi); }
/* long skill names wrap to two lines, then end with … (full name in the tooltip) */
.pg-practice__what { font-size: var(--fs-sm); line-height: 1.35; color: var(--text); white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.pg-practice__btn:disabled { opacity: .5; cursor: not-allowed; }

/* Board header (Phase 6 tidy-up): status pill only while loading/offline; armed clear button */
#board-pill[hidden], .board__demo[hidden] { display: none; }
.tool.is-armed { color: #FECACA; background: var(--danger-soft); box-shadow: inset 0 0 0 1px rgba(248, 113, 113, .45); }

/* AI noise suppression setting */
#ains-hint[data-tone="success"] { color: var(--success); }
#ains-hint[data-tone="warning"] { color: var(--warning); }
#ains-strength-field[hidden] { display: none; }

/* ---------- 18. Fixed, non-scrolling studio (desktop) ----------
   The studio fills the window exactly; only inner areas scroll (transcript, Progress, settings).
   The page itself never scrolls, so the wheel can't get "stuck" between the page and the board
   (Excalidraw handles wheel/pinch on the board). Small screens keep normal page scrolling. */
@media (min-width: 1121px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .app { height: 100dvh; overflow: hidden; }
  .studio { overflow: hidden; }
  .studio > .panel { min-height: 0; }
}

/* ---------- 19. Home (landing) ---------- */
.home {
  position: fixed; inset: 0; z-index: 35; overflow-y: auto; overscroll-behavior: contain;
  background:
    radial-gradient(900px 520px at 78% 18%, rgba(99, 102, 241, 0.20), transparent 65%),
    radial-gradient(700px 420px at 8% 92%, rgba(34, 211, 238, 0.10), transparent 70%),
    var(--bg-1);
  transition: opacity var(--t-slow) var(--ease), visibility 0s linear 0s, transform var(--t-slow) var(--ease);
}
body[data-view="studio"] .home { opacity: 0; visibility: hidden; transform: scale(1.015); pointer-events: none; transition: opacity var(--t-slow) var(--ease), visibility 0s linear var(--t-slow), transform var(--t-slow) var(--ease); }
body[data-view="home"] .dock { visibility: hidden; }
.home__bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: 14px clamp(16px, 4vw, 48px); background: linear-gradient(180deg, rgba(11, 16, 32, 0.92), rgba(11, 16, 32, 0.6)); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.home__bar-right { display: flex; align-items: center; gap: var(--s-2); }
.home__grade { flex: none; width: 132px; height: 38px; }

.home__eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; color: var(--accent-hi); background: var(--accent-soft); border: 1px solid rgba(129, 140, 248, .25); }
.home__eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(52, 211, 153, .18); animation: pulse-dot 1.8s ease infinite; }
.home__title { margin: 18px 0 14px; font-size: clamp(2rem, 1.1rem + 2.6vw, 3.4rem); line-height: 1.08; letter-spacing: -0.035em; font-weight: 700; }
.home__hl { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home__lead { max-width: 52ch; margin: 0 0 26px; font-size: clamp(1rem, .9rem + .3vw, 1.15rem); line-height: 1.6; color: var(--text-2); }
.home__ctas { display: flex; flex-wrap: wrap; gap: 12px; }
.home__cta { height: 50px; padding: 0 24px; border-radius: var(--r-md); font-size: 1rem; }
.home__cta .ico { width: 18px; height: 18px; }
.btn--primary.home__cta { box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 14px 34px -12px rgba(99, 102, 241, .95); }
.home__fine { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.home__fine .ico { width: 15px; height: 15px; color: var(--cyan); }

.home__visual { position: relative; justify-self: center; width: min(100%, 420px); }
.home__glow { position: absolute; inset: 8% -6% -4% -6%; border-radius: 40px; background: conic-gradient(from 210deg, rgba(99,102,241,.55), rgba(34,211,238,.35), rgba(129,140,248,.5), rgba(99,102,241,.55)); filter: blur(46px); opacity: .55; animation: breathe 7s ease-in-out infinite; }
.home__portrait { position: relative; aspect-ratio: 4 / 5; border-radius: 28px; overflow: hidden; border: 1px solid rgba(255,255,255,.12); box-shadow: 0 40px 80px -30px rgba(0,0,0,.8); }
.home__portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.home__portrait::after { content: ''; position: absolute; inset: 55% 0 0; background: linear-gradient(180deg, transparent, rgba(7, 11, 23, .55)); }
.home__chip { position: absolute; display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 14px; font-size: var(--fs-sm); color: var(--text); background: rgba(17, 24, 39, 0.78); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 16px 34px -14px rgba(0,0,0,.7); animation: float 6s ease-in-out infinite; }
.home__chip--state { left: -8%; bottom: 16%; }
.home__chip--math { right: -7%; top: 12%; font-family: var(--font-mono); animation-delay: -2s; }
.home__chip--math .ico { width: 16px; height: 16px; color: var(--success); }
.home__chip--name { left: 16px; bottom: 16px; flex-direction: column; align-items: flex-start; gap: 0; animation: none; background: rgba(7, 11, 23, .55); }
.home__chip--name strong { font-size: var(--fs-md); }
.home__chip--name span { font-size: var(--fs-xs); color: var(--text-2); }
.home__chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(34, 211, 238, .2); }
.home__bars { display: inline-flex; align-items: center; gap: 2px; height: 18px; }
.home__bars i { width: 3px; border-radius: 2px; background: var(--cyan); animation: eq 1.1s ease-in-out infinite; }
.home__bars i:nth-child(2) { animation-delay: -.3s; } .home__bars i:nth-child(3) { animation-delay: -.6s; } .home__bars i:nth-child(4) { animation-delay: -.15s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.home__welcome { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--r-lg); background: linear-gradient(135deg, rgba(99, 102, 241, .16), rgba(34, 211, 238, .06)); border: 1px solid rgba(129, 140, 248, .3); }
.home__welcome[hidden] { display: none; }
.home__welcome-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent-hi); }
.home__welcome-icon .ico { width: 20px; height: 20px; }
.home__welcome-text { flex: 1; min-width: 220px; }
.home__welcome-title { margin: 0; font-weight: 600; }
.home__welcome-meta { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--text-2); }
.home__welcome-actions { display: flex; gap: 8px; }

.home__features { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.feature { padding: 18px; border-radius: var(--r-lg); background: rgba(21, 29, 46, 0.6); border: 1px solid var(--border); transition: border-color var(--t-med), transform var(--t-med) var(--ease), background var(--t-med); }
.feature:hover { border-color: rgba(129, 140, 248, .35); transform: translateY(-2px); background: rgba(26, 35, 53, .75); }
.feature__icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--accent-hi); background: var(--accent-soft); margin-bottom: 12px; }
.feature__icon .ico { width: 19px; height: 19px; }
.feature h3 { margin: 0 0 4px; font-size: var(--fs-lg); font-weight: 600; }
.feature p { margin: 0; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; }

.home__ready { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 16px; border-radius: var(--r-lg); background: rgba(7, 11, 23, 0.45); border: 1px solid var(--border); font-size: var(--fs-sm); }
.home__ready-title { font-weight: 600; color: var(--text); margin-right: 4px; }
.ready { --c: var(--text-3); display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.ready[data-state="ok"] { --c: var(--success); }
.ready[data-state="warn"] { --c: var(--warning); color: var(--warning); }
.ready__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.ready[data-state="wait"] .ready__dot { animation: pulse-dot 1.4s ease infinite; }
.ready__btn { font-size: var(--fs-xs); font-weight: 600; color: var(--accent-hi); padding: 2px 8px; border-radius: var(--r-full); background: var(--accent-soft); }
.ready__meter { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.ready__meter i { width: 4px; height: 4px; border-radius: 1px; background: rgba(148,163,184,.3); transition: height 80ms, background 80ms; }
.ready__meter i:nth-child(2) { height: 6px; } .ready__meter i:nth-child(3) { height: 8px; } .ready__meter i:nth-child(4) { height: 11px; } .ready__meter i:nth-child(5) { height: 14px; }
.ready__meter i.on { background: var(--success); }
.home__foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }

.topbar .brand { cursor: pointer; }

/* ---------- 20. End-of-lesson card ---------- */
.lesson-end {
  position: absolute; z-index: 25; top: 72px; right: 20px; width: min(360px, calc(100% - 40px));
  padding: 18px 18px 16px; border-radius: var(--r-lg);
  background: rgba(17, 24, 39, 0.92); border: 1px solid rgba(129, 140, 248, .35);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.8); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: rise var(--t-slow) var(--ease) both;
}
.lesson-end[hidden] { display: none; }
.lesson-end__close { position: absolute; top: 10px; right: 10px; }
.lesson-end__eyebrow { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--success); }
.lesson-end__eyebrow .ico { width: 15px; height: 15px; }
.lesson-end__meta { margin: 6px 0 10px; font-size: var(--fs-lg); font-weight: 600; padding-right: 28px; }
.lesson-end__summary { margin: 0; font-size: var(--fs-sm); line-height: 1.55; color: var(--text-2); }
.lesson-end__summary.is-loading { color: var(--text-3); font-style: italic; }
.lesson-end__next { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--accent-hi); }
.lesson-end__actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- 21. Presenter mode (?presenter) ---------- */
.presenter {
  position: absolute; z-index: 24; left: 20px; top: 72px; width: 268px; padding: 12px 14px;
  border-radius: var(--r-md); background: rgba(7, 11, 23, 0.86); border: 1px solid rgba(34, 211, 238, .3);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: var(--fs-xs); color: var(--text-2);
  box-shadow: 0 18px 40px -18px rgba(0,0,0,.8);
}
.presenter[hidden] { display: none; }
.presenter__title { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--cyan); }
.presenter__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: pulse-dot 1.4s ease infinite; }
.presenter__row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.presenter__row b { font-weight: 600; color: var(--text); font-family: var(--font-mono); white-space: nowrap; }
.presenter__row small { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.presenter__row--hero { padding: 4px 0 6px; font-size: var(--fs-sm); color: var(--text); }
.presenter__row--hero b { color: var(--success); font-size: var(--fs-md); }
.presenter__sep { height: 1px; margin: 6px 0; background: var(--border); }
.presenter__note { margin: 8px 0 0; font-size: 10.5px; line-height: 1.4; color: var(--text-3); }

/* ---------- 19b. Home: one screen, no scrolling (desktop) ----------
   Top bar · two columns (text + actions | portrait sized by viewport height) · slim bottom bar.
   Sizes scale with viewport height so 1366×768 and up fit without scrolling. */
.home { display: flex; flex-direction: column; }
.home__bar { flex: none; padding-block: 10px; }
.home__main {
  flex: 1; min-height: 0; width: 100%; max-width: 1340px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  gap: clamp(24px, 3.5vw, 56px); padding: clamp(12px, 3vh, 36px) clamp(16px, 4vw, 48px);
}
.home__left { display: flex; flex-direction: column; gap: clamp(12px, 2.4vh, 24px); min-width: 0; }
.home__title { margin: clamp(10px, 1.6vh, 16px) 0 clamp(8px, 1.4vh, 12px); font-size: clamp(1.8rem, 1rem + 3.4vh, 3.1rem); }
.home__lead { margin: 0 0 clamp(14px, 2.4vh, 22px); font-size: clamp(.95rem, .8rem + .6vh, 1.1rem); }
.home__cta { height: clamp(42px, 5.6vh, 50px); }
.home__fine { margin-top: clamp(8px, 1.6vh, 14px); }
.home__visual { width: auto; justify-self: end; }
.home__portrait { height: clamp(260px, 46vh, 430px); width: auto; aspect-ratio: 4 / 5; }
.home__glow { inset: 6% -8% -4% -8%; }
.home__welcome { padding: 10px 14px; }
.home__welcome-icon { width: 36px; height: 36px; }
.home__features { gap: 10px; }
.feature { padding: clamp(10px, 1.6vh, 14px) 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center; }
.feature__icon { grid-row: span 2; width: 34px; height: 34px; margin: 0; }
.feature h3 { margin: 0; font-size: var(--fs-md); white-space: nowrap; }
.feature p { font-size: var(--fs-xs); }
.home__bottom {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px 24px; flex-wrap: wrap;
  padding: 10px clamp(16px, 4vw, 48px); border-top: 1px solid var(--border); background: rgba(7, 11, 23, 0.55);
}
.home__ready { padding: 0; border: 0; background: none; gap: 8px 16px; }
.home__foot { padding: 0; border: 0; }
.home__foot span + span { display: none; }

/* Short screens: tighter, card text hidden, smaller portrait. */
@media (max-height: 700px) and (min-width: 961px) {
  .feature p, .home__fine { display: none; }
  .feature__icon { grid-row: auto; }
  .home__portrait { height: clamp(220px, 48vh, 360px); }
  .home__eyebrow { padding: 4px 10px; }
}
/* Narrow windows / tablets: stacked layout, scrolling allowed. */
@media (max-width: 960px) {
  .home { display: block; }
  .home__main { grid-template-columns: minmax(0, 1fr); }
  .home__visual { grid-row: 1; justify-self: center; }
  .home__portrait { height: clamp(240px, 40vh, 360px); }
  .home__features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home__foot span + span { display: inline; }
}
@media (max-width: 560px) {
  .home__features { grid-template-columns: minmax(0, 1fr); }
  .home__chip--state, .home__chip--math { display: none; }
  .home__cta { flex: 1; }
}
