/* Lamdio
   Colour tokens from the brand kit (tokens.css, 6 Nov 2026). Light, navy and amber, is the default. Dark, petrol and
   coral on #111214, follows the device, unless <html data-mode="light"> forces light; data-mode="dark" forces dark
   (Settings > Appearance, set before the first paint by the script in index.html). The dark values are for the screen
   only: printing is always light.
   Two looks share the tokens:
   standard (age 12+ and teachers): slate paper, navy ink, amber answer dot, mono headline
   kids (grades 1 to 6): sky blue, grape, star yellow, rounded display type, chunky pressable shapes. Always light. */

:root {
  --bg: #edf0f3;
  --surface: #ffffff;
  --ink: #15203b;
  --muted: #5a6579;
  --line: #d3d9e2;
  --line-strong: #7d8799;        /* input borders: 3:1 against the page */
  --accent: #17254a;
  --accent-strong: #0f1a38;
  --accent-soft: #e1e7f6;
  --on-accent: #ffffff;          /* text on a filled accent button */
  --mark: #d99a06;               /* the answer dot: highlights and marks, not text (2.45:1) */
  --mark-soft: #fbf1d3;
  --mark-ink: #7a5600;           /* amber as text */
  --on-mark: #15203b;            /* text on a filled mark (the star count) */
  --wrong: #a83c29;
  --wrong-soft: #f7e3de;
  --focus: #17254a;              /* the focus ring */
  --glass-bg: linear-gradient(160deg, #d3dbf0, #eceff6 60%, #f8ecd0);
  --glass-card: rgba(255, 255, 255, 0.78);
  --glass-tile: rgba(255, 255, 255, 0.55);
  --mark-edge: solid;            /* a hint's edge: dashed in dark, where coral and the error red look alike */
  color-scheme: light;
  --radius: 10px;
  --radius-lg: 14px;
  --font-body: "Atkinson Hyperlegible", "Heebo", "Segoe UI", system-ui, sans-serif;
  --font-display: "JetBrains Mono", "Heebo", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display-weight: 500;
  --press: 0px;
}
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #111214;
    --surface: #1a1c1f;
    --ink: #ecf0f3;
    --muted: #a3abb8;
    --line: #2a2e34;
    --line-strong: #7a8290;
    --accent: #3aa6bf;
    --accent-strong: #5cc0d6;
    --accent-soft: #15303a;
    --on-accent: #06222b;
    --mark: #ff9b7a;
    --mark-soft: #3a241c;
    --mark-ink: #ffb59b;
    --on-mark: #111214;
    --wrong: #ff7b72;
    --wrong-soft: #3a1c1a;
    --focus: #ff9b7a;
    --glass-bg: linear-gradient(160deg, #172a30, #131416 60%, #261b17);
    --glass-card: rgba(26, 28, 31, 0.72);
    --glass-tile: rgba(255, 255, 255, 0.07);
    --mark-edge: dashed;
    color-scheme: dark;
  }
}
@media screen {
  :root[data-mode="dark"] {
    --bg: #111214;
    --surface: #1a1c1f;
    --ink: #ecf0f3;
    --muted: #a3abb8;
    --line: #2a2e34;
    --line-strong: #7a8290;
    --accent: #3aa6bf;
    --accent-strong: #5cc0d6;
    --accent-soft: #15303a;
    --on-accent: #06222b;
    --mark: #ff9b7a;
    --mark-soft: #3a241c;
    --mark-ink: #ffb59b;
    --on-mark: #111214;
    --wrong: #ff7b72;
    --wrong-soft: #3a1c1a;
    --focus: #ff9b7a;
    --glass-bg: linear-gradient(160deg, #172a30, #131416 60%, #261b17);
    --glass-card: rgba(26, 28, 31, 0.72);
    --glass-tile: rgba(255, 255, 255, 0.07);
    --mark-edge: dashed;
    color-scheme: dark;
  }
}

/* The kids look sets every colour itself, so it stays light when the device or the setting says dark. */
body[data-theme="kids"] {
  --bg: #dff2ff;
  --surface: #ffffff;
  --ink: #22305c;
  --muted: #55618a;
  --line: #bbdcf5;
  --line-strong: #7288b8;
  --accent: #6b4df2;
  --accent-strong: #4f34c9;
  --accent-soft: #ece7ff;
  --on-accent: #ffffff;
  --mark: #ffc533;
  --mark-soft: #fff3cc;
  --mark-ink: #6b4a00;
  --on-mark: #22305c;
  --wrong: #c0392b;
  --wrong-soft: #ffe6e2;
  --focus: #4f34c9;
  --glass-bg: linear-gradient(160deg, #cfe8ff, #ece7ff 60%, #fff3cc);
  --glass-card: rgba(255, 255, 255, 0.78);
  --glass-tile: rgba(255, 255, 255, 0.55);
  --mark-edge: solid;
  color-scheme: light;
  --radius: 18px;
  --radius-lg: 26px;
  --font-display: "Baloo 2", "Heebo", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  --display-weight: 800;
  --press: 4px;
  font-size: 18px;
}
html:has(body[data-theme="kids"]) { color-scheme: light; }

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-strong); }   /* not the browser's blue and purple, which do not change with the mode */
::placeholder { color: var(--muted); opacity: 1; }   /* the browser's grey is 3.7:1 in dark */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
/* ---------- shell: sidebar + page ---------- */
.wordmark { color: var(--ink); line-height: 0; }
.wordmark svg { display: block; width: auto; height: 1.9rem; }
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 1.2rem 0.8rem 1rem;
  background: var(--surface); border-inline-end: 1px solid var(--line);
}
.sidebar .wordmark { padding: 0 0.75rem; }
.nav { display: grid; gap: 2px; margin-top: 1.4rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.65rem; width: 100%;
  padding: 0.6rem 0.75rem; border: 0; border-radius: var(--radius); background: none;
  color: var(--muted); font: inherit; font-weight: 700; text-align: start; text-decoration: none; cursor: pointer;
}
.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; padding-top: 1.2rem; display: grid; gap: 0.35rem; }
.sidebar-foot .segmented, .sidebar-foot .chip { justify-self: start; margin: 0 0.4rem 0.4rem; }
.who { padding: 0.3rem 0.75rem 0; overflow: hidden; text-overflow: ellipsis; }
.shell-main { min-width: 0; }
.mobile-bar { display: none; }
.scrim { display: none; }
.icon-btn { padding: 0.45rem 0.55rem; }
.page { width: min(760px, 100% - 2.5rem); margin: 0 auto; padding: clamp(1.25rem, 5vh, 3rem) 0 4rem; display: grid; gap: 1.4rem; align-content: start; }
.page-wide { width: min(1180px, 100% - 2.5rem); }
.narrow { width: min(680px, 100%); display: grid; gap: 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem 1rem; flex-wrap: wrap; }
.select { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 0.5rem 0.7rem; max-width: 100%; }
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.class-bar { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.column { width: min(680px, 100% - 2rem); margin: 0 auto; }
.wide { width: min(1180px, 100% - 2rem); margin: 0 auto; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 0; border-radius: var(--radius); cursor: pointer;
  padding: 0.62rem 1.05rem; font-weight: 700; white-space: nowrap;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 var(--press) 0 var(--accent-strong);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.btn:hover { background: var(--accent-strong); }
a.btn { text-decoration: none; }
a.btn.text:hover { text-decoration: underline; }
.btn:active { transform: translateY(var(--press)); box-shadow: 0 0 0 var(--accent-strong); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.quiet:hover { background: var(--surface); }
.btn.text { background: none; box-shadow: none; color: var(--muted); padding: 0.35rem 0.5rem; font-weight: 400; }
.btn.text:hover { color: var(--ink); text-decoration: underline; }
.btn.danger { color: var(--wrong); }

label.field { display: block; }
label.field > span { display: block; font-size: 0.86rem; color: var(--muted); margin-bottom: 0.25rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], input[type="email"], textarea {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); padding: 0.6rem 0.75rem;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 2.8rem; }

.segmented { display: inline-flex; background: var(--bg); border-radius: var(--radius); padding: 3px; }
.segmented button {
  border: 0; background: none; padding: 0.4rem 0.9rem; border-radius: calc(var(--radius) - 3px);
  cursor: pointer; color: var(--muted); font-weight: 700;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(21, 32, 59, 0.12); }

.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.6rem; border-radius: 99px; font-size: 0.84rem; background: var(--bg); }
.chip.good { background: var(--accent-soft); color: var(--accent-strong); }
.chip.weak { background: var(--wrong-soft); color: var(--wrong); }
.chip.warn { background: var(--mark-soft); color: var(--mark-ink); }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; color: inherit; font-size: 1rem; line-height: 1; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem);
  background: var(--ink); color: var(--surface); padding: 0.7rem 1.1rem; border-radius: var(--radius);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: min(90vw, 520px); z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--wrong); }
#toast.error::before { content: "⚠ "; }   /* an error is told by a sign too, not by colour alone */

/* ---------- sign in ---------- */
/* A glassy gradient behind the sign-in and sign-up screens (the brand kit's glass tokens), the card frosted over it */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--glass-bg); }
.auth-demo { color: var(--ink); padding: clamp(2rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: center; gap: 2.2rem; }
.auth-demo .wordmark svg { height: 2.6rem; }
.auth-demo h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.5rem, 2.6vw, 2.1rem); line-height: 1.25; letter-spacing: -0.02em; max-width: 18ch; }
.demo-chat { display: grid; gap: 0.6rem; max-width: 420px; font-size: 0.98rem; }
.demo-chat p { padding: 0.6rem 0.85rem; border-radius: 10px; width: fit-content; max-width: 100%; }
.demo-chat .t { background: var(--glass-tile); border-inline-start: 3px solid var(--accent); }
.demo-chat .s { background: var(--accent); color: var(--on-accent); justify-self: end; }
.demo-chat .hint { border-inline-start-color: var(--mark); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: min(440px, 100%); display: grid; gap: 1.1rem; padding: clamp(1.2rem, 4vw, 2rem); border-radius: var(--radius-lg);
  background: var(--glass-card); border: 1px solid var(--glass-tile); box-shadow: 0 18px 50px rgba(21, 32, 59, 0.12);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.auth-card h2 { font-size: 1.5rem; }
.auth-card form { display: grid; gap: 0.85rem; }
.auth-card .switch { text-align: center; }
.form-error { color: var(--wrong); font-size: 0.92rem; min-height: 1.3em; }

/* ---------- language ---------- */
html[lang="he"]:root { --font-display: "Heebo", system-ui, sans-serif; --display-weight: 700; }
html[lang="he"] body[data-theme="kids"] { --font-display: "Heebo", "Baloo 2", system-ui, sans-serif; }
/* Text typed or written in the "other" direction (English inside a Hebrew page, and the reverse) keeps its own
   punctuation placement. Empty fields still follow the page direction. */
.msg, input[type="text"], textarea { unicode-bidi: plaintext; }
.auth-form { flex-direction: column; }
.segmented button { font-family: inherit; }

/* ---------- settings ---------- */
.page-title { font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.4rem, 3.4vw, 1.9rem); letter-spacing: -0.01em; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; flex-wrap: wrap; padding: 1.1rem 1.25rem; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-text { flex: 1; min-width: 200px; }
.setting-text h2 { font-size: 1.02rem; margin-bottom: 0.15rem; }

/* ---------- student home ---------- */
.home { padding: clamp(1.5rem, 7vh, 4.5rem) 0 4rem; display: grid; gap: 1.6rem; }   /* the error screen */
.greeting {
  font-family: var(--font-display); font-weight: var(--display-weight);
  font-size: clamp(1.45rem, 4vw, 2.1rem); line-height: 1.25; letter-spacing: -0.02em; min-height: 2.5em;
}
.caret { display: inline-block; width: 0.55em; height: 1.05em; margin-inline-start: 2px; background: var(--accent); vertical-align: -0.15em; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.cards { display: grid; gap: 0.8rem; }
.cards:empty { display: none; }
.action-card {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem;
  border-inline-start: 5px solid var(--line);
}
.action-card.mark { border-inline-start-color: var(--mark); }
.action-card.accent { border-inline-start-color: var(--accent); }
.action-card.soft { border-inline-start-color: var(--accent); background: var(--accent-soft); }
.action-card h2 { font-size: 1.05rem; }
.action-card .grow { flex: 1; min-width: 200px; }
.action-card .join { margin-top: 0; }

.study-bar { display: flex; gap: 0.5rem; background: var(--surface); border-radius: var(--radius-lg); padding: 0.45rem; border: 1.5px solid var(--line); }
.study-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.study-bar input { border: 0; background: none; flex: 1; padding: 0.55rem 0.7rem; min-width: 0; }
.study-bar input:focus { box-shadow: none; }
/* Topics suggested from the class syllabus */
.suggest { display: grid; gap: 0.6rem; }
.suggest h2 { font-size: 1rem; }
.suggest-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 0.6rem; }
.suggest-list:empty { display: none; }
.suggest-item {
  display: grid; gap: 0.15rem; align-content: start; padding: 0.75rem 0.95rem;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-lg);
}
.suggest-item .actions { margin-top: 0.55rem; }
.suggest-item .btn, .lesson-row .btn { padding: 0.45rem 0.8rem; }
.suggest-topic { font-weight: 700; overflow-wrap: anywhere; }

/* Practice by subject: a tree of tick boxes. The box chooses everything under it; the name opens it. */
.pick { display: grid; gap: 0.6rem; }
.pick-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.pick-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.9rem; }
.pick-row input, .pick-leaf input { width: 1.2rem; height: 1.2rem; margin: 0; flex: none; }
.pick-open {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 0.3rem 0.6rem; flex-wrap: wrap;
  border: 0; background: none; padding: 0.35rem 0.4rem; border-radius: var(--radius); text-align: start; cursor: pointer;
}
.pick-open:hover { background: var(--bg); }
.pick-open::after { content: "▾"; margin-inline-start: auto; color: var(--muted); }
.pick-open[aria-expanded="true"]::after { content: "▴"; }
.pick-open[disabled] { opacity: 0.6; cursor: progress; }
.pick-group > .pick-row { font-weight: 700; }
.pick-children { border-top: 1px solid var(--line); padding-inline-start: 1.5rem; }
.pick-topic + .pick-topic { border-top: 1px solid var(--line); }
.pick-leaf { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.45rem 0.9rem; cursor: pointer; }
.pick-leaf span { overflow-wrap: anywhere; }

.section-title { font-size: 1rem; color: var(--muted); font-weight: 400; margin-bottom: 0.5rem; }
.lesson-list { display: grid; gap: 1px; background: var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.lesson-row { display: flex; align-items: center; gap: 1rem; background: var(--surface); padding: 0.85rem 1.1rem; }
.lesson-row .grow { flex: 1; min-width: 0; }
.lesson-row h3 { font-size: 1rem; }
.meter { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 0.4rem; max-width: 220px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s; }
.empty { background: var(--surface); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; }
.join { display: flex; gap: 0.5rem; margin-top: 0.7rem; max-width: 340px; }
.join input { flex: 1; min-width: 7rem; }

.metrics { display: flex; gap: 2.2rem; flex-wrap: wrap; }
.metric b { font-family: var(--font-display); font-size: 1.6rem; font-weight: 500; display: block; line-height: 1.1; }
.metric span { font-size: 0.86rem; color: var(--muted); }

.stars-bar { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.star-count { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; background: var(--mark); color: var(--on-mark); border-radius: 99px; padding: 0.1rem 0.9rem; box-shadow: 0 4px 0 color-mix(in srgb, var(--mark) 82%, #000); }
.star-count.bump { animation: bump 0.45s; }
@keyframes bump { 40% { transform: scale(1.25) rotate(-4deg); } }
.badges { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.badge { background: var(--surface); border-radius: 18px; padding: 0.5rem 0.8rem; text-align: center; min-width: 96px; border: 2px solid var(--line); }
.badge .icon-emoji { font-size: 1.6rem; display: block; }
.badge b { font-size: 0.82rem; display: block; }
.badge small { font-size: 0.7rem; color: var(--muted); display: block; line-height: 1.2; }
.badge.locked { border-style: dashed; }   /* not yet earned: a grey sign and a dashed edge; its words stay readable (4.5:1) */
.badge.locked .icon-emoji { filter: grayscale(1); opacity: 0.55; }
.badge.earned { border-color: var(--mark); background: var(--mark-soft); }

/* ---------- session ---------- */
.session { display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; }   /* the column never grows past the screen for a long title */
.session-head { display: flex; align-items: center; gap: 1rem; padding: 0.7rem clamp(1rem, 4vw, 2rem); background: var(--surface); border-bottom: 1px solid var(--line); }
.session-head h1 { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-head .grow { flex: 1; min-width: 0; }
.session-head .meter { max-width: none; }
/* Difficulty of the questions being practised (1 to 10). Marked and blinking while the tutor suggests another level. */
.difficulty { display: grid; gap: 0.2rem; justify-items: center; padding: 0.3rem 0.6rem; border: 1.5px solid transparent; border-radius: var(--radius); white-space: nowrap; }
.difficulty .pips { display: inline-flex; gap: 3px; }
.difficulty .pips i { width: 8px; height: 13px; border-radius: 3px; background: var(--line); }
.difficulty .pips i.on { background: var(--accent); }
.difficulty.suggest { border-color: var(--mark); background: var(--mark-soft); font-weight: 700; animation: level-blink 1s ease-in-out infinite; }
.difficulty.suggest .pips i.offer { background: var(--mark); outline: 2px solid var(--ink); outline-offset: 1px; }
@keyframes level-blink { 50% { opacity: 0.25; } }
.chat { overflow-y: auto; padding: 1.5rem 0 1rem; }
.chat-inner { display: grid; gap: 0.55rem; }
.msg { max-width: 85%; padding: 0.65rem 0.95rem; border-radius: var(--radius-lg); white-space: pre-wrap; overflow-wrap: anywhere; animation: rise 0.22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg.assistant { background: var(--surface); justify-self: start; border-inline-start: 4px solid var(--line); border-start-start-radius: 4px; }
.msg.student { background: var(--accent); color: var(--on-accent); justify-self: end; border-end-end-radius: 4px; }
.msg.question { border-inline-start-color: var(--accent); font-weight: 700; }
.msg.correct { border-inline-start-color: var(--accent); background: var(--accent-soft); }
.msg.incorrect { border-inline-start-color: var(--wrong); background: var(--wrong-soft); }
.msg.hint { border-inline-start-color: var(--mark); border-inline-start-style: var(--mark-edge); background: var(--mark-soft); }
.msg.retry { border-inline-start-color: var(--mark); border-inline-start-style: var(--mark-edge); background: var(--mark-soft); }   /* "try again", not "wrong" */
.msg.complete { border-inline-start-color: var(--mark); font-weight: 700; }
.msg.info, .msg.redirect { border-inline-start-color: var(--muted); }
.msg.quiz { border-inline-start-color: var(--accent); }
.divider { text-align: center; font-size: 0.82rem; color: var(--muted); margin: 0.4rem 0; }
/* During a quiz, everything before the tutor's latest turn is blurred, so an earlier answer cannot be read back. */
.msg.past { filter: blur(7px); opacity: 0.55; user-select: none; -webkit-user-select: none; pointer-events: none; }
.typing { display: inline-flex; gap: 4px; padding: 0.9rem 0.95rem; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 30% { transform: translateY(-4px); opacity: 0.5; } }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 0.7rem 0 max(0.7rem, env(safe-area-inset-bottom)); }
.composer form { display: flex; gap: 0.5rem; }
.composer .done { display: flex; gap: 0.6rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
/* Multiple choice: a circle (one right option) or a square (several) next to each option, then Submit. */
.composer form.choice-form { display: grid; gap: 0.6rem; }
.choices { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 0.4rem; max-height: 46vh; overflow-y: auto; }
.choices legend { padding: 0; margin-bottom: 0.35rem; }
.choice { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.6rem 0.8rem; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 1.2rem; height: 1.2rem; margin: 0.15rem 0 0; flex: none; }
.choice span { overflow-wrap: anywhere; unicode-bidi: plaintext; }
body[data-theme="kids"] .choice { padding: 0.75rem 1rem; font-size: 1.05rem; }

body[data-theme="kids"] .msg.assistant { border: 2px solid var(--line); }
body[data-theme="kids"] .msg.student { background: var(--accent); }
body[data-theme="kids"] .msg.correct { border-color: #9be0c8; background: #e2f9f0; }
body[data-theme="kids"] .msg.incorrect { border-color: #ffc2bb; }
body[data-theme="kids"] .msg.hint, body[data-theme="kids"] .msg.retry { border-color: var(--mark); }
body[data-theme="kids"] .msg.question { border-color: var(--accent); font-size: 1.1rem; }
body[data-theme="kids"] .msg.quiz { border-color: var(--accent); }
body[data-theme="kids"] .meter { height: 12px; }
body[data-theme="kids"] .meter i { background: linear-gradient(90deg, #2ec4a6, #6b4df2); }
.burst { position: fixed; pointer-events: none; font-size: 1.5rem; z-index: 40; animation: fly 0.9s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(200deg) scale(0.4); opacity: 0; } }

/* ---------- teacher ---------- */
.build { display: grid; grid-template-columns: minmax(320px, 0.85fr) 1.15fr; gap: 1.2rem; align-items: start; }
.panel { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--line); }
.panel-head { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 0.6rem; }
.panel-head h2 { font-size: 1rem; flex: 1; }
.panel-body { padding: 1rem 1.1rem; }
.builder-chat { display: grid; grid-template-rows: auto 1fr auto; height: min(72vh, 720px); position: sticky; top: 1rem; }
.builder-chat .chat { padding: 1rem 1.1rem; }
.builder-chat .msg { max-width: 92%; font-size: 0.95rem; }
.builder-chat .msg.assistant { background: var(--bg); border-inline-start-color: var(--accent); }
.builder-foot { border-top: 1px solid var(--line); padding: 0.7rem 0.9rem; display: grid; gap: 0.5rem; }
.builder-foot .row { display: flex; gap: 0.5rem; align-items: flex-end; }
.files { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.draft-form { display: grid; gap: 0.9rem; }
.q { display: grid; grid-template-columns: 1.6rem 1fr; gap: 0.5rem; padding: 0.8rem 0; border-top: 1px solid var(--line); }
.q .n { font-family: var(--font-display); color: var(--muted); padding-top: 0.55rem; }
.q-fields { display: grid; grid-template-columns: 3fr 2fr; gap: 0.5rem; }
.q-fields .full { grid-column: 1 / -1; }
.q-fields input[type="text"], .q-fields .select { padding: 0.45rem 0.6rem; font-size: 0.94rem; width: 100%; }
.q-fields label.field > span, .q-options > span { font-size: 0.8rem; margin-bottom: 0.15rem; }
.q-options > span { display: block; color: var(--muted); }
.q-option-list { display: grid; gap: 0.35rem; }
.q-option { display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: center; }
.q-option input[type="radio"], .q-option input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; }
.assign { border-top: 1px solid var(--line); padding-top: 0.9rem; display: grid; gap: 0.5rem; }
.assign label { display: flex; gap: 0.5rem; align-items: center; }
.assign .picks { display: flex; gap: 0.4rem 1rem; flex-wrap: wrap; padding-inline-start: 1.6rem; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: start; font-weight: 400; color: var(--muted); font-size: 0.86rem; padding: 0.6rem 1.1rem; border-bottom: 1px solid var(--line); }
table.grid td { padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
.num { font-family: var(--font-display); }
.class-code { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; margin-bottom: 1rem; }
.class-code code { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: 0.12em; background: var(--surface); border: 1.5px dashed var(--accent); border-radius: var(--radius); padding: 0.2rem 0.7rem; }
.student { border-bottom: 1px solid var(--line); }
.student:last-child { border-bottom: 0; }
.student-head { display: grid; grid-template-columns: 1.2fr 1fr 2fr 2fr auto; gap: 1rem; padding: 0.6rem 1.1rem; }
.student summary { display: grid; grid-template-columns: 1.2fr 1fr 2fr 2fr auto; gap: 1rem; padding: 0.85rem 1.1rem; cursor: pointer; align-items: center; list-style: none; }
.student summary::-webkit-details-marker { display: none; }
.student summary:hover { background: var(--bg); }
.tags { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.student-detail { padding: 0.3rem 1.1rem 1.2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.student-detail h4 { margin: 0 0 0.4rem; font-size: 0.86rem; color: var(--muted); font-weight: 400; }
.student-detail ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.45rem; }
.bar-row { display: grid; grid-template-columns: 1fr 90px 3rem; gap: 0.6rem; align-items: center; font-size: 0.92rem; }
.bar-row .meter { margin: 0; }
.bar-row .meter.low i { background: var(--wrong); }
.bar-row .meter.mid i { background: var(--mark); }

/* ---------- lessons, progress, classes pages ---------- */
.classes-strip { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.classes-strip .grow { flex: 1; min-width: 200px; }
.classes-strip .join { margin-top: 0; }
.lesson-row .chip { vertical-align: 1px; }
details.completed > summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 0.5rem 0; }
details.completed > summary:hover { color: var(--ink); }
details.completed[open] > summary { margin-bottom: 0.5rem; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.bars .bar-row { grid-template-columns: minmax(0, 1fr) minmax(90px, 40%) 3rem; }
.table-wrap { overflow-x: auto; }
.class-card-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.class-card-head .grow { flex: 1; min-width: 160px; }
.class-card-head h2 { font-size: 1.05rem; }
.class-card .class-code { margin: 0.9rem 0 0; }
.class-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.class-form .actions { grid-column: 1 / -1; }
.syllabus { display: grid; gap: 0.6rem; margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.syllabus h3 { font-size: 0.95rem; }
.syllabus-form { display: grid; gap: 0.6rem; }
.bank { display: grid; gap: 0.45rem; margin-top: 0.4rem; padding-top: 0.8rem; border-top: 1px dashed var(--line); }
.bank h3 { font-size: 0.95rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(280px, 85vw); z-index: 30; transform: translateX(-100%); transition: transform 0.2s; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .shell.open .sidebar { transform: none; box-shadow: 0 0 40px rgba(21, 32, 59, 0.25); }
  .shell.open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(21, 32, 59, 0.4); }
  .mobile-bar { display: flex; align-items: center; gap: 0.8rem; position: sticky; top: 0; z-index: 10; padding: 0.55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
  .class-form { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-demo { padding: 2rem 1.25rem; gap: 1.2rem; }
  .auth-demo .demo-chat { display: none; }
  .build { grid-template-columns: 1fr; }
  .builder-chat { position: static; height: 60vh; }
  .student summary, .student-head { grid-template-columns: 1fr 1fr; }
  .student-head span:nth-child(n+3) { display: none; }
  .student-detail { grid-template-columns: 1fr; }
  .q-fields { grid-template-columns: 1fr; }
  .session-head { gap: 0.6rem; }
  .difficulty { padding: 0.25rem 0.4rem; }
  .difficulty .pips i { width: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
