/* Mobile-first styles. Desktop just centres a phone-width column. */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --ink: #1b1d24;
  --muted: #6b6f7b;
  --line: #e2e0d9;
  --accent: #2f5fd0;
  --accent-ink: #ffffff;
  --accent-soft: #e5ecfb;
  --good: #1f9254;
  --good-soft: #e1f4e8;
  --bad: #d1373f;
  --bad-soft: #fde6e6;
  --gold: #e6a700;
  --flame: #f06a24;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: none;
  --tabbar-h: 64px;
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* Height of the screen and of the area between top bar and tab bar.
     Game boards use it so the board and all its buttons fit without scrolling. */
  --vh: 100vh;
  --view-h: calc(var(--vh) - var(--topbar-h) - var(--safe-t) - var(--tabbar-h) - var(--safe-b) - 20px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Brand gradients, taken from the Klataza logo, plus one colour per step. */
  --brand-a: #5287ef;
  --brand-b: #2a51c0;
  --teal-a: #2ccaa5;
  --teal-b: #0f8a7d;
  --warm-a: #ffb547;
  --warm-b: #ee6236;
  --gold-a: #ffd35a;
  --gold-b: #f0a000;
  --on-grad: #ffffff;
  --grad-brand: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  --grad-teal: linear-gradient(135deg, var(--teal-a), var(--teal-b));
  --grad-warm: linear-gradient(135deg, var(--warm-a), var(--warm-b));
  --grad-gold: linear-gradient(135deg, var(--gold-a), var(--gold-b));
  --grad-good: linear-gradient(90deg, #3fd383, #15a9a0);
  color-scheme: light;
}

/* Section colour (set on <body data-tone> by the router). */
body { --tone-a: var(--brand-a); --tone-b: var(--brand-b); }
body[data-tone="words"] { --tone-a: var(--teal-a); --tone-b: var(--teal-b); }
body[data-tone="sent"] { --tone-a: var(--warm-a); --tone-b: var(--warm-b); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --surface: #1d2029;
    --surface-2: #272a35;
    --ink: #eef0f5;
    --muted: #9aa0ae;
    --line: #2f3340;
    --accent: #7c9cff;
    --accent-ink: #0d1020;
    --accent-soft: #252e4d;
    --good: #45c27d;
    --good-soft: #17352a;
    --bad: #ff6b6f;
    --bad-soft: #3d1f24;
    --shadow: none;
    color-scheme: dark;
  }
}

/* Same dark values for an explicit dark choice. */
:root[data-theme="dark"] {
  --bg: #14161c;
  --surface: #1d2029;
  --surface-2: #272a35;
  --ink: #eef0f5;
  --muted: #9aa0ae;
  --line: #2f3340;
  --accent: #7c9cff;
  --accent-ink: #0d1020;
  --accent-soft: #252e4d;
  --good: #45c27d;
  --good-soft: #17352a;
  --bad: #ff6b6f;
  --bad-soft: #3d1f24;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.icon { display: inline-flex; width: 24px; height: 24px; flex: none; }
.icon svg { width: 100%; height: 100%; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; justify-content: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap { gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

[lang="ru"] { font-feature-settings: "kern"; }

/* Stress accent drawn above the vowel (see ui.js ru()). */
.st { position: relative; }
.st::after {
  content: "";
  position: absolute;
  left: 50%;
  top: .12em;
  width: .085em;
  min-width: 1.5px;
  height: .26em;
  border-radius: 1px;
  background: currentColor;
  transform: translateX(-10%) skewX(-38deg);
  pointer-events: none;
}
.st.up::after { top: -.12em; }

/* ---------- Shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  padding-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  outline: none;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
}
.tabbar a.active { color: var(--accent); }
.tabbar a .icon { padding: 3px 12px; box-sizing: content-box; border-radius: 99px; transition: background .2s; }
.tabbar a.active .icon { background: var(--accent-soft); }
.tabbar a .icon { width: 26px; height: 26px; }

@supports (height: 100dvh) { :root { --vh: 100dvh; } }
body.in-session { --view-h: calc(var(--vh) - var(--safe-t) - var(--safe-b) - 20px); }
body.in-session .tabbar,
body.in-session .topbar { display: none; }
body.in-session main { padding: 0; max-width: 640px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.icon-btn:active { background: var(--surface-2); }
.topbar .icon-btn { background: var(--surface); box-shadow: var(--shadow); width: 40px; height: 40px; }
.session-top .icon-btn { background: var(--surface); box-shadow: var(--shadow); }

/* ---------- Common pieces ---------- */

.page { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.lead { color: var(--muted); }
.section-title { font-size: 1.05rem; margin-top: 12px; }

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
a.card:active { transform: scale(.985); }
.card h3 { font-size: 1.05rem; }
.go { color: var(--muted); margin-left: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
}
.btn .icon { width: 20px; height: 20px; }
.btn.block { display: flex; width: 100%; }
.btn.primary {
  background: var(--grad-brand);
  color: var(--on-grad);
}
.btn.primary:active { transform: scale(.98); filter: brightness(.95); }
.btn.primary:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; cursor: default; }
.btn.secondary {
  background: var(--surface);
  color: var(--accent);
  border: 2px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.btn.secondary:active { transform: scale(.98); background: var(--accent-soft); }
.btn.ghost { background: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--tone-a), var(--tone-b)); transition: width .35s ease; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { padding: 4px 12px; border-radius: 99px; background: var(--surface-2); font-size: .9rem; font-weight: 600; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

.speak {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.speak .icon { width: 22px; height: 22px; }
.speak.big { width: 72px; height: 72px; }
.speak.big .icon { width: 34px; height: 34px; }
.speak.playing { animation: pulse 1s ease-in-out infinite; }
.speak:active { transform: scale(.94); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  50% { box-shadow: 0 0 0 10px transparent; }
}

.notice {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  font-size: .9rem;
}
.notice .icon { color: var(--bad); }

.note {
  font-size: .85rem;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--gold) 14%, var(--surface));
  margin-top: 4px;
}

.ring { position: relative; width: 48px; height: 48px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .ring-bg { stroke: var(--surface-2); }
.ring .ring-fg { stroke-linecap: round; transition: stroke-dashoffset .5s; }
.ring { --ring-a: var(--tone-a); --ring-b: var(--tone-b); }
.ring-stop-a { stop-color: var(--ring-a); }
.ring-stop-b { stop-color: var(--ring-b); }
.goal .ring { --ring-a: #3fd383; --ring-b: #15a9a0; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; }

/* ---------- Home ---------- */

.hero { padding: 8px 4px 4px; }
.hero-greet { font-size: 1.05rem; color: var(--muted); font-weight: 600; }
.hero-name { font-size: 1.9rem; line-height: 1.15; }
.stats { display: flex; gap: 10px; margin-top: 16px; }
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stat strong { font-size: 1.3rem; line-height: 1.2; }
.stat span:last-child { font-size: .75rem; color: var(--muted); }
.stat .icon { width: 20px; height: 20px; color: var(--muted); }
.icon.flame { color: var(--flame); }
.icon.star { color: var(--gold); }

.card.next {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--grad-brand); color: var(--on-grad); border: 0;
}
.card.next .muted, .card.next .go { color: inherit; opacity: .9; }
/* Big faint letters of the course in the background (e.g. "Яя"). */
.card.next::after {
  content: attr(data-mark);
  position: absolute; right: -6px; bottom: -34px; z-index: -1;
  font-family: Georgia, "Times New Roman", serif; font-size: 7.5rem; font-weight: 700; line-height: 1;
  color: #fff; opacity: .13; pointer-events: none;
}
.card.next h3 { font-size: 1.25rem; }
.eyebrow { font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.card.review .icon:first-child { color: var(--accent); }

.path-num {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}
.path-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.path-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

/* ---------- Alphabet ---------- */

.lesson-body { flex: 1; min-width: 0; }
.lesson-letters { margin-top: 4px; font-weight: 700; letter-spacing: .04em; color: var(--accent); word-spacing: 4px; }

.letter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 400px) { .letter-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.letter-tile {
  --s: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.letter-tile.started {
  border-color: color-mix(in srgb, var(--good) calc(var(--s) * 100%), var(--line));
  background: color-mix(in srgb, var(--good-soft) calc(var(--s) * 100%), var(--surface));
}
.letter-tile:active { transform: scale(.95); }
.lt-letter { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.lt-letter small { font-size: 1.1rem; font-weight: 500; margin-left: 2px; color: var(--muted); }
.lt-label { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 4px; }

.letter-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  margin: 0 auto;
  padding: 8px 28px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 5.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.letter-big .lower { font-size: 4rem; font-weight: 500; color: var(--muted); }

.letter-detail { display: flex; flex-direction: column; gap: 14px; text-align: center; }
.sound { font-size: 1.05rem; }
.example {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: left;
}
.example-ru { font-size: 1.5rem; font-weight: 700; }

.tip { flex-direction: column; align-items: stretch; }
.tip h3 { display: flex; align-items: center; gap: 10px; }
.tip-num {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .9rem;
}
.tip-examples { display: flex; flex-direction: column; gap: 8px; }
.tip-example {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.tip-ru { font-size: 1.3rem; font-weight: 700; }

/* ---------- Words & phrases ---------- */

.cat-icon {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 12px; background: var(--surface-2); font-size: 1.5rem;
}

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 14px;
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.li-main { flex: 1; min-width: 0; }
.li-ru { font-size: 1.3rem; font-weight: 700; }

.dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--line); }
.dot.seen { background: var(--gold); }
.dot.learned { background: var(--accent); }
.dot.mastered { background: var(--good); }

.phrase { flex-direction: column; align-items: stretch; }
.phrase-head { display: flex; gap: 12px; align-items: flex-start; }
.phrase-head .dot { margin-top: 10px; }
.phrase-ru { font-size: 1.25rem; font-weight: 700; }
.phrase-en { margin-top: 2px; }

.gloss { display: flex; flex-wrap: wrap; gap: 6px; }
.gloss-word {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  text-align: left;
}
.gloss-word .ru { font-weight: 700; }
.gloss-word small { color: var(--muted); font-size: .75rem; }
.gloss-word:active { background: var(--accent-soft); }

/* ---------- Session ---------- */

.session { display: flex; flex-direction: column; min-height: 100dvh; }
.session-top {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 8px) 12px 8px 6px;
}
.session-bar { flex: 1; height: 12px; }
.session-bar .bar-fill { background: var(--grad-good); }

.session-body { flex: 1; padding: 8px 16px 24px; }
.session-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px calc(14px + var(--safe-b));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.session-foot.feedback { animation: slide-up .2s ease-out; }
.session-foot.good { background: var(--good-soft); border-color: transparent; }
.session-foot.bad { background: var(--bad-soft); border-color: transparent; }
.session-foot.good .btn.primary { background: var(--grad-good); color: #fff; }
.session-foot.bad .btn.primary { background: var(--bad); color: #fff; }
.feedback-head { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; }
.good .feedback-head { color: var(--good); }
.bad .feedback-head { color: var(--bad); }
.feedback-detail { display: flex; flex-direction: column; gap: 4px; }
.feedback-flag { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 1rem; line-height: 1; padding: 6px 8px; border-radius: 8px; cursor: pointer; opacity: .7; }
.feedback-flag:active { background: rgba(0, 0, 0, .06); }
/* Report a problem */
.report-sheet h2 { padding-right: 44px; }
.report-text, .report-email { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; }
.report-text { resize: vertical; min-height: 96px; }
/* Classes: results from class links */
.class-result { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1.5px solid var(--line); text-align: left; }
.class-result .row { align-items: stretch; }
.class-name { flex: 1; min-width: 0; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; }
.class-sent { margin: 0; font-weight: 700; color: var(--good); }
.class-picker { gap: 4px; }
.class-picker select { padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; }
.class-head { flex-direction: column; align-items: stretch; gap: 6px; }
.class-lesson { flex-direction: column; align-items: stretch; gap: 8px; }
.class-lesson-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.class-lesson-head h3 { margin: 0; font-size: 1rem; }
.class-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.class-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 32px; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.class-row-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-row-score { font-variant-numeric: tabular-nums; font-weight: 700; }
.class-row-score.good { color: var(--good); } .class-row-score.ok { color: var(--ink); } .class-row-score.low { color: var(--bad); }
.class-row-x { width: 32px; height: 32px; }
.class-delete { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.class-row-x .icon { width: 16px; height: 16px; }
/* Lesson editor: tasks and questions for texts */
.text-task { flex-wrap: wrap; }
.text-task button { font-size: .85rem; }
.questions-box { gap: 8px; }
.question-edit { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1.5px dashed var(--line); border-radius: 12px; }
.question-edit input[type=text], .question-edit select { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
.choice-edit-row { display: flex; align-items: center; gap: 8px; }
.choice-edit-row input[type=radio] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
/* Reading / listening comprehension */
.comp-text { max-height: min(34vh, 300px); overflow-y: auto; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1.5px solid var(--line); text-align: left; line-height: 1.55; overscroll-behavior: contain; }
.comp-title { margin: 0 0 6px; font-weight: 800; }
.comp-ru { font-size: 1.05rem; }
.comp-listen { display: flex; flex-direction: column; gap: 8px; }
.comp-q { display: flex; flex-direction: column; gap: 4px; }
.comp-step { font-size: .8rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.comp-detail { display: flex; flex-direction: column; gap: 6px; }
/* Privacy notice (once) */
.privacy-notice { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); transform: translateX(-50%); z-index: 45;
  width: min(520px, calc(100% - 20px)); display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1.5px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); animation: slide-up .25s ease-out; }
.privacy-notice p { margin: 0; font-size: .92rem; line-height: 1.4; }
.privacy-notice.leaving { opacity: 0; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; }
.reminder-time { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reminder-hour { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; }
.report-link { align-self: center; border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; text-decoration: underline; text-underline-offset: 2px; padding: 6px; cursor: pointer; }
.fd-row { display: flex; align-items: center; gap: 10px; }
.fd-ru { font-size: 1.3rem; font-weight: 700; }
.fd-letter { font-size: 2rem; font-weight: 700; }

@keyframes slide-up { from { transform: translateY(30%); opacity: 0; } }

.ex { display: flex; flex-direction: column; gap: 16px; animation: fade-in .25s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }
.ex.intro { text-align: center; align-items: center; padding-top: 8px; }
.prompt { font-size: 1.3rem; line-height: 1.3; }
.stage { display: flex; justify-content: center; padding: 12px 0; }
.stage-word { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; text-align: center; }

.letter-prompt { font-size: 6rem; font-weight: 700; line-height: 1; }
.letter-prompt span { font-size: 4.2rem; font-weight: 500; color: var(--muted); margin-left: 12px; }
.big-ru { font-size: 2.6rem; font-weight: 700; line-height: 1.2; }
.phrase-big { font-size: 1.7rem; font-weight: 700; line-height: 1.3; }
.pron { font-size: 1.1rem; color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.translation { font-size: 1.15rem; }

.options { display: grid; grid-template-columns: 1fr; gap: 10px; }
.option {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 1.15rem;
  font-weight: 600;
  text-align: left;
}
.option .ru { font-size: 1.35rem; }
.option.latin { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.1rem; }
.opt-letter { font-size: 1.6rem; }
.opt-key {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border: 1.5px solid var(--line); border-radius: 8px;
  font-size: .8rem; color: var(--muted); font-family: var(--font);
}
.option:active:not(:disabled) { transform: scale(.99); background: var(--surface-2); }
.option:disabled { cursor: default; opacity: .55; }
.option.correct { opacity: 1; border-color: var(--good); background: var(--good-soft); color: var(--good); }
.option.wrong { opacity: 1; border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
@media (min-width: 420px) { .options:has(.opt-letter) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.build-answer {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px;
  min-height: 112px;
  padding: 12px 4px;
  border-bottom: 2px solid var(--line);
  background-image: linear-gradient(transparent 51px, var(--line) 51px, var(--line) 53px, transparent 53px);
  background-size: 100% 56px;
}
.build-answer.correct .tile { border-color: var(--good); color: var(--good); }
.build-answer.wrong .tile { border-color: var(--bad); color: var(--bad); }
.build-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 8px; }
.tile {
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1.15rem;
  font-weight: 600;
}
.tile:active:not(:disabled) { transform: scale(.97); background: var(--surface-2); }

.speak-ex { align-items: center; text-align: center; }
.mic {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 128px; height: 128px; margin-top: 8px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: .85rem;
}
.mic .icon { width: 40px; height: 40px; }
.mic:active { transform: scale(.97); }
.mic.listening { background: var(--bad); box-shadow: 0 0 0 0 var(--bad); animation: listening 1.2s ease-out infinite; }
.mic:disabled { background: var(--good); box-shadow: none; }
@keyframes listening {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 50%, transparent); }
  100% { box-shadow: 0 0 0 28px transparent; }
}
.speak-result { min-height: 3em; display: flex; flex-direction: column; gap: 4px; }

.finish { align-items: center; text-align: center; padding-top: 10vh; }
.finish-emoji, .empty-emoji { font-size: 4.5rem; }
.finish h2 { font-size: 2rem; }
.finish-stats { display: flex; gap: 10px; width: 100%; margin-top: 12px; }

.empty { align-items: center; text-align: center; padding: 20vh 24px 0; }

/* ---------- Bottom sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 12, 18, 0);
  transition: background .25s;
}
.sheet-backdrop.open { background: rgba(10, 12, 18, .45); }
.sheet {
  position: relative;
  width: 100%; max-width: 560px; max-height: 90dvh; overflow-y: auto;
  padding: 12px 20px calc(24px + var(--safe-b));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  transform: translateY(100%);
  transition: transform .25s ease-out;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-handle { width: 40px; height: 5px; margin: 0 auto 12px; border-radius: 99px; background: var(--line); }
.sheet-close { position: absolute; top: 8px; right: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 60;
  width: max-content; max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 600; text-align: center;
  transform: translate(-50%, 20px); opacity: 0; transition: .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; transition: transform .3s cubic-bezier(.34, 1.4, .64, 1), opacity .2s; }

/* ---------- Profile ---------- */

.summary { flex-direction: column; align-items: stretch; }
.summary .stats { margin-top: 0; }
.summary .stat { box-shadow: none; background: var(--surface-2); }
.mastery { display: flex; flex-direction: column; gap: 6px; }
.mastery-row { display: flex; justify-content: space-between; }

.settings, .about { flex-direction: column; align-items: stretch; gap: 0; padding: 4px 16px; }
.about { gap: 14px; padding: 16px; }
.reset-confirm { display: flex; flex-direction: column; gap: 10px; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting.stack { flex-direction: column; align-items: stretch; gap: 8px; }
.setting input[type="text"], .setting select {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.setting input[type="range"] { width: 100%; accent-color: var(--accent); }
input[role="switch"] {
  appearance: none; -webkit-appearance: none;
  position: relative; width: 50px; height: 30px; flex: none; margin: 0;
  border-radius: 99px; background: var(--line); transition: background .2s;
}
input[role="switch"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
input[role="switch"]:checked { background: var(--good); }
input[role="switch"]:checked::after { transform: translateX(20px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Accounts ---------- */

.account { flex-direction: column; align-items: stretch; gap: 14px; }
.account-head { display: flex; align-items: center; gap: 12px; }
.account-head > .icon { width: 36px; height: 36px; padding: 6px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 1.2rem;
}
.sync-status { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--muted); }
.sync-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--line); }
.sync-status.synced .sync-dot { background: var(--good); }
.sync-status.syncing .sync-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.sync-status.offline .sync-dot { background: var(--gold); }
.sync-status.error .sync-dot { background: var(--bad); }
.sync-status.error { color: var(--bad); }

.account-actions { display: flex; flex-direction: column; gap: 10px; }
.expander { border-top: 1px solid var(--line); }
.expander-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 48px; padding: 0; border: 0; background: none;
  font-weight: 600; text-align: left;
}
.expander-btn .icon { width: 20px; height: 20px; color: var(--muted); transition: transform .2s; }
.expander-btn[aria-expanded="true"] .icon { transform: rotate(90deg); }
.expander-body:not(:empty) { padding-bottom: 14px; }

.auth { gap: 16px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: .9rem; }
.field input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 1rem;
}
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; min-width: 0; }
.field-toggle {
  flex: none; min-width: 64px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--muted); font-weight: 600; font-size: .875rem;
}
.form-error { color: var(--bad); font-weight: 600; font-size: .9rem; }
.form-error:empty { display: none; }
.auth-switch { text-align: center; color: var(--muted); }
.auth-switch a { color: var(--accent); font-weight: 700; }

.account-prompt .icon:first-child { color: var(--accent); }

/* ---------- Welcome ---------- */

.welcome {
  gap: 18px; max-width: 480px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
}
.welcome-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.1rem; }
.welcome-mark {
  display: grid; place-items: center; width: 52px; height: 52px; flex: none;
  border-radius: 14px; background: linear-gradient(135deg, #3d6ee0, #2447a8); color: #fff;
  font-family: Georgia, "Times New Roman", serif; font-size: 1.5rem; font-weight: 700;
}
.welcome-title { font-size: 2.1rem; line-height: 1.15; text-wrap: balance; }
.welcome-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.welcome-steps li { display: flex; align-items: center; gap: 12px; }
.welcome-steps .path-num { width: 34px; height: 34px; border-radius: 10px; font-size: .9rem; }
.welcome-form {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.welcome-form label { font-weight: 700; }
.welcome-form input {
  width: 100%; min-height: 52px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1.1rem;
}
.welcome-form input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.welcome-account { display: flex; flex-direction: column; gap: 10px; }
.welcome-or { text-align: center; color: var(--muted); font-weight: 600; font-size: .9rem; }

/* Onboarding: every step fits on one screen. Header, the step (takes the
   space that is left and only scrolls inside itself on tiny screens), the
   step's buttons pinned below, then one line of small links. */
.welcome.onboard {
  height: 100vh; height: 100dvh; overflow: hidden; gap: 12px;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 8px);
}
.onboard .welcome-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.onboard .welcome-brand { font-size: 1rem; gap: 8px; flex: none; }
.onboard .welcome-mark { width: 36px; height: 36px; border-radius: 10px; }
.onboard .welcome-lang { margin: 0; width: auto; flex: 0 1 230px; min-width: 0; }
.onboard .lang-picker button { white-space: nowrap; padding-left: 6px; padding-right: 6px; }
@media (max-width: 400px) { .onboard .welcome-top:has(.welcome-lang) .welcome-brand span { display: none; } }
@media (max-height: 700px) { .onboard .welcome-lead-short { display: none; } }
.onboard .goal-options { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.onboard .goal-options button { padding: 8px 4px; }
.onboard .goal-options button strong { font-size: .92rem; }
.onboard .goal-options button small { font-size: .7rem; line-height: 1.2; }
.onboard .welcome-actions .btn { white-space: nowrap; }
.onboard .welcome-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; gap: 12px; padding: 2px; margin: -2px; }
.onboard .welcome-body .av-editor { flex: 1 1 auto; }
.onboard .welcome-title { font-size: 1.65rem; }
.onboard .lead { font-size: .95rem; line-height: 1.35; }
.onboard .welcome-sub { margin: 2px 0 0; font-size: 1rem; }
.onboard .welcome-form { padding: 14px; }
.onboard .welcome-actions { flex: none; display: flex; flex-direction: column; gap: 8px; }
.onboard .welcome-actions .row.gap > .btn.ghost { flex: none; padding-left: 8px; padding-right: 8px; }
.onboard .welcome-actions .row.gap > .btn.primary.grow { flex: 1 1 auto; }
.onboard .welcome-foot { flex: none; margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 14px; }
.onboard .welcome-account-slot:empty { display: none; }
.onboard .legal-links { margin: 0; font-size: .72rem; gap: 2px 10px; justify-content: center; }
.onboard .welcome-account { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 12px; font-size: .9rem; }
.onboard .welcome-or { font-size: .85rem; }
.welcome-link {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 2px; border: 0; background: none;
  color: var(--accent); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
}
.welcome-link .icon { width: 16px; height: 16px; }
.welcome-choices { gap: 6px; }
.welcome-choices .choice { min-height: 0; padding: 7px 12px; gap: 10px; }
.welcome-choices .choice-icon { width: 34px; font-size: 1.4rem; }
.welcome-choices .choice-text strong { font-size: .98rem; line-height: 1.3; }
.welcome-choices .choice-text small { font-size: .82rem; }
.welcome-choices .choice-text small { -webkit-line-clamp: 1; }
.reason-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.reason-grid .choice { min-height: 52px; padding: 8px 10px; gap: 8px; }
.reason-grid .choice-icon { width: 26px; font-size: 1.25rem; }
.reason-grid .choice-text strong { font-size: .9rem; line-height: 1.2; }
.reason-grid .choice-check { display: none; }

/* ---------- Admin ---------- */

.admin .stat strong { font-size: 1.4rem; }
.admin-link .icon { color: var(--accent); }
.admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
/* Admin → Statistics: simple horizontal bars */
.stat-card { flex-direction: column; align-items: stretch; gap: 4px; }
.stat-cols-wrap { display: flex; flex-direction: column; gap: 4px; }
.stat-cols { display: flex; align-items: flex-end; gap: 2px; height: 96px; }
.stat-col { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 3px; background: var(--surface-2); }
.stat-col-fill { display: block; width: 100%; border-radius: 3px; background: var(--grad-brand); }
.stat-cols-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }
.stat-range { margin-bottom: 4px; }
.stat-bars { list-style: none; margin: 6px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stat-bar { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: .85rem; }
.stat-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar-track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.stat-bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--grad-brand); }
.stat-bar-n { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Admin → Errors */
.error-count { flex: none; min-width: 40px; padding: 4px 8px; border-radius: 99px; background: var(--bad-soft); color: var(--bad); font-weight: 800; text-align: center; font-size: .85rem; }
.error-msg { word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
.error-stack pre { margin: 6px 0 0; padding: 10px; max-height: 220px; overflow: auto; border-radius: 10px; background: var(--surface-2); font-size: .75rem; white-space: pre-wrap; word-break: break-word; }
.admin-item { flex-direction: column; align-items: stretch; gap: 10px; }
.admin-item-head { display: flex; align-items: flex-start; gap: 12px; }
.admin-name { font-weight: 700; }
.admin-actions { display: flex; flex-direction: column; gap: 10px; }
.admin-actions:not(:empty) { padding-bottom: 12px; }
.invite-form { flex-direction: column; align-items: stretch; gap: 12px; }
.invite-form .field, .admin-item .field { flex: 1; min-width: 130px; }
.field select, .invite-form input {
  width: 100%; min-height: 46px; padding: 8px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1rem;
}
.row.wrap { flex-wrap: wrap; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: .9rem; border-radius: 10px; }
.confirm-row { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: .04em; word-break: break-all; }
.small-code { font-size: 1rem; }
.new-code { flex-direction: column; align-items: stretch; gap: 8px; border: 2px solid var(--good); }
.pill {
  flex: none; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
}
.pill.active { background: var(--good-soft); color: var(--good); }
.pill.admin { background: var(--accent-soft); color: var(--accent); }
.pill.revoked, .pill.expired { background: var(--bad-soft); color: var(--bad); }


/* ---------- Menus (account actions etc.) ---------- */

.menu { display: flex; flex-direction: column; border: 1.5px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.menu > * + * { border-top: 1.5px solid var(--line); }
.menu .expander { border-top: 0; }
.menu > .expander + *, .menu > * + .expander { border-top: 1.5px solid var(--line); }
.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 56px; padding: 8px 12px; border: 0; background: var(--surface);
  color: var(--ink); font-weight: 700; text-align: left;
}
.menu-row:active { background: var(--surface-2); }
.menu-row:disabled { opacity: .6; }
.menu-icon {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: 10px; background: var(--accent-soft); color: var(--accent);
}
.menu-icon .icon { width: 20px; height: 20px; }
.menu-label { flex: 1; display: flex; flex-direction: column; }
.menu-label small { color: var(--muted); font-weight: 500; font-size: .8rem; }
.menu-chevron { width: 20px; height: 20px; color: var(--muted); transition: transform .2s; }
.menu-row[aria-expanded="true"] .menu-chevron { transform: rotate(90deg); }
.menu-row.accent .menu-label { color: var(--accent); }
.menu-row.danger { color: var(--bad); }
.menu-row.danger .menu-icon { background: var(--bad-soft); color: var(--bad); }
.menu .expander-body:not(:empty) { padding: 4px 12px 14px; background: var(--surface); }

/* Admin "Manage" toggles look like buttons too */
.admin .expander-btn {
  min-height: 44px; padding: 0 12px; margin-top: 4px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2);
}

/* ---------- Brand, course, goal ---------- */

.course-chip {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  margin-bottom: 10px; padding: 6px 8px 6px 12px; border-radius: 99px;
  background: var(--surface); box-shadow: var(--shadow); border: 1.5px solid var(--line);
  font-weight: 700; font-size: .9rem;
}
.course-chip .flag { font-size: 1.1rem; }
.course-chip .icon { width: 16px; height: 16px; color: var(--muted); }
.hero { display: flex; flex-direction: column; }
.goal .ring span { font-size: .75rem; }
.install-card { width: 100%; border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--line)); text-align: left; color: var(--ink); }
.install-card > .icon:first-child { color: var(--accent); }

.course-list { display: flex; flex-direction: column; gap: 8px; }
.course-option {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.course-option.current { border-color: var(--accent); background: var(--accent-soft); }
.course-option .flag { font-size: 1.6rem; }
.course-option.soon { opacity: .6; border-style: dashed; }

/* ---------- Install sheet ---------- */

.install { display: flex; flex-direction: column; gap: 16px; }
.install-head { display: flex; align-items: center; gap: 14px; }
.install-head img { border-radius: 16px; box-shadow: var(--shadow); }
.install-head h2 { font-size: 1.3rem; }
.install-benefits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.install-benefits li { display: flex; align-items: center; gap: 8px; }
.install-benefits .icon { width: 18px; height: 18px; color: var(--good); }
.install-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.install-steps li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.install-num {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .9rem;
}
.install-text { flex: 1; }
.install-glyph { display: inline-flex; width: 26px; height: 26px; color: var(--accent); flex: none; }
.install-glyph svg { width: 100%; height: 100%; }

/* ---------- Handwriting ---------- */

.trace { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.trace-stage {
  position: relative; width: 100%; max-width: 300px; aspect-ratio: 1; margin: 0 auto;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden;
}
.trace-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.trace-pad { touch-action: none; cursor: crosshair; }
.trace-result { min-height: 1.5em; font-weight: 700; text-align: center; }
.trace-result.good { color: var(--good); }
.trace-result.bad { color: var(--bad); }
.segmented { display: flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); }
.segmented button {
  flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 700; color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.segmented button span { font-size: 1.15rem; }
.welcome-mark { border-radius: 14px; object-fit: cover; }
.welcome-course { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.welcome-course .eyebrow { color: var(--accent); opacity: 1; }
.welcome-course-head { display: flex; align-items: center; gap: 12px; }
.welcome-course-head .flag { font-size: 2rem; }

.goal-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.goal-options button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 60px; padding: 8px 4px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
}
.goal-options button small { color: var(--muted); font-size: .75rem; }
.goal-options button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.btn.danger .icon { width: 18px; height: 18px; }

.notice.success { background: var(--good-soft); }
.notice.success .icon { color: var(--good); }

/* ---------- Invites ---------- */

.invite-hello {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  border-radius: var(--radius); background: var(--accent-soft);
}
.invite-hello h2 { font-size: 1.4rem; }
.invite-wave { font-size: 2.2rem; }
.invite-greeting:empty { display: none; }

/* ---------- Admin tabs, filters, search ---------- */

.admin-tabs { position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 5; }
.admin-tabs a {
  flex: 1; display: grid; place-items: center; min-height: 40px; border-radius: 9px;
  font-weight: 700; color: var(--muted); text-align: center; font-size: .9rem;
}
.admin-tabs a[aria-current="page"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.admin-content { display: flex; flex-direction: column; gap: 12px; }
.stats-4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 0; }
@media (min-width: 480px) { .stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chips button {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 38px; padding: 0 12px; border-radius: 99px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: .875rem;
}
.filter-chips button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filter-chips .count {
  min-width: 22px; padding: 0 6px; border-radius: 99px; background: var(--surface-2);
  font-size: .75rem; line-height: 20px; text-align: center; color: var(--muted);
}
.filter-chips button[aria-pressed="true"] .count { background: var(--surface); color: var(--accent); }
input.search {
  width: 100%; min-height: 46px; padding: 8px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 1rem;
}
input.search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
details.new-invite { flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; }
details.new-invite > summary {
  display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 16px;
  font-weight: 700; color: var(--accent); cursor: pointer; list-style: none;
}
details.new-invite > summary::-webkit-details-marker { display: none; }
details.new-invite > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; font-weight: 600; }
details.new-invite[open] > summary::after { content: "–"; }
details.new-invite .invite-form { box-shadow: none; border-radius: 0; border-top: 1.5px solid var(--line); }
.joined { display: flex; align-items: center; gap: 4px; color: var(--good); font-weight: 600; }
.joined .icon { width: 16px; height: 16px; }
.edit-invite { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.edit-invite input { width: 100%; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); }
.pill.used_up { background: var(--accent-soft); color: var(--accent); }


/* ---------- Gradients and colour accents ---------- */

/* Stats: coloured icon badges */
.stat .icon { width: 30px; height: 30px; padding: 6px; box-sizing: border-box; border-radius: 50%; color: var(--on-grad); background: var(--grad-brand); margin-bottom: 2px; }
.stat .icon.flame { background: var(--grad-warm); color: var(--on-grad); }
.stat .icon.star { background: var(--grad-gold); color: var(--on-grad); }
.stat .icon.review { background: var(--grad-teal); }

/* Learning path: one colour per step */
.card.path .path-num { color: var(--on-grad); background: linear-gradient(135deg, var(--tone-a), var(--tone-b)); }
.card.path.tone-alpha { --tone-a: var(--brand-a); --tone-b: var(--brand-b); }
.card.path.tone-words { --tone-a: var(--teal-a); --tone-b: var(--teal-b); }
.card.path.tone-sent { --tone-a: var(--warm-a); --tone-b: var(--warm-b); }

/* Section pages pick up their colour */
.cat-icon { background: linear-gradient(135deg, color-mix(in srgb, var(--tone-a) 22%, var(--surface)), color-mix(in srgb, var(--tone-b) 22%, var(--surface))); }
.lesson .ring span { color: var(--tone-b); }
.lesson-letters { color: var(--tone-b); }
.page > a.btn.primary.block { background: linear-gradient(135deg, var(--tone-a), var(--tone-b)); }


/* Top bar: title on the left, course chip on the right */
.topbar h1 { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar .course-chip { margin: 0; padding: 6px 12px; box-shadow: none; font-size: .85rem; }

/* Microphone and lesson finish */
.mic { background: var(--grad-brand); color: var(--on-grad); }
.mic.listening { background: var(--bad); }

/* Avatars and the welcome course card */
.avatar { background: var(--grad-brand); color: var(--on-grad); }
.welcome-steps li:nth-child(1) .path-num { background: var(--grad-brand); color: var(--on-grad); }
.welcome-steps li:nth-child(2) .path-num { background: var(--grad-teal); color: var(--on-grad); }
.welcome-steps li:nth-child(3) .path-num { background: var(--grad-warm); color: var(--on-grad); }


/* ---------- Flat design: thin borders instead of shadows ---------- */

.card, .stat, .list-item, .letter-tile, .welcome-form, .welcome-course, .tip-example,
.topbar .icon-btn, .session-top .icon-btn { border: 1.5px solid var(--line); }
.card.next, .card.path .path-num, .summary .stat { border: 0; }
details.new-invite .invite-form { border: 0; border-top: 1.5px solid var(--line); }
.summary .stat { background: var(--surface-2); }
.install-card { border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--line)); }
.new-code { border: 2px solid var(--good); }
.letter-tile.started { border-width: 1.5px; }
.segmented button[aria-pressed="true"], .admin-tabs a[aria-current="page"] { box-shadow: none; outline: 1.5px solid var(--line); }
a.card:active, button.card:active { transform: scale(.99); background: var(--surface-2); }

/* ---------- Logo in the design ---------- */

.logo-mark { display: inline-flex; }
.logo-mark svg { width: 100%; height: 100%; }
.topbar-logo { width: 30px; height: 30px; border-radius: 8px; flex: none; margin-left: 4px; }

/* Install banner on the home screen: brand gradient with the logo bubble */
.install-banner {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px; border-radius: var(--radius);
  background: var(--grad-brand); color: var(--on-grad);
}
.install-banner-mark {
  position: absolute; z-index: -1; right: -28px; bottom: -36px;
  width: 170px; height: 156px; color: #fff; opacity: .14; transform: rotate(-8deg);
}
.install-banner-head { display: flex; align-items: center; gap: 12px; }
.install-banner-head img { border-radius: 12px; outline: 2px solid rgba(255, 255, 255, .35); }
.install-banner-head .eyebrow { opacity: .85; }
.install-banner-head h3 { font-size: 1.2rem; }
.install-banner-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .95rem; }
.install-banner-points li { display: flex; align-items: center; gap: 8px; }
.install-banner-points .icon { width: 18px; height: 18px; padding: 2px; border-radius: 50%; background: rgba(255, 255, 255, .2); }
.install-banner-btn { align-self: flex-start; min-height: 46px; padding: 10px 18px; background: #fff; color: var(--brand-b); }
.install-banner-btn:active { transform: scale(.98); }

/* Me page: logo in "About" and a small footer */
.about-brand { display: flex; align-items: center; gap: 12px; }
.about-brand img { border-radius: 12px; }
.page-footer { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px 0 4px; color: var(--muted); font-weight: 800; letter-spacing: .02em; }
.footer-mark { width: 26px; height: 24px; color: var(--accent); }
.install-banner-close {
  position: absolute; top: 10px; right: 10px;
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .18); color: #fff;
}
.install-banner-close .icon { width: 18px; height: 18px; }
.install-banner-close:active { background: rgba(255, 255, 255, .3); }
.install-banner-head { padding-right: 40px; }

/* ---------- Progress towards "mastered" ---------- */

.pips { display: inline-flex; gap: 3px; flex: none; }
.pips i { width: 12px; height: 6px; border-radius: 3px; background: var(--line); }
.pips i.on { background: linear-gradient(90deg, var(--tone-a), var(--tone-b)); }
.pips.mastered i { background: var(--grad-good); }
.pips i.pop { animation: pip-pop .45s ease-out; }
@keyframes pip-pop { 0% { transform: scaleY(1); } 40% { transform: scale(1.35, 1.8); } 100% { transform: scaleY(1); } }
.li-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.letter-tile .pips { margin-top: 4px; }
.letter-tile .pips i { width: 7px; height: 4px; }
.mastery-line { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .9rem; }
.mastery-line.center { justify-content: center; }
.feedback .mastery-line .pips i { width: 16px; height: 7px; }
.feedback .mastery-line .pips i:not(.on) { background: color-mix(in srgb, currentColor 18%, transparent); }
.mastery-row { display: flex; flex-direction: column; gap: 6px; }
.stack-bar { display: flex; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.stack-mastered { background: var(--grad-good); }
.stack-learned { background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); opacity: .55; }
.mastery { gap: 12px; }

.update { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.update-status:empty { display: none; }
.update-status { color: var(--good); font-weight: 600; text-align: center; }

/* ---------- Learning path ---------- */

.path-section { display: flex; flex-direction: column; gap: 4px; }
.path-map {
  list-style: none; margin: 0; padding: 8px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  --swing: min(30vw, 120px);
}
.path-node {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transform: translateX(calc(var(--x) * var(--swing))); width: 140px; text-align: center;
}
.path-dot {
  position: relative; display: grid; place-items: center;
  width: 72px; height: 72px; border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--tone-a), var(--tone-b)); color: var(--on-grad);
}
.path-dot:active { transform: scale(.95); }
.path-emoji { font-size: 1.9rem; line-height: 1; }
.path-node.current .path-dot { width: 84px; height: 84px; outline: 4px solid color-mix(in srgb, var(--tone-a) 35%, transparent); outline-offset: 4px; }
.path-node.complete .path-dot { background: var(--grad-good); }
.path-node.locked .path-dot { background: var(--surface-2); color: var(--muted); border: 2px dashed var(--line); }
.path-node.locked .path-dot .icon { width: 26px; height: 26px; }
.path-check {
  position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface); color: var(--good); border: 2px solid var(--good);
}
.path-check .icon { width: 16px; height: 16px; }
.path-title { font-weight: 800; font-size: .95rem; line-height: 1.2; }
.path-sub { font-size: .75rem; color: var(--muted); }
.path-node.locked .path-title { color: var(--muted); }
.path-start {
  padding: 4px 12px; border-radius: 99px; margin-bottom: 2px;
  background: linear-gradient(135deg, var(--tone-a), var(--tone-b)); color: var(--on-grad);
  font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.practice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.practice-tile { flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px 12px; }
.practice-tile .path-num { width: 36px; height: 36px; font-size: 1rem; color: var(--on-grad); background: linear-gradient(135deg, var(--tone-a), var(--tone-b)); }
.practice-tile .bar { width: 100%; }

/* Unit page */
.unit-hero {
  display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: var(--on-grad);
}
.unit-page.tone-words .unit-hero { background: var(--grad-teal); }
.unit-page.tone-sent .unit-hero { background: var(--grad-warm); }
.unit-hero-icon { font-size: 3rem; line-height: 1; }
.unit-hero h2 { font-size: 1.5rem; }
.unit-hero .eyebrow { opacity: .85; }
.unit-lessons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.unit-lesson {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.unit-lesson-num {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: var(--surface-2); font-weight: 800; color: var(--muted);
}
.unit-lesson-num .icon { width: 18px; height: 18px; }
.unit-lesson.done .unit-lesson-num { background: var(--grad-good); color: #fff; }
.unit-lesson.next { border-color: var(--accent); }
.unit-lesson.next .unit-lesson-num { background: var(--grad-brand); color: #fff; }
.unit-lesson.locked { opacity: .6; }
.unit-lesson .btn.small { flex: none; }

/* Finish screen */
.unit-done { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--good-soft); color: var(--good); text-align: center; }
.unit-done.soft { background: var(--surface-2); color: var(--muted); }

/* ---------- Animations (all switched off by "reduce motion" above) ---------- */

/* Page change */
.page-enter { animation: page-in .22s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }

/* Answer feedback: the chosen option pops when right, shakes when wrong. */
.option.picked.correct { animation: pop .32s ease-out; }
.option.picked.wrong, .build-answer.wrong { animation: shake .38s ease-in-out; }
.build-answer.correct .tile { animation: pop .32s ease-out; }
.build-answer.correct .tile:nth-child(2) { animation-delay: .04s; }
.build-answer.correct .tile:nth-child(3) { animation-delay: .08s; }
.build-answer.correct .tile:nth-child(4) { animation-delay: .12s; }
.build-answer.correct .tile:nth-child(n+5) { animation-delay: .16s; }
@keyframes pop { 40% { transform: scale(1.05); } }
@keyframes shake {
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); }
}
/* The check mark in the feedback bar draws itself. */
.feedback.good .feedback-head .icon path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .35s .08s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.feedback.bad .feedback-head .icon { animation: shake .38s ease-in-out; }

/* Lesson progress bar: a little springy. */
.session-bar .bar-fill { transition: width .45s cubic-bezier(.34, 1.4, .64, 1); }

/* Finish screen */
.finish .finish-emoji { animation: drop-in .55s cubic-bezier(.34, 1.56, .64, 1) both; }
.finish h2, .finish > p { animation: rise .35s .12s ease-out both; }
.finish-stats .stat { animation: rise .35s ease-out both; }
.finish-stats .stat:nth-child(1) { animation-delay: .2s; }
.finish-stats .stat:nth-child(2) { animation-delay: .3s; }
.finish-stats .stat:nth-child(3) { animation-delay: .4s; }
.finish .xp-breakdown { animation: rise .35s .5s ease-out both; }
.finish .unit-done { animation: rise .4s .6s cubic-bezier(.34, 1.4, .64, 1) both; }
.finish .unit-done + .unit-done { animation-delay: .7s; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-30px) scale(.6); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.icon.bump { animation: bump .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes bump { 40% { transform: scale(1.35) rotate(-8deg); } }

/* Letter confetti */
.confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -2.5rem; font-weight: 800; line-height: 1;
  animation: confetti-fall var(--dur, 2s) var(--delay, 0s) cubic-bezier(.25, .6, .5, 1) forwards;
}
@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: 0; }
}

/* Daily goal ring fills up; a small pop when the goal was just reached. */
.ring.filling .ring-fg { transition: stroke-dashoffset .9s cubic-bezier(.3, .8, .4, 1) .15s; }
.ring.reached { animation: pop .45s 1s ease-out; }
.ring.reached span { animation: rise .3s 1s ease-out both; }

/* A freshly unlocked unit on the path */
.path-node.unlocking .path-dot { animation: unlock .7s .45s cubic-bezier(.34, 1.56, .64, 1) both; }
.path-node.unlocking .path-start { animation: rise .35s 1s ease-out both, bob 1.6s 1.35s ease-in-out infinite; }
@keyframes unlock {
  0% { transform: scale(.7); filter: grayscale(1); opacity: .6; }
  60% { transform: scale(1.12); filter: none; opacity: 1; }
}

/* ---------- Accent colours (Me → Appearance) ---------- */
:root[data-accent="teal"] { --brand-a: #2ccaa5; --brand-b: #0f8a7d; --accent: #0f7f73; --accent-soft: #dcf4ef; }
:root[data-accent="green"] { --brand-a: #4cc77a; --brand-b: #1e8f52; --accent: #1f8a4f; --accent-soft: #e1f4e8; }
:root[data-accent="orange"] { --brand-a: #f9923f; --brand-b: #df4f22; --accent: #c8501f; --accent-soft: #fdeadf; }
:root[data-accent="pink"] { --brand-a: #f06aa4; --brand-b: #c9306f; --accent: #c2306c; --accent-soft: #fce6ef; }
:root[data-accent="purple"] { --brand-a: #9b6cf0; --brand-b: #6a3fc9; --accent: #6b45c8; --accent-soft: #efe8fc; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-accent="teal"] { --accent: #4fd6bd; --accent-soft: #163a36; }
  :root:not([data-theme="light"])[data-accent="green"] { --accent: #5fd08f; --accent-soft: #193a29; }
  :root:not([data-theme="light"])[data-accent="orange"] { --accent: #ffa36b; --accent-soft: #45281b; }
  :root:not([data-theme="light"])[data-accent="pink"] { --accent: #ff8fbd; --accent-soft: #4a2234; }
  :root:not([data-theme="light"])[data-accent="purple"] { --accent: #b49cff; --accent-soft: #33295a; }
}
:root[data-theme="dark"][data-accent="teal"] { --accent: #4fd6bd; --accent-soft: #163a36; }
:root[data-theme="dark"][data-accent="green"] { --accent: #5fd08f; --accent-soft: #193a29; }
:root[data-theme="dark"][data-accent="orange"] { --accent: #ffa36b; --accent-soft: #45281b; }
:root[data-theme="dark"][data-accent="pink"] { --accent: #ff8fbd; --accent-soft: #4a2234; }
:root[data-theme="dark"][data-accent="purple"] { --accent: #b49cff; --accent-soft: #33295a; }

/* ---------- Profile ---------- */

.avatar.has-emoji { line-height: 1; }
.hero-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-avatar { flex: none; border-radius: 50%; }
.profile-card { align-items: center; gap: 14px; }
.profile-card h2 { margin: 0; font-size: 1.3rem; }
.avatar-btn { position: relative; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; }
.avatar-edit {
  position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line);
}
.avatar-edit .icon { width: 14px; height: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .icon.flame.best { background: var(--grad-gold); }
@media (max-width: 360px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.calendar { display: flex; flex-direction: column; gap: 8px; }
.cal-grid { display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.cal-day { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.cal-day.future { background: none; }
.cal-day.l1 { background: color-mix(in srgb, var(--good) 25%, var(--surface-2)); }
.cal-day.l2 { background: color-mix(in srgb, var(--good) 50%, var(--surface-2)); }
.cal-day.l3 { background: color-mix(in srgb, var(--good) 78%, var(--surface-2)); }
.cal-day.l4 { background: var(--good); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-legend { display: flex; align-items: center; gap: 4px; }
.cal-legend .cal-day { width: 12px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 0; color: #fff; cursor: pointer;
}
.swatch .icon { width: 20px; height: 20px; opacity: 0; }
.swatch[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }
.swatch[aria-pressed="true"] .icon { opacity: 1; }

.profile-editor { display: flex; flex-direction: column; gap: 12px; }
.profile-editor h2 { margin: 0; }
/* Sheets whose content fits the screen: the middle part takes the space
   that is left, the buttons at the end always stay visible. */
.sheet.fit-sheet { display: flex; flex-direction: column; overflow: hidden; max-height: calc(100dvh - var(--safe-t) - 16px); padding-bottom: calc(16px + var(--safe-b)); }
.sheet.fit-sheet > :last-child { flex: 1 1 auto; min-height: 0; }
.fit-sheet .profile-editor { gap: 10px; }
.fit-sheet .profile-editor h2 { font-size: 1.2rem; padding-right: 44px; }
.fit-sheet .av-editor { flex: 1 1 auto; }
.inline-field { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.inline-field > span { flex: none; }
.inline-field input { flex: 1; min-width: 0; }
.avatar-preview { display: grid; place-items: center; padding: 4px 0; }
.field > span, .field-label { font-weight: 700; font-size: .9rem; margin: 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.emoji-opt {
  aspect-ratio: 1; padding: 0; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: 1.4rem; cursor: pointer; color: var(--ink);
}
.emoji-opt.initial { font-size: .9rem; font-weight: 800; }
.emoji-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 360px) { .emoji-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.stats-grid .stat span:last-child { text-align: center; }

/* ---------- Friends ---------- */

.friends-body { display: flex; flex-direction: column; gap: 14px; }
.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-row { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lb-row.me { border-color: var(--accent); background: var(--accent-soft); }
.lb-main { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: default; }
.lb-row:not(.me) .lb-main { cursor: pointer; }
.lb-main .li-main p { margin: 2px 0 0; }
.lb-rank { width: 26px; text-align: center; font-weight: 800; font-size: 1.05rem; color: var(--muted); flex: none; }
.lb-medal { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: .9rem; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.lb-medal.m1 { background: linear-gradient(135deg, #f7d34f, #d9a300); }
.lb-medal.m2 { background: linear-gradient(135deg, #d9dde4, #9aa3b2); }
.lb-medal.m3 { background: linear-gradient(135deg, #e8a77a, #b46a3a); }
.lb-xp { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; flex: none; }
.lb-xp strong { font-size: 1.2rem; }
.lb-xp small { color: var(--muted); font-size: .7rem; font-weight: 700; }
.lb-extra:empty { display: none; }
.lb-extra { display: flex; flex-direction: column; gap: 10px; padding: 0 14px 14px; animation: rise .2s ease-out; }
.lb-extra p { margin: 0; }
.cheer-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cheer-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 1.4rem; cursor: pointer; padding: 0;
}
.cheer-btn:active { transform: scale(.92); }
.cheer-btn.sent { animation: pop .4s ease-out; border-color: var(--good); background: var(--good-soft); }
.request-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.request-row + .request-row { border-top: 1.5px solid var(--line); }
.request-row .li-main p { margin: 2px 0 0; }
.friend-code { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.friend-code code { font-size: 1.15rem; font-weight: 800; letter-spacing: .04em; }
.cheers-card { flex-direction: column; align-items: stretch; gap: 10px; }
.cheer-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cheer-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 99px; background: var(--surface-2); font-weight: 700; font-size: .9rem; animation: pop .4s ease-out; }
.cheer-emoji { font-size: 1.2rem; }
.friend-link { align-items: center; text-align: center; }
.friends-card { align-items: center; gap: 12px; }
.friends-stack { display: flex; flex: none; }
.friends-stack .avatar { border: 2px solid var(--surface); }
.friends-stack .avatar + .avatar { margin-left: -12px; }
.badge-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 800; display: grid; place-items: center; }

.recorder { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mic.small-mic { width: auto; height: auto; flex-direction: row; gap: 8px; padding: 12px 20px; border-radius: 99px; font-size: .95rem; }
.mic.small-mic .icon { width: 22px; height: 22px; }
.record-playback .btn .icon { width: 18px; height: 18px; }
.path-node.review-stop .path-dot { background: var(--grad-warm); text-decoration: none; }
.path-new { padding: 2px 10px; border-radius: 99px; background: var(--gold-a); color: #4a3200; font-weight: 800; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Printing ---------- */
.print-page { gap: 12px; }
.print-toolbar { display: flex; flex-direction: column; gap: 10px; }
.print-page .ws { border-radius: var(--radius); }
.unit-lesson .print-btn { color: var(--muted); }
@media print {
  body { background: #fff !important; }
  .topbar, .tabbar, .print-toolbar, .toast, .sheet-backdrop, .confetti { display: none !important; }
  #view, .page, .print-page { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .print-page .ws { border: 0; }
}

/* ---------- Lessons: editor, library ---------- */
.lesson-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lesson-row { flex-direction: column; align-items: stretch; gap: 10px; padding: 0; }
.lesson-open { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: inherit; text-decoration: none; }
.lesson-open .li-main p { margin: 2px 0 4px; }
.lesson-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--surface-2); font-size: 1.5rem; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 14px; }
.lesson-actions:empty { display: none; }
.lesson-actions .btn .icon { width: 16px; height: 16px; }
.pill.status-draft { background: var(--surface-2); color: var(--muted); }
.pill.status-shared { background: var(--accent-soft); color: var(--accent); }
.pill.status-path, .pill.status-published { background: var(--good-soft); color: var(--good); }
.create-intro { flex-direction: column; align-items: stretch; gap: 12px; }
.create-intro h2 { margin: 0 0 4px; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--accent); }
.library-card, .menu-card { align-items: center; gap: 12px; }
.menu-card { flex-direction: column; align-items: stretch; padding: 6px; gap: 0; }
.token-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1.5px solid var(--line); }
.token-row .li-main p { margin: 2px 0 0; }
.token-new { flex-direction: column; }
.token-secret { display: block; margin: 8px 0; padding: 10px; border-radius: 10px; background: var(--surface); word-break: break-all; font-size: .85rem; }
.editor-body { display: flex; flex-direction: column; gap: 12px; }
.editor-hint { margin: -6px 0 0; }
.edit-rows { display: flex; flex-direction: column; gap: 8px; }
.edit-row { display: grid; grid-template-columns: 22px 1fr 1fr 36px; gap: 6px; align-items: center; }
.edit-row input, .icon-input, .json-area, .library-page > input[type="search"] {
  width: 100%; min-width: 0; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.edit-row input:focus, .json-area:focus { border-color: var(--accent); outline: none; }
.edit-num { color: var(--muted); font-size: .8rem; font-weight: 700; text-align: center; }
.icon-level { align-items: flex-end; }
.icon-level .field { flex: 1; }
.icon-input { font-size: 1.3rem; text-align: center; }
.icon-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-picks .emoji-opt { width: 40px; aspect-ratio: 1; font-size: 1.2rem; }
.editor-actions { display: flex; flex-direction: column; gap: 10px; }
.json-area { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; resize: vertical; }
.editor-problems ul { margin: 4px 0 0; padding-left: 18px; }
@media (max-width: 380px) {
  .edit-row { grid-template-columns: 18px 1fr 36px; }
  .edit-row input:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .edit-row .icon-btn { grid-column: 3; grid-row: 1; }
}
.unit-tools .btn .icon { width: 16px; height: 16px; }
.mic span:not(.icon) { text-align: center; padding: 0 12px; line-height: 1.2; }

/* ---------- Dictionary ---------- */
.dict-page { gap: 12px; }
.dict-search {
  width: 100%; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1.05rem;
}
.dict-search:focus { border-color: var(--accent); outline: none; }
.dict-results { display: flex; flex-direction: column; gap: 10px; }
.dict-entry { flex-direction: column; align-items: stretch; gap: 10px; }
.dict-head { display: flex; align-items: flex-start; gap: 12px; }
.dict-word { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.dict-ru { font-size: 1.6rem; font-weight: 800; }
.dict-en { margin: 4px 0 0; font-weight: 600; }
.dict-explain { margin: 0; line-height: 1.5; }
.dict-forms { margin: 0; }
.dict-example { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.dict-example p { margin: 0; }
.dict-example .speak { flex: none; }
.dict-source { align-self: flex-end; text-decoration: none; }
.dict-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; text-align: left;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.dict-row .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dict-row-ru { font-weight: 700; font-size: 1.1rem; }
.dict-credit { margin-top: 8px; }
.dict-credit a { color: inherit; }
.dict-card { align-items: center; gap: 12px; }
.dict-card > .icon:first-child { width: 40px; height: 40px; padding: 8px; border-radius: 12px; background: var(--grad-teal); color: var(--on-grad); flex: none; }
.dict-card-text { flex: 1; display: flex; flex-direction: column; font-weight: 800; }
.dict-card-text small { font-weight: 500; color: var(--muted); font-size: .8rem; }
.myword { align-items: center; gap: 10px; padding: 10px 12px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }
.teacher-link { margin-top: 18px; } .teacher-link a { color: inherit; }
.lyrics-area { min-height: 220px; font-family: inherit; font-size: 1rem; }
.read-along { flex-direction: column; align-items: stretch; gap: 10px; }
.read-along summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; }
.read-along summary::-webkit-details-marker { display: none; }
.read-along ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.read-along li p { margin: 2px 0 0; }
.create-intro .row.gap { flex-wrap: wrap; }

/* ---------- Word filters ---------- */
.word-browser { display: flex; flex-direction: column; gap: 10px; }
.dict-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.dict-filter {
  width: 100%; min-width: 0; padding: 9px 8px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .85rem;
}
.clear-filters { align-self: flex-start; font-size: .85rem; margin-top: 6px; }
.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.topic-grid.levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.topic-chip {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; text-align: left;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
}
.topic-chip span { font-size: 1.2rem; }
.level-chip { flex: none; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 800; }
.dict-count { align-items: baseline; }
.dict-row.added { border-color: var(--good); background: var(--good-soft); }
.word-picker .dict-results { max-height: 50vh; overflow-y: auto; }
.row.gap.wrap { flex-wrap: wrap; }

/* ---------- Admin: word topics ---------- */
.topic-card { flex-direction: column; align-items: stretch; gap: 8px; transition: opacity .25s; }
.topic-card.decided { opacity: .45; }
.topic-card-head { display: flex; align-items: flex-start; gap: 10px; }
.topic-card p { margin: 2px 0 0; }
.topic-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.topic-all { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.topic-all[hidden] { display: none; }
.topic-pick {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.topic-pick.chosen, .btn.chosen { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.topic-done { align-items: center; gap: 10px; padding: 10px 12px; }
.topic-done .li-main p { margin: 2px 0 0; }
.admin-topic { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1.5px dashed var(--line); }
.admin-tabs a { font-size: .85rem; }

/* ---------- Games ---------- */
.game-card { align-items: center; gap: 12px; }
.game-icon { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 14px; background: var(--surface-2); font-size: 1.6rem; }
.puzzle-page { gap: 12px; outline: none; }
.puzzle-intro { flex-direction: column; align-items: stretch; gap: 6px; }
.puzzle-title { display: flex; align-items: center; gap: 10px; }
.puzzle-title h2 { margin: 0; }
.puzzle-icon { font-size: 1.8rem; }
.level-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.level-btn { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.level-btn small { color: var(--muted); }
.pz-bar { display: flex; align-items: center; justify-content: space-between; min-height: 36px; width: 100%; max-width: 480px; margin: 0 auto; }
.pz-bar .icon-btn { width: 36px; height: 36px; }
.pz-bar-space { width: 36px; flex: none; }
/* "?" in the top bar: how to play */
.howto-btn { font-weight: 800; font-size: 1.15rem; color: var(--accent); }
.topbar .howto-btn { width: 40px; height: 40px; }
.howto { display: flex; flex-direction: column; gap: 12px; }
.howto h2 { padding-right: 44px; font-size: 1.2rem; }
.howto-dots { justify-content: center; }
.howto-step { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; min-height: 236px; }
.howto-step h3 { margin: 4px 0 0; font-size: 1.1rem; }
.howto-step p { margin: 0; max-width: 34em; }
.howto-emoji { font-size: 3.4rem; line-height: 1.1; padding: 12px 0 4px; }
.howto-pic { width: 132px; }
.howto-pic svg { display: block; width: 100%; height: auto; }
.howto-pic .frame { fill: var(--surface); stroke: var(--ink); stroke-width: 6; }
.howto-pic .thin { stroke: color-mix(in srgb, var(--ink) 25%, var(--surface)); stroke-width: 3; }
.howto-pic .thick { stroke: var(--ink); stroke-width: 6; }
.howto-pic text { font: 800 48px system-ui, sans-serif; text-anchor: middle; fill: var(--ink); }
.howto-pic text.new { fill: var(--accent); }
.howto-pic rect.fill.new, .howto-pic rect.fill.sel { fill: var(--accent-soft); }
.howto-pic rect.fill.black { fill: var(--ink); }
.howto-pic .cage { fill: none; stroke: var(--accent); stroke-width: 5; stroke-dasharray: 14 10; }
.howto-pic text.sum { font-size: 30px; text-anchor: start; fill: var(--ink); }
.howto-ru { font-weight: 700; color: var(--ink); }
.pz-done:empty { display: none; }
.pz-menu { display: inline-flex; align-items: center; gap: 2px; border: 1.5px solid var(--line); font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); }
.pz-menu-icon { width: 16px; height: 16px; transform: rotate(90deg); }
.pz-menu-sheet { display: flex; flex-direction: column; gap: 12px; }
.pz-menu-sheet h2 { padding-right: 44px; }
.pz-time { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.pz-grid {
  display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); grid-template-rows: repeat(9, minmax(0, 1fr)); margin: 0 auto;
  width: min(100%, 480px, max(240px, calc(var(--view-h) - 172px)));
  position: relative; aspect-ratio: 1; border: 2.5px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--surface);
  touch-action: manipulation; user-select: none;
}
.pz-cell {
  position: relative; display: grid; place-items: center; padding: 0; min-width: 0; min-height: 0; overflow: hidden;
  border: 0; border-radius: 0; -webkit-appearance: none; appearance: none;
  background: var(--surface); color: var(--accent); font: inherit; font-size: clamp(1rem, 5.2vw, 1.6rem); font-weight: 700; cursor: pointer;
}
/* Lines: one SVG on top of the cells (see gridLines() in puzzle.js). */
.pz-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.pz-lines line { vector-effect: non-scaling-stroke; }
.pz-lines .thin { stroke: var(--line); stroke: color-mix(in srgb, var(--ink) 22%, var(--surface)); stroke-width: 1px; }
.pz-lines .thick { stroke: var(--ink); stroke-width: 2px; }
.pz-cell.given { color: var(--ink); }
.pz-cell.peer { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.pz-cell.same { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.pz-cell.sel { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.pz-cell.bad .pz-v { color: var(--bad); }
.pz-cell.bad { background: var(--bad-soft); }
.pz-cell.black { background: var(--ink); color: var(--surface); cursor: default; }
.pz-cell.black .pz-v { color: var(--surface); font-size: .8em; }
.pz-notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; height: 100%; padding: 1px; }
/* Killer: the cage sum sits in the top-left corner, so the notes move down a little (the 1 stays visible). */
.pz-cell.cage .pz-notes { padding: 12%; grid-template-rows: repeat(3, minmax(0, 1fr)); }
.pz-cell.has-sum .pz-notes { padding: 34% 12% 11%; }
.pz-cell.cage .pz-notes i { font-size: clamp(.4rem, 1.8vw, .55rem); }
.pz-notes i { font-style: normal; font-size: clamp(.45rem, 2vw, .62rem); font-weight: 600; color: var(--muted); display: grid; place-items: center; line-height: 1; }
/* Killer cages: dashed outlines a little inside the cells (one SVG, see
   cageOutlines() in puzzle.js); the sum sits on the top-left corner. */
.pz-cages { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.pz-cages path { fill: none; stroke: var(--ink); stroke-opacity: .72; stroke-width: 3.5; stroke-dasharray: 9 7; stroke-linecap: butt; }
.pz-cages g.on path { stroke: var(--accent); stroke-opacity: 1; stroke-width: 5; }
.cage-sum { position: absolute; top: 1px; left: 2px; font-size: clamp(.5rem, 2.2vw, .66rem); font-weight: 800; color: var(--ink); line-height: 1; z-index: 3; background: inherit; padding: 1px 2px; border-radius: 3px; }
.pz-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; max-width: 480px; width: 100%; margin: 0 auto; }
.pz-tools .btn { padding-left: 4px; padding-right: 4px; justify-content: center; }
.pz-tools .btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pz-tools .btn .icon { width: 16px; height: 16px; }
.pz-pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; max-width: 480px; width: 100%; margin: 0 auto; }
.pz-key {
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 0 4px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--accent);
  font: inherit; font-size: 1.4rem; font-weight: 800; cursor: pointer; touch-action: manipulation;
}
.pz-key small { font-size: .6rem; color: var(--muted); font-weight: 700; min-height: .8em; }
.pz-key.used-up { opacity: .35; }
.pz-new { max-width: 480px; width: 100%; margin: 0 auto; }
.puzzle-done { max-width: 480px; margin: 0 auto; width: 100%; }
.puzzle-done .btn { margin-top: 6px; }
/* Learning games */
.memory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 8px; height: min(calc(var(--view-h) - 40px), 600px); }
@media (min-width: 420px) { .memory-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); } }
.memory-card {
  min-height: 0; padding: 6px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--grad-brand); color: var(--on-grad); font: inherit; font-weight: 700; cursor: pointer; overflow: hidden; word-break: break-word;
}
.memory-card.up { background: var(--surface); color: var(--ink); }
.memory-card.matched { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.memory-back { font-size: 1.6rem; opacity: .6; }
.speed-bar { font-size: 1.1rem; }
.speed-q { text-align: center; padding: 10px 0; }
.scramble-hint { text-align: center; font-weight: 700; font-size: 1.1rem; margin: 0; }
.scramble-answer { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.scramble-slot { width: 34px; height: 42px; display: grid; place-items: center; border-bottom: 2.5px solid var(--line); font-size: 1.4rem; font-weight: 800; }
.scramble-answer.correct .scramble-slot { border-color: var(--good); color: var(--good); }
.scramble-answer.wrong .scramble-slot { border-color: var(--bad); color: var(--bad); }
.scramble-bank { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.row.center { justify-content: center; }

/* ---------- Math ---------- */
.math-q { text-align: center; font-size: clamp(1.8rem, 9vw, 2.6rem); font-weight: 800; font-variant-numeric: tabular-nums; padding: 12px 0; line-height: 1.25; }
.math-ex { align-items: stretch; }
.math-answer-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.math-prefix { font-size: 1.6rem; font-weight: 800; }
.math-input {
  width: 160px; padding: 12px; text-align: center; font: inherit; font-size: 1.8rem; font-weight: 800;
  border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
}
.math-input:focus { border-color: var(--accent); outline: none; }
.math-input.correct { border-color: var(--good); color: var(--good); }
.math-input.wrong { border-color: var(--bad); color: var(--bad); }
.option.math-opt { justify-content: center; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.options:has(.math-opt) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* ---------- Onboarding ---------- */
.welcome-body { display: flex; flex-direction: column; gap: 14px; }
.welcome-dots { display: flex; gap: 6px; }
.welcome-dots span { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.welcome-dots span.on { background: var(--accent); }
.welcome-sub { margin: 6px 0 0; font-size: 1.05rem; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  font: inherit; cursor: pointer;
}
.choice-icon { font-size: 1.7rem; width: 36px; text-align: center; flex: none; }
.choice-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice-text small { color: var(--muted); }
.choice-check { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line); color: transparent; }
.choice-check .icon { width: 16px; height: 16px; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.choice[aria-pressed="true"] .choice-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice-list.compact .choice { padding: 10px 14px; }
.choice-list.compact .choice-icon { font-size: 1.3rem; }
.course-switcher .course-option { text-decoration: none; color: inherit; }

/* ---------- Public profiles ---------- */
.profile-public { gap: 12px; }
.profile-hero { flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 22px 16px; }
.profile-hero h2 { margin: 4px 0 0; display: flex; align-items: center; gap: 8px; }
.profile-hero p { margin: 0; }
.profile-subjects { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.profile-actions { width: 100%; margin-top: 6px; }
.profile-actions .btn .icon, .lb-extra .btn .icon { width: 16px; height: 16px; }
.person-row { align-items: center; gap: 12px; padding: 10px 14px; text-decoration: none; color: inherit; }
.person-row .li-main p { margin: 2px 0 0; }
/* Only boxes become centred rows; centred text stays normal text (a flex
   paragraph splits its words and links into columns). */
div.center { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); }

/* ---------- Chat ---------- */
.chat-page { gap: 10px; height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - var(--safe-b) - var(--safe-t) - 24px); }
.chat-head { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 4px 2px; }
.chat-head .li-main { display: flex; flex-direction: column; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 8px 2px; }
.bubble { max-width: 80%; align-self: flex-start; padding: 8px 12px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1.5px solid var(--line); }
.bubble.mine { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.bubble a { color: inherit; text-decoration: underline; }
.bubble small { display: block; font-size: .68rem; opacity: .7; margin-top: 2px; text-align: right; }
.chat-compose { display: flex; flex-direction: column; gap: 6px; }
.chat-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chat-quick .chip { flex: none; border: 0; cursor: pointer; font: inherit; font-size: .85rem; }
.chat-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input { flex: 1; resize: none; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); font: inherit; max-height: 120px; }
.chat-input:focus { border-color: var(--accent); outline: none; }
.chat-send { width: 46px; height: 46px; padding: 0; border-radius: 50%; justify-content: center; font-size: 1.1rem; }
.msg-badge { text-decoration: none; background: var(--accent); }
.challenge-row { align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; }
.challenge-row .li-main p { margin: 2px 0 0; }
.level-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.challenge-row > .row.gap { flex-basis: 100%; padding-left: 52px; }

/* ---------- Layout system: even spacing, three sizes ----------
   Buttons:  small 40px · normal 48px · full width 56px
   Cards:    compact 64px · standard 84px (two lines of text at most)
   Spacing:  10px between cards and between buttons */
:root { --gap: 10px; --btn-s: 40px; --btn-m: 48px; --btn-l: 56px; --card-s: 64px; --card-m: 100px; }

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row.gap, .row.gap.wrap { gap: var(--gap); }
.choice-list, .course-list, .lesson-list, .leaderboard, .dict-results, .edit-rows,
.unit-lessons, .lesson-actions, .topic-grid, .level-grid, .practice-grid, .goal-options, .pz-tools { gap: var(--gap); }

.btn { min-height: var(--btn-m); padding: 10px 18px; line-height: 1.2; }
.btn.small { min-height: var(--btn-s); padding: 8px 14px; }
.btn.block { min-height: var(--btn-l); }
.btn.small.block { min-height: var(--btn-s); }
/* Buttons side by side share the width equally. */
.row.gap > .btn.grow, .row.gap > .grow { flex: 1 1 0; min-width: 0; }
.install-banner-btn { min-height: var(--btn-m); }
.chip, .pill { line-height: 1.3; }

/* Standard list cards: same height, icon, title and up to two lines. */
.game-card, .library-card, .dict-card, .friends-card, .card.goal, .card.review,
.lesson-open, .course-option, .choice, .card.category, .install-card {
  min-height: var(--card-m); padding: 14px 16px; gap: 14px; text-align: left;
}
.course-option, .choice { width: 100%; font: inherit; color: inherit; text-decoration: none; }
.game-icon, .lesson-icon { width: 48px; height: 48px; border-radius: 14px; font-size: 1.6rem; }
.game-card .path-body, .library-card .path-body, .friends-card .path-body, .course-option .li-main, .choice-text { min-width: 0; flex: 1; }
.game-card .path-body p, .library-card .path-body p, .friends-card .path-body p, .dict-card-text small,
.course-option .li-main p, .choice-text small, .lesson-open .li-main p {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 0; line-height: 1.3;
}
.course-option .flag, .choice-icon { width: 48px; text-align: center; font-size: 1.7rem; flex: none; }
.course-option > .icon:last-child { margin-left: auto; color: var(--muted); }
/* Compact rows */
.dict-row, .person-row, .request-row, .token-row, .challenge-row, .topic-done, .myword { min-height: var(--card-s); }
.dict-row, .level-btn, .topic-chip, .topic-pick { text-align: left; }
.level-btn { min-height: var(--card-s); justify-content: center; }
.topic-chip { min-height: var(--btn-m); }
.install-banner { cursor: pointer; }
.install-how h3 { margin: 8px 0 4px; font-size: 1rem; }

/* ---------- Handwriting ---------- */
.hand-glyph { display: inline-block; vertical-align: middle; overflow: visible; }
.hand-glyph path { fill: none; stroke: currentColor; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.hand-text { display: inline-flex; flex-wrap: wrap; align-items: center; row-gap: 4px; }
.hand-space { display: inline-block; width: .6em; }
.hand-char { font-size: 1.1em; }
.hand-message { line-height: 1; }
.hand-panel { display: flex; flex-direction: column; gap: var(--gap); padding: 12px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hand-panel[hidden] { display: none; }
.hand-preview { min-height: 52px; display: flex; align-items: center; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); overflow-x: auto; }
.hand-keys { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.hand-keys.extra { grid-template-columns: 2fr repeat(5, minmax(0, 1fr)); }
.hand-key {
  min-height: var(--btn-s); padding: 2px; display: grid; place-items: center;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer;
}
.hand-key.missing { color: var(--muted); border-style: dashed; font-weight: 500; }
.chat-hand-btn { width: 46px; min-height: 46px; padding: 0; border-radius: 50%; font-size: 1.2rem; flex: none; }
.chat-hand-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.game-card h3, .library-card h3, .friends-card h3, .card.goal h3, .card.review h3 { margin: 0; line-height: 1.3; }

/* Class links (#class-…): one lesson from a teacher's QR code, no tab bar */
body.class-mode .tabbar { display: none; }
body.class-mode:not(.in-session) main { padding-bottom: calc(var(--safe-b) + 24px); }
.class-page { display: flex; flex-direction: column; gap: var(--gap); }
.class-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 16px; }
.class-hero h2 { margin: 0; }
.class-hero p { margin: 0; }
.class-icon { font-size: 2.4rem; line-height: 1; margin-bottom: 4px; }
.class-kicker { font-weight: 700; color: var(--accent); font-size: .9rem; }
.class-items { display: flex; flex-direction: column; gap: 6px; }
.class-items p { margin: 0; }
.class-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.class-chip { display: inline-flex; align-items: baseline; gap: 6px; }
.class-chip .ru { font-weight: 700; }
.class-summary { text-align: center; font-weight: 600; margin: 0; }
.class-lessons { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.class-lessons p { margin: 0; }
.class-lessons .btn.small { min-width: 48px; }
.class-footer { margin-top: 8px; }
.qr-box { background: #fff; border-radius: 12px; padding: 4px; display: block; line-height: 0; width: 100%; max-width: 280px; align-self: center; }
.class-url { word-break: break-all; }
.qr-box svg { width: 100%; height: auto; display: block; }

/* Friends leaderboard: profile picture and message button in the row */
.lb-avatar { flex: none; border-radius: 50%; line-height: 0; }
.lb-msg { position: relative; flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.lb-msg .icon { width: 20px; height: 20px; }
.lb-msg-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad, #e5484d); color: #fff; font-size: .7rem; font-weight: 800; line-height: 18px; text-align: center; }
.lb-extra .cheer-row { flex-wrap: nowrap; justify-content: space-between; gap: 6px; }
.lb-extra .cheer-btn { width: 40px; height: 40px; font-size: 1.15rem; flex: none; }

/* Alphabet along the way: letters of the word after a correct answer */
.letter-peek { display: flex; flex-direction: column; gap: 8px; }
.letter-peek-list { display: flex; flex-wrap: wrap; gap: 8px; }
.letter-peek-item { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px 4px 6px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.lp-glyph { display: grid; place-items: center; min-width: 40px; height: 32px; padding: 0 4px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 1.1rem; }
.lp-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.lp-text small { color: var(--muted); font-size: .72rem; }
.letter-check { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); }
.lc-question { margin: 0; font-size: .95rem; }
.lc-options { display: flex; gap: 8px; }
.lc-option { flex: 1 1 0; min-height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.lc-option.right { border-color: var(--good); background: var(--good-soft); }
.lc-option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.lc-status:empty { display: none; }
.lc-status { font-size: .88rem; color: var(--muted); }

/* Fill the gaps (gapped texts) */
.cloze-text { font-size: 1.15rem; line-height: 2.1; margin: 0; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1.5px solid var(--line); }
.cloze-gap { display: inline-flex; align-items: center; justify-content: center; height: 1.7em; padding: 0 6px; margin: 0 2px; vertical-align: middle; border-bottom: 2px solid var(--line); border-radius: 6px 6px 0 0; background: var(--surface-2); line-height: 1; }
.cloze-gap.current { border-color: var(--accent); background: var(--accent-soft); }
.cloze-gap.filled { background: var(--good-soft); border-color: var(--good); font-weight: 700; }
.cloze-gap.shown { background: var(--bad-soft); border-color: var(--bad); font-weight: 700; }
.cloze-num { font-size: .7rem; color: var(--muted); font-weight: 700; }
.cloze-bank .tile.used { visibility: hidden; }
.tile.shake { animation: shake .35s; border-color: var(--bad); }
.dictation-input { width: 100%; min-height: 56px; padding: 0 16px; font: inherit; font-size: 1.2rem; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.dictation-input:focus { outline: none; border-color: var(--accent); }
.dictation-ex { gap: var(--gap); }
.edit-text { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.edit-text:last-child { border-bottom: 0; padding-bottom: 0; }
.edit-text textarea, .edit-text input { width: 100%; font: inherit; padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); resize: vertical; }
.gap-preview { margin: 0; }

/* Teacher home */
.teach-home { display: flex; flex-direction: column; gap: var(--gap); }
.teach-home .section-title { margin: 12px 0 0; }
.teach-hero { display: flex; flex-direction: column; gap: 8px; }
.teach-hero h2, .teach-hero p { margin: 0; }
.teach-stats { display: flex; align-items: center; gap: 12px; }
.teach-stats-icon { font-size: 1.8rem; }
.teach-stats p { margin: 2px 0 0; }
.teach-empty p { margin: 0; }
.pill.status-class { background: var(--good-soft); color: var(--good); }

/* Admin: words from teachers */
.contrib-summary p { margin: 0; }
.contrib-summary { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.contrib-row { display: flex; align-items: flex-start; gap: 12px; }
.contrib-row input[type=checkbox] { width: 22px; height: 22px; margin-top: 4px; flex: none; }
.contrib-row .li-main p { margin: 2px 0 0; }
.contrib-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; }
.contrib-actions { display: flex; gap: 6px; flex: none; }
.icon-btn.good { color: var(--good); }
.icon-btn.bad { color: var(--bad); }
.pill.kind-word, .pill.kind-phrase { font-size: .7rem; }
.letters-watch { margin: 0; }
.profile-activity { display: flex; flex-direction: column; gap: 16px; }
.mastery-course { margin: 0; font-weight: 700; }

/* Layered avatars (several emojis placed by the person) */
.avatar.layered { position: relative; overflow: hidden; display: block; }
.av-layer { position: absolute; line-height: 1; white-space: nowrap; pointer-events: none; user-select: none; }

/* Avatar creator */
.av-editor { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.av-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; }
.av-stage { display: grid; place-items: center; }
.av-canvas { position: relative; width: clamp(110px, min(42vw, 26dvh), 200px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; touch-action: none; box-shadow: var(--shadow); }
.av-layer.editable { pointer-events: auto; cursor: grab; touch-action: none; padding: 2px; border-radius: 8px; }
.av-layer.editable.selected { outline: 2px dashed rgba(255, 255, 255, .9); outline-offset: 2px; }
.av-initial { position: absolute; inset: 0; display: grid; place-items: center; font-size: 5rem; font-weight: 800; color: rgba(255, 255, 255, .55); }
.av-controls { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.av-controls p { margin: 0; text-align: left; }
.av-selected { display: flex; align-items: center; gap: 8px; min-width: 0; }
.av-selected .small { line-height: 1.2; min-width: 0; }
.av-selected-emoji { font-size: 1.6rem; line-height: 1; }
.av-remove { width: 36px; height: 36px; flex: none; border: 1.5px solid var(--line); background: var(--surface); }
.av-remove .icon { width: 18px; height: 18px; }
.av-slider { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; min-height: 28px; }
.av-slider input { width: 100%; accent-color: var(--accent); margin: 0; }
.av-controls .btn.small { min-height: 34px; }
.av-tabs button { font-size: .9rem; }
.av-editor .emoji-grid { flex: 1 1 auto; min-height: 92px; overflow-y: auto; align-content: start; padding: 2px; margin: -2px; overscroll-behavior: contain; }
.av-editor .emoji-opt { font-size: 1.3rem; }
.av-bottom { display: flex; align-items: center; gap: 8px; }
.av-bottom .swatches { flex: 1; min-width: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; padding: 5px; } /* one row, however many colours */
.av-bottom .swatch { width: 100%; height: auto; aspect-ratio: 1; max-width: 34px; justify-self: center; }
.av-bottom .swatch .icon { width: 14px; height: 14px; }
.av-bottom .swatch[aria-pressed="true"] { outline-width: 2.5px; }
.av-reset { width: 38px; height: 38px; flex: none; border: 1.5px solid var(--line); background: var(--surface); }
.av-reset .icon { width: 18px; height: 18px; }
/* The avatar stays in view while scrolling through the emojis. */


/* "What's new" banner */
.news-banner { position: relative; display: flex; flex-direction: column; gap: 10px; border-color: var(--accent); background: linear-gradient(135deg, var(--accent-soft), var(--surface)); }
.news-head { display: flex; align-items: center; gap: 14px; padding-right: 36px; }
.news-head h3 { margin: 2px 0; }
.news-head p { margin: 0; }
.news-also { margin: 0; }
.news-close { position: absolute; top: 8px; right: 8px; }

/* Calendar: exactly 16 columns that always fit the card. */
.cal-grid { grid-template-columns: repeat(16, minmax(0, 1fr)); grid-auto-columns: minmax(0, 1fr); overflow: hidden; min-width: 0; }
.cal-day { min-width: 0; width: 100%; }
.calendar, .summary, .profile-activity { min-width: 0; }

/* No zooming: no double-tap zoom, and no zoom when a text field gets focus
   (iPhones zoom into fields with text smaller than 16px). */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
input, textarea, select { font-size: max(16px, 1em); }
/* Daily goal choices never stick out on narrow phones. */
.goal-options > button { min-width: 0; }
@media (max-width: 360px) { .goal-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Puzzle tools: four buttons that always fit */
.pz-tools .btn { min-width: 0; gap: 3px; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 2px; padding-right: 2px; }
.pz-tools .btn .icon { width: 15px; height: 15px; }
@media (max-width: 360px) { .pz-tools .btn .icon { display: none; } }
.pz-tools .btn .icon { flex: none; }

/* Long words (emails, links) wrap instead of widening the page. */
.li-main, .li-main *, .card p, .card h3, .notice, .chat-list p { min-width: 0; overflow-wrap: anywhere; }
/* Safety net: nothing can make the whole app wider than the screen (that
   also moved the tab bar on iPhones). */
html, body { max-width: 100%; overflow-x: clip; }
.filter-chips { flex-wrap: wrap; }
.practice-tile strong { font-size: clamp(.8rem, 3.9vw, 1rem); }
@media (max-width: 360px) { .practice-tile { padding: 12px 10px; } }
.recommend { display: flex; flex-direction: column; gap: 8px; }
.recommend .section-title { margin: 6px 0 0; }
.recommend-card { min-height: var(--card-s, 64px); }
.recommend-card h3 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill.new-pill { background: var(--accent); color: var(--accent-ink, #fff); font-size: .7rem; }

/* Jump to a chapter */
.jump-sheet { gap: 8px; }
.jump-section { margin: 10px 0 0; font-size: .9rem; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.jump-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: var(--btn-l, 56px); padding: 8px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.jump-icon { font-size: 1.4rem; width: 32px; text-align: center; flex: none; }
.jump-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.jump-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jump-state.done { color: var(--good); }
.jump-state.done .icon { width: 20px; height: 20px; }
.math-q.long { font-size: clamp(1.1rem, 4.6vw, 1.35rem); line-height: 1.45; font-weight: 700; text-align: left; }

/* ===== Games: boards, cards, drawing ===== */
.game-page { display: flex; flex-direction: column; gap: var(--gap); }
.game-result:empty { display: none; }
/* Games with friends: × closes a game (ends it for both) or removes it. */
.match-row { display: flex; align-items: center; gap: 6px; }
.match-row > .card { flex: 1; min-width: 0; }
.match-row.closed > .card { opacity: .7; }
.match-close { flex: none; width: 40px; height: 40px; border: 1.5px solid var(--line); background: var(--surface); }
.match-close .icon { width: 18px; height: 18px; }
.match-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.match-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.match-head .match-close { width: 36px; height: 36px; }
/* "Russian in games" switch on the Games page */
.games-ru { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.games-ru-flag { font-size: 1.5rem; }
.games-ru-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.games-ru-text small { font-size: .82rem; }
/* Pages with more text around the board leave it a bit more room. */
.chess-lesson-page { --board-room: 200px; }
.game-page:has(> .match-head) { --board-room: 214px; }
.game-status { margin: 0; text-align: center; font-weight: 700; min-height: 1.5em; }
.game-tools { flex-wrap: wrap; }
.match-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); width: min(100%, 480px, max(220px, calc(var(--view-h) - var(--board-room, 160px)))); margin: 0 auto; aspect-ratio: 1; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); touch-action: manipulation; }
.sq { position: relative; display: grid; place-items: center; padding: 0; border: 0; aspect-ratio: 1; cursor: pointer; }
.sq.light { background: #eedfc5; }
.sq.dark { background: #b58863; }
.draughts-board .sq.light { background: #f1e6d0; }
.draughts-board .sq.dark { background: #7a5236; }
.sq.last { box-shadow: inset 0 0 0 100px rgba(255, 214, 10, .28); }
.sq.sel { box-shadow: inset 0 0 0 3px #ffd60a, inset 0 0 0 100px rgba(255, 214, 10, .35); }
.sq.target::after { content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 30, 50, .35); }
.sq.target.cap::after { width: 86%; height: 86%; background: none; border: 4px solid rgba(20, 30, 50, .35); }
.sq.goal { box-shadow: inset 0 0 0 3px #e5484d; }
.piece { font-size: min(9.2vw, 46px); line-height: 1; pointer-events: none; user-select: none; }
.piece.white { color: #fff; text-shadow: 0 0 1px #000, 0 0 2px #000, 1px 1px 0 #333, -1px -1px 0 #333; }
.piece.black { color: #1b1d24; text-shadow: 0 0 1px #fff3; }
.dr-piece { width: 78%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: min(5vw, 24px); pointer-events: none; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .3); }
.dr-piece.white { background: #f6f0e4; color: #b8860b; }
.dr-piece.black { background: #2a2321; color: #f0c040; }
.piece-name { display: inline-flex; align-items: center; gap: 8px; align-self: center; min-height: var(--btn-s); padding: 4px 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.piece-name .icon { width: 18px; height: 18px; color: var(--accent); }
.piece-name-glyph { font-size: 1.5rem; line-height: 1; }
.promo-btn { flex-direction: column; min-height: 72px; }
.promo-btn .piece { font-size: 2rem; color: var(--ink); text-shadow: none; }
.lesson-text { margin: 0; }
.lessons-intro p { margin: 0; }
.notice.good { border-color: var(--good); background: var(--good-soft); }

.four-board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; width: min(100%, 420px, max(240px, calc((var(--view-h) - var(--board-room, 160px)) * 7 / 6))); margin: 0 auto; padding: 8px; border-radius: 14px; background: #2a5bd7; }
.four-col { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; }
.four-col:disabled { cursor: default; }
.four-cell { aspect-ratio: 1; border-radius: 50%; background: #e9eef9; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3); }
.four-cell.x { background: #e5484d; }
.four-cell.o { background: #ffc53d; }
.four-cell.win { outline: 3px solid #fff; outline-offset: -3px; }

.durak-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.durak-opp { display: flex; flex-direction: column; gap: 4px; }
.card-backs { display: flex; }
.card-back { display: inline-block; width: 28px; height: 40px; border-radius: 5px; background: repeating-linear-gradient(45deg, #2a51c0, #2a51c0 4px, #3d63d4 4px, #3d63d4 8px); border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.card-backs .card-back + .card-back { margin-left: -18px; }
.durak-deck { display: flex; gap: 10px; align-items: center; }
.deck-stack { position: relative; }
.deck-count { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; }
.trump { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.card-face { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 52px; height: 76px; flex: none; border-radius: 8px; border: 1.5px solid #c9c4b8; background: #fff; color: #1b1d24; font: inherit; font-weight: 800; line-height: 1; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); cursor: default; padding: 0; }
.card-face.small { width: 44px; height: 64px; }
.card-face.red { color: #d1373f; }
.card-face .card-rank { font-size: 1.1rem; }
.card-face .card-suit { font-size: 1.4rem; }
.card-face.playable { cursor: pointer; border-color: var(--accent); transform: translateY(-6px); box-shadow: 0 6px 10px rgba(0, 0, 0, .18); }
.card-face:disabled { opacity: 1; }
.durak-table { display: flex; flex-wrap: wrap; gap: 14px 10px; justify-content: center; min-height: 90px; padding: 10px; border-radius: var(--radius); background: color-mix(in srgb, var(--good) 22%, var(--surface)); }
.durak-pair { position: relative; width: 60px; height: 82px; }
.durak-def { position: absolute; left: 12px; top: 14px; }
.durak-hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding-top: 8px; }
/* Small phones: a little less room around the cards, so the hand stays on screen. */
@media (max-height: 620px) {
  .durak-table { min-height: 76px; padding: 6px; }
  .durak-pair { height: 74px; }
  .card-face { width: 46px; height: 68px; }
  .sea-page > p.muted.small { display: none; }
}
@media (max-width: 340px) {
  .draw-row .draw-size { width: 34px; height: 34px; }
  .draw-row.row.gap { gap: 5px; }
  .draw-row .btn.small { padding-left: 8px; padding-right: 8px; }
  .draw-page { --draw-room: 200px; }
  .durak-hand { gap: 4px; }
  .durak-hand .card-face { width: 42px; height: 62px; }
  .game-tools .btn { padding-left: 8px; padding-right: 8px; font-size: .9rem; }
}
.rules ul { padding-left: 20px; margin: 0; display: grid; gap: 6px; }

.sea-title { margin: 4px 0 0; font-size: .95rem; }
.sea-grid { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 2px; width: 100%; max-width: 420px; margin: 0 auto; }
.sea-grid.setup { width: min(100%, 420px, max(220px, calc(var(--view-h) - 236px))); }
.sea-grid.enemy { width: min(100%, 420px, max(220px, calc(var(--view-h) - 214px))); }
.sea-grid.own { width: 100%; gap: 1px; }
.sea-grid.own .sea-label, .sea-grid.own .sea-corner { font-size: .5rem; }
.sea-grid.own .sea-cell { border-radius: 2px; }
/* Battle: your own fleet small next to the buttons, so both fit. */
.sea-bottom { display: flex; align-items: flex-start; gap: 12px; width: 100%; max-width: 420px; margin: 0 auto; }
.sea-own { flex: none; width: clamp(120px, 38vw, 170px); }
.sea-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sea-side .sea-title { margin: 0; }
.sea-side p { margin: 0; text-align: left; }
.sea-label, .sea-corner { display: grid; place-items: center; font-size: .7rem; color: var(--muted); font-weight: 700; }
.sea-cell { aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; background: color-mix(in srgb, #2a7de1 22%, var(--surface)); position: relative; cursor: pointer; }
.sea-cell.ship { background: #6b7280; }
.sea-cell.hit { background: #e5484d; }
.sea-cell.hit::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: .8rem; }
.sea-cell.miss::after { content: ''; position: absolute; inset: 38%; border-radius: 50%; background: var(--muted); }
.sea-cell.miss.auto::after { opacity: .45; }
.sea-cell:disabled { cursor: default; }

.mine-grid { display: grid; gap: 2px; margin: 0 auto; width: min(100%, 460px, max(200px, calc((var(--view-h) - 150px) * var(--cols, 9) / var(--rows, 9)))); }
.mine-cell { aspect-ratio: 1; padding: 0; border: 0; border-radius: 4px; background: color-mix(in srgb, var(--accent) 35%, var(--surface)); font: inherit; font-weight: 800; font-size: clamp(.7rem, 3.4vw, 1.05rem); cursor: pointer; color: var(--ink); }
.mine-cell.open { background: var(--surface-2); cursor: default; }
.mine-cell.boom { background: #e5484d; }
.mine-cell.n1 { color: #2a7de1; } .mine-cell.n2 { color: #22a35a; } .mine-cell.n3 { color: #e5484d; } .mine-cell.n4 { color: #6a3fc9; } .mine-cell.n5 { color: #b45309; } .mine-cell.n6 { color: #0f8a7d; }

.guess-lives { font-size: 1.1rem; letter-spacing: 1px; }
.guess-hint { margin: 0; text-align: center; }
.guess-word { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.guess-letter { display: grid; place-items: center; width: clamp(28px, 9vw, 40px); height: 46px; border-bottom: 3px solid var(--ink); font-size: 1.6rem; font-weight: 800; text-transform: lowercase; }
.guess-letter.blank { border-color: var(--muted); }
.guess-keys { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.guess-key { min-height: var(--btn-s); padding: 0; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer; }
.guess-key.good { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.guess-key.bad { opacity: .35; }

.draw-pad { display: flex; flex-direction: column; gap: 10px; }
.draw-canvas { width: min(100%, 480px, max(200px, calc(var(--view-h) - var(--draw-room, 196px)))); aspect-ratio: 1; margin: 0 auto; display: block; border-radius: var(--radius); border: 1.5px solid var(--line); background: #fff; touch-action: none; }
.draw-tools { display: flex; flex-direction: column; gap: 8px; }
.draw-colors { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; width: 100%; max-width: 360px; margin: 0 auto; }
.draw-colors .draw-color { width: 100%; max-width: 36px; justify-self: center; }
.draw-row { justify-content: center; }
.draw-row .btn.small { min-height: var(--btn-s); padding-left: 10px; padding-right: 10px; }
.draw-row .btn.small .icon { width: 18px; height: 18px; }
.draw-color { aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; }
.draw-color[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.draw-row { flex-wrap: wrap; gap: 6px; }
.draw-size { display: grid; place-items: center; width: var(--btn-s); height: var(--btn-s); border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; padding: 0; }
.draw-size span { display: block; border-radius: 50%; background: var(--ink); }
.draw-size[aria-pressed="true"], .draw-eraser[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.guess-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.game-tools .btn { white-space: nowrap; }
.sea-fleet { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; font-size: .8rem; letter-spacing: 1px; color: var(--accent); }
.sea-ship.done { color: var(--muted); opacity: .45; }
.sea-grid.setup { max-width: 420px; }

/* Menu language */
.lang-picker button { flex: 1 1 0; min-width: 0; }
.welcome-lang { display: flex; justify-content: center; margin: 0 auto 4px; width: min(100%, 280px); }
.welcome-lang .lang-picker { width: 100%; }
.welcome-lang .lang-picker button { padding: 6px 8px; font-size: .9rem; }
.news-flag { font-size: 2.4rem; line-height: 1; }
.news-banner h3 { font-weight: 800; }
.news-banner .row.gap > .btn { padding-inline: 10px; white-space: nowrap; }

/* ---------- Polish: colourful icon tiles, gentle entrances, press feedback ---------- */

/* Icon tiles in lists get a soft colour, cycling through six hues. */
.lesson-icon, .game-icon {
  --ti-a: #5287ef; --ti-b: #2a51c0;
  background: linear-gradient(140deg, color-mix(in srgb, var(--ti-a) 20%, var(--surface)), color-mix(in srgb, var(--ti-b) 26%, var(--surface)));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ti-b) 16%, transparent);
}
:nth-child(6n+2) > .lesson-icon, :nth-child(6n+2) > .game-icon { --ti-a: #2ccaa5; --ti-b: #0f8a7d; }
:nth-child(6n+3) > .lesson-icon, :nth-child(6n+3) > .game-icon { --ti-a: #ffb547; --ti-b: #ee6236; }
:nth-child(6n+4) > .lesson-icon, :nth-child(6n+4) > .game-icon { --ti-a: #9b6cf0; --ti-b: #6a3fc9; }
:nth-child(6n+5) > .lesson-icon, :nth-child(6n+5) > .game-icon { --ti-a: #ffd35a; --ti-b: #f0a000; }
:nth-child(6n) > .lesson-icon, :nth-child(6n) > .game-icon { --ti-a: #f06aa4; --ti-b: #c9306f; }
@media (prefers-color-scheme: dark) {
  .lesson-icon, .game-icon {
    background: linear-gradient(140deg, color-mix(in srgb, var(--ti-a) 26%, var(--surface)), color-mix(in srgb, var(--ti-b) 34%, var(--surface)));
  }
}
.menu-icon { transition: transform .2s cubic-bezier(.34, 1.56, .64, 1); }
.menu-row:active .menu-icon, a.card:active .lesson-icon, a.card:active .game-icon { transform: scale(.92); }

/* Page content comes in one after another (not in lessons). */
body:not(.in-session) .page-enter { animation: none; }
body:not(.in-session) .page-enter > * { animation: rise .3s ease-out both; }
body:not(.in-session) .page-enter > :nth-child(2) { animation-delay: .03s; }
body:not(.in-session) .page-enter > :nth-child(3) { animation-delay: .06s; }
body:not(.in-session) .page-enter > :nth-child(4) { animation-delay: .09s; }
body:not(.in-session) .page-enter > :nth-child(5) { animation-delay: .12s; }
body:not(.in-session) .page-enter > :nth-child(6) { animation-delay: .15s; }
body:not(.in-session) .page-enter > :nth-child(7) { animation-delay: .18s; }
body:not(.in-session) .page-enter > :nth-child(n+8) { animation-delay: .2s; }

/* Buttons and choices give way a little when pressed. */
.btn, .choice, .chip, .segmented button { transition: transform .12s ease-out, background-color .2s, box-shadow .2s; }
.btn:active:not(:disabled), .choice:active, .chip:active, .segmented button:active { transform: scale(.97); }

/* The tab you switch to bounces once. */
.tabbar a.active .icon { animation: tab-pop .42s cubic-bezier(.34, 1.56, .64, 1); }
.tabbar a:active .icon { transform: scale(.9); }
@keyframes tab-pop { 0% { transform: scale(.82); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.calendar > .row.between { flex-wrap: wrap; gap: 2px 12px; align-items: baseline; }
.calendar > .row.between > strong { white-space: nowrap; }
.calendar > .row.between > span { margin-left: auto; }
.xp-pill { align-self: center; padding: 3px 12px; border-radius: 99px; background: var(--gold-soft, #fff4d6); color: #9a6a00; font-weight: 800; font-size: .9rem; animation: pop .45s .2s ease-out both; }
@media (prefers-color-scheme: dark) { .xp-pill { background: #3a2f12; color: #ffd35a; } }

/* ---------- Admin: email settings and contact inbox ---------- */
.admin-tabs { overflow-x: auto; scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs a { flex: 1 0 auto; padding: 0 12px; white-space: nowrap; }
.notice.info { background: var(--accent-soft); }
.notice.info .icon { color: var(--accent); }
.notice p { margin: 2px 0 0; }
.mail-form h3, .mail-help h3 { margin: 0; }
.mail-form select, .contact-text {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.mail-advanced summary, .mail-log summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: 4px 0; }
.mail-advanced[open] > .stack { margin-top: 10px; }
.mail-log pre {
  margin: 8px 0 0; padding: 10px; max-height: 260px; overflow: auto; border-radius: 10px;
  background: var(--surface-2); font-size: .75rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mail-result { display: flex; flex-direction: column; gap: 8px; }
.mail-result:empty { display: none; }
.mail-help ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.contact-item.unread { border-color: var(--accent); }
.contact-subject { margin: 0; font-weight: 700; }
.contact-message, .contact-answer p:last-child { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.contact-answer { padding: 10px 12px; border-radius: 8px; background: var(--good-soft); }
.contact-answer p { margin: 0; }
.contact-reply:empty { display: none; }
.contact-text { resize: vertical; min-height: 110px; }

/* Links to Impressum, privacy notice, terms, contact */
.legal-links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; }
.legal-links.center { justify-content: center; margin-top: 8px; }
.legal-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.auth-legal { margin: 0; }
.mail-form, .admin-content > section.card.stack { align-items: stretch; text-align: left; }
.mail-form h3, .admin-content > section.card.stack h3 { text-align: left; }

/* ---------- Support chat, roles, newsletter ---------- */
.tabbar a.has-dot { position: relative; }
.tabbar a.has-dot::after {
  content: ""; position: absolute; top: 6px; left: calc(50% + 12px); width: 9px; height: 9px;
  border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--surface);
}
.badge { flex: none; min-width: 22px; padding: 2px 8px; border-radius: 99px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 800; text-align: center; }
.verify-notice { position: relative; padding-right: 44px; }
.verify-notice .btn { margin-top: 8px; }
.verify-notice .news-close { position: absolute; top: 6px; right: 6px; }
.setting-row input[role="switch"] { flex: none; }
.user-pills { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 45%; }
.pill.role { background: var(--accent-soft); color: var(--accent); }
.pill.unverified { background: var(--surface-2); color: var(--muted); }
.role-toggles { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1.5px dashed var(--line); }
.role-toggles p { flex-basis: 100%; margin: 0; }
.support-filters button .count { opacity: .7; }
.support-list { gap: 8px; }
.support-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px; text-decoration: none; color: inherit; }
.support-row.unread { border-color: var(--accent); }
.support-src { font-size: 1.4rem; line-height: 1.2; }
.support-row-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.support-row .li-main p { margin: 2px 0 0; }
.support-subject { font-weight: 600; }
.support-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.unread-dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--accent); }
.support-back { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--accent); text-decoration: none; }
.support-back .icon { width: 18px; height: 18px; }
.support-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.support-head h2 { margin: 0; font-size: 1.2rem; }
.support-head p { margin: 2px 0 0; }
.support-subject-big { font-weight: 700; }
.support-status, .support-text {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit;
}
.support-text { width: 100%; resize: vertical; min-height: 96px; }
.bubbles { display: flex; flex-direction: column; gap: 10px; }
.bubbles .bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); }
.bubbles .bubble p { margin: 0; }
.bubbles .bubble-meta { font-size: .75rem; color: var(--muted); font-weight: 600; margin-bottom: 4px !important; }
.bubbles .bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubbles .bubble.user { align-self: flex-start; border-radius: 16px 16px 16px 4px; }
.bubbles .bubble.staff, .bubbles .bubble.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; color: var(--ink); border-radius: 16px 16px 4px 16px; }
.support-chat .bubble.staff { align-self: flex-start; background: var(--surface); border-color: var(--line); border-radius: 16px 16px 16px 4px; }
.bubbles .bubble.note { align-self: stretch; max-width: none; background: #fff6d6; border-color: #f1d77a; border-style: dashed; }
@media (prefers-color-scheme: dark) { .bubbles .bubble.note { background: #3a3215; border-color: #6d5c1d; } }
.support-filters button, .support-modes button { white-space: nowrap; }
.support-compose { display: flex; flex-direction: column; gap: 10px; }
.support-compose p { margin: 0; }
.support-modes button { font-size: .85rem; padding: 0 6px; }
.ai-note:empty { display: none; }
.support-hello { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: 16px; background: var(--accent-soft); }
.support-hello p { margin: 0; }
.support-page { gap: 14px; }
.nl-summary p { margin: 0; }
.pill.nl-sent { background: var(--good-soft); color: var(--good); }
.pill.nl-sending { background: var(--accent-soft); color: var(--accent); }
.nl-form input, .nl-body {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit;
}
.nl-body { min-height: 260px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; line-height: 1.5; }
.nl-help summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.nl-help ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.nl-help code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }
.nl-preview { width: 100%; height: 520px; border: 1.5px solid var(--line); border-radius: 12px; background: #f6f5f2; }
.nl-progress .bar { margin-top: 4px; }
.nl-progress:empty { display: none; }
.nl-send { gap: 10px; }

/* ---------- Banners (announcements) ---------- */
.announce {
  --b-a: #5287ef; --b-b: #2a51c0;
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 12px;
  border: 0; color: #fff; background: linear-gradient(135deg, var(--b-a), var(--b-b));
  box-shadow: 0 8px 24px -14px var(--b-b);
}
.announce.tone-teal { --b-a: #2ccaa5; --b-b: #0f8a7d; }
.announce.tone-warm { --b-a: #ffb547; --b-b: #ee6236; }
.announce.tone-gold { --b-a: #f7c948; --b-b: #d98e04; }
.announce.tone-purple { --b-a: #9b6cf0; --b-b: #6a3fc9; }
.announce.tone-pink { --b-a: #f06aa4; --b-b: #c9306f; }
.announce-head { display: flex; gap: 12px; align-items: flex-start; padding-right: 32px; }
.announce-emoji { font-size: 2rem; line-height: 1; flex: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,.15)); }
.announce h3 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 800; color: #fff; }
.announce p { margin: 0; font-size: .92rem; line-height: 1.45; color: rgba(255,255,255,.92); white-space: pre-line; }
.announce .announce-btn { align-self: flex-start; background: #fff; color: var(--b-b); border: 0; font-weight: 800; min-height: 40px; padding: 0 18px; }
.announce .announce-close { position: absolute; top: 6px; right: 6px; color: #fff; background: rgba(255,255,255,.16); }
.announce .announce-close:active { background: rgba(255,255,255,.3); }
.announce-off { align-self: flex-start; padding: 2px 0; border: 0; background: none; color: rgba(255,255,255,.8); font-size: .75rem; text-decoration: underline; cursor: pointer; }
.banner-preview { pointer-events: auto; }
.banner-preview .announce { margin: 0; }
.pill.banner-live { background: var(--good-soft); color: var(--good); }
.pill.banner-ended { background: var(--surface-2); color: var(--muted); }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.template-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.template-card .muted { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.template-emoji { font-size: 1.8rem; line-height: 1.1; }
.banner-form input:not([type="checkbox"]), .banner-select, .banner-text {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit;
}
.banner-text { min-height: 84px; font-family: inherit; }
.emoji-input { width: 72px !important; text-align: center; font-size: 1.4rem !important; }
.banner-form .field.grow { flex: 1 1 140px; min-width: 0; }
.tone-row { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.tone-swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; background: linear-gradient(135deg, #5287ef, #2a51c0); }
.tone-swatch.tone-teal { background: linear-gradient(135deg, #2ccaa5, #0f8a7d); }
.tone-swatch.tone-warm { background: linear-gradient(135deg, #ffb547, #ee6236); }
.tone-swatch.tone-gold { background: linear-gradient(135deg, #f7c948, #d98e04); }
.tone-swatch.tone-purple { background: linear-gradient(135deg, #9b6cf0, #6a3fc9); }
.tone-swatch.tone-pink { background: linear-gradient(135deg, #f06aa4, #c9306f); }
.tone-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--ink); }
.preview-lang button { padding: 4px 10px; min-height: 32px; font-size: .8rem; }

/* ---------- Home: compact stats, quick grid ---------- */
/* Stats: icon on the left, number and label next to it (lower, so the path shows sooner). */
.home .stats { margin-top: 12px; gap: 8px; }
.home .stat { padding: 8px 6px; gap: 2px; }
.stat-top { display: flex; align-items: center; justify-content: center; gap: 6px; }
.home .stat strong { font-size: 1.15rem; line-height: 1.2; }
.home .stat > span:last-child { font-size: .72rem; line-height: 1.2; text-align: center; }
a.stat { color: inherit; text-decoration: none; transition: transform .12s; }
a.stat:active { transform: scale(.96); }
.stat-goal .ring { width: 22px; height: 22px; --ring-a: var(--gold-a); --ring-b: var(--flame); }
.stat-goal .ring circle { stroke-width: 7; }
.stat-goal .ring span { font-size: .7rem; color: var(--good); }
/* Quick tiles: 2 × 2, emoji left, title and one line of text right. */
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.home-grid > :last-child:nth-child(odd) { grid-column: span 2; }
.home-tile {
  --t-a: #5287ef; --t-b: #2a51c0;
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto;
  column-gap: 9px; align-items: center; min-height: 64px; padding: 10px 10px; margin: 0;
  text-align: left; font: inherit; color: inherit; text-decoration: none; cursor: pointer; min-width: 0;
}
.home-tile:has(.tile-badge) { padding-right: 30px; }
.home-tile.tone-teal { --t-a: #2ccaa5; --t-b: #0f8a7d; }
.home-tile.tone-warm { --t-a: #ffb547; --t-b: #ee6236; }
.home-tile.tone-gold { --t-a: #ffd35a; --t-b: #f0a000; }
.home-tile.tone-purple { --t-a: #9b6cf0; --t-b: #6a3fc9; }
.home-tile.tone-pink { --t-a: #f06aa4; --t-b: #c9306f; }
.tile-emoji, .tile-faces { grid-row: span 2; }
.tile-emoji {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; font-size: 1.15rem;
  background: linear-gradient(140deg, color-mix(in srgb, var(--t-a) 22%, var(--surface)), color-mix(in srgb, var(--t-b) 30%, var(--surface)));
}
.tile-title { align-self: end; font-size: .92rem; line-height: 1.25; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { align-self: start; font-size: .75rem; line-height: 1.3; color: var(--muted); max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-badge { position: absolute; top: 8px; right: 8px; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 800; text-align: center; }
.tile-badge.new { background: var(--accent); }
.tile-faces { display: flex; align-items: center; }
.tile-faces > * { margin-right: -10px; box-shadow: 0 0 0 2px var(--surface); border-radius: 50%; }
.tile-faces > :last-child { margin-right: 0; }
.home-tile:active { transform: scale(.97); }

/* One-line greeting on the home screen (more room for the path). */
.hero-compact { align-items: center; }
.hero-line { margin: 0; font-size: 1.45rem; line-height: 1.2; font-weight: 800; }
.hero-line .hero-greet { display: inline; font-size: inherit; color: var(--muted); font-weight: 700; }
.hero-line .hero-name { display: inline; font-size: inherit; }
.home .card.next { padding-top: 14px; padding-bottom: 14px; }
.home .card.next h3 { margin: 2px 0; }
.path-earlier { display: flex; justify-content: center; padding: 4px 0 8px; list-style: none; }
.path-earlier .btn { gap: 6px; }

/* ---------- Streak freezes (js/freeze.js) ---------- */
.stat { position: relative; }
.freeze-badge { position: absolute; top: 4px; right: 5px; display: inline-flex; align-items: center; gap: 1px; padding: 1px 5px; border-radius: 999px; font-size: .66rem !important; font-weight: 800; line-height: 1.3; color: #1d6fb8 !important; background: color-mix(in srgb, #4aa8ff 18%, var(--surface)); }
:root[data-theme="dark"] .freeze-badge { color: #8ccaff !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .freeze-badge { color: #8ccaff !important; } }
.freeze-row { display: flex; gap: 12px; align-items: flex-start; margin: 12px 0 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, #4aa8ff 10%, var(--surface-2)); }
.freeze-row strong { display: block; }
.freeze-row p { margin: 2px 0 0; }
.freeze-icons { display: flex; gap: 2px; font-size: 1.25rem; line-height: 1.2; flex-shrink: 0; }
.freeze-icons span { filter: grayscale(1); opacity: .35; }
.freeze-icons span.on { filter: none; opacity: 1; }
.cal-day.frozen { background: color-mix(in srgb, #4aa8ff 55%, var(--surface-2)); }
.card.referral-card { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.referral-card p { margin: 0; }

/* ---------- Math: answer field + keypad (js/math/keypad.js) ---------- */
.prompt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prompt-row .prompt { margin: 0; }
.math-explain-btn { font-size: 1.15rem; flex-shrink: 0; width: 40px; height: 40px; }
.math-stage { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.math-refresh { margin: 0; align-self: center; font-size: .8rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 10px; border-radius: 99px; }
.math-q sup { font-size: .6em; }
.math-ex .math-q { padding: 4px 0; }
.math-ex .math-q:not(.long) { font-size: clamp(1.5rem, 7vw, 2.2rem); }
.mf { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.mf-field { display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 6px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow); }
.mf-field.locked { border-color: var(--line); }
.mf-field.correct { border-color: var(--good); background: var(--good-soft); }
.mf-field.wrong { border-color: var(--bad); background: var(--bad-soft); }
.mf-prefix { font-weight: 800; font-size: 1.25rem; white-space: nowrap; }
.mf-display { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; outline: none; overflow-x: auto; }
.mf-ch { padding: 0 1px; cursor: text; }
.mf-placeholder { color: var(--muted); font-weight: 600; }
.mf-caret { display: inline-block; width: 2px; height: 1.3em; margin: 0 1px; background: var(--accent); animation: mf-blink 1s steps(1) infinite; }
.mf-field.locked .mf-caret { display: none; }
@keyframes mf-blink { 50% { opacity: 0; } }
.mf-preview { text-align: center; font-size: 1.15rem; color: var(--muted); min-height: 0; }
.mf-preview[hidden] { display: none; }
.mf-keypad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: auto; }
.mf-keypad.mf-expr { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.mf-key { min-height: 44px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.mf-key.digit { background: var(--surface); box-shadow: var(--shadow); font-size: 1.2rem; }
.mf-key.wide { grid-column: span 2; }
.mf-key:active { transform: scale(.95); }
.mf-key:disabled { opacity: .5; }
.mf-expr .mf-key { min-height: 40px; font-size: .95rem; }
.mf-expr .mf-key.digit { font-size: 1.1rem; }
@media (max-height: 700px) { .mf-key { min-height: 38px; } .mf-expr .mf-key { min-height: 34px; } }
.m-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; font-size: .9em; }
.m-frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }
.m-frac > span:last-child { padding: 0 3px; }
.m-sqrt { white-space: nowrap; }
.m-rad { border-top: 1.5px solid currentColor; padding: 0 2px; }
.math-fb { display: flex; flex-direction: column; gap: 6px; }
.math-fb p { margin: 0; }
.math-diag { padding: 8px 10px; border-radius: 10px; background: var(--surface); font-size: .92rem; }
.math-steps { font-size: .92rem; }
.math-steps summary { font-weight: 700; cursor: pointer; }
.math-steps ol { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 2px; max-height: 26vh; overflow-y: auto; }
.math-explain-link { align-self: flex-start; }
.math-tip { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Math: interactive explanations (js/math/explain.js, widgets.js) ---------- */
.mx { display: flex; flex-direction: column; gap: 10px; }
.mx-head { display: flex; flex-direction: column; gap: 2px; }
.mx-head .eyebrow { margin: 0; }
.mx-title { margin: 0; font-size: 1.3rem; }
.mx-dots { display: flex; gap: 6px; margin-top: 4px; }
.mx-dots span { width: 22px; height: 5px; border-radius: 3px; background: var(--surface-2); }
.mx-dots .on { background: var(--accent); }
.mx-dots .done { background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.mx-text { margin: 0; font-size: 1rem; line-height: 1.45; }
.mx-ask { display: flex; flex-direction: column; gap: 6px; }
.mx-q { margin: 0; font-weight: 700; }
.mx-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.mx-opts .option { flex: 1 1 30%; min-height: 44px; padding: 8px 10px; justify-content: center; }
.mx-why { margin: 0; font-size: .92rem; }
.mx-why.good { color: var(--good); }
.mx-why.bad { color: var(--bad); }
.mx-related { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.mx-related .chips { justify-content: flex-start; }
.mx-related button.chip { border: 0; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; color: var(--accent); background: var(--accent-soft); }
.mx-nav .mx-buttons, .session-foot .mx-buttons { width: 100%; }
.mx-sheet { padding-bottom: 8px; }
.mw { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.mw-pic { display: flex; justify-content: center; }
.mw-svg { width: 100%; max-width: 360px; height: auto; max-height: 30vh; overflow: visible; }
.mw-svg.square { max-width: 220px; }
.mw-cap { margin: 0; font-size: .88rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.mw-controls { display: flex; flex-direction: column; gap: 4px; }
.mw-controls > .btn { align-self: center; }
.mw-slider { display: grid; grid-template-columns: minmax(70px, auto) 1fr 44px; align-items: center; gap: 8px; font-size: .85rem; }
.mw-slider input { width: 100%; accent-color: var(--accent); }
.mw-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.mw-svg .axis { stroke: var(--ink); stroke-width: 1.5; }
.mw-svg .grid { stroke: var(--line); stroke-width: .6; }
.mw-svg .tick { stroke: var(--ink); stroke-width: 1.2; }
.mw-svg .lbl { font-size: 10px; fill: var(--muted); text-anchor: middle; }
.mw-svg .arc { fill: none; stroke-width: 2.5; stroke: var(--accent); }
.mw-svg .arc.two { stroke: #2fa36b; }
.mw-svg .arc-lbl { font-size: 11px; font-weight: 700; text-anchor: middle; fill: var(--accent); }
.mw-svg .arc-lbl.two { fill: #2fa36b; }
.mw-svg .dot.start { fill: var(--muted); }
.mw-svg .dot.end, .mw-svg .pt { fill: var(--accent); }
.mw-svg .dot { fill: var(--accent); }
.mw-svg .g0 { fill: var(--accent); }
.mw-svg .g1 { fill: #2fa36b; }
.mw-svg .group { fill: none; stroke: var(--line); stroke-width: 1; }
.mw-svg .ten.a, .mw-svg .one.a { fill: var(--accent); }
.mw-svg .ten.b, .mw-svg .one.b { fill: #2fa36b; }
.mw-svg .ten.r, .mw-svg .one.r { fill: #e0913b; }
.mw-svg .op { font-size: 22px; font-weight: 800; fill: var(--ink); text-anchor: middle; }
.mw-svg rect.on, .mw-svg circle.on { fill: var(--accent); }
.mw-svg rect.on2, .mw-svg circle.on2 { fill: #2fa36b; }
.mw-svg rect.off, .mw-svg circle.off { fill: var(--surface-2); }
.mw-svg rect.b { fill: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }
.mw-svg .beam { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.mw-svg .stand { fill: var(--muted); }
.mw-svg .xbox { fill: var(--accent); }
.mw-svg .xl { fill: #fff; font-size: 13px; font-weight: 800; text-anchor: middle; }
.mw-svg .unit { fill: #e0913b; }
.mw-svg .fn { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.mw-svg .fn.fd { stroke: #2fa36b; stroke-width: 2; stroke-dasharray: 5 4; }
.mw-svg .tan { stroke: #e0913b; stroke-width: 2; }
.mw-svg .area { fill: color-mix(in srgb, var(--accent) 28%, transparent); }
.mw-svg .asym { stroke: var(--bad); stroke-width: 1.4; stroke-dasharray: 5 4; }
.mw-svg .ptl { font-size: 11px; font-weight: 700; fill: var(--ink); }
.mw-svg .ring { fill: none; stroke: var(--line); stroke-width: 2; }
.mw-svg .cos { stroke: #2fa36b; stroke-width: 3; }
.mw-svg .sin { stroke: #e0913b; stroke-width: 3; }
.mw-svg .vec { stroke: var(--accent); stroke-width: 3; }
.mw-svg .tri { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: var(--muted); stroke-dasharray: 4 3; }
.mw-order { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; font-size: 1.6rem; font-weight: 800; padding: 8px 0; }
.mw-order.shake { animation: shake .35s; }
.mo-op { min-width: 44px; min-height: 44px; border: 2px solid var(--accent); border-radius: 12px; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 1.4rem; font-weight: 800; cursor: pointer; }
/* Small screens: explanation pictures get a bit smaller so a step fits without scrolling. */
@media (max-height: 720px) {
  .session .mx { gap: 6px; }
  .session .mx-title { font-size: 1.15rem; }
  .session .mx-text { font-size: .93rem; line-height: 1.38; }
  .session .mw { padding: 6px 8px; gap: 4px; }
  .session .mw-svg { max-height: 21vh; }
  .session .mw-svg.square { max-width: 150px; }
  .session .mw-slider { font-size: .8rem; gap: 6px; }
  .session .mw-slider input { height: 20px; }
  .session .mw-cap { font-size: .8rem; }
}

/* ---- Whole math tasks (js/math/tasks.js): task card, part chips, several fields ---------- */
.task-ex { gap: 10px; }
.task-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.task-chip { min-width: 30px; height: 30px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 15px; background: var(--surface-2); color: var(--muted); font-weight: 800; font-size: .9rem; }
.task-chip.on { background: var(--accent); color: var(--accent-ink); }
.task-chip.ok { background: var(--good-soft); color: var(--good); }
.task-chip.bad { background: var(--bad-soft); color: var(--bad); }
.task-chip.on.ok, .task-chip.on.bad { outline: 2px solid var(--accent); outline-offset: 1px; }
.task-card { border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.task-card summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 9px 12px; cursor: pointer; list-style: none; font-weight: 800; }
.task-card summary::-webkit-details-marker { display: none; }
.task-card summary::after { content: '▾'; color: var(--muted); font-size: .9rem; }
.task-card:not([open]) summary::after { content: '▸'; }
.task-title { flex: 1; min-width: 0; }
.task-part { color: var(--muted); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.task-body { display: flex; flex-direction: column; gap: 6px; padding: 0 12px 10px; max-height: 30vh; overflow-y: auto; }
.task-line { margin: 0; line-height: 1.45; font-size: .97rem; }
.task-line sup, .task-q sup { font-size: .65em; }
.task-table { border-collapse: collapse; font-size: .9rem; align-self: flex-start; }
.task-table th, .task-table td { border: 1px solid var(--line); padding: 3px 9px; text-align: center; }
.task-table th { background: var(--surface-2); }
.task-tools { align-items: center; flex-shrink: 0; }
.task-fig-btn { white-space: nowrap; }
.task-fig .mw { box-shadow: none; padding: 0; background: transparent; }
.task-fig .mw-svg { max-height: 22vh; }
.task-q { margin: 0; font-size: 1.08rem; font-weight: 700; line-height: 1.4; }
.task-letter { color: var(--accent); margin-right: 2px; }
.task-hint { margin: -4px 0 0; }
.task-ex .options.task-options { display: flex; flex-direction: column; gap: 6px; grid-template-columns: none; }
.task-ex .option.task-opt { justify-content: flex-start; text-align: left; min-height: 44px; padding: 8px 12px; font-size: 1rem; font-weight: 650; line-height: 1.3; }
.mf-multi { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mf-multi.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mf-multi.n1 { grid-template-columns: 1fr; }
.mf-multi.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.mf-multi.n4 .mf-field { padding: 4px 6px; gap: 3px; }
.mf-multi.n4 .mf-prefix { font-size: .9rem; }
.mf-multi.n4 .mf-display { font-size: 1.05rem; }
.mf-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-multi .mf-field { min-height: 46px; padding: 4px 8px; border-color: var(--line); cursor: pointer; }
.mf-multi .mf-field.active { border-color: var(--accent); }
.mf-multi .mf-field.correct { border-color: var(--good); }
.mf-multi .mf-field.wrong { border-color: var(--bad); }
.mf-multi .mf-prefix { font-size: 1rem; }
.mf-multi .mf-display { font-size: 1.2rem; }
.mf-multi .mf-preview { font-size: .95rem; }
.mw-svg .fn.f1 { stroke: #2fa36b; }
.mw-svg .fn.f2 { stroke: #e0913b; stroke-width: 1.5; stroke-dasharray: 4 4; }
.mw-svg .tri-shape { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.mw-svg .tri-right, .mw-svg .tri-angle { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.mw-svg .tri-lbl { text-anchor: middle; }
.mw-svg .tri-side { fill: var(--ink); font-size: 11px; font-weight: 600; }
.mw-svg .sol { fill: none; stroke: var(--ink); stroke-width: 2; }
.mw-svg .sol-back { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 4 3; }
.mw-svg .sol-dim { stroke: var(--accent); stroke-width: 2; }
.mw-svg .sol-h { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 5 3; }
.mw-svg .tree-br { stroke: var(--muted); stroke-width: 1.6; }
.mw-svg .tree-p { fill: var(--accent); font-weight: 700; }
@media (max-height: 720px) {
  .task-ex { gap: 6px; }
  .task-card summary { padding: 7px 12px; }
  .task-body { max-height: 18vh; padding-bottom: 8px; }
  .task-fig .mw-svg { max-height: 16vh; }
  .task-ex .mf-key { min-height: 34px; }
  .task-ex .mf-expr .mf-key { min-height: 31px; }
  .task-ex .option.task-opt { min-height: 40px; padding: 6px 12px; }
  .task-line { font-size: .9rem; line-height: 1.38; }
  .task-q { font-size: 1rem; }
  .task-chip { min-width: 26px; height: 26px; font-size: .82rem; }
  .mf-multi .mf-field { min-height: 40px; }
}

/* ---- Math: start question and topic overview (js/views/mathhome.js) ---------------------- */
.mstart-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mstart .choice { min-height: 0; padding: 8px 10px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 6px; row-gap: 3px; text-align: left; }
.mstart .choice-text { display: contents; }
.mstart .choice .choice-icon { width: auto; font-size: 1.15rem; }
.mstart .choice strong { font-size: .95rem; line-height: 1.2; }
.mstart .choice small { grid-column: 1 / -1; line-height: 1.25; font-size: .74rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mstart .choice .choice-check { display: none; }
.mstart .choice[aria-pressed="true"] { outline: 2px solid var(--accent); }
.mstart .welcome-title { font-size: 1.45rem; }
.mstart-branch, .mm-branch { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mstart-branch[hidden], .mm-branch[hidden] { display: none; }
.seg { min-height: 34px; padding: 4px 12px; border-radius: 17px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; }
.seg[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.math-map { gap: 10px; }
.mm-active { display: flex; flex-direction: column; gap: 6px; }
.mm-active .eyebrow { margin: 0; }
.mm-active-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.mm-active-row::-webkit-scrollbar { display: none; }
.mm-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.mm-chip small { color: var(--muted); font-weight: 600; }
.mm-levels { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.mm-levels::-webkit-scrollbar { display: none; }
.mm-tab { flex: 0 0 auto; min-height: 38px; padding: 6px 12px; border-radius: 19px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.mm-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mm-count { margin: 0; }
.mm-groups { display: flex; flex-direction: column; gap: 12px; }
.mm-group { display: flex; flex-direction: column; gap: 6px; }
.mm-group-title { margin: 0; font-size: .95rem; color: var(--muted); }
.mm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mm-unit { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 12px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; min-width: 0; }
.mm-unit.started { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.mm-icon { font-size: 1.5rem; line-height: 1; }
.mm-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mm-text strong { font-size: .95rem; line-height: 1.25; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.mm-text small { color: var(--muted); font-size: .76rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mm-bar { margin-top: auto; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.mm-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.mm-unit.done .mm-bar span { background: var(--good); }
.mm-badge { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.mm-badge.ok { background: var(--good-soft); color: var(--good); }
.mm-badge.ok svg { width: 14px; height: 14px; }
.mm-badge.weak { background: var(--bad-soft); color: var(--bad); }

/* ---- MathPrint input (js/math/keypad.js): fractions, powers, roots as you type ----------- */
.mf-display.mq { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 3px 0; scrollbar-width: none; }
.mq-row { display: inline-flex; align-items: center; }
.mq-frac { display: inline-flex; flex-direction: column; align-items: stretch; margin: 0 3px; font-size: .84em; }
.mq-num { display: flex; justify-content: center; padding: 0 3px 2px; border-bottom: 2px solid currentColor; }
.mq-den { display: flex; justify-content: center; padding: 2px 3px 0; }
.mq-sup { display: inline-flex; align-self: center; position: relative; top: -.62em; font-size: .64em; margin: 0 1px; }
.mq-sqrt { display: inline-flex; align-items: stretch; margin: 0 1px; }
.mq-radix { display: flex; align-items: flex-end; font-size: 1.1em; line-height: 1.05; padding-right: 1px; cursor: text; }
.mq-rad { display: inline-flex; align-items: center; margin-top: 3px; padding: 1px 3px 0 2px; border-top: 2px solid currentColor; }
.mq-fn { display: inline-flex; align-items: center; }
.mq-fname { margin-right: 1px; cursor: text; }
.mq-empty { display: inline-flex; align-items: center; justify-content: center; min-width: .72em; min-height: 1.05em; padding: 0 1px; border: 1.5px dashed color-mix(in srgb, var(--muted) 70%, transparent); border-radius: 3px; cursor: text; }
.mq-empty.on { border-color: var(--accent); background: var(--accent-soft); }
.mq .mf-caret { height: 1.15em; }
.mq-frac .mf-caret, .mq-sup .mf-caret { height: 1em; }
.mf-key sup { font-size: .62em; }
.mf-key .kf { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.mf-key .kf span { width: 11px; height: 8px; border: 1.5px solid currentColor; border-radius: 2px; }
.mf-key .kf i { width: 17px; height: 2px; background: currentColor; border-radius: 1px; }
.mf-key .kp sup { margin-left: 1px; }
.mf-key .kr span { border-top: 1.5px solid currentColor; padding: 0 1px; }

/* ---- Math notebook (js/math/notes.js): lines like on paper, keypad with four pages -------- */
.math-notes-btn { font-size: 1.1rem; flex-shrink: 0; width: 40px; height: 40px; }
.prompt-row .task-tools { flex-shrink: 0; }
.sheet.nb-sheet { height: min(94dvh, 900px); max-height: calc(100dvh - var(--safe-t) - 8px); display: flex; flex-direction: column; overflow: hidden; padding: 10px 12px calc(10px + var(--safe-b)); background: var(--bg); }
.sheet.nb-sheet .sheet-handle { margin-bottom: 6px; }
.sheet.nb-sheet > .nb-panel { flex: 1 1 auto; min-height: 0; }
.nb-panel { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.nb-head { display: flex; align-items: center; gap: 8px; padding-right: 40px; }
.nb-panel.full .nb-head { padding-right: 0; }
.nb-icon { font-size: 1.2rem; }
.nb-title { flex: 1; min-width: 0; border: 0; border-bottom: 1.5px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-weight: 800; font-size: 1.05rem; padding: 4px 2px; }
.nb-title:focus { outline: none; border-color: var(--accent); }
.nb-paper { flex: 1; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.nb-lines { display: flex; flex-direction: column; min-height: 100%; padding: 4px 0 40px; background-image: linear-gradient(to right, transparent 34px, color-mix(in srgb, var(--bad) 35%, transparent) 34px, color-mix(in srgb, var(--bad) 35%, transparent) 35.5px, transparent 35.5px); }
.nb-line { border-bottom: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line)); }
.mf-field.nb-field { min-height: 46px; padding: 4px 10px 4px 44px; border: 0; border-radius: 0; background: transparent; box-shadow: none; cursor: text; }
.mf-field.nb-field.active { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.nb-display { font-size: 1.3rem; flex-wrap: nowrap; }
.mq-space { display: inline-block; width: .4em; align-self: stretch; cursor: text; }
.mq-rel { padding: 0 .18em; }
.mq-sub { display: inline-flex; align-self: center; position: relative; top: .5em; font-size: .64em; margin: 0 1px; }
.mq-int { display: inline-flex; align-items: center; margin-right: 2px; }
.mq-int-sign { font-size: 1.7em; line-height: 1; font-weight: 400; cursor: text; }
.mq-int-lim { display: inline-flex; flex-direction: column; justify-content: space-between; align-self: stretch; font-size: .6em; margin-left: -2px; gap: 6px; }
.mq-mat { display: inline-flex; align-items: stretch; margin: 2px 3px; }
.mq-br { display: flex; width: .5em; flex-shrink: 0; cursor: text; }
.mq-br svg { width: 100%; height: 100%; overflow: visible; }
.mq-br path { fill: none; stroke: currentColor; stroke-width: 1.8; }
.mq-mat.k-brace .mq-br.l { width: .6em; margin-right: 3px; }
.mq-grid { display: inline-grid; align-items: center; column-gap: 10px; row-gap: 3px; padding: 2px 1px; }
.mq-cell { display: inline-flex; align-items: center; justify-content: center; min-height: 1.3em; }
.k-brace .mq-cell { justify-content: flex-start; }
.mq-cell.aug { border-left: 1.5px dashed currentColor; padding-left: 8px; }
.mq-label { font-size: .62em; color: var(--muted); font-weight: 800; }
.nb-keys { display: flex; flex-direction: column; gap: 6px; }
.nb-tabs { display: flex; gap: 6px; }
.nb-tab { flex: 1; min-height: 32px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 800; font-size: .9rem; cursor: pointer; }
.nb-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mf-keypad[class*="mf-n-"] { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.mf-keypad.mf-n-abc { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.mf-keypad[class*="mf-n-"] .mf-key { min-height: 40px; font-size: .98rem; padding: 0 2px; }
.mf-keypad.mf-n-abc .mf-key { min-height: 42px; font-size: 1.02rem; }
.mf-keypad.mf-n-abc .mf-key.wide { grid-column: span 3; }
.mf-keypad.shifted .mf-key.letter { text-transform: uppercase; }
.mf-keypad.shifted .mf-key[data-key="⇧"] { background: var(--accent); color: var(--accent-ink); }
.mf-key.enter { background: var(--accent); color: var(--accent-ink); }
.mf-key sub { font-size: .62em; }
.mf-key .kb { font-size: 1.25em; line-height: 1; }
.mf-key .kl { font-size: .62em; line-height: 1; display: inline-block; vertical-align: middle; }
.nb-page { display: flex; flex-direction: column; height: 100dvh; }
.nb-page .nb-panel { padding: 0 16px 10px; }
.nb-page-title { flex: 1; font-size: 1rem; }
.nb-home { gap: 12px; }
.nb-list { display: flex; flex-direction: column; gap: 8px; }
.nb-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.nb-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: var(--ink); text-decoration: none; }
.nb-preview { overflow: hidden; font-size: .95rem; color: var(--muted); max-height: 3.2em; }
.nb-preview .mf-display { font-size: 1rem; }
.nb-del { flex-shrink: 0; }
@media (max-height: 720px) {
  .mf-keypad[class*="mf-n-"] .mf-key { min-height: 34px; }
  .nb-tab { min-height: 28px; }
}
.nb-saved { white-space: nowrap; }
.nb-display .mf-ch { padding: 0; }
.nb-display { font-weight: 650; letter-spacing: .01em; }

/* Notebook tools: check badges, compute, graph, sketch layer */
.nb-tools { display: flex; flex-direction: column; gap: 6px; }
.nb-bar, .nb-drawbar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.nb-bar[hidden], .nb-drawbar[hidden], .nb-keys[hidden] { display: none; }
.nb-act, .nb-tool { flex: 0 0 auto; white-space: nowrap; }
.nb-act[aria-pressed="true"], .nb-tool[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.nb-drawbar .btn { margin-left: auto; }
.nb-lines { position: relative; }
.nb-line { position: relative; }
.nb-line.ok .nb-field { background: color-mix(in srgb, var(--good) 7%, transparent); }
.nb-line.bad .nb-field { background: color-mix(in srgb, var(--bad) 7%, transparent); }
.nb-line.warn .nb-field { background: color-mix(in srgb, #e0913b 8%, transparent); }
.nb-badge { position: absolute; top: 8px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; display: grid; place-items: center; font-weight: 800; font-size: .85rem; cursor: pointer; z-index: 2; }
.nb-badge.ok { background: var(--good-soft); color: var(--good); }
.nb-badge.bad { background: var(--bad-soft); color: var(--bad); }
.nb-badge.warn { background: color-mix(in srgb, #e0913b 20%, transparent); color: #c0731f; }
.nb-msg { display: none; margin: 0; padding: 2px 40px 6px 44px; font-size: .82rem; line-height: 1.35; color: var(--muted); }
.nb-msg.open { display: block; }
.nb-line.bad .nb-msg { color: var(--bad); }
.nb-line.warn .nb-msg { color: #c0731f; }
.nb-line:has(.nb-badge) .nb-field { padding-right: 38px; }
.nb-canvas { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; }
.nb-lines.drawing .nb-canvas { pointer-events: auto; touch-action: none; cursor: crosshair; }
.nb-lines.drawing { outline: 2px dashed color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: -2px; }
.sheet.gr-sheet { max-width: 640px; }
.gr { display: flex; flex-direction: column; gap: 8px; }
.gr-box { border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.gr-svg { display: block; width: 100%; max-width: none; max-height: 55vh; touch-action: none; cursor: crosshair; }
.gr-svg .gr-fn { fill: none; stroke-width: 2.4; }
.gr-svg .gr-pt { stroke: var(--surface); stroke-width: 1.5; }
.gr-svg .gr-trace { stroke: var(--muted); stroke-dasharray: 3 3; }
.gr-info { margin: 0; font-weight: 700; min-height: 1.3em; }
.gr-legend { display: flex; gap: 10px; flex-wrap: wrap; font-weight: 700; }
.gr-key i, .gr-chip i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.gr-points { display: flex; flex-wrap: wrap; gap: 6px; max-height: 22vh; overflow-y: auto; }
.gr-chip { font-size: .82rem; }
.nb-act { font-size: .86rem; padding: 6px 10px; }
/* Exam simulation */
.exam-timer { flex-shrink: 0; font-weight: 800; font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.exam-timer.late { background: var(--bad-soft); color: var(--bad); }
.task-chip.done { background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); color: var(--accent); }
.exam-intro { text-align: center; align-items: center; }
.exam-result { text-align: left; }
.exam-result h2, .exam-result > .muted, .exam-result .finish-emoji { text-align: center; }
.exam-review-title { margin: 8px 0 0; }
.exam-review { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.exam-item { border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); padding: 8px 12px; }
.exam-item summary { cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.exam-mark { font-weight: 800; width: 1.2em; flex-shrink: 0; }
.exam-item.ok .exam-mark { color: var(--good); }
.exam-item.bad .exam-mark, .exam-item.skip .exam-mark { color: var(--bad); }
.exam-home { gap: 12px; }
.exam-past { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.exam-past-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; }
/* Leagues (js/views/friends.js) */
.league-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.league-badge { display: grid; place-items: center; flex: none; border-radius: 50%; color: #fff; background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--lg) 55%, #fff), var(--lg) 70%); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.league-badge .icon { width: 55%; height: 55%; fill: currentColor; }
.league-dots { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.league-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lg); opacity: .25; }
.league-dot.past { opacity: .6; }
.league-dot.on { width: 12px; height: 12px; opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lg) 25%, transparent); }
.lb-row.zone-down .lb-rank { color: var(--bad); }
/* Statistics (js/views/stats.js) */
.stats-page { gap: 12px; }
.st-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.st-svg { width: 100%; height: auto; display: block; }
.st-svg .st-bar { fill: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.st-svg .st-bar.now { fill: var(--accent); }
.st-svg .st-val { font-size: 9px; fill: var(--ink); text-anchor: middle; font-weight: 700; }
.st-svg .st-lbl { font-size: 8px; fill: var(--muted); text-anchor: middle; }
.st-svg .st-line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.st-svg .st-dot { fill: var(--accent); }
.st-svg .st-grid { stroke: var(--good); stroke-dasharray: 4 4; }
.st-topics { display: flex; flex-direction: column; gap: 10px; }
.st-meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.st-meter.big { height: 12px; border-radius: 6px; }
.st-meter span { display: block; height: 100%; border-radius: inherit; }
.st-meter .good { background: var(--good); }
.st-meter .mid { background: #e0913b; }
.st-meter .low { background: var(--bad); }
.st-actions { margin-top: 4px; }
.st-link { margin-top: 8px; }
.st-card.st-league { flex-direction: row; align-items: center; gap: 12px; }
.placement-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.placement .stage { margin: 4px 0; }
/* Homework (teacher card and pupil list) */
.homework-card { display: flex; flex-direction: column; gap: 8px; }
.homework-card h3 { margin: 0; }
.hw-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.hw-names { margin: 2px 0 0; color: var(--good); }
.hw-link { align-items: center; }
.hw-link code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.homework-page { gap: 10px; }
.hw-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; }
.hw-check { font-size: 1.3rem; font-weight: 800; color: var(--muted); width: 1.4em; text-align: center; }
.hw-item.done .hw-check { color: var(--good); }
.hw-item.late { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
/* AI conversation partner */
.tutor-scenes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tutor-scene { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 14px; color: var(--ink); text-decoration: none; }
.tutor-ico { font-size: 1.6rem; }
.tutor-page { gap: 10px; }
.tutor-log { display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
.tutor-msg { max-width: 88%; padding: 10px 12px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.tutor-msg.me { align-self: flex-end; background: var(--accent-soft); }
.tutor-msg.typing { color: var(--muted); }
.tutor-text { font-size: 1.1rem; }
.tutor-tr { margin: 0; color: var(--muted); font-size: .9rem; }
.tutor-show { align-self: flex-start; }
.tutor-fix { font-size: .9rem; color: var(--good); }
.tutor-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.tutor-form { display: flex; gap: 8px; position: sticky; bottom: 8px; }
.tutor-input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem; }
.ai-wrap[hidden], .ai-explain[hidden] { display: none; }
.ai-wrap { display: flex; flex-direction: column; gap: 6px; }
.ai-btn { align-self: flex-start; }
.ai-explain { padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-size: .92rem; }
.ai-explain p { margin: 0 0 4px; }
.pill.premium { background: #fff4d6; color: #8a5a00; }
.premium-line { margin: 4px 0 0; color: #8a5a00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.premium { background: #3a2e10; color: #f5c96a; } :root:not([data-theme="light"]) .premium-line { color: #f5c96a; } }
:root[data-theme="dark"] .pill.premium { background: #3a2e10; color: #f5c96a; }
:root[data-theme="dark"] .premium-line { color: #f5c96a; }
.mail-dns { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mail-dns-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.mail-dns-item p { margin: 2px 0 0; }
.mail-dns-dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--good, #2e9e5b); }
.mail-dns-item.warn .mail-dns-dot { background: #d99a1e; }
.mail-dns-item.bad .mail-dns-dot { background: var(--bad, #d64545); }
.mail-dns-value { word-break: break-all; }
code.mail-dns-value { user-select: all; }
.link-url code { word-break: break-all; user-select: all; font-size: .9rem; }
.link-qr { width: 160px; max-width: 50%; background: #fff; padding: 8px; border-radius: 12px; }
.link-qr svg { display: block; width: 100%; height: auto; }
.link-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.link-bios { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.link-bios li { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: center; }
.link-bios code { font-size: .8rem; word-break: break-all; }
.link-bio-name { font-weight: 600; font-size: .9rem; }
.link-sources { justify-content: flex-start; }
.link-sources .chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Areas: Klataza Sprachen / Mathe / Spiele ---------- */
.topbar-brand { display: inline-flex; align-items: center; gap: 2px; padding: 4px; margin-left: 0; border: 0; background: transparent; border-radius: 12px; cursor: pointer; flex: none; }
.topbar-brand:active { background: var(--surface-2); }
.topbar-brand .topbar-logo { margin-left: 0; }
.topbar-brand .brand-caret { width: 14px; height: 14px; color: var(--muted); transform: rotate(90deg); }
#title .area-name { color: var(--area-tone, var(--accent)); }
.area-switcher-head { display: flex; align-items: center; gap: 10px; }
.area-switcher-head img { border-radius: 8px; }
.area-switcher-head h2 { margin: 0; }
.area-list { display: grid; gap: 10px; }
.area-card { border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.area-card.current { border-color: var(--area); box-shadow: inset 0 0 0 1px var(--area); }
.area-card-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
button.area-card-head { cursor: pointer; }
button.area-card-head:active { background: var(--surface-2); }
.area-card-head strong { font-size: 1.02rem; }
.area-brand { color: var(--muted); font-weight: 600; }
.area-logo { border-radius: 12px; flex: none; }
.area-langs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px 68px; }
.area-lang { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); color: inherit; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.area-lang.on { border-color: var(--area); background: color-mix(in srgb, var(--area) 12%, var(--surface)); cursor: default; }
.area-lang:not(.mine):not(.on) { color: var(--muted); }
.area-more summary { cursor: pointer; font-weight: 700; padding: 8px 0; color: var(--muted); }
.area-teaser { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit; }
.area-teaser .area-logo { border-radius: 10px; }
.welcome-area { display: flex; align-items: center; gap: 6px; margin: 6px 2px 0; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: none; }
.welcome-area:first-child { margin-top: 0; }
.welcome-area img { border-radius: 5px; }
.welcome-area span { font-weight: 600; }
.post-templates { justify-content: flex-start; }
.post-templates .chip { cursor: pointer; border: 1.5px solid var(--line); }
.post-templates .chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.post-canvas { width: 100%; max-width: 420px; height: auto; margin: 0 auto; display: block; border-radius: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .12); }
.post-caption { width: 100%; font: inherit; font-size: .92rem; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: inherit; resize: vertical; }
.post-fields textarea { width: 100%; font: inherit; }
.boot-help { position: fixed; inset: auto 16px 40%; z-index: 100; padding: 18px; border-radius: 16px; background: var(--surface, #fff); border: 1.5px solid var(--line, #ddd); text-align: center; display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); }
.boot-help p { margin: 0; font-weight: 600; }
.post-seg { flex-wrap: wrap; }
.post-edit summary { cursor: pointer; font-weight: 700; }
.post-edit[open] summary { margin-bottom: 12px; }
.post-edit { display: block; }
.post-both { gap: 12px; }
.post-new-invite summary { cursor: pointer; font-weight: 600; margin: 4px 0 8px; }
.post-new-invite .field { flex: 1 1 140px; }

/* ---------- Klataza Wohlbefinden (wellbeing) ---------- */
.wb-card { text-align: left; width: 100%; border: 0; font: inherit; color: inherit; cursor: pointer; }
.wb-ico { font-size: 1.7rem; width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--surface-2); }
.wb-plus { flex: none; }
.wb-private { text-align: center; }
.wb-page > section.card { align-items: stretch; }
.wb-page > section.card > h3 { text-align: left; }
.wb-home .card p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-glass { position: relative; width: 150px; height: 190px; margin: 4px auto 0; border: 4px solid var(--line); border-top: 0; border-radius: 6px 6px 34px 34px; overflow: hidden; background: var(--surface); }
.wb-glass-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #7cc7f5, #3a8fe0); transition: height .5s ease; }
.wb-glass-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.wb-glass-text strong { font-size: 2.6rem; line-height: 1; }
.wb-glass-text span, .wb-glass-text small { font-size: .85rem; }
.wb-water-btns .btn { font-size: 1.05rem; }
.wb-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; height: 96px; align-items: end; }
.wb-bar { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.wb-bar-track { flex: 1; width: 100%; max-width: 26px; display: flex; align-items: flex-end; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.wb-bar-fill { width: 100%; background: var(--area-tone, var(--accent)); opacity: .55; border-radius: 8px; min-height: 0; }
.wb-bar-fill.met { opacity: 1; }
.wb-bar small { color: var(--muted); font-size: .72rem; }
/* Dream journal */
.wb-step { font-size: 1rem; margin-top: 4px; }
.wb-moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wb-mood, .wb-symbol { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.wb-mood span { font-size: 1.7rem; line-height: 1.1; }
.wb-symbol span { font-size: 1.45rem; line-height: 1.1; }
.wb-mood small, .wb-symbol small { font-size: .68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.wb-mood[aria-pressed="true"], .wb-symbol[aria-pressed="true"], .wb-chip[aria-pressed="true"], .wb-sound[aria-pressed="true"] { border-color: var(--area-tone, var(--accent)); background: color-mix(in srgb, var(--area-tone, var(--accent)) 14%, var(--surface)); }
.wb-symbols { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
@media (max-width: 380px) { .wb-symbols { grid-template-columns: repeat(5, 1fr); } }
.wb-row2 { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.wb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wb-chip { padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); font: inherit; font-size: .85rem; color: inherit; cursor: pointer; }
.wb-clarity-wrap { display: flex; align-items: center; gap: 6px; }
.wb-clarity { display: flex; gap: 4px; }
.wb-clarity button { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); padding: 0; cursor: pointer; }
.wb-clarity button[aria-pressed="true"] { background: var(--area-tone, var(--accent)); border-color: transparent; }
.wb-more summary, .wb-sketch-box summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.wb-more .stack { display: flex; flex-direction: column; gap: 8px; }
.wb-more input, .wb-more textarea { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; }
.wb-sketch { display: block; width: 100%; height: auto; aspect-ratio: 600 / 340; border: 1.5px solid var(--line); border-radius: 12px; margin: 4px 0 6px; touch-action: none; }
.wb-save-bar { display: flex; gap: 8px; position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 2; padding: 8px 0; background: var(--bg); }
.wb-dream-row { padding: 12px 14px; }
.wb-dream-mood { font-size: 1.6rem; }
.wb-empty { padding-top: 8vh; }
/* Workout player */
.wb-workout { align-items: center; text-align: center; gap: 8px; }
.wb-w-ring { --p: 0%; width: 170px; height: 170px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--area-tone, var(--accent)) var(--p), var(--surface-2) 0); }
.wb-w-ring.rest { background: conic-gradient(#3fb98a var(--p), var(--surface-2) 0); }
.wb-w-ring.ready { background: conic-gradient(var(--muted) var(--p), var(--surface-2) 0); }
.wb-w-time { width: 138px; height: 138px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.wb-w-label { font-weight: 700; }
.wb-w-emoji { font-size: 2.6rem; line-height: 1; }
.wb-w-name { font-size: 1.35rem; }
.wb-w-how { max-width: 34ch; min-height: 2.6em; }
.wb-workout .row { width: 100%; }
/* Breathing */
.wb-breathe { align-items: center; text-align: center; }
.wb-breath { width: 120px; height: 120px; margin: 64px auto; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #ffc49b, var(--area-tone, var(--accent))); color: #fff; transition-property: transform; transition-timing-function: ease-in-out; transform: scale(1); }
.wb-breath.big { transform: scale(1.8); }
.wb-breath.still { animation: wb-glow 6s ease-in-out infinite; }
@keyframes wb-glow { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .wb-breath.still { animation: none; } }
.wb-breath-label { font-weight: 700; font-size: .95rem; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.wb-breath-clock { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
/* Sleep */
.wb-times label { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.wb-times input { padding: 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; font-size: 1.1rem; }
.wb-sounds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wb-sound { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.wb-sound span { font-size: 1.8rem; }
.wb-tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.wb-reset { align-self: center; color: var(--muted); }
/* Wellbeing coach */
.wb-hero-row { flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.wb-goal-pill { border: 0; font: inherit; font-size: .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }
.wb-goal-pill .icon { width: 14px; height: 14px; }
.wb-goals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wb-goal { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.wb-goal span { font-size: 1.8rem; }
.wb-goal[aria-pressed="true"] { border-color: var(--area-tone, var(--accent)); background: color-mix(in srgb, var(--area-tone, var(--accent)) 14%, var(--surface)); }
.wb-goal-card, .wb-today, .wb-tip-card, .wb-program-done { align-items: stretch; }
.wb-count { font-weight: 800; font-size: .9rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.wb-count.all { background: var(--good-soft); color: var(--good); }
.wb-plan { display: flex; flex-direction: column; gap: 2px; }
.wb-plan-item { display: flex; align-items: center; gap: 10px; padding: 8px 2px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
.wb-plan-item:first-child { border-top: 0; }
.wb-plan-item .li-main { display: flex; flex-direction: column; }
.wb-plan-item strong { font-size: .95rem; }
.wb-plan-item.done strong { text-decoration: line-through; color: var(--muted); }
.wb-check { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: #fff; }
.wb-plan-item.done .wb-check { background: var(--good); border-color: var(--good); }
.wb-plan-emoji { font-size: 1.35rem; flex: none; }
.wb-all-done { font-weight: 700; color: var(--good); text-align: center; }
.wb-program-offer .btn { flex: none; }
.wb-kicker { font-weight: 700; color: var(--area-tone, var(--accent)); text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
.wb-star { font-size: 1.3rem; color: var(--gold); }
.wb-more-link { font-weight: 700; color: var(--area-tone, var(--accent)); text-decoration: none; }
.wb-tip-card p, .wb-tip p { margin: 0; line-height: 1.45; }
.wb-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wb-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 4px; border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; font-weight: 600; }
.wb-tile span { font-size: 1.6rem; }
.wb-tile:active, .wb-tracker:active { transform: scale(.97); }
.wb-trackers { display: grid; grid-template-columns: 1.45fr 1fr 1fr; gap: 6px; }
.wb-tracker { display: flex; align-items: center; gap: 5px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface); color: inherit; text-decoration: none; min-width: 0; }
.wb-tracker > span { font-size: 1.3rem; }
.wb-tracker div { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.wb-tracker .wb-plus { margin-left: auto; flex: none; width: 30px; height: 30px; padding: 0; min-height: 0; border-radius: 50%; justify-content: center; }
.wb-tracker small { font-size: .74rem; }
.wb-help { border-top: 1px solid var(--line); padding-top: 10px; }
/* Guided exercise */
.wb-ex { min-height: var(--view-h); }
.wb-ex-bar, .wb-prog-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.wb-ex-bar span, .wb-prog-bar span { display: block; height: 100%; background: var(--area-tone, var(--accent)); transition: width .3s; }
.wb-ex-step { text-align: center; }
.wb-ex-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 12px 0; }
.wb-ex-text { font-size: 1.25rem; font-weight: 600; text-align: center; line-height: 1.4; max-width: 30ch; }
.wb-ex-clock { width: 138px; height: 138px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.wb-ex-input { width: 100%; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: inherit; resize: vertical; }
.wb-ex-choices { justify-content: center; }
.wb-ex-choices .wb-chip { padding: 10px 14px; font-size: .95rem; }
.wb-ex-done { padding-top: 10vh; }
.wb-ex-done .btn { width: 100%; }
/* Journal, tips, programs */
.wb-journal { align-items: stretch; position: relative; }
.wb-qa p { margin: 2px 0 0; white-space: pre-wrap; }
.wb-del { align-self: flex-end; }
.wb-tip-filter { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.wb-tip-filter .wb-chip { flex: none; }
.wb-tip { align-items: stretch; }
.wb-tip-page { align-items: center; text-align: center; padding-top: 4vh; }
.wb-tip-emoji { font-size: 3.4rem; }
.wb-tip-big { font-size: 1.1rem; line-height: 1.5; max-width: 34ch; }
.wb-tip-page .btn { width: 100%; }
.wb-program { align-items: stretch; }
.wb-program.on { outline: 2px solid var(--area-tone, var(--accent)); }
.wb-days { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.wb-days li { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.wb-days li.now { color: var(--ink); font-weight: 700; }
.wb-day-n { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .75rem; font-weight: 800; }
.wb-days li.done .wb-day-n { background: var(--good); color: #fff; }
.wb-days li.now .wb-day-n { background: var(--area-tone, var(--accent)); color: #fff; }
