/* ==========================================================================
   Тренажёр слов Legal English: система оформления
   ==========================================================================

   КАТАЛОГ КЛАССОВ (примеры разметки). Экран собирается из этих кирпичей,
   новые цвета и размеры не вводить: брать переменные из :root.

   Каркас
     <div class="app" data-nav="on|off">         всё приложение; data-nav="off" прячет навигацию
       <aside class="rail">…</aside>              боковая навигация (компьютер)
       <div class="main"><main id="view">…</main></div>
       <nav class="tabbar">…</nav>                нижняя навигация (телефон)
     <section class="screen">…</section>          колонка содержимого (до 880 px)
     <header class="topbar"><h1 class="topbar-title">Путь</h1><span class="spacer"></span><button class="btn btn-ghost">…</button></header>
     <nav class="tabbar"><a href="#/today" class="is-active">[значок]<span>Сегодня</span></a>…</nav>
     <aside class="rail"><div class="rail-brand">Legal English</div><a href="#/today" class="is-active">[значок]<span>Сегодня</span></a>…</aside>

   Контейнеры и служебные
     .stack (вертикально с промежутками), .row (горизонтально), .row-wrap, .grid-2, .grid-3, .spacer (растяжка),
     .muted (приглушённый текст), .center, .serif, .small, .mt-1…mt-4 (верхний отступ), .visually-hidden

   Карточка и списки
     <div class="card"><h2>Заголовок</h2><p>Текст</p></div>      .card.is-flat без тени; .card.is-accent бордовая; .card.is-gold золотая
     <div class="list"><a class="list-item" href="#/unit/1"><div class="list-item-main">Юнит 1<div class="list-item-sub">12 слов</div></div><div class="list-item-end"><span class="pill">3</span></div></a></div>

   Кнопки
     <button class="btn btn-primary">Учить</button>   .btn-ghost, .btn-ok, .btn-bad
     <button class="btn btn-primary btn-big btn-block">Проверить</button>        .btn-big выше, .btn-block на всю ширину
     <button class="btn btn-icon btn-ghost" aria-label="Закрыть">[значок]</button>  квадратная кнопка со значком

   Метки
     <button class="chip is-active">Юнит 3</button>   выбираемая метка-фильтр (is-active выбрана)
     <span class="pill">12 слов</span>                 небольшая метка (.pill.is-ok, .is-bad, .is-gold, .is-accent)
     <span class="badge">3</span>                      круглый счётчик (.badge.is-gold)

   Показатели
     <div class="stat"><div class="stat-value">86%</div><div class="stat-label">готовность</div></div>
     <div class="progress" role="progressbar" aria-valuenow="40"><div class="progress-bar"></div></div>   ширина: --p (0..100)
     <div class="ring" style через JS: --p:72"><span class="ring-label">72%</span></div>                   кольцо; --ring-size, --ring-w

   Слова и ответы
     <div class="word">a unanimous verdict</div> <div class="ipa">/juːˈnænɪməs ˈvɜːdɪkt/</div>      .word.is-sm меньше
     <div class="tiles"><button class="tile is-used">verdict</button>…</div>     банк плиток; .is-used использована
     <div class="tiles tiles-line"><button class="tile is-placed">a</button></div>  строка ответа; .is-placed поставлена
     <div class="choices"><button class="choice is-picked|is-correct|is-wrong">вариант</button>…</div>
     <input class="input-answer is-correct|is-wrong" lang="en" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false">
     <div class="word-img">[img] или заглушка .word-img.is-ph[data-unit]</div>

   Урок (сетка на весь экран)
     <div class="lesson">
       <div class="lesson-head"><button class="btn btn-icon btn-ghost">[×]</button><div class="progress">…</div></div>
       <div class="lesson-prompt"><div class="lesson-kind">Переведите на английский</div>…</div>
       <div class="lesson-answer">…варианты, плитки, поле ввода…</div>
       <div class="lesson-foot"><button class="btn btn-primary btn-big btn-block">Проверить</button></div>
     </div>
     Результат ответа вместо кнопки в .lesson-foot:
     <div class="feedback ok|bad|info"><div class="feedback-title">[значок] Верно</div><div class="feedback-body">пояснение</div><button class="btn btn-ok btn-big btn-block">Дальше</button></div>

   Поверх экрана
     <div class="sheet-backdrop"><div class="sheet" role="dialog">…</div></div>   нижний лист (ui.confirmSheet)
     <div class="toast">Сохранено</div>                                            всплывающая подсказка (ui.toast)
     <div class="netbar">Нет сети: ответы сохранятся</div>   .updatebar, .boot (загрузка), .empty, .skeleton
     <div class="empty">[значок]<h2>Пусто</h2><p>Пояснение</p></div>
     <div class="skeleton" style по высоте через JS></div>

   Форма входа: .login, .field, .form-error
   ========================================================================== */

/* ---------- Переменные ---------- */
:root {
  color-scheme: light;
  /* палитра проекта */
  --navy: #14213d; --paper: #faf7f0; --ink: #1c1b19;
  --burgundy: #8c1c2b; --gold: #c49a2c; --good: #2f7d4f; --error: #b3261e;

  /* роли (светлая тема) */
  --bg: var(--paper); --surface: #ffffff; --surface-2: #f1ece0;
  --text: var(--ink); --muted: #6a655a; --head: var(--navy);
  --line: #ddd5c2; --line-strong: #c9bfa6;
  --accent: var(--burgundy); --accent-hover: #74161f; --on-accent: #ffffff;
  --accent-text: var(--burgundy); --accent-soft: #f4e4e6;
  --ok: var(--good); --ok-soft: #e3f1e8; --bad: var(--error); --bad-soft: #fbe6e4;
  --info-soft: #e6eaf3; --gold-soft: #f7edd0; --gold-text: #86650f;
  --shadow-1: 0 1px 2px rgba(20, 33, 61, .08), 0 2px 8px rgba(20, 33, 61, .06);
  --shadow-2: 0 10px 30px rgba(20, 33, 61, .22);
  --scrim: rgba(15, 21, 36, .5);

  /* шрифты */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-serif: "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;

  /* отступы, радиусы, размеры */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-s: 10px; --r-m: 16px; --r-l: 22px; --r-pill: 999px;
  --tap: 44px; --nav-h: 58px; --rail-w: 236px; --rail-narrow: 64px; --col: 880px;
  --t: 150ms;

  /* вырез экрана */
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}

/* тёмная тема: по системе или по настройке */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1524; --surface: #1a2236; --surface-2: #232d47;
    --text: #ece7da; --muted: #9ba2b6; --head: #f1ecdf;
    --line: #2f3a58; --line-strong: #3f4c70;
    --accent: #9b2335; --accent-hover: #b02a40; --accent-text: #ea8e9c; --accent-soft: #3b1f2b;
    --gold: #d9b24c; --gold-soft: #3a3118; --gold-text: #e3c46a;
    --ok: #62c18b; --ok-soft: #173628; --bad: #f2877f; --bad-soft: #3e1d22; --info-soft: #1f2b48;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);
    --scrim: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1524; --surface: #1a2236; --surface-2: #232d47;
  --text: #ece7da; --muted: #9ba2b6; --head: #f1ecdf;
  --line: #2f3a58; --line-strong: #3f4c70;
  --accent: #9b2335; --accent-hover: #b02a40; --accent-text: #ea8e9c; --accent-soft: #3b1f2b;
  --gold: #d9b24c; --gold-soft: #3a3118; --gold-text: #e3c46a;
  --ok: #62c18b; --ok-soft: #173628; --bad: #f2877f; --bad-soft: #3e1d22; --info-soft: #1f2b48;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);
  --scrim: rgba(0, 0, 0, .6);
}

/* ---------- Основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.45 var(--font-ui); overflow-x: hidden; overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
h1, h2, h3 { font-family: var(--font-serif); color: var(--head); margin: 0 0 .4em; line-height: 1.2; font-weight: 700; }
h1 { font-size: 28px; } h2 { font-size: 21px; } h3 { font-size: 17px; }
p { margin: 0 0 .8em; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
.lesson, .quiz, .tabbar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lesson input, .quiz input, input, textarea { -webkit-user-select: text; user-select: text; }
input, select, textarea { font-size: 16px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* служебные */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-s { display: flex; flex-direction: column; gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.spacer { flex: 1 1 auto; }
.muted { color: var(--muted); }
.center { text-align: center; }
.serif { font-family: var(--font-serif); }
.small { font-size: 14px; }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-4); } .mt-4 { margin-top: var(--sp-5); }
.icon { width: 24px; height: 24px; flex: none; vertical-align: middle; }

/* ---------- Каркас и навигация ---------- */
.app { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--sab)); }
.app[data-nav="off"] { padding-bottom: 0; }
.main { min-width: 0; }
.view:focus { outline: none; }
.screen {
  max-width: var(--col); margin: 0 auto;
  padding: var(--sp-4) calc(var(--sp-4) + var(--sar)) var(--sp-5) calc(var(--sp-4) + var(--sal));
}
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--sp-3);
  min-height: calc(52px + var(--sat)); padding: var(--sat) calc(var(--sp-4) + var(--sar)) 0 calc(var(--sp-4) + var(--sal));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar-title { margin: 0; font-size: 22px; }

.rail { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  height: calc(var(--nav-h) + var(--sab)); padding: 0 var(--sar) var(--sab) var(--sal);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a, .rail a {
  display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--muted);
  min-height: var(--tap); transition: color var(--t), background var(--t);
}
.tabbar a { flex: 1 1 0; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 600; }
.tabbar a.is-active, .rail a.is-active { color: var(--accent-text); }
.tabbar a.is-active .icon { stroke-width: 2.4; }
.app[data-nav="off"] .tabbar, .app[data-nav="off"] .rail { display: none; }

/* компьютер: боковая навигация, содержимое до 880 px */
@media (min-width: 900px) and (min-height: 521px) {
  .app { padding-bottom: 0; padding-left: var(--rail-w); }
  .app[data-nav="off"] { padding-left: 0; }
  .tabbar { display: none; }
  .rail {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 20; width: var(--rail-w); display: flex; flex-direction: column; gap: 4px;
    padding: var(--sp-5) var(--sp-3); background: var(--surface); border-right: 1px solid var(--line);
  }
  .rail-brand { font-family: var(--font-serif); font-size: 20px; font-weight: 700; color: var(--head); padding: 0 var(--sp-3) var(--sp-4); }
  .rail a { justify-content: flex-start; gap: var(--sp-3); padding: 0 var(--sp-3); border-radius: var(--r-m); font-weight: 600; font-size: 16px; min-height: 48px; }
  @media (hover: hover) and (pointer: fine) { .rail a:hover { background: var(--surface-2); } }
  .rail a.is-active { background: var(--accent-soft); }
  .topbar { position: static; background: transparent; border-bottom: 0; }
}

/* телефон в ландшафте: нижняя панель заменяется узкой колонкой значков, в уроке навигации нет */
@media (orientation: landscape) and (max-height: 520px) {
  .app { padding-bottom: 0; padding-left: calc(var(--rail-narrow) + var(--sal)); }
  .app[data-nav="off"] { padding-left: 0; }
  .tabbar {
    top: 0; right: auto; bottom: 0; width: calc(var(--rail-narrow) + var(--sal)); height: auto;
    flex-direction: column; justify-content: center; border-top: 0; border-right: 1px solid var(--line);
    padding: var(--sat) 0 var(--sab) var(--sal);
  }
  .tabbar a { flex: 0 0 auto; min-height: 52px; }
  .tabbar a span { display: none; }
  .topbar { min-height: calc(44px + var(--sat)); }
  .screen { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
}

/* ---------- Карточка, списки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  padding: var(--sp-4); box-shadow: var(--shadow-1);
}
.card.is-flat { box-shadow: none; }
.card.is-accent { background: var(--accent-soft); border-color: transparent; }
.card.is-gold { background: var(--gold-soft); border-color: transparent; }
.card > :last-child { margin-bottom: 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: var(--sp-2) var(--sp-4);
  color: var(--text); text-decoration: none; background: none; border: 0; width: 100%; text-align: left;
  border-bottom: 1px solid var(--line); transition: background var(--t);
}
.list-item:last-child { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) { a.list-item:hover, button.list-item:hover { background: var(--surface-2); } }
.list-item-main { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.list-item-sub { font-weight: 400; font-size: 14px; color: var(--muted); }
.list-item-end { flex: none; display: flex; align-items: center; gap: var(--sp-2); color: var(--muted); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 48px; padding: 0 var(--sp-5); border: 2px solid transparent; border-radius: var(--r-m);
  font-weight: 700; font-size: 16px; line-height: 1.1; text-decoration: none; text-align: center;
  background: var(--surface-2); color: var(--text);
  transition: transform var(--t), background var(--t), box-shadow var(--t), opacity var(--t);
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 0 rgba(0, 0, 0, .22); }
@media (hover: hover) and (pointer: fine) { .btn-primary:hover { background: var(--accent-hover); } }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
@media (hover: hover) and (pointer: fine) { .btn-ghost:hover { background: var(--surface-2); } }
.btn-ok { background: var(--good); color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .22); }
.btn-bad { background: var(--error); color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .22); }
.btn-big { min-height: 56px; font-size: 18px; border-radius: var(--r-l); }
.btn-block { display: flex; width: 100%; }
.btn-icon { min-width: var(--tap); width: var(--tap); min-height: var(--tap); padding: 0; border-radius: 50%; }

/* ---------- Метки ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface);
  font-size: 15px; font-weight: 600; color: var(--text); text-decoration: none; transition: background var(--t), border-color var(--t);
}
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1.5;
}
.pill.is-ok { background: var(--ok-soft); color: var(--ok); }
.pill.is-bad { background: var(--bad-soft); color: var(--bad); }
.pill.is-gold { background: var(--gold-soft); color: var(--gold-text); }
.pill.is-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700;
}
.badge.is-gold { background: var(--gold); color: #1c1b19; }

/* ---------- Показатели ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-family: var(--font-serif); font-size: 30px; font-weight: 700; color: var(--head); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }
.progress { --p: 0; height: 12px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; flex: 1 1 auto; }
.progress-bar { height: 100%; width: calc(var(--p) * 1%); border-radius: var(--r-pill); background: var(--good); transition: width 200ms ease; }
.progress.is-gold .progress-bar { background: var(--gold); }
.ring {
  --p: 0; --ring-size: 96px; --ring-w: 11px; --ring-color: var(--accent); --ring-hole: var(--surface);
  position: relative; flex: none; display: grid; place-items: center; width: var(--ring-size); height: var(--ring-size); border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--p) * 1%), var(--surface-2) 0);
}
.ring::before { content: ""; position: absolute; inset: var(--ring-w); border-radius: 50%; background: var(--ring-hole); }
.ring-label { position: relative; font-family: var(--font-serif); font-size: calc(var(--ring-size) * .26); font-weight: 700; color: var(--head); }

/* ---------- Слова ---------- */
.word { font-family: var(--font-serif); font-size: clamp(30px, 8vw, 44px); line-height: 1.15; font-weight: 700; color: var(--head); }
.word.is-sm { font-size: clamp(22px, 5.5vw, 28px); }
.ipa { font-family: var(--font-serif); font-size: 17px; color: var(--muted); }
.word-img {
  --img-h: 26dvh; position: relative; aspect-ratio: 4 / 3; width: min(100%, 320px, calc(var(--img-h) * 4 / 3));
  border-radius: var(--r-l); overflow: hidden; background: var(--surface-2); flex: none;
}
.word-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.word-img.is-ph {
  --hue: 220; display: grid; place-items: center;
  background: linear-gradient(135deg, hsl(var(--hue) 38% 26%), hsl(var(--hue) 42% 18%));
}
.word-img.is-ph .ph-letter { font-family: var(--font-serif); font-size: 64px; font-weight: 700; color: var(--gold); opacity: .92; line-height: 1; }

.tiles { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-content: flex-start; }
.tiles-line { min-height: 64px; padding: var(--sp-2) 0; border-bottom: 2px solid var(--line-strong); margin-bottom: var(--sp-4); }
.tile {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: var(--tap); padding: 0 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-s); background: var(--surface); color: var(--text);
  font-family: var(--font-serif); font-size: 20px; font-weight: 600; box-shadow: 0 2px 0 var(--line-strong);
  transition: transform var(--t), opacity var(--t), border-color var(--t);
}
.tile:active { transform: translateY(1px); }
.tile.is-used { opacity: .3; pointer-events: none; box-shadow: none; background: var(--surface-2); }
.tile.is-placed { border-color: var(--accent); }

.choices { display: flex; flex-direction: column; gap: var(--sp-3); }
.choice {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 56px; padding: var(--sp-3) var(--sp-4);
  border: 2px solid var(--line-strong); border-radius: var(--r-m); background: var(--surface); color: var(--text);
  text-align: left; font-size: 18px; font-weight: 600; box-shadow: 0 2px 0 var(--line-strong);
  transition: border-color var(--t), background var(--t), transform var(--t);
}
.choice:active { transform: translateY(1px); }
.choice.is-picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 2px 0 var(--accent); }
.choice.is-correct { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 2px 0 var(--ok); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 2px 0 var(--bad); animation: shake 180ms ease; }
.choice[disabled] { pointer-events: none; }

.input-answer {
  display: block; width: 100%; min-height: 56px; padding: var(--sp-3) var(--sp-4);
  border: 2px solid var(--line-strong); border-radius: var(--r-m); background: var(--surface); color: var(--text);
  font-family: var(--font-serif); font-size: 22px; transition: border-color var(--t), background var(--t);
}
.input-answer:focus { outline: none; border-color: var(--accent); }
.input-answer.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.input-answer.is-wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake 180ms ease; }

/* ---------- Урок ---------- */
.lesson {
  position: fixed; top: var(--vvt, 0px); left: 0; right: 0; z-index: 30; margin: 0 auto;
  width: min(100%, 760px); height: 100vh; height: var(--vvh, 100dvh);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "head" "prompt" "answer" "foot";
  padding: var(--sat) var(--sar) var(--sab) var(--sal); background: var(--bg);
}
.kb-open .lesson { padding-bottom: 0; }
.lesson-head { grid-area: head; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); }
.lesson-prompt {
  grid-area: prompt; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); text-align: center; min-height: 0; overflow: auto;
}
.lesson-kind { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lesson-answer { grid-area: answer; min-height: 0; overflow-y: auto; padding: var(--sp-3) var(--sp-4); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.lesson-foot { grid-area: foot; padding: var(--sp-3) var(--sp-4); }
.lesson-foot:has(.feedback) { padding: 0; }

.feedback {
  display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4) var(--sp-4) var(--sp-4);
  border-top: 2px solid var(--line-strong); background: var(--info-soft); animation: slideup 180ms ease;
}
.feedback.ok { background: var(--ok-soft); border-color: var(--ok); }
.feedback.bad { background: var(--bad-soft); border-color: var(--bad); }
.feedback-title { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; font-size: 19px; }
.feedback.ok .feedback-title { color: var(--ok); }
.feedback.bad .feedback-title { color: var(--bad); }
.feedback-body { font-size: 16px; }

/* телефон в ландшафте: две колонки, при высоте 360 px всё без прокрутки страницы */
@media (orientation: landscape) and (max-height: 520px) {
  .lesson {
    width: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "head answer" "prompt answer" "prompt foot"; column-gap: var(--sp-4);
  }
  .lesson-head { padding: var(--sp-1) var(--sp-3); }
  .lesson-prompt { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .lesson-answer { padding: var(--sp-2) var(--sp-3); }
  .lesson-foot { padding: var(--sp-2) var(--sp-3); }
  .word-img { --img-h: 34dvh; }
  .word { font-size: clamp(22px, 8dvh, 34px); }
  .choices { gap: var(--sp-2); }
  .choice { min-height: var(--tap); padding: var(--sp-2) var(--sp-3); font-size: 16px; }
  .tiles-line { min-height: 52px; margin-bottom: var(--sp-2); }
  .feedback { padding: var(--sp-2) var(--sp-3); gap: var(--sp-1); }
  .feedback-title { font-size: 17px; }
  .btn-big { min-height: 48px; font-size: 17px; }
}

/* ---------- Поверх экрана ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  background: var(--scrim); animation: fade 160ms ease;
}
.sheet {
  width: 100%; max-width: 560px; padding: var(--sp-5) var(--sp-4) calc(var(--sp-4) + var(--sab));
  background: var(--surface); border-radius: var(--r-l) var(--r-l) 0 0; box-shadow: var(--shadow-2); animation: slideup 180ms ease;
}
.sheet h2 { margin-bottom: var(--sp-2); }
.sheet-actions { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--sab) + 12px); z-index: 110; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); pointer-events: none; padding: 0 var(--sp-4); }
.toast {
  max-width: 420px; padding: 10px 18px; border-radius: var(--r-pill); background: var(--navy); color: #fff;
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow-2); animation: pop 160ms ease;
}
.netbar, .updatebar {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-3); padding: 6px var(--sp-4);
  background: var(--gold-soft); color: var(--gold-text); font-size: 14px; font-weight: 600; text-align: center;
}
.updatebar { background: var(--info-soft); color: var(--text); }
.updatebar .btn { min-height: var(--tap); padding: 0 var(--sp-4); }
.netbar { padding-top: calc(6px + var(--sat)); }
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--muted); }
.empty .icon { width: 48px; height: 48px; color: var(--gold); }
.empty h2 { margin: 0; }
.empty p { max-width: 36ch; margin: 0; }
.skeleton { min-height: 16px; border-radius: var(--r-s); background: var(--surface-2); animation: pulse 1.2s ease-in-out infinite; }
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-4); min-height: 70vh; min-height: 70dvh; padding: var(--sp-5); text-align: center; color: var(--muted); }
.boot-mark { font-family: var(--font-serif); font-size: 26px; font-weight: 700; color: var(--head); }
.boot-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--accent); animation: spin 800ms linear infinite; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4) calc(var(--sp-4) + var(--sar)) var(--sp-4) calc(var(--sp-4) + var(--sal)); }
.login-card { width: 100%; max-width: 380px; }
.login-mark { display: block; width: 72px; height: 72px; margin: 0 auto var(--sp-3); border-radius: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field label { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input {
  min-height: 52px; padding: 0 var(--sp-4); border: 2px solid var(--line-strong); border-radius: var(--r-m);
  background: var(--surface); transition: border-color var(--t);
}
.field input:focus { outline: none; border-color: var(--accent); }
.form-error { min-height: 1.4em; margin: 0 0 var(--sp-3); color: var(--bad); font-weight: 600; font-size: 15px; }

/* ---------- Анимации (не дольше 200 мс) ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slideup { from { opacity: .4; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes shake { 20% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 80% { transform: translateX(-3px); } }
@keyframes pulse { 50% { opacity: .5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
