/* Shared course stylesheet — linked by every lesson and reference doc. */

:root {
  --ink: #2d2a3e;
  --paper: #fffdf7;
  --accent: #6c5ce7;
  --accent-soft: #efeaff;
  --sun: #fdcb6e;
  --sun-soft: #fff4dd;
  --mint: #00b894;
  --mint-soft: #e3f9f2;
  --coral: #e17055;
  --coral-soft: #fdeae4;
  --line: #e8e4da;
  --code-bg: #2d2a3e;
  --code-ink: #f8f8f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-size: 1.1rem;
  line-height: 1.65;
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 5rem;
}

/* ---------- Headings ---------- */
h1, h2, h3 { line-height: 1.25; }

h1 {
  font-size: 2.2rem;
  margin: 1rem 0 0.5rem;
}

h2 {
  font-size: 1.5rem;
  margin-top: 2.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 3px solid var(--sun);
  display: inline-block;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 2rem;
}

.subtitle { font-size: 1.2rem; color: #6b6880; margin-top: 0; }

/* ---------- Hero banner (course home) ---------- */
.hero-banner {
  background: linear-gradient(120deg, var(--accent), #8f7bff 60%, #b39dff);
  border-radius: 20px;
  padding: 1.75rem 1.75rem 1.5rem;
  margin: 1.25rem 0 1.75rem;
  color: white;
  box-shadow: 0 12px 32px rgba(108, 92, 231, 0.25);
}

.hero-banner .kicker { color: rgba(255, 255, 255, 0.85); margin-top: 0; }
.hero-banner h1 { color: white; margin: 0.25rem 0 0.5rem; }
.hero-banner .subtitle { color: rgba(255, 255, 255, 0.92); margin-bottom: 0; font-size: 1.05rem; }

/* ---------- Top navigation strip (sticky) ---------- */
.lesson-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  /* plain rgba (not color-mix): html2canvas screenshots choke on modern color functions */
  background: rgba(255, 253, 247, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

html.dark .lesson-nav { background: rgba(25, 23, 34, 0.88); }

.lesson-nav a {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.lesson-nav a:hover { background: var(--accent); color: white; }

/* ---------- Boxes ---------- */
.box {
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border: 2px solid transparent;
}

.box .box-title {
  font-weight: 800;
  display: block;
  margin-bottom: 0.35rem;
}

.box-idea   { background: var(--sun-soft);   border-color: var(--sun); }
.box-try    { background: var(--mint-soft);  border-color: var(--mint); }
.box-warn   { background: var(--coral-soft); border-color: var(--coral); }
.box-source { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Code ---------- */
code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--accent-soft);
  padding: 0.1em 0.4em;
  border-radius: 6px;
}

pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 1rem 1.25rem;
  border-radius: 14px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code { background: none; padding: 0; color: inherit; font-size: 0.95rem; }

/* ---------- Tables (cheat sheets) ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 1rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Steps ---------- */
ol.steps { counter-reset: step; list-style: none; padding-left: 0; }

ol.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 3rem;
  margin: 1.25rem 0;
}

ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Quiz (rendered by quiz.js) ---------- */
.quiz {
  background: white;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.quiz-question { font-weight: 700; margin: 0 0 0.75rem; }

.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  margin: 0.4rem 0;
  cursor: pointer;
}

.quiz-option:hover:not(:disabled) { border-color: var(--accent); }
.quiz-option.correct { background: var(--mint-soft); border-color: var(--mint); font-weight: 700; }
.quiz-option.wrong   { background: var(--coral-soft); border-color: var(--coral); }
.quiz-option:disabled { cursor: default; }

.quiz-feedback { margin-top: 0.6rem; font-weight: 600; min-height: 1.5em; }
.quiz-score {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
  margin-top: 1rem;
}

/* ---------- Code task (rendered by code-task.js) ---------- */
.code-task {
  background: white;
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.code-task-title {
  font-weight: 800;
  font-size: 1.15rem;
  margin: 0 0 0.25rem;
  color: var(--accent);
}

.code-task-desc { margin-top: 0; }

.code-task-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 40rem) {
  .code-task-pane { grid-template-columns: 1fr; }
}

.code-task-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b6880;
  margin: 0 0 0.3rem;
}

.code-task-editor {
  width: 100%;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  background: var(--code-bg);
  color: var(--code-ink);
  border: none;
  border-radius: 10px;
  padding: 0.75rem;
  resize: vertical;
}

.code-task-editor:focus { outline: 3px solid var(--sun); }

.code-task-preview {
  width: 100%;
  height: 100%;
  min-height: 10rem;
  background: white;
  border: 2px dashed var(--line);
  border-radius: 10px;
}

.code-task-check {
  font: inherit;
  font-weight: 800;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.5rem;
  margin-top: 1rem;
  cursor: pointer;
}

.code-task-check:hover { background: #5a4bd1; }

.code-task-results {
  list-style: none;
  padding-left: 0;
  margin: 0.75rem 0 0;
}

.code-task-results li { margin: 0.35rem 0; font-weight: 600; }
.code-task-results .check-pass { color: var(--mint); }
.code-task-results .check-fail { color: var(--coral); }

.code-task-verdict { font-weight: 800; min-height: 1.5em; }

@media print {
  .code-task { display: none; }
}

/* ---------- XP badge & toasts (rendered by score.js) ---------- */
.xp-badge {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 50;
  background: white;
  border: 2px solid var(--sun);
  border-radius: 14px;
  padding: 0.5rem 0.9rem;
  box-shadow: 0 4px 14px rgba(45, 42, 62, 0.12);
  text-align: center;
  min-width: 8.5rem;
}

.xp-badge-xp { display: block; font-weight: 800; font-size: 1.05rem; }
.xp-badge-level { display: block; font-size: 0.8rem; font-weight: 700; color: #6b6880; }

.xp-badge-barwrap {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  margin-top: 0.35rem;
  overflow: hidden;
}

.xp-badge-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--sun), var(--accent));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.xp-toast {
  position: fixed;
  top: 5.5rem;
  right: 0.75rem;
  z-index: 60;
  background: var(--accent);
  color: white;
  font-weight: 800;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(108, 92, 231, 0.4);
  animation: xp-pop 2.5s ease forwards;
}

@keyframes xp-pop {
  0%   { opacity: 0; transform: translateY(-10px) scale(0.8); }
  10%  { opacity: 1; transform: translateY(0) scale(1.05); }
  20%  { transform: scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

@media print {
  .xp-badge, .xp-toast { display: none; }
}

/* ---------- Progress: locks, fail-back, next button (progress.js) ---------- */
.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(45, 42, 62, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.lock-card {
  background: var(--paper);
  border: 3px solid var(--sun);
  border-radius: 20px;
  padding: 2rem 2.25rem;
  max-width: 26rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.lock-card h2 { margin: 0.5rem 0; border: none; display: block; }
.lock-emoji { font-size: 3.5rem; line-height: 1; }

.progress-next-btn {
  display: inline-block;
  font-weight: 800;
  background: var(--accent);
  color: white !important;
  text-decoration: none;
  border-radius: 999px;
  padding: 0.6rem 1.5rem;
  margin-top: 0.75rem;
}

.progress-next-btn:hover { background: #5a4bd1; }

.progress-next-inline {
  background: var(--mint-soft);
  border: 2px solid var(--mint);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
}

a.lesson-locked {
  opacity: 0.45;
  pointer-events: none;
}

/* Lesson-status badges on the course home (progress.js) */
.mark-done { margin-left: 0.35rem; }
.mark-locked { margin-left: 0.35rem; opacity: 0.55; font-size: 0.85em; }
.mark-continue {
  display: inline-block;
  margin-left: 0.45rem;
  background: var(--accent);
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.12rem 0.65rem;
  vertical-align: middle;
  animation: help-pulse 2s ease-in-out infinite;
}

@media print {
  .lock-overlay, .progress-next-inline { display: none; }
}

/* ---------- XP badge extras (streak + mute) ---------- */
.xp-badge-streak { display: block; font-size: 0.75rem; font-weight: 700; color: var(--coral); }
.xp-badge-mute {
  position: absolute;
  top: -0.5rem;
  left: -0.5rem;
  font-size: 0.85rem;
  background: white;
  border: 2px solid var(--line);
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  cursor: pointer;
  padding: 0;
}
.xp-badge { position: fixed; } /* (already fixed; .xp-badge-mute anchors to it) */

/* ---------- Trophy shelf (index) ---------- */
.trophy-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.trophy {
  text-align: center;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  min-width: 7rem;
  filter: grayscale(1);
  opacity: 0.45;
  background: white;
}

.trophy-earned {
  filter: none;
  opacity: 1;
  border-color: var(--sun);
  background: var(--sun-soft);
}

.trophy-emoji { font-size: 2rem; }
.trophy-name { font-size: 0.8rem; font-weight: 700; }

/* ---------- Playground ---------- */
.playground-main { max-width: 72rem; }

.playground-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 50rem) { .playground-grid { grid-template-columns: 1fr; } }

.playground-preview { min-height: 16rem; height: 100%; }

.timer-snooze { background: #9a93b8; }

/* Visible study-timer widget (bottom-right, rendered by timer.js) */
.study-timer {
  position: fixed;
  bottom: 0.75rem;
  right: 0.75rem;
  z-index: 50;
  background: white;
  border: 2px solid var(--mint);
  border-radius: 14px;
  padding: 0.45rem 0.9rem;
  box-shadow: 0 4px 14px rgba(45, 42, 62, 0.12);
  text-align: center;
  min-width: 8.5rem;
  font-size: 0.85rem;
}

.study-timer-time { display: block; font-weight: 800; }
.study-timer-break { display: block; font-weight: 700; color: #6b6880; font-size: 0.78rem; }

.study-timer-barwrap {
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  margin-top: 0.3rem;
  overflow: hidden;
}

.study-timer-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--mint), var(--coral));
  border-radius: 999px;
  transition: width 0.5s ease;
}

@media print { .study-timer { display: none; } }

/* ---------- Parent mode ---------- */
.parent-main { max-width: 60rem; }

.parent-preview-bar {
  position: sticky;
  top: 0;
  z-index: 90;
  /* fixed dark — var(--ink) turns near-white in dark mode (white-on-white bug) */
  background: #2d2a3e;
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.parent-preview-bar a,
html.dark .parent-preview-bar a,
html.dark .parent-preview-bar a:visited { color: #fdcb6e; font-weight: 700; }

/* While the preview bar is shown, shift top-anchored UI below it */
body.has-preview-bar .lesson-nav { top: var(--pbar-h, 2.5rem); }
body.has-preview-bar .mobile-menu-fab { top: calc(var(--pbar-h, 2.5rem) + 0.6rem); }
body.has-preview-bar .xp-badge { top: calc(var(--pbar-h, 2.5rem) + 0.75rem); }
@media (max-width: 48rem) {
  body.has-preview-bar main { padding-top: calc(var(--pbar-h, 2.5rem) + 3.6rem); }
}

.stat-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.stat-tile {
  background: white;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  min-width: 8rem;
  text-align: center;
}

.stat-tile-emoji { font-size: 1.4rem; }
.stat-tile-value { font-size: 1.25rem; font-weight: 800; }
.stat-tile-label { font-size: 0.78rem; color: #6b6880; font-weight: 700; }

.day-bar-wrap {
  background: var(--line);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.day-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--mint));
  border-radius: 999px;
}

.pin-input {
  font-size: 1.6rem;
  letter-spacing: 0.6em;
  text-align: center;
  width: 8.5rem;
}

.pin-error { color: var(--coral); font-weight: 700; min-height: 1.4em; }

.email-form {
  background: white;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem;
  margin: 1rem 0 2rem;
}

.email-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 44rem) { .email-form-grid { grid-template-columns: 1fr; } }

.email-field { display: flex; flex-direction: column; }
.email-field-wide { grid-column: 1 / -1; }

.email-field-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b6880;
  margin-bottom: 0.3rem;
}

.email-field input {
  font: inherit;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  width: 100%;
}

.email-field input:focus { outline: 3px solid var(--sun); border-color: var(--accent); }

.email-form-toggle { font-weight: 600; }

.email-minutes {
  font: inherit;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
  width: 4.5rem;
  text-align: center;
}

/* ---------- Certificate ---------- */
.cert {
  background: white;
  border: 6px double var(--accent);
  border-radius: 8px;
  padding: 1rem;
  margin: 1.5rem 0;
}

.cert-inner {
  border: 2px solid var(--sun);
  border-radius: 4px;
  padding: 2.5rem 2rem;
  text-align: center;
}

.cert-brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0 0 0.4rem;
}
.cert-crown { font-size: 3rem; }
.cert-heading {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin: 0.5rem 0 1.5rem;
  color: var(--accent);
}
.cert-line { margin: 0.4rem 0; color: #6b6880; }
.cert-name {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 0.5rem 0;
  border-bottom: 2px solid var(--line);
  display: inline-block;
  padding: 0 2rem 0.25rem;
}
.cert-course { font-size: 1.3rem; font-weight: 800; margin: 0.5rem 0; }
.cert-badges { margin: 1.25rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.cert-badge {
  background: var(--sun-soft);
  border: 1px solid var(--sun);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
}
.cert-stats { font-weight: 700; }
.cert-date { color: #6b6880; font-size: 0.9rem; }
.cert-input {
  font: inherit;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
}

@media print {
  .cert { border-color: black; margin: 0; }
  .no-print { display: none !important; }
}

/* ---------- Language switcher (i18n.js) ---------- */
.lang-switch {
  position: fixed;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 50;
  background: white;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.3rem;
  box-shadow: 0 4px 14px rgba(45, 42, 62, 0.12);
}

.lang-switch button {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  border: none;
  background: none;
  color: #6b6880;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
}

.lang-switch button.lang-active { background: var(--accent); color: white; }

@media print { .lang-switch { display: none; } }

/* ---------- Skill Tree ---------- */
.st-level-track {
  position: relative;
  height: 5rem;
  /* inset so the centered milestone labels at 0%/100% stay inside the page */
  margin: 2.5rem 2.4rem 1rem;
  border-top: 6px solid var(--line);
}

.st-level-fill {
  position: absolute;
  top: -6px;
  left: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--sun), var(--accent));
  border-radius: 999px;
  transition: width 1s ease;
}

.st-level-mark { position: absolute; top: -6px; transform: translateX(-50%); text-align: center; }
.st-level-dot {
  display: block;
  width: 14px; height: 14px;
  margin: -4px auto 0.25rem;
  border-radius: 50%;
  background: var(--line);
  border: 3px solid var(--paper);
}
.st-level-hit .st-level-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.st-level-name { font-size: 0.62rem; font-weight: 700; color: #6b6880; line-height: 1.25; display: block; width: 5.2rem; }
.st-level-hit .st-level-name { color: var(--ink); }

.st-wrap { position: relative; }
.st-svg { width: 100%; height: auto; display: block; }

.st-edge {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}
.st-edge-locked { stroke: var(--line); stroke-dasharray: 3 10; }
.st-edge-done {
  stroke-dasharray: 14 10;
  animation: st-flow 1.2s linear infinite;
  opacity: 0.85;
}
@keyframes st-flow { to { stroke-dashoffset: -24; } }

.st-node { cursor: pointer; }
.st-ring { fill: none; stroke-width: 3; stroke: transparent; }
.st-core { stroke: var(--line); stroke-width: 2; }
.st-emoji { font-size: 26px; }
.st-num { font-size: 12px; font-weight: 700; fill: var(--ink); }

.st-done .st-core { stroke: none; }
.st-done .st-emoji { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35)); }
/* fade-in only — a CSS transform here would override the SVG translate */
.st-done { animation: st-pop 0.6s ease backwards; }
@keyframes st-pop { from { opacity: 0; } }

.st-frontier .st-ring {
  stroke: var(--accent);
  animation: st-pulse 1.6s ease-in-out infinite;
}
@keyframes st-pulse {
  0%, 100% { stroke-width: 3; opacity: 1; }
  50% { stroke-width: 9; opacity: 0.45; }
}

.st-locked { opacity: 0.45; }
.st-locked .st-emoji { font-size: 18px; }

/* Witcher-style game panel for the concept skill tree: always dark */
.st-panel {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(108, 92, 231, 0.25), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(0, 206, 201, 0.15), transparent 55%),
    linear-gradient(160deg, #171423, #201b33 60%, #171423);
  border: 2px solid #38304f;
  border-radius: 20px;
  padding: 1rem 0.5rem;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.5), 0 12px 30px rgba(0, 0, 0, 0.25);
}

.st-panel .st-core { stroke: #4a4168; }
.st-panel .st-num, .stt-label { fill: #cfc9e8; font-size: 12.5px; font-weight: 700; }
.stt-sublabel { fill: #8d84b0; font-size: 11px; font-weight: 700; }

/* Text halos: outline labels in the background color so connector lines
   passing behind them never make the text unreadable (game-UI trick). */
.st-num {
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 5px;
  stroke-linejoin: round;
}
.st-panel .st-num, .stt-label, .stt-sublabel, .stt-rootlabel {
  paint-order: stroke;
  stroke: #1c1830;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.stt-rootcore { fill: #6c5ce7; }
.stt-rootemoji { font-size: 34px; }
.stt-rootlabel { font-size: 15px; fill: #ffffff; }
.st-panel .st-locked { opacity: 0.35; }
.st-panel .st-frontier .st-ring { stroke-width: 3; }
.stt-head .st-emoji { filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.25)); }

.st-dimtext { color: #6b6880; margin-top: -0.5rem; }

.st-tip {
  position: fixed;
  z-index: 20;
  width: 260px;
  background: white;
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  box-shadow: 0 12px 30px rgba(45, 42, 62, 0.25);
  font-size: 0.85rem;
}
.st-tip-head { font-weight: 800; margin-bottom: 0.3rem; text-transform: capitalize; }
.st-tip-xp { font-weight: 800; color: var(--accent); margin-bottom: 0.3rem; }
.st-tip-list { margin: 0 0 0.5rem; padding-left: 1rem; }
.st-tip-list li { margin: 0.15rem 0; }
.st-tip .progress-next-btn { padding: 0.4rem 1rem; font-size: 0.85rem; }
.st-tip-lock { font-weight: 700; color: #6b6880; margin: 0; }

html.dark .st-tip { background: #221f30; }
html.dark .st-core[fill="var(--paper)"] { stroke: var(--line); }
html.dark .st-num { fill: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .st-edge-done, .st-frontier .st-ring, .st-done { animation: none !important; }
}

/* ---------- Lesson step tabs (Learn / Practice / Quiz) ---------- */
.ltab-bar {
  position: sticky;
  top: 2.9rem; /* under the sticky lesson-nav */
  z-index: 35;
  display: flex;
  gap: 0.5rem;
  padding: 1.4rem 0 0.7rem;
  background: var(--paper);
  margin-bottom: 0.5rem;
}

body.has-preview-bar .ltab-bar { top: calc(var(--pbar-h, 2.5rem) + 2.9rem); }

.ltab-btn {
  flex: 1;
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  background: white;
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ltab-n {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.ltab-on { background: var(--accent); border-color: var(--accent); color: white; }
.ltab-on .ltab-n { background: rgba(255, 255, 255, 0.25); }
.ltab-check { color: var(--mint); font-weight: 900; }
.ltab-on .ltab-check { color: #b8ffe8; }

/* success state: completed steps turn green, number circle becomes ✓ */
.ltab-done {
  background: var(--mint-soft);
  border-color: var(--mint);
  color: var(--ink);
}
.ltab-done .ltab-n {
  background: var(--mint);
  color: white;
  font-weight: 900;
}
/* retry state: quiz finished but not perfect — amber, ↻ in the circle */
.ltab-retry { background: var(--sun-soft); border-color: var(--sun); }
.ltab-retry .ltab-n { background: var(--sun); color: #5c4708; font-weight: 900; }
.ltab-retry.ltab-on { background: var(--sun); border-color: var(--sun); color: #3c2f05; }
html.dark .ltab-retry { background: var(--sun-soft); color: var(--ink); }

.ltab-done.ltab-on { background: var(--mint); border-color: var(--mint); color: white; }
.ltab-done.ltab-on .ltab-n { background: rgba(255, 255, 255, 0.3); }
html.dark .ltab-done { background: var(--mint-soft); color: var(--ink); }
html.dark .ltab-done.ltab-on { background: var(--mint); color: #10241d; }

.ltab-continue { text-align: right; margin: 2rem 0 0.5rem; }

html.dark .ltab-bar { background: var(--paper); }
html.dark .ltab-btn { background: #221f30; color: var(--ink); }
html.dark .ltab-on { background: var(--accent); color: white; }

@media (max-width: 48rem) {
  /* NOT sticky on mobile — the fixed ☰ button and XP badge own the top
     band there, and tab switches jump to the top anyway */
  .ltab-bar { position: static; padding-top: 0.8rem; }
  .ltab-btn { font-size: 0.78rem; padding: 0.5rem 0.3rem; gap: 0.25rem; }
  .ltab-n { width: 1.2rem; height: 1.2rem; font-size: 0.7rem; }
}

/* ---------- Lesson movie player ---------- */
.movie-card {
  background: #171423;
  border-radius: 18px;
  overflow: hidden;
  margin: 1.25rem 0 2rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.movie-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(160deg, #1c1830, #241e3e 60%, #1c1830);
  overflow: hidden;
}

.movie-bigplay {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 5rem;
  height: 5rem;
  z-index: 5;
  font-size: 2rem;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(108, 92, 231, 0.6);
}
.movie-bigplay:hover { transform: scale(1.08); }

.movie-sub {
  min-height: 3.2em;
  padding: 0.6rem 1.25rem;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 0.98rem;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.movie-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  background: #100e1b;
}

.movie-btn {
  font: inherit;
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 0.95rem;
}

.movie-dots { display: flex; gap: 0.45rem; flex: 1; }
.movie-dot {
  width: 0.75rem;
  height: 0.75rem;
  border: none;
  border-radius: 50%;
  background: #38304f;
  cursor: pointer;
  padding: 0;
}
.movie-dot-on { background: var(--accent); }
.movie-count { color: #8d84b0; font-size: 0.8rem; font-weight: 700; }

/* --- scene building blocks --- */
.mv-scene { position: absolute; inset: 0; display: flex; color: white; }
.mv-center { flex-direction: column; align-items: center; justify-content: center; gap: 0.8rem; text-align: center; }
.mv-huge { font-size: clamp(3rem, 9vw, 5rem); }
.mv-title { font-size: clamp(1.4rem, 4.5vw, 2.4rem); font-weight: 800; }
.mv-dim { color: #b3abd6; font-weight: 600; }

.mv-house { display: flex; gap: clamp(0.8rem, 4vw, 2.5rem); }
.mv-house-item { text-align: center; font-size: clamp(2.2rem, 7vw, 3.6rem); }
.mv-house-item span { display: block; font-size: clamp(0.8rem, 2.2vw, 1.05rem); font-weight: 800; margin-top: 0.3rem; }
.mv-house-item small { color: #b3abd6; font-weight: 600; }

.mv-brick { display: flex; align-items: center; gap: 0.6rem; font-size: clamp(1.1rem, 3.5vw, 1.8rem); }
.mv-tag { background: #6c5ce7; padding: 0.4rem 0.8rem; border-radius: 10px; font-family: "SF Mono", Menlo, monospace; font-weight: 700; }
.mv-tag-close { background: #e17055; }
.mv-words { background: rgba(255,255,255,0.12); padding: 0.4rem 0.9rem; border-radius: 10px; }
.mv-note { position: absolute; bottom: 12%; width: 100%; text-align: center; color: #ffd97a; font-weight: 700; font-size: clamp(0.9rem, 2.6vw, 1.2rem); }

.mv-split { gap: 2%; padding: 4%; align-items: stretch; }
.mv-code {
  flex: 1;
  background: #0f0d18;
  border-radius: 12px;
  padding: clamp(0.6rem, 2.5vw, 1.4rem);
  font-family: "SF Mono", Menlo, monospace;
  font-size: clamp(0.7rem, 2.2vw, 1.05rem);
  color: #9ae6b4;
  line-height: 1.9;
}
.mv-preview {
  flex: 1;
  background: #fffdf7;
  border-radius: 12px;
  padding: clamp(0.6rem, 2.5vw, 1.4rem);
  color: #2d2a3e;
}
.mv-preview-h1 { font-size: clamp(1rem, 3.4vw, 1.7rem); font-weight: 800; }
.mv-preview-p { margin-top: 0.5rem; font-size: clamp(0.75rem, 2.2vw, 1rem); }
.mv-broken .mv-preview-h1 { color: #c0392b; }
.mv-alarm { font-size: clamp(1.6rem, 5vw, 2.6rem); text-align: center; margin-top: 0.5rem; }
.mv-gone { text-decoration: line-through; opacity: 0.35; }

.mv-ritual { display: flex; align-items: center; gap: clamp(0.8rem, 4vw, 2rem); font-size: clamp(1.6rem, 5vw, 2.6rem); }
.mv-ritual-step { text-align: center; }
.mv-ritual-step small { display: block; font-size: 1rem; color: #b3abd6; font-weight: 700; }
.mv-ritual-arrow { color: var(--sun); }

/* --- entrance animations (staggered) --- */
.mv-pop { animation: mv-pop 0.6s ease backwards; }
.mv-pop2 { animation: mv-pop 0.6s ease 1.2s backwards; }
.mv-rise { animation: mv-rise 0.7s ease 0.3s backwards; }
.mv-rise2 { animation: mv-rise 0.7s ease 1s backwards; }
.mv-rise3 { animation: mv-rise 0.7s ease 1.7s backwards; }
.mv-typing { animation: mv-type 1.6s steps(24) 0.4s backwards; white-space: nowrap; overflow: hidden; display: inline-block; vertical-align: bottom; }
@keyframes mv-pop { from { opacity: 0; transform: scale(0.3); } }
@keyframes mv-rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes mv-type { from { width: 0; } to { width: 100%; } }

/* render mode: freeze at visual stages for MP4 frames */
.movie-static * { animation: none !important; }
.mv-s0 .mv-rise, .mv-s0 .mv-rise2, .mv-s0 .mv-rise3, .mv-s0 .mv-pop2 { opacity: 0; }
.mv-s1 .mv-rise2, .mv-s1 .mv-rise3, .mv-s1 .mv-pop2 { opacity: 0; }
.movie-rendermode .xp-badge, .movie-rendermode .study-timer, .movie-rendermode .mobile-menu-fab,
.movie-rendermode .help-fab, .movie-rendermode .movie-bigplay, .movie-rendermode .lock-overlay { display: none !important; }
/* fullscreen stage so viewport screenshots ARE the video frames */
.movie-rendermode .movie-card { position: fixed; inset: 0; z-index: 999; border-radius: 0; margin: 0; }
.movie-rendermode .movie-stage { aspect-ratio: auto; position: absolute; inset: 0; }
.movie-rendermode .movie-sub { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.65); z-index: 3; }
.movie-rendermode .movie-bar { display: none; }

@media (prefers-reduced-motion: reduce) {
  .mv-pop, .mv-pop2, .mv-rise, .mv-rise2, .mv-rise3, .mv-typing { animation: none; }
}

.movie-mp4note video { width: 100%; border-radius: 12px; margin-top: 0.5rem; }

/* ---------- Footer ---------- */
.lesson-footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: #6b6880;
}

/* ---------- Dark mode (html.dark, toggled via 🌙 in the lang pill) ---------- */
html.dark {
  --ink: #eceaf5;
  --paper: #191722;
  --accent: #9d8cff;
  --accent-soft: #2c2745;
  --sun: #d9a93f;
  --sun-soft: #322a18;
  --mint: #2fd2a5;
  --mint-soft: #14322a;
  --coral: #ff8a70;
  --coral-soft: #3a221c;
  --line: #363247;
}

html.dark .quiz,
html.dark .code-task,
html.dark .stat-tile,
html.dark .trophy,
html.dark .email-form,
html.dark .xp-badge,
html.dark .study-timer,
html.dark .lang-switch,
html.dark .profile-chip,
html.dark .cert,
html.dark .xp-badge-mute { background: #221f30; color: var(--ink); }

html.dark .quiz-option { background: #191722; color: var(--ink); }
html.dark .lock-card { background: #221f30; }
html.dark .code-task-preview { background: white; } /* previews render the kid's page — keep light */
html.dark th { background: var(--accent-soft); color: var(--accent); }
html.dark .subtitle, html.dark .lesson-footer,
html.dark .xp-badge-level, html.dark .study-timer-break,
html.dark .stat-tile-label, html.dark .email-field-label,
html.dark .code-task-label { color: #a49fc0; }
html.dark .cert-input, html.dark .email-field input, html.dark .email-minutes,
html.dark .notebook-input { background: #191722; color: var(--ink); border-color: var(--line); }
html.dark img { opacity: 0.9; }
html.dark a { color: #8fb8ff; }
html.dark pre { border: 1px solid var(--line); }
html.dark .hero-banner { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); }
html.dark .hero-banner .subtitle { color: rgba(255, 255, 255, 0.92); }
html.dark .hero-banner .kicker { color: rgba(255, 255, 255, 0.85); }
html.dark .hero-banner h1 { color: white; }
html.dark table tr:nth-child(even) td { background: rgba(157, 140, 255, 0.07); }
html.dark a:visited { color: #b79df5; }
html.dark .lesson-nav a { color: var(--accent); }
html.dark .lesson-nav a:hover { color: white; }

/* ---------- Micro-interactions & global polish ---------- */
html { scroll-behavior: smooth; }
::selection { background: var(--accent); color: white; }

.progress-next-btn, .code-task-check, .quiz-option, .help-send,
.help-chip, .lang-switch button, .profile-chip, .help-fab, .xp-badge-mute {
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.progress-next-btn:active, .code-task-check:active, .quiz-option:active:not(:disabled),
.help-send:active, .help-chip:active, .help-fab:active, .profile-chip:active {
  transform: scale(0.97);
}

@media (hover: hover) {
  .quiz:hover, .code-task:hover, .stat-tile:hover, .email-form:hover {
    box-shadow: 0 6px 20px rgba(45, 42, 62, 0.08);
  }
  .trophy-earned:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(253, 203, 110, 0.35); }
  .trophy { transition: transform 0.15s ease, box-shadow 0.15s ease; }
  .progress-next-btn:hover, .code-task-check:hover, .help-send:hover:not(:disabled) {
    box-shadow: 0 4px 14px rgba(108, 92, 231, 0.35);
  }
}

/* Zebra tables — helps the dense parent dashboard everywhere */
table tr:nth-child(even) td { background: rgba(108, 92, 231, 0.045); }
@media (hover: hover) { table tr:hover td { background: rgba(108, 92, 231, 0.09); } }

/* Lesson-complete banner: celebratory */
.progress-next-inline {
  background: linear-gradient(120deg, var(--mint-soft), var(--sun-soft));
  border: 2px solid var(--mint);
}

/* Toast stacking: don't overlap when two fire together */
.xp-toast + .xp-toast { top: 9rem; }

/* ---------- Accessibility ---------- */
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .xp-toast, .mark-continue, .help-thinking, .help-mic-on { animation: none; }
  .xp-badge-bar, .study-timer-bar, .day-bar { transition: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Profile chip + overlay ---------- */
.profile-chip {
  position: fixed;
  bottom: 3.2rem;
  left: 0.75rem;
  z-index: 50;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  background: white;
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(45, 42, 62, 0.12);
}

.profile-card { max-width: 22rem; }
.profile-row { display: flex; gap: 0.4rem; justify-content: center; margin: 0.4rem 0; }
.profile-pick { width: 100%; }
.profile-current { background: var(--mint); }
.profile-del { font: inherit; background: none; border: none; cursor: pointer; }
.profile-new { margin: 1rem 0 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.profile-emoji {
  font-size: 1.2rem; background: none; border: 2px solid transparent;
  border-radius: 8px; cursor: pointer; padding: 0.15rem 0.3rem;
}
.profile-emoji-on { border-color: var(--accent); background: var(--accent-soft); }
.profile-parent {
  width: 100%;
  margin-top: 0.9rem;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Help (ask-my-teacher) ---------- */
.help-fab {
  position: fixed;
  bottom: 4.6rem;
  right: 0.75rem;
  z-index: 50;
  font-size: 1.3rem;
  background: var(--sun);
  border: none;
  border-radius: 50%;
  width: 2.8rem;
  height: 2.8rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(45, 42, 62, 0.2);
}

/* Ask-my-teacher modal — chat layout: header / chat body / composer */
.help-card {
  background: var(--paper);
  border-radius: 20px;
  max-width: 34rem;
  width: 100%;
  text-align: left;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.help-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  background: linear-gradient(120deg, var(--accent), #8f7bff);
  color: white;
}

.help-avatar {
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 2.6rem;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.help-head-titles { display: flex; flex-direction: column; min-width: 0; }
.help-head-titles strong { font-size: 1.05rem; }
.help-head-sub {
  font-size: 0.72rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.help-x {
  margin-left: auto;
  font: inherit;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  border-radius: 50%;
  width: 1.9rem;
  height: 1.9rem;
  cursor: pointer;
  flex-shrink: 0;
}
.help-x:hover { background: rgba(255, 255, 255, 0.3); }

.help-chat {
  flex: 1;
  min-height: 8rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem;
  background: var(--accent-soft);
}

.help-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  max-width: 85%;
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.45;
}

.help-kid {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.help-tutor {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.help-thinking { animation: help-pulse 1.2s ease-in-out infinite; }
@keyframes help-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

.help-foot { padding: 0.7rem 1rem 0.8rem; border-top: 1px solid var(--line); }

.help-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.help-chip {
  font: inherit; font-size: 0.78rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 999px; padding: 0.35rem 0.8rem; cursor: pointer;
}
.help-chip:hover { background: var(--accent); color: white; }

.help-shot { margin-bottom: 0.5rem; }
.help-shot-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--mint-soft);
  border: 1px solid var(--mint);
  border-radius: 999px;
  padding: 0.2rem 0.6rem 0.2rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--mint);
}
.help-thumb { height: 1.6rem; border-radius: 999px 6px 6px 999px; display: block; }
.help-shot-off {
  background: var(--line);
  border-color: #b9b4a8;
  color: #6b6880;
  filter: grayscale(0.6);
}

.help-shot-rm {
  font: inherit; font-size: 0.7rem; background: none;
  border: none; color: inherit; cursor: pointer; opacity: 0.7; padding: 0 0.1rem;
}
.help-shot-rm:hover { opacity: 1; }

.help-inputrow { display: flex; gap: 0.45rem; align-items: flex-end; }

.help-input {
  flex: 1;
  font: inherit;
  font-size: 0.95rem;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 0.55rem 0.9rem;
  resize: none;
  background: white;
  color: var(--ink);
  line-height: 1.4;
}
.help-input:focus { outline: none; border-color: var(--accent); }

.help-mic {
  font-size: 1.1rem; background: white; border: 2px solid var(--line);
  border-radius: 50%; width: 2.5rem; height: 2.5rem; cursor: pointer; flex-shrink: 0;
}
.help-mic-on { border-color: var(--coral); background: var(--coral-soft); animation: help-pulse 1.2s ease-in-out infinite; }

.help-send {
  font: inherit; font-weight: 800; font-size: 0.9rem;
  background: var(--accent); color: white;
  border: none; border-radius: 999px;
  padding: 0.6rem 1.2rem; cursor: pointer; flex-shrink: 0;
}
.help-send:hover:not(:disabled) { background: #5a4bd1; }
.help-send:disabled { opacity: 0.6; cursor: wait; }

.help-options { font-size: 0.78rem; font-weight: 600; color: #6b6880; margin-top: 0.45rem; }
.help-status { font-weight: 600; font-size: 0.78rem; min-height: 1.2em; margin: 0.25rem 0 0; }

.help-fab-label {
  font-size: 0.6rem;
  display: block;
  font-weight: 800;
  line-height: 1;
}

@media (max-width: 40rem) {
  .help-card { max-height: 94vh; border-radius: 16px; }
  .help-send { padding: 0.6rem 0.9rem; }
}

html.dark .help-card { background: #221f30; }
html.dark .help-tutor { background: #191722; color: var(--ink); }
html.dark .help-input { background: #191722; color: var(--ink); }
html.dark .help-mic { background: #221f30; }

/* ---------- Mobile menu (☰ + bottom sheet) ---------- */
.mobile-menu-fab {
  display: block;
  position: fixed;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 55;
  font-size: 1.3rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 2.9rem;
  height: 2.9rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(45, 42, 62, 0.3);
}

.mobile-scrim {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(45, 42, 62, 0.55);
  display: flex;
  align-items: flex-end;
}

.mobile-sheet {
  background: var(--paper);
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 0.5rem 1rem 1.25rem;
  animation: sheet-up 0.25s ease;
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 2.5rem;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 0.4rem auto 0.8rem;
}
.sheet-brand {
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent);
  padding: 0 0 0.6rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.4rem;
}

.sheet-row {
  display: flex;
  flex-wrap: wrap; /* lets the voice list drop to a full-width second line */
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0;
}
.sheet-row:last-child { border-bottom: none; }

.sheet-label { font-weight: 700; }
.sheet-section {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #6b6880;
}
.sheet-dim { font-weight: 600; font-size: 0.85rem; color: #6b6880; }

.sheet-btn {
  font: inherit;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  cursor: pointer;
}

.sheet-voices {
  flex-basis: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.sheet-voice {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: left;
  background: var(--accent-soft);
  color: var(--accent);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
}
.sheet-voice-on { border-color: var(--accent); background: var(--accent); color: white; }
.sheet-voice-tip {
  font-size: 0.75rem;
  color: #6b6880;
  line-height: 1.45;
  padding: 0.3rem 0.2rem 0;
}
html.dark .sheet-voice-tip { color: #9a97ad; }
/* a11y: lift the ☰ sheet's muted labels off the #6b6880 grey (3.0:1 on the
   dark sheet, fails WCAG AA) to the same #9a97ad the voice tip already uses
   (5.67:1). Colour-only — no layout change. */
html.dark .sheet-section, html.dark .sheet-dim { color: #9a97ad; }

.sheet-langs { display: flex; gap: 0.4rem; }
.sheet-lang {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  min-height: 40px;
}
.sheet-lang-on { background: var(--accent); color: white; }
.sheet-wide { width: 100%; text-align: left; }
.sheet-continue {
  background: var(--accent);
  color: white !important;
  border-radius: 12px;
  padding: 0.6rem 0.9rem !important;
  font-weight: 800;
}

.sheet-link {
  display: block;
  width: 100%;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
  padding: 0.35rem 0;
}

html.dark .mobile-sheet { background: #221f30; }
html.dark .sheet-btn, html.dark .sheet-lang { background: var(--accent-soft); }

@media (max-width: 48rem) {
  /* navbar items live in the mobile menu (menu clones them from the
     hidden .lesson-nav, so keep it in the DOM — just not displayed) */
  .lesson-nav { display: none; }
  main { padding-top: 3.4rem; } /* clear the ☰ / XP badge row */
}

/* Desktop: same ☰, but the menu opens as a LEFT DRAWER, not a bottom sheet */
@media (min-width: 48.01rem) {
  .mobile-scrim { align-items: stretch; justify-content: flex-start; }
  .mobile-sheet {
    width: 340px;
    max-height: 100%;
    height: 100%;
    border-radius: 0 20px 20px 0;
    animation: drawer-in 0.22s ease;
    padding-top: 1rem;
  }
  .sheet-handle { display: none; }
}

@keyframes drawer-in {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) { .mobile-sheet { animation: none !important; } }

@media (prefers-reduced-motion: reduce) { .mobile-sheet { animation: none; } }

/* ---------- Mobile / tablet ---------- */
@media (max-width: 40rem) {
  body { font-size: 1rem; }
  main { padding: 3.6rem 0.9rem 7rem; } /* top clears the ☰ / XP badge row */
  h1 { font-size: 1.7rem; }

  .xp-badge { top: 0.4rem; right: 0.4rem; min-width: 6.5rem; padding: 0.3rem 0.6rem; }
  .xp-badge-xp { font-size: 0.85rem; }
  .xp-badge-level { font-size: 0.65rem; }
  .xp-badge-streak { font-size: 0.6rem; }
  .xp-badge-barwrap { display: none; }

  .study-timer { bottom: 0.4rem; right: 0.4rem; min-width: 6.5rem; padding: 0.3rem 0.6rem; font-size: 0.7rem; }
  .lang-switch { bottom: 0.4rem; left: 0.4rem; }
  .lang-switch button { font-size: 0.65rem; padding: 0.2rem 0.35rem; }
  .profile-chip { bottom: 2.6rem; left: 0.4rem; font-size: 0.7rem; }
  .help-fab { bottom: 3.4rem; right: 0.4rem; width: 2.4rem; height: 2.4rem; }

  .quiz-option { min-height: 44px; }
  .code-task-check, .progress-next-btn { min-height: 44px; }

  table { display: block; overflow-x: auto; }
  pre { font-size: 0.85rem; }

  .lock-card { max-height: 85vh; overflow-y: auto; padding: 1.25rem 1rem; }
  .lock-overlay { padding: 0.75rem; }
  .lesson-nav { padding: 0.5rem 0; gap: 0.35rem; font-size: 0.8rem; }
  .hero-banner { padding: 1.25rem 1.1rem; }
}

/* ---------- Workbook print pages ---------- */
.workbook-cover { text-align: center; padding: 4rem 0; page-break-after: always; }
.workbook-section { page-break-before: always; }
@media print {
  .workbook-toc, .lang-switch, .profile-chip { display: none; }
}

/* ---------- Print ---------- */
@media print {
  body { font-size: 11pt; background: white; }
  .lesson-nav, .quiz, .no-print { display: none; }
  pre { border: 1px solid #ccc; background: white; color: black; }
  a { color: inherit; text-decoration: none; }
}
