/* The board room: a full-screen whiteboard with chrome floating over it.
   Built for a tablet held by a kid: 56px+ targets, nothing small to hit,
   one primary action (Check my work), everything else a tap away. */

html, body.app { height: 100%; overflow: hidden; overscroll-behavior: none; }
body.app { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
body.app input, body.app textarea { -webkit-user-select: text; user-select: text; }
.screen[hidden], .room[hidden] { display: none !important; }

/* ---------- picker ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); overflow-y: auto; background: var(--paper); }
.pick-inner, .quiz-inner, .intro-inner { width: min(760px, 100%); text-align: center; display: grid; gap: 28px; justify-items: center; }
.pick h1, .quiz h1 { font-size: var(--t-3xl); }
.pip-big { width: 84px; height: 84px; border-radius: 30px; background: var(--cobalt); position: relative; box-shadow: inset 0 -8px 0 rgba(0,0,0,.14), var(--shadow-2); animation: bob 3.2s ease-in-out infinite; }
.pip-big i { position: absolute; top: 30px; width: 11px; height: 16px; border-radius: 6px; background: var(--butter); animation: blink 5s infinite; }
.pip-big i:first-child { left: 24px; } .pip-big i:last-child { right: 24px; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
.kids { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.kid { display: grid; justify-items: center; gap: 12px; width: 156px; padding: 22px 12px 18px; border: 0; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-1); cursor: pointer; font-weight: 700; font-size: var(--t-lg); transition: transform 160ms var(--spring), box-shadow 200ms; }
.kid:hover { box-shadow: var(--shadow-2); }
.kid:active { transform: scale(0.96); }
.kid .av { width: 96px; height: 96px; font-size: 54px; border-radius: 32%; }
.grown-up { color: var(--ink-3); font-weight: 600; font-size: var(--t-sm); }

/* ---------- interests quiz ---------- */
.step-dot { font-weight: 700; color: var(--ink-3); font-size: var(--t-sm); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 680px; }
.chip-btn { min-height: 52px; padding: 0 20px; border-radius: var(--r-pill); border: 2px solid var(--line); background: var(--card); font-weight: 600; font-size: var(--t-md); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: transform 140ms var(--spring), background 160ms, border-color 160ms; }
.chip-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--blue) 14%, var(--card)); border-color: var(--blue); color: var(--ink); }
.chip-btn[aria-pressed="true"]::after { content: "✓"; color: var(--blue); font-weight: 800; }
.chip-btn:active { transform: scale(0.95); }
.own { display: flex; gap: 10px; width: min(440px, 100%); }
.own input { min-height: 52px; }
.quiz-actions, .intro-actions { display: flex; gap: 12px; justify-content: center; align-items: center; }

/* ---------- AI can be wrong ---------- */
.intro-cards { position: relative; width: 100%; min-height: 360px; }
.icard { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 18px; opacity: 0; transform: translateX(40px) scale(0.98); transition: opacity 360ms var(--out), transform 520ms var(--out); pointer-events: none; }
.icard.on { opacity: 1; transform: none; pointer-events: auto; }
.icard.gone { transform: translateX(-40px) scale(0.98); }
.icard h1 { font-size: var(--t-2xl); max-width: 18ch; }
.icard p { font-size: var(--t-lg); color: var(--ink-2); max-width: 32ch; }
.icard-art { font-size: 84px; line-height: 1; position: relative; }
.icard-art b { position: absolute; right: -24px; top: -10px; font: 800 48px var(--hand); color: var(--orange); }
.dots { display: flex; gap: 8px; margin-right: 12px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); transition: background 200ms, width 300ms var(--out); }
.dots i.on { background: var(--cherry); width: 26px; border-radius: 9px; }

/* ---------- the room ---------- */
.room { position: fixed; inset: 0; background: var(--paper); }
.room.dark-board { background: #0f1014; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.room[data-tool="hand"] #board { cursor: grab; }
.room[data-tool="eraser"] #board { cursor: cell; }

.topbar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 8px; border-radius: var(--r-lg); box-shadow: var(--shadow-1); z-index: 5; }
.who { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 6px 12px 6px 6px; border-radius: var(--r-md); font-weight: 700; font-size: var(--t-md); cursor: pointer; min-height: 52px; }
.who .av { width: 42px; height: 42px; font-size: 24px; }
.who:hover { background: var(--paper-2); }
.link-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-pill); background: var(--paper-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); margin: 0 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.lp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); flex: none; }
.link-pill.live { color: var(--ink); background: color-mix(in srgb, var(--green) 16%, var(--card)); }
.link-pill.live .lp-dot { background: var(--green); box-shadow: 0 0 0 0 var(--green); animation: live 2s infinite; }
.link-pill.pip { background: color-mix(in srgb, var(--blue) 14%, var(--card)); color: var(--ink); }
.link-pill.pip .lp-dot { background: var(--blue); }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.top-actions { display: flex; gap: 6px; }
.iconbtn { display: inline-flex; align-items: center; gap: 8px; min-width: 52px; min-height: 52px; justify-content: center; padding: 0 12px; border: 0; border-radius: var(--r-md); background: none; color: var(--ink); font-weight: 700; font-size: var(--t-sm); cursor: pointer; transition: background 160ms, transform 120ms; }
.iconbtn:hover { background: var(--paper-2); }
.iconbtn:active { transform: scale(0.94); }
.iconbtn[aria-pressed="true"] { background: var(--cobalt); color: var(--butter); }
.iconbtn svg, .tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.menu { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 72px); right: 12px; width: 260px; padding: 14px; border-radius: var(--r-lg); box-shadow: var(--shadow-2); z-index: 8; display: grid; gap: 4px; transform-origin: top right; animation: pop 260ms var(--spring); }
.menu[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(0.92) translateY(-6px); } }
.menu-label { font-size: var(--t-xs); font-weight: 700; color: var(--ink-3); padding: 0 8px 4px; }
.theme-row { display: flex; gap: 8px; padding: 0 6px 10px; }
.theme-row button { width: 48px; height: 48px; border-radius: var(--r-sm); border: 2px solid var(--line); cursor: pointer; }
.theme-row button.on { border-color: var(--cobalt); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }
.theme-row [data-theme="paper"] { background: #fff radial-gradient(#c9d3ec 1.2px, transparent 1.4px) 0 0 / 10px 10px; }
.theme-row [data-theme="graph"] { background: #fff linear-gradient(#cfe0ff 1px, transparent 1px) 0 0 / 8px 8px, linear-gradient(90deg, #cfe0ff 1px, transparent 1px) 0 0 / 8px 8px; }
.theme-row [data-theme="chalk"] { background: #24453a; }
.theme-row [data-theme="night"] { background: #0f1014 radial-gradient(rgba(255,255,255,.14) 1.2px, transparent 1.4px) 0 0 / 10px 10px; }
.menu-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font-weight: 600; font-size: var(--t-md); cursor: pointer; text-align: left; }
.menu-row:hover { background: var(--paper-2); }

/* tools: a floating rail on the left (bottom on narrow screens) */
.tools { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: var(--r-lg); box-shadow: var(--shadow-1); z-index: 4; }
.tool-group { display: flex; flex-direction: column; gap: 4px; }
.tool-group + .tool-group, .swatches + .tool-group, .tool-group + .swatches { border-top: 1px solid var(--line); padding-top: 6px; }
.tool { width: 52px; height: 52px; display: grid; place-items: center; border: 0; border-radius: var(--r-md); background: none; color: var(--ink); cursor: pointer; transition: background 140ms, transform 120ms, color 140ms; }
.tool:hover { background: var(--paper-2); }
.tool:active { transform: scale(0.92); }
.tool.on { background: var(--cobalt); color: var(--butter); }
.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 4px 2px; }
.swatches button { width: 23px; height: 23px; margin: auto; border-radius: 50%; border: 0; cursor: pointer; transition: transform 160ms var(--spring); position: relative; }
.swatches button::before { content: ""; position: absolute; inset: -9px; } /* bigger hit area */
.swatches button.on { transform: scale(1.25); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px currentColor; }
.swatches [data-color="blue"] { background: #2340f0; color: #2340f0; } .swatches [data-color="red"] { background: #e0313f; color: #e0313f; }
.swatches [data-color="green"] { background: #0f9f76; color: #0f9f76; } .swatches [data-color="orange"] { background: #ff7a1a; color: #ff7a1a; }
.swatches [data-color="purple"] { background: #7b5cff; color: #7b5cff; } .swatches [data-color="ink"] { background: #0d1b5e; color: #0d1b5e; }
[data-theme="dark"] .swatches [data-color="ink"], .room.dark-board .swatches [data-color="ink"] { background: #eef2fb; color: #eef2fb; }

/* caption: the tutor's words, big enough to read along */
.caption { --c: 1; position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 84px); transform: translateX(-50%); width: min(720px, calc(100% - 180px)); display: flex; gap: 14px; align-items: flex-start; padding: 14px 20px 14px 14px; border-radius: var(--r-lg); background: var(--cobalt); color: #fff8de; box-shadow: var(--shadow-2); z-index: 4; animation: rise 420ms var(--out); }
.caption[hidden] { display: none; }
.caption p { display: grid; gap: 2px; font-size: var(--t-lg); line-height: 1.35; }
.caption small { font-size: var(--t-xs); font-weight: 700; opacity: .7; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 16px); } }

.start-card .launch { width: 100%; }
.launch-top { min-height: 42px; gap: 8px; margin-right: 4px; }
@media (max-width: 720px) { .launch-top span { display: none; } .launch-top { padding: 0 12px; } }
.start-card { position: absolute; right: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 84px); width: 340px; padding: 22px; border-radius: var(--r-lg); box-shadow: var(--shadow-2); z-index: 4; display: grid; gap: 12px; animation: pop 400ms var(--spring); }
.start-card[hidden] { display: none; }
.start-card h2 { font-size: var(--t-xl); }
.start-card ol { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; }
.start-card q { font-family: var(--hand); font-weight: 600; color: var(--blue); quotes: "“" "”"; }
.start-card .small { font-size: var(--t-sm); }
.start-card .btn { justify-self: start; }

/* dock */
.dock { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; z-index: 5; }
.btn.check { --bg: var(--cobalt); --fg: var(--butter); min-height: 64px; padding: 0 28px; font-size: var(--t-lg); box-shadow: var(--shadow-2); }
.btn.check svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.btn.check.busy { opacity: .7; pointer-events: none; }
.pip-talk { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 6px; border-radius: var(--r-pill); background: var(--card); box-shadow: var(--shadow-2); }
.pip-talk[hidden] { display: none; }
.mic { position: relative; width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--cobalt); color: var(--butter); display: grid; place-items: center; cursor: pointer; touch-action: none; transition: transform 160ms var(--spring); }
.mic svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; position: relative; }
.mic.rec { background: var(--cherry); color: #fff; transform: scale(1.08); }
.mic.rec .mic-ring { position: absolute; inset: 0; border-radius: 50%; animation: micring 1.2s infinite; border: 3px solid var(--cherry); }
.mic.think { background: var(--purple); }
@keyframes micring { to { transform: scale(1.6); opacity: 0; } }
.type-to-pip { display: flex; gap: 6px; align-items: center; }
.type-to-pip input { min-height: 48px; width: min(280px, 34vw); border-radius: var(--r-pill); }

/* sheets (homework, progress) */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(12, 20, 36, .42); animation: fade 240ms; }
.sheet[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.sheet-card { width: min(560px, 100%); max-height: min(86vh, 760px); overflow-y: auto; background: var(--card); border-radius: var(--r-xl); padding: 24px; box-shadow: var(--shadow-2); display: grid; gap: 18px; align-content: start; animation: sheetup 420ms var(--out); }
@keyframes sheetup { from { transform: translateY(40px) scale(.98); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.drop { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 26px 18px; border: 2.5px dashed color-mix(in srgb, var(--blue) 45%, var(--line)); border-radius: var(--r-lg); cursor: pointer; background: color-mix(in srgb, var(--blue) 5%, var(--card)); transition: background 160ms, transform 160ms var(--spring); }
.drop:hover, .drop.over { background: color-mix(in srgb, var(--blue) 11%, var(--card)); }
.drop:active { transform: scale(.98); }
.drop-icon { font-size: 40px; }
.drop b { font-size: var(--t-lg); }
.drop .muted { font-size: var(--t-sm); max-width: 32ch; }
.upload-status { display: grid; gap: 8px; font-size: var(--t-sm); font-weight: 600; }
.upload-status[hidden] { display: none; }
.bar { height: 8px; border-radius: 9px; background: var(--paper-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--blue); border-radius: inherit; transition: width 300ms; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.files li { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: var(--r-md); background: var(--paper-2); }
.files .fname { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .fmeta { font-size: var(--t-xs); color: var(--ink-3); font-weight: 500; display: block; }
.files .pages { display: flex; gap: 6px; flex-wrap: wrap; }
.files .pages button { min-width: 44px; min-height: 44px; border-radius: var(--r-sm); border: 0; background: var(--card); font-weight: 700; cursor: pointer; box-shadow: var(--shadow-1); }
.files .pages button:hover { background: var(--blue); color: #fff; }
.files .empty { justify-content: center; color: var(--ink-3); background: none; }

.learn-group { display: grid; gap: 10px; }
.learn-group h3 { font-size: var(--t-lg); display: flex; align-items: center; gap: 8px; }
.learn-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.learn-tags span { padding: 8px 14px; border-radius: var(--r-pill); background: var(--paper-2); font-weight: 600; font-size: var(--t-sm); }
.learn-tags.confident span { background: color-mix(in srgb, var(--green) 16%, var(--card)); }
.learn-tags.practicing span { background: color-mix(in srgb, var(--yellow) 30%, var(--card)); }

/* break + time's up */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fade 300ms; }
.overlay[hidden] { display: none; }
.pause-card { text-align: center; display: grid; gap: 16px; justify-items: center; max-width: 440px; }
.pause-art { font-size: 88px; animation: bob 2.6s ease-in-out infinite; }
.pause-card h2 { font-size: var(--t-3xl); }
.pause-card p { font-size: var(--t-lg); color: var(--ink-2); }

.recap { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 24px; background: rgba(12, 20, 36, .45); animation: fade 260ms; }
.recap[hidden] { display: none; }
.recap-card { position: relative; width: min(480px, 100%); background: var(--card); border-radius: var(--r-xl); padding: 36px 28px 28px; text-align: center; display: grid; gap: 14px; justify-items: center; box-shadow: var(--shadow-2); animation: sheetup 520ms var(--spring); }
.recap-card h2 { font-size: var(--t-2xl); }
.recap-card p { color: var(--ink-2); font-size: var(--t-lg); }
.recap-card ul { text-align: left; }
.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ticks li { padding-left: 32px; position: relative; font-weight: 600; }
.ticks li::before { content: "✓"; position: absolute; left: 0; top: -1px; width: 22px; height: 22px; border-radius: 50%; background: color-mix(in srgb, var(--green) 18%, var(--card)); color: var(--green); display: grid; place-items: center; font-size: 13px; font-weight: 800; }

/* celebration: a short burst of marker-colored confetti, then gone */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall var(--d, 1.8s) cubic-bezier(.2, .6, .4, 1) forwards; }
@keyframes fall { to { transform: translate(var(--x, 0), 105vh) rotate(var(--r, 540deg)); opacity: .9; } }
.toast { z-index: 50; }

/* narrow screens and phones in portrait: tools go along the bottom */
@media (max-width: 760px) {
  .topbar { height: 58px; left: 8px; right: 8px; }
  .iconbtn span { display: none; }
  .link-pill { max-width: 36vw; font-size: var(--t-xs); }
  .tools { top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 76px); left: 50%; transform: translateX(-50%); flex-direction: row; max-width: calc(100% - 16px); overflow-x: auto; }
  .tool-group { flex-direction: row; }
  .tool-group + .tool-group, .swatches + .tool-group, .tool-group + .swatches { border-top: 0; padding-top: 0; border-left: 1px solid var(--line); padding-left: 6px; }
  .swatches { grid-template-columns: repeat(3, 1fr); }
  .tool { width: 46px; height: 46px; }
  .caption { width: calc(100% - 24px); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 150px); }
  .caption p { font-size: var(--t-md); }
  .start-card { left: 12px; right: 12px; width: auto; top: 84px; bottom: auto; }
  .type-to-pip input { width: 38vw; }
  .btn.check { min-height: 56px; padding: 0 20px; font-size: var(--t-md); }
}

@media (prefers-reduced-motion: reduce) {
  .pip-big, .pause-art { animation: none; }
  .confetti { display: none; }
}

/* Dark board: the chrome goes dark glass so the board reads like a blackboard. */
.room.dark-board .topbar, .room.dark-board .tools, .room.dark-board .start-card, .room.dark-board .pip-talk {
  background: rgba(28, 30, 38, .72); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
  color: #f7f5ee; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 12px 32px -12px rgba(0,0,0,.6);
}
.room.dark-board .tool, .room.dark-board .who, .room.dark-board .topbar button { color: #f7f5ee; }
.room.dark-board .who:hover, .room.dark-board .tool:hover { background: rgba(255,255,255,.08); }
.room.dark-board .start-card h2, .room.dark-board .start-card b { color: #fff; }
.room.dark-board .start-card p, .room.dark-board .start-card li { color: #c9ccd8; }
