/*
 * Study-tool shell shared by every tool page and the podcast page (2026 revamp):
 *   top bar (title chip, level chips, close button) · Study Path stepper · "Next: <tool>" call to action
 *   · loading / no-edit overlays · toasts + confirm dialog (src/client/tools/util.ts) · answer burst
 *   · the generic tool placeholder page.
 * Colours, radii, shadows and motion come from tokens.css. The few values tokens.css has no name for
 * (text and translucent "glass" layers that sit ON the bright tool backgrounds) are defined once below.
 */
body {
  --on-tool: var(--text);                       /* text/icons placed directly on a tool background */
  --glass: color-mix(in srgb, var(--tool-accent) 13%, #fff);        /* soft tinted chip on a tool background */
  --glass-strong: color-mix(in srgb, var(--tool-accent) 22%, #fff);
  --glass-border: color-mix(in srgb, var(--tool-accent) 38%, #fff);
  --scrim: rgba(18, 26, 22, 0.55);              /* modal backdrop */
  --tool-accent: var(--tool-podcast);           /* per-tool accent (icon badge, highlights) */
}
body.tool-flashcards, body.tool-editor { --tool-accent: var(--tool-flashcards); }
body.tool-mc { --tool-accent: var(--tool-quiz); }
body.tool-memory { --tool-accent: var(--tool-memory); }
body.tool-short-answer { --tool-accent: var(--tool-short); }
body.tool-teach-back { --tool-accent: var(--tool-teach); }
/* Study Path v2 tool colours not in tokens.css yet (same values in explorer.css): the lesson step
 * reuses the podcast blue; practice scenarios get a calm teal (soft-ground family). */
:root { --tool-lesson: var(--tool-podcast); --tool-scenarios: #0f9e99; }
[data-tool='lesson'] { --tool-c: var(--tool-lesson); }
[data-tool='scenarios'] { --tool-c: var(--tool-scenarios); }
body.tool-scenarios { --tool-accent: var(--tool-scenarios); }

/* Page grounds. Two families (owner's call):
 *  - deep: podcast (blue), mini quiz (green), flashcards + editor (purple) keep a solid deep colour,
 *    white text and light drifting circles;
 *  - soft: memory, short answer, explain-it-back use a pale tint with slightly darker, quiet circles. */
body { --tool-ground: color-mix(in srgb, var(--tool-accent) 7%, var(--bg)); --blob-color: var(--tool-accent); --blob-strength: 1.5; }
body.podcast-page, body.tool-mc, body.tool-flashcards, body.tool-editor {
  --on-tool: #fff;
  --glass: rgba(255, 255, 255, 0.16);
  --glass-strong: rgba(255, 255, 255, 0.26);
  --glass-border: rgba(255, 255, 255, 0.4);
  --blob-color: #fff;
  --blob-strength: 1;
}
body.podcast-page { --tool-ground: #4181d7; }
body.tool-mc { --tool-ground: #3e8e5a; }
body.tool-flashcards, body.tool-editor { --tool-ground: #8548c8; }
body.tool-memory, body.tool-short-answer, body.tool-teach-back, body.tool-scenarios { --blob-color: color-mix(in srgb, var(--tool-accent) 80%, #000); }

/* ───────────── drifting background blobs ─────────────
 * Each tool keeps its own bright page colour; on top of it five soft circles drift slowly (transform
 * only, GPU-friendly, behind the content, never interactive). Size / position / speed differ per tool
 * so the pages don't look alike. Markup: <div class="tool-blobs" aria-hidden="true"><i></i>×5</div>. */
.tool-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; contain: strict; }
.tool-blobs i {
  position: absolute; left: var(--x, 0); top: var(--y, 0); width: var(--size, 30vmax); height: var(--size, 30vmax); border-radius: 50%;
  background: var(--blob-color); opacity: calc(var(--o, 0.1) * var(--blob-strength)); will-change: transform;
  animation: blobDrift var(--dur, 48s) ease-in-out var(--delay, 0s) infinite alternate;
}
.tool-blobs i:nth-child(even) { animation-name: blobDriftAlt; }
@keyframes blobDrift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  35% { transform: translate3d(var(--dx, 5vw), var(--dy, 4vh), 0) scale(1.08); }
  70% { transform: translate3d(calc(var(--dx, 5vw) * -0.6), calc(var(--dy, 4vh) * 0.8), 0) scale(0.94); }
  100% { transform: translate3d(calc(var(--dx, 5vw) * 0.4), calc(var(--dy, 4vh) * -0.9), 0) scale(1.04); }
}
@keyframes blobDriftAlt {
  0% { transform: translate3d(0, 0, 0) scale(1.05); }
  40% { transform: translate3d(calc(var(--dx, 5vw) * -0.8), var(--dy, 4vh), 0) scale(0.92); }
  75% { transform: translate3d(var(--dx, 5vw), calc(var(--dy, 4vh) * -0.6), 0) scale(1.1); }
  100% { transform: translate3d(calc(var(--dx, 5vw) * 0.3), calc(var(--dy, 4vh) * 0.5), 0) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .tool-blobs i { animation: none !important; } }
/* default arrangement (deck editor, anything without its own set) */
.tool-blobs i:nth-child(1) { --x: -12vmax; --y: -16vmax; --size: 44vmax; --dx: 5vw; --dy: 4vh; --dur: 52s; --o: 0.1; }
.tool-blobs i:nth-child(2) { --x: 72vw; --y: 58vh; --size: 34vmax; --dx: 6vw; --dy: 5vh; --dur: 44s; --delay: -12s; --o: 0.09; }
.tool-blobs i:nth-child(3) { --x: 58vw; --y: -8vh; --size: 14vmax; --dx: 4vw; --dy: 7vh; --dur: 38s; --delay: -20s; --o: 0.08; }
.tool-blobs i:nth-child(4) { --x: 8vw; --y: 62vh; --size: 18vmax; --dx: 7vw; --dy: 4vh; --dur: 60s; --delay: -6s; --o: 0.07; }
.tool-blobs i:nth-child(5) { --x: 38vw; --y: 34vh; --size: 9vmax; --dx: 9vw; --dy: 8vh; --dur: 34s; --delay: -15s; --o: 0.06; }
/* podcast: big slow "sound wave" rings spreading from the left */
body.podcast-page .tool-blobs i:nth-child(1) { --x: -22vmax; --y: 8vh; --size: 56vmax; --dx: 4vw; --dy: 3vh; --dur: 64s; --o: 0.08; }
body.podcast-page .tool-blobs i:nth-child(2) { --x: -12vmax; --y: 20vh; --size: 36vmax; --dx: 5vw; --dy: 4vh; --dur: 50s; --delay: -18s; --o: 0.08; }
body.podcast-page .tool-blobs i:nth-child(3) { --x: 78vw; --y: -12vh; --size: 26vmax; --dx: 5vw; --dy: 6vh; --dur: 42s; --delay: -9s; --o: 0.1; }
body.podcast-page .tool-blobs i:nth-child(4) { --x: 62vw; --y: 66vh; --size: 20vmax; --dx: 8vw; --dy: 4vh; --dur: 56s; --delay: -25s; --o: 0.07; }
body.podcast-page .tool-blobs i:nth-child(5) { --x: 44vw; --y: 12vh; --size: 7vmax; --dx: 10vw; --dy: 9vh; --dur: 30s; --delay: -4s; --o: 0.07; }
/* flashcards: two large "cards" of light top-left / bottom-right plus small floaters */
body.tool-flashcards .tool-blobs i:nth-child(1) { --x: -10vmax; --y: -22vmax; --size: 50vmax; --dx: 6vw; --dy: 5vh; --dur: 48s; --o: 0.11; }
body.tool-flashcards .tool-blobs i:nth-child(2) { --x: 68vw; --y: 52vh; --size: 42vmax; --dx: 5vw; --dy: 6vh; --dur: 58s; --delay: -22s; --o: 0.09; }
body.tool-flashcards .tool-blobs i:nth-child(3) { --x: 80vw; --y: 6vh; --size: 10vmax; --dx: 6vw; --dy: 8vh; --dur: 32s; --delay: -8s; --o: 0.09; }
body.tool-flashcards .tool-blobs i:nth-child(4) { --x: 4vw; --y: 70vh; --size: 13vmax; --dx: 8vw; --dy: 5vh; --dur: 40s; --delay: -14s; --o: 0.08; }
body.tool-flashcards .tool-blobs i:nth-child(5) { --x: 30vw; --y: 18vh; --size: 6vmax; --dx: 10vw; --dy: 10vh; --dur: 36s; --delay: -19s; --o: 0.06; }
/* mini quiz: a scatter of medium bubbles, livelier */
body.tool-mc .tool-blobs i:nth-child(1) { --x: 70vw; --y: -18vh; --size: 34vmax; --dx: 5vw; --dy: 6vh; --dur: 40s; --o: 0.11; }
body.tool-mc .tool-blobs i:nth-child(2) { --x: -6vw; --y: 6vh; --size: 17vmax; --dx: 7vw; --dy: 6vh; --dur: 34s; --delay: -10s; --o: 0.1; }
body.tool-mc .tool-blobs i:nth-child(3) { --x: 66vw; --y: 62vh; --size: 23vmax; --dx: 6vw; --dy: 5vh; --dur: 46s; --delay: -21s; --o: 0.09; }
body.tool-mc .tool-blobs i:nth-child(4) { --x: 14vw; --y: 66vh; --size: 12vmax; --dx: 9vw; --dy: 6vh; --dur: 30s; --delay: -5s; --o: 0.08; }
body.tool-mc .tool-blobs i:nth-child(5) { --x: 46vw; --y: 30vh; --size: 8vmax; --dx: 11vw; --dy: 9vh; --dur: 28s; --delay: -16s; --o: 0.07; }
/* memory: pairs of equal circles mirrored left / right */
body.tool-memory .tool-blobs i:nth-child(1) { --x: -14vmax; --y: 18vh; --size: 32vmax; --dx: 5vw; --dy: 7vh; --dur: 50s; --o: 0.1; }
body.tool-memory .tool-blobs i:nth-child(2) { --x: calc(100vw - 18vmax); --y: 18vh; --size: 32vmax; --dx: 5vw; --dy: 7vh; --dur: 50s; --delay: -25s; --o: 0.1; }
body.tool-memory .tool-blobs i:nth-child(3) { --x: 12vw; --y: -10vh; --size: 13vmax; --dx: 7vw; --dy: 5vh; --dur: 36s; --delay: -7s; --o: 0.08; }
body.tool-memory .tool-blobs i:nth-child(4) { --x: 76vw; --y: 72vh; --size: 13vmax; --dx: 7vw; --dy: 5vh; --dur: 36s; --delay: -19s; --o: 0.08; }
body.tool-memory .tool-blobs i:nth-child(5) { --x: 44vw; --y: 78vh; --size: 20vmax; --dx: 8vw; --dy: 4vh; --dur: 62s; --delay: -30s; --o: 0.06; }
/* short answer: a long diagonal run of circles, bottom-left → top-right */
body.tool-short-answer .tool-blobs i:nth-child(1) { --x: -16vmax; --y: 56vh; --size: 40vmax; --dx: 6vw; --dy: 4vh; --dur: 56s; --o: 0.1; }
body.tool-short-answer .tool-blobs i:nth-child(2) { --x: 20vw; --y: 44vh; --size: 16vmax; --dx: 6vw; --dy: 6vh; --dur: 38s; --delay: -11s; --o: 0.07; }
body.tool-short-answer .tool-blobs i:nth-child(3) { --x: 50vw; --y: 20vh; --size: 11vmax; --dx: 8vw; --dy: 7vh; --dur: 33s; --delay: -17s; --o: 0.08; }
body.tool-short-answer .tool-blobs i:nth-child(4) { --x: 74vw; --y: -20vh; --size: 38vmax; --dx: 5vw; --dy: 5vh; --dur: 48s; --delay: -28s; --o: 0.1; }
body.tool-short-answer .tool-blobs i:nth-child(5) { --x: 84vw; --y: 70vh; --size: 9vmax; --dx: 6vw; --dy: 9vh; --dur: 29s; --delay: -3s; --o: 0.07; }
/* teach-back: one huge calm circle rising from the bottom with small "speech" bubbles above */
body.tool-teach-back .tool-blobs i:nth-child(1) { --x: 18vw; --y: 62vh; --size: 64vmax; --dx: 4vw; --dy: 3vh; --dur: 70s; --o: 0.09; }
body.tool-teach-back .tool-blobs i:nth-child(2) { --x: 82vw; --y: 4vh; --size: 15vmax; --dx: 6vw; --dy: 7vh; --dur: 36s; --delay: -13s; --o: 0.1; }
body.tool-teach-back .tool-blobs i:nth-child(3) { --x: 72vw; --y: 26vh; --size: 7vmax; --dx: 7vw; --dy: 8vh; --dur: 28s; --delay: -6s; --o: 0.09; }
body.tool-teach-back .tool-blobs i:nth-child(4) { --x: -6vw; --y: -12vh; --size: 26vmax; --dx: 6vw; --dy: 5vh; --dur: 46s; --delay: -24s; --o: 0.09; }
body.tool-teach-back .tool-blobs i:nth-child(5) { --x: 8vw; --y: 36vh; --size: 9vmax; --dx: 9vw; --dy: 7vh; --dur: 32s; --delay: -18s; --o: 0.07; }
/* practice scenarios: two big calm circles low left / high right, three small "puzzle" dots */
body.tool-scenarios .tool-blobs i:nth-child(1) { --x: -10vw; --y: 48vh; --size: 48vmax; --dx: 5vw; --dy: 4vh; --dur: 60s; --o: 0.08; }
body.tool-scenarios .tool-blobs i:nth-child(2) { --x: 70vw; --y: -18vh; --size: 34vmax; --dx: 5vw; --dy: 6vh; --dur: 50s; --delay: -20s; --o: 0.09; }
body.tool-scenarios .tool-blobs i:nth-child(3) { --x: 58vw; --y: 62vh; --size: 10vmax; --dx: 8vw; --dy: 6vh; --dur: 31s; --delay: -9s; --o: 0.08; }
body.tool-scenarios .tool-blobs i:nth-child(4) { --x: 24vw; --y: 18vh; --size: 7vmax; --dx: 7vw; --dy: 8vh; --dur: 27s; --delay: -14s; --o: 0.07; }
body.tool-scenarios .tool-blobs i:nth-child(5) { --x: 88vw; --y: 52vh; --size: 8vmax; --dx: 6vw; --dy: 9vh; --dur: 35s; --delay: -4s; --o: 0.07; }

/* small shared pieces used on tool pages and the podcast page */
.modal-x {
  position: absolute; top: var(--s-3); right: var(--s-3); display: grid; place-items: center; width: 36px; height: 36px; padding: 0 0 2px;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--text-2); font: 400 22px/1 var(--font-body); cursor: pointer;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease);
}
.modal-x:hover { background: var(--surface-3); color: var(--text); }
.mini-spinner { display: inline-block; flex: none; width: 16px; height: 16px; border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; border-radius: 50%; animation: tt-spin 0.8s linear infinite; vertical-align: -3px; }

/* ───────────── top bar ───────────── */
.tool-topbar {
  position: relative; z-index: 20; box-sizing: border-box;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'title close' 'steps steps';
  gap: var(--s-4) var(--s-3); align-items: center;
  max-width: 1280px; margin: 0 auto; padding: var(--s-4) var(--s-4) 0;
  font-family: var(--font-body);
}
.tool-topbar *, .tool-topbar *::before, .tool-topbar *::after { box-sizing: border-box; }
.tool-topbar #title-wrapper { grid-area: title; }
.tool-topbar .study-fixedoffset-bar-wrapper, .tool-topbar #study-nav-root { grid-area: steps; justify-self: center; }
.tool-topbar #exit-button-container, .tool-topbar #close-button-container { grid-area: close; justify-self: end; align-self: start; }
@media (min-width: 1160px) {
  .tool-topbar { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: 'title steps close'; padding: var(--s-6) var(--s-8) 0; }
  .tool-topbar #exit-button-container, .tool-topbar #close-button-container { align-self: center; }
}

.tool-title { display: flex; align-items: center; gap: var(--s-3); min-width: 0; margin: 0; animation: t-fade-up var(--t-slow) var(--ease) both; }
.tool-badge {
  flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-lg);
  background: var(--surface); color: var(--tool-accent); font-size: 20px; box-shadow: var(--shadow-2);
}
.tool-title-text { min-width: 0; }
#title-section {
  display: block; margin: 0; padding: 0; background: none; color: var(--on-tool);
  font: 700 var(--text-lg)/1.25 var(--font-display); letter-spacing: -0.01em; overflow-wrap: anywhere;
}
#subtitle-section { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: 6px; padding: 0; background: none; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 2px 10px; border: 0; border-radius: var(--r-pill);
  background: var(--glass); color: var(--on-tool); font: 500 var(--text-xs)/1.5 var(--font-body); text-decoration: none; white-space: nowrap;
}
.tool-chip i { font-size: 0.9em; opacity: 0.9; }
a.tool-chip-link, button.tool-chip-link {
  background: var(--glass-strong); color: var(--on-tool); font-weight: 600; cursor: pointer;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease);
}
a.tool-chip-link:hover, button.tool-chip-link:hover { background: var(--surface); color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow-2); }
a.tool-chip-link:active, button.tool-chip-link:active { transform: scale(0.97); }

/* close "×" (tool pages: #exit-button, podcast page: #close-button) */
#exit-button-container, #close-button-container { position: static; display: flex; align-items: center; gap: var(--s-2); }
#exit-button, #close-button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0 0 3px; box-sizing: border-box;
  border: 1.5px solid var(--glass-border); border-radius: 50%; background: var(--glass); color: var(--on-tool);
  font: 400 28px/1 var(--font-body); text-decoration: none;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease), transform var(--t-med) var(--ease-spring), box-shadow var(--t-med) var(--ease);
}
#exit-button:hover, #close-button:hover { background: var(--surface); color: var(--text); transform: rotate(90deg); box-shadow: var(--shadow-2); }
#exit-button:active, #close-button:active { transform: rotate(90deg) scale(0.92); }
/* speaker (UI sounds on/off, src/client/lib/sound.ts) */
.sound-toggle {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1.5px solid var(--glass-border); border-radius: 50%;
  background: var(--glass); color: var(--on-tool); font-size: 15px; cursor: pointer;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-med) var(--ease);
}
.sound-toggle:hover { background: var(--surface); color: var(--text); transform: translateY(-1px); }
.sound-toggle:active { transform: scale(0.92); }
.sound-toggle.is-muted { opacity: 0.7; }
.tool-topbar a:focus-visible, .tool-topbar button:focus-visible, .path-next:focus-visible { outline: 3px solid var(--on-tool); outline-offset: 3px; }

/* ───────────── Study Path stepper (6 labelled steps: done / current / upcoming) ───────────── */
.study-fixedoffset-bar-wrapper { position: relative; z-index: 30; max-width: 100%; animation: t-fade-up var(--t-slow) var(--ease) both; }
#study-nav-root { min-height: 76px; max-width: 100%; }
.progress-bar-container-fixedoffset {
  display: flex; align-items: flex-start; width: auto; height: auto; box-sizing: border-box;
  padding: 10px 8px 8px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-2);
}
.progress-circle-fixedoffset {
  position: relative; flex: 1 1 0; width: 88px; min-width: 0; height: auto; min-height: 58px; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0 2px; margin: 0;
  border: 0; border-radius: var(--r-md); background: none; color: var(--text-2); cursor: pointer;
  font-family: var(--font-body); -webkit-tap-highlight-color: transparent; transform: none;
}
/* connector from the previous step */
.progress-circle-fixedoffset::before {
  content: ''; position: absolute; top: 16px; right: 50%; width: 100%; height: 4px; border-radius: 2px;
  background: var(--surface-3); transition: background-color var(--t-slow) var(--ease);
}
.progress-circle-fixedoffset:first-child::before { display: none; }
.progress-circle-fixedoffset.fixedoffset-completed::before, .progress-circle-fixedoffset.fixedoffset-current::before { background: var(--green-400); }
.step-dot {
  position: relative; z-index: 1; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-3); font-size: 14px; border: 3px solid var(--surface);
  transition: transform var(--t-med) var(--ease-spring), box-shadow var(--t-med) var(--ease), background-color var(--t-med) var(--ease);
}
.step-label { display: block; max-width: 100%; color: var(--text-2); font: 600 11px/1.2 var(--font-body); text-align: center; }
.progress-circle-fixedoffset.fixedoffset-completed { background: none; }
.progress-circle-fixedoffset.fixedoffset-completed .step-dot { background: var(--green-500); color: var(--surface); }
.progress-circle-fixedoffset.fixedoffset-current { background: none; }
.progress-circle-fixedoffset.fixedoffset-current .step-dot {
  background: var(--tool-path); color: var(--surface); transform: scale(1.14);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tool-path) 28%, transparent);
}
.progress-circle-fixedoffset.fixedoffset-current .step-label { color: var(--text); font-weight: 700; }
.progress-circle-fixedoffset.is-missing:not(.fixedoffset-current) .step-dot { background: var(--surface); border: 2px dashed var(--border-strong); color: var(--text-3); }
.progress-circle-fixedoffset:hover, .progress-circle-fixedoffset:focus-visible { transform: none; }
.progress-circle-fixedoffset:hover .step-dot { transform: translateY(-3px) scale(1.1); box-shadow: var(--shadow-2); }
.progress-circle-fixedoffset.fixedoffset-current:hover .step-dot { transform: translateY(-2px) scale(1.18); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tool-path) 28%, transparent), var(--shadow-2); }
.progress-circle-fixedoffset:hover .step-label { color: var(--text); }
.progress-circle-fixedoffset:active .step-dot { transform: scale(0.94); }
.progress-circle-fixedoffset:focus-visible { outline: 3px solid var(--green-600); outline-offset: 2px; }
.progress-circle-fixedoffset.is-loading .step-dot i { animation: tt-spin 0.9s linear infinite; }
/* Explain it back before its 24 h (spaced recall): a quiet clock instead of the step icon */
.progress-circle-fixedoffset.is-locked:not(.fixedoffset-current) .step-dot { background: var(--surface-2); color: var(--text-2); border-style: solid; }
.progress-circle-fixedoffset.is-locked.is-missing:not(.fixedoffset-current) .step-dot { border: 2px dashed var(--border-strong); }
/* hover / keyboard label — only generated while shown, so hidden labels never widen the page */
.progress-circle-fixedoffset:focus-visible::after {
  content: attr(data-hover); position: absolute; top: calc(100% + 12px); left: 50%; z-index: 10; transform: translateX(-50%);
  padding: 6px 10px; border-radius: var(--r-sm); background: var(--text); color: var(--surface); box-shadow: var(--shadow-2);
  font: 600 var(--text-xs)/1.3 var(--font-body); white-space: nowrap; pointer-events: none; animation: tt-fade var(--t-med) var(--ease) both;
}
@media (hover: hover) {
  .progress-circle-fixedoffset:hover::after {
    content: attr(data-hover); position: absolute; top: calc(100% + 12px); left: 50%; z-index: 10; transform: translateX(-50%);
    padding: 6px 10px; border-radius: var(--r-sm); background: var(--text); color: var(--surface); box-shadow: var(--shadow-2);
    font: 600 var(--text-xs)/1.3 var(--font-body); white-space: nowrap; pointer-events: none; animation: tt-fade var(--t-med) var(--ease) both;
  }
}
.progress-circle-fixedoffset:nth-child(-n + 2)::after { left: 0; transform: none; }
.progress-circle-fixedoffset:nth-last-child(-n + 2)::after { left: auto; right: 0; transform: none; }
@keyframes navBreath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.breathing-nav { animation: navBreath 1.6s ease-in-out 0s 3; }
@media (max-width: 1159px) {
  .tool-topbar .study-fixedoffset-bar-wrapper, .tool-topbar #study-nav-root { justify-self: stretch; width: 100%; max-width: 620px; margin: 0 auto; }
  .progress-circle-fixedoffset { width: auto; }
}
@media (max-width: 480px) {
  .progress-bar-container-fixedoffset { padding: 10px 4px 8px; border-radius: var(--r-lg); }
  .step-label { font-size: 10px; }
  /* seven steps on a phone: the short names ("Cards", "Quiz", "Write") so labels never collide */
  .step-label[data-mini] { font-size: 0; }
  .step-label[data-mini]::after { content: attr(data-mini); font-size: 10px; }
  .tool-badge { width: 44px; height: 44px; font-size: 18px; }
  #title-section { font-size: var(--text-md); }
}

/* ───────────── "Next: <tool>" call to action ───────────── */
.path-next-wrap { display: flex; justify-content: center; padding: var(--s-6) var(--s-4) 0; }
.path-next-wrap:empty { display: none; }
.path-next {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-3); min-height: 52px; padding: 0 var(--s-6); box-sizing: border-box;
  border: 1.5px solid var(--glass-border); border-radius: var(--r-pill); background: var(--glass); color: var(--on-tool);
  font: 600 var(--text-md)/1.2 var(--font-body); text-decoration: none; cursor: pointer;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease);
}
.path-next .path-next-kicker { font-weight: 500; opacity: 0.85; }
.path-next .path-next-arrow { transition: transform var(--t-med) var(--ease-spring); }
.path-next:hover { background: var(--surface); color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow-3); }
.path-next:hover .path-next-arrow { transform: translateX(4px); }
.path-next:active { transform: scale(0.98); }
.path-next.is-ready { background: var(--surface); color: var(--green-800); border-color: var(--surface); box-shadow: var(--shadow-3); animation: nextPulse 2s var(--ease) infinite; }
.path-next.is-ready .path-next-arrow { animation: nextNudge 1.2s var(--ease) infinite; }
@keyframes nextPulse { 0%, 100% { box-shadow: var(--shadow-3), 0 0 0 0 var(--glass-border); } 50% { box-shadow: var(--shadow-3), 0 0 0 10px transparent; } }
@keyframes nextNudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }
/* inside a white card (results / win modal) */
.path-next.in-card { border-color: transparent; background: var(--green-600); color: var(--surface); box-shadow: var(--shadow-1); animation: none; }
.path-next.in-card:hover { background: var(--green-700); color: var(--surface); box-shadow: var(--shadow-2); }
.path-next.in-card:focus-visible { outline: none; box-shadow: var(--ring); }

/* ───────────── overlays (loading, no-edit) ───────────── */
.tool-overlay, #education-loading-overlay {
  display: none; position: fixed; z-index: 100000; inset: 0; padding: var(--s-4); box-sizing: border-box;
  background: var(--scrim); align-items: center; justify-content: center; font-family: var(--font-body);
}
.tool-overlay.show, #education-loading-overlay.show { display: flex; animation: tt-fade var(--t-med) var(--ease) both; }
@keyframes tt-fade { from { opacity: 0; } to { opacity: 1; } }
#education-popup-box {
  position: relative; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: min(380px, 100%); min-height: 180px; padding: var(--s-8) var(--s-6); background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); animation: t-pop var(--t-slow) var(--ease-spring) both;
}
#education-spinner-container { position: relative; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; }
#education-spinner-container .spinner { position: absolute; inset: 0; box-sizing: border-box; border: 5px solid var(--green-100); border-top-color: var(--green-600); border-radius: 50%; animation: tt-spin 0.9s linear infinite; }
#education-spinner-container .inner-circle { position: absolute; inset: 14px; box-sizing: border-box; border-radius: 50%; background: var(--green-50); }
@keyframes tt-spin { to { transform: rotate(360deg); } }
#education-loading-text { margin-top: var(--s-5); max-width: 300px; color: var(--text); font: 600 var(--text-md)/1.45 var(--font-body); text-align: center; }
#education-loading-step { margin-top: var(--s-2); min-height: 1.3em; color: var(--text-2); font: 400 var(--text-sm)/1.3 var(--font-body); text-align: center; }
.no-edit-box {
  box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: var(--s-3); width: min(360px, 100%); padding: var(--s-8) var(--s-6);
  background: var(--surface); color: var(--text-2); border-radius: var(--r-xl); box-shadow: var(--shadow-3); text-align: center;
  font: 400 var(--text-md)/1.5 var(--font-body); animation: t-pop var(--t-slow) var(--ease-spring) both;
}
.no-edit-box br { display: none; }
.no-edit-box strong { color: var(--text); font: 700 var(--text-xl)/1.2 var(--font-display); }
.no-edit-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--warning-bg); color: var(--warning); font-size: 22px; }
#no-edit-close, .no-edit-back { margin-top: var(--s-2); }

/* ───────────── toasts + confirm dialog (src/client/tools/util.ts) ───────────── */
.tt-toasts {
  position: fixed; z-index: 100003; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  width: min(460px, calc(100vw - 32px)); pointer-events: none; font-family: var(--font-body);
}
.tt-toast {
  display: flex; align-items: flex-start; gap: var(--s-3); width: 100%; box-sizing: border-box; padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--text); color: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-3); pointer-events: auto;
  font: 500 var(--text-sm)/1.45 var(--font-body); animation: ttToastIn var(--t-slow) var(--ease-spring) both;
}
.tt-toast.is-leaving { animation: ttToastOut var(--t-med) var(--ease) both; }
.tt-toast-icon { flex: none; margin-top: 2px; font-size: 16px; color: var(--green-400); }
.tt-toast.is-error .tt-toast-icon { color: var(--tool-short); }
.tt-toast.is-info .tt-toast-icon { color: var(--tool-teach); }
.tt-toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tt-toast-text a { color: var(--green-400); font-weight: 700; }
.tt-toast-close { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin: -2px 0; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; opacity: 0.7; cursor: pointer; font-size: 18px; line-height: 1; }
.tt-toast-close:hover { opacity: 1; background: var(--glass); }
@keyframes ttToastIn { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes ttToastOut { to { opacity: 0; transform: translateY(8px); } }
@media (max-width: 600px) { .tt-toasts { bottom: 92px; } } /* clear the floating chat launcher */

.tt-dialog-overlay { position: fixed; z-index: 100002; inset: 0; display: flex; align-items: center; justify-content: center; padding: var(--s-4); box-sizing: border-box; background: var(--scrim); font-family: var(--font-body); animation: tt-fade var(--t-med) var(--ease) both; }
.tt-dialog { box-sizing: border-box; width: min(420px, 100%); padding: var(--s-6); background: var(--surface); color: var(--text); border-radius: var(--r-xl); box-shadow: var(--shadow-3); animation: t-pop var(--t-slow) var(--ease-spring) both; }
.tt-dialog h2 { margin: 0 0 var(--s-2); color: var(--text); font: 700 var(--text-xl)/1.25 var(--font-display); }
.tt-dialog p { margin: 0; color: var(--text-2); font: 400 var(--text-md)/1.5 var(--font-body); }
.tt-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-6); }
@media (max-width: 480px) { .tt-dialog-actions .btn { flex: 1 1 100%; min-height: 48px; } }

/* Step 1 "Lesson" chooser (src/client/tools/lesson-choice.ts): Podcast or Whiteboard lesson */
.tt-lesson-dialog { width: min(460px, 100%); }
.tt-lesson-dialog .tt-lesson-eyebrow { margin: 0 0 var(--s-1); color: var(--tool-lesson); font: 700 var(--text-xs)/1.4 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; }
.tt-lesson-dialog .tt-lesson-topic { margin-top: var(--s-1); font-size: var(--text-sm); overflow-wrap: anywhere; }
.tt-lesson-dialog .tt-lesson-topic strong { color: var(--text); }
.tt-lesson-options { display: grid; gap: var(--s-3); margin-top: var(--s-5); }
.tt-lesson-option {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 72px; margin: 0; padding: var(--s-3) var(--s-4); box-sizing: border-box;
  border: 1.5px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); text-align: left; font-family: var(--font-body); cursor: pointer;
  transition: border-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), transform var(--t-fast) var(--ease), background-color var(--t-med) var(--ease);
}
.tt-lesson-option:hover { border-color: var(--tool-lesson); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.tt-lesson-option:active { transform: scale(0.99); }
.tt-lesson-option:focus-visible { outline: none; box-shadow: var(--ring); }
.tt-lesson-ico { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); background: color-mix(in srgb, var(--tool-lesson) 12%, var(--surface)); color: var(--tool-lesson); font-size: var(--text-lg); }
.tt-lesson-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tt-lesson-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); font: 700 var(--text-md)/1.3 var(--font-body); }
.tt-lesson-text { color: var(--text-2); font: 400 var(--text-sm)/1.45 var(--font-body); }
.tt-lesson-badge { padding: 1px var(--s-2); border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font: 700 0.6875rem/1.6 var(--font-body); letter-spacing: 0.02em; }
.tt-lesson-go { flex: none; color: var(--text-3); transition: transform var(--t-med) var(--ease-spring), color var(--t-med) var(--ease); }
.tt-lesson-option:hover .tt-lesson-go { color: var(--tool-lesson); transform: translateX(3px); }
.tt-lesson-option.is-soon { border-style: dashed; background: var(--surface-2); cursor: default; }
.tt-lesson-option.is-soon:hover { border-color: var(--border-strong); box-shadow: none; transform: none; }
.tt-lesson-option.is-soon .tt-lesson-ico { background: var(--surface); color: var(--text-3); }
.tt-lesson-dialog .tt-lesson-note { min-height: 0; margin-top: var(--s-3); color: var(--text-2); font-size: var(--text-sm); }
.tt-lesson-dialog .tt-lesson-note:empty { display: none; }
.tt-lesson-dialog .tt-dialog-actions { margin-top: var(--s-5); }

/* ───────────── answer burst (confetti-like, CSS only) ───────────── */
.tt-burst { position: fixed; z-index: 100001; width: 0; height: 0; pointer-events: none; }
.tt-burst i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--green-400)); animation: ttBurst 720ms var(--ease) both; }
.tt-burst i:nth-child(3n) { border-radius: 50%; }
.tt-burst i:nth-child(4n) { width: 5px; height: 11px; }
@keyframes ttBurst {
  0% { transform: translate(0, 0) rotate(0) scale(0.4); opacity: 1; }
  65% { opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--rot, 180deg)) scale(1); opacity: 0; }
}

/* ───────────── generic tool placeholder / generating / error page ───────────── */
.tool-placeholder { box-sizing: border-box; display: grid; place-items: center; min-height: 60vh; padding: var(--s-10) var(--s-4); font-family: var(--font-body); }
.tool-placeholder-card { box-sizing: border-box; width: min(520px, 100%); padding: var(--s-10) var(--s-8); text-align: center; animation: t-fade-up var(--t-slow) var(--ease) both; }
.tool-placeholder-icon { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto var(--s-5); border-radius: 50%; background: var(--green-50); color: var(--green-600); font-size: 28px; }
.tool-placeholder.is-error .tool-placeholder-icon { background: var(--danger-bg); color: var(--danger); }
.tool-placeholder.is-generating .tool-placeholder-icon i { animation: tt-spin 1.1s linear infinite; }
.tool-placeholder h1 { margin: 0 0 var(--s-3); color: var(--text); font: 700 var(--text-2xl)/1.2 var(--font-display); overflow-wrap: anywhere; }
.tool-placeholder p { margin: 0 0 var(--s-6); color: var(--text-2); font: 400 var(--text-md)/1.55 var(--font-body); }
.tool-placeholder-bar { height: 6px; margin: 0 auto var(--s-6); max-width: 260px; border-radius: var(--r-pill); }
.tool-placeholder-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); }
@media (max-width: 480px) { .tool-placeholder-card { padding: var(--s-8) var(--s-5); } .tool-placeholder-actions .btn { flex: 1 1 100%; min-height: 48px; } }
