/* «Тетрадь»: токены, отступы и движение - DESIGN.md */
:root {
  --btn-h: 64px; --btn-sec-h: 56px; --dock-gap: 12px; --dock-edge: 8px;   /* источник высот кнопок и панели .dock */
  --bg: #FBF8F1; --surface: #F3EEE2; --ink: #1D2433; --muted: #6A6F7B; --line: #DDD5C3;
  --accent: #1F4FD1; --good: #1D7A46; --err: #C2410C; --errBg: #FDF1E8; --gold: #C8961E; --tile-line: #CFC6B2;
  --serif: 'Literata', Georgia, serif; --sans: 'Onest', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root { --ease: linear(0, 0.32 7%, 0.75 16%, 1.04 29%, 1.02 40%, 0.995 55%, 1); }
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; display: flex; flex-direction: column; min-height: 100dvh; color: var(--ink); font: 400 18px/1.5 var(--sans); -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { max-width: 560px; width: 100%; margin: 0 auto; padding: 20px 20px 32px; flex: 1; display: flex; flex-direction: column; gap: 16px; outline: none; }
#app.wide { max-width: 940px; }
/* плашка сети и полоска учителя - один липкий блок: плашка fixed поверх вёрстки (не сдвигает контент, клики проходят к ✕ и к полоске под ней) */
#top { position: sticky; top: 0; z-index: 10; }
.net { position: fixed; top: 0; left: 0; right: 0; z-index: 10; pointer-events: none; background: var(--errBg); color: var(--err); border-bottom: 1px solid var(--err); padding: 12px 20px; text-align: center; font-weight: 600; }
.as-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 500; }
.who-bar { padding: 6px 20px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* одна строка: длинное имя обрезается, главная кнопка остаётся в окне */

h1, h2 { font: 700 24px/1.3 var(--serif); letter-spacing: -0.01em; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.lesson-hit { background: var(--errBg); border-left: 4px solid var(--err); padding: 8px 12px; border-radius: 8px; }
.small { font-size: 16px; font-weight: 500; color: var(--muted); }
.spacer { margin-top: auto; }
.col { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.sent { font: 600 24px/1.45 var(--serif); white-space: pre-line; }
.sent .ctx { font-weight: 400; }
.en { font-family: var(--serif); }

.btn { min-height: var(--btn-h); padding: 8px 20px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 22px; font-weight: 600; width: 100%; }
.btn[disabled] { background: var(--tile-line); color: var(--muted); cursor: default; }
.btn.sec { background: var(--bg); color: var(--accent); border: 2px solid var(--accent); font-size: 18px; min-height: var(--btn-sec-h); }
.btn.quiet { background: transparent; color: var(--muted); border: 0; font-size: 18px; min-height: 56px; width: auto; padding: 8px 12px; text-decoration: underline; }
.icon-btn { min-width: 56px; min-height: 56px; border: 0; background: transparent; border-radius: 8px; font-size: 22px; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.icon-btn[data-testid=exit] { border: 2px solid var(--line); background: #fff; font-size: 24px; }
.opts.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
.opts.grid2 .opt { font-size: 19px; }
.icon-btn.snd { padding: 0 12px; }

.opt, .tile { display: block; width: 100%; min-height: 56px; padding: 12px 16px; background: #fff; border: 1px solid var(--tile-line); border-radius: 12px; box-shadow: 0 1px 0 var(--tile-line); text-align: left; font: 600 21px/1.3 var(--serif); }
.opt.ru-text { font-family: var(--serif); }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt[aria-checked="true"], .opt.picked { border-color: var(--accent); }
.opt.right { border: 2px solid var(--good); background: #EAF5EE; }
.opt.wrong { border: 2px solid var(--err); background: var(--errBg); }
.opt, .row-zone { transition: background-color .15s, border-color .15s; }   /* вспышка верного: только цвет, ≤150 мс */
.row-zone.right { background: #EAF5EE; border-bottom-color: var(--good); }
.verdict { display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 32px; color: var(--good); }
.verdict.err { color: var(--err); }

.progress { display: flex; gap: 4px; flex: 1; }
.progress i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); transition: background-color .2s; }
.progress i.on { background: var(--accent); }
.progress i.bad { background: var(--tile-line); }
.topbar { display: flex; align-items: center; gap: 8px; margin: -8px -8px 0; }
.mode { flex: 1; text-align: left; min-width: 0; font-size: 17px; line-height: 1.25; font-weight: 600; color: var(--ink); }

.slot-line { font: 600 24px/1.7 var(--serif); }   /* обычный поток строки, не flex: зазор flex-gap повисал пробелом перед «.» после пропуска */
.slot-line .blank { vertical-align: baseline; }
.blank { display: inline-block; min-width: 72px; min-height: 56px; padding: 0 10px; border: 0; border-bottom: 3px solid var(--tile-line); background: var(--surface); border-radius: 8px 8px 0 0; font: inherit; vertical-align: baseline; text-align: center; }
.blank.active { border-bottom-color: var(--accent); background: #E4EBFB; }
.blank.filled { border-bottom-color: var(--ink); background: transparent; }
.blank.block { display: block; width: 100%; text-align: left; min-height: 56px; padding: 8px 12px; }
.blank.block:not(.filled) { background: transparent; border: 2px dashed var(--tile-line); border-radius: 12px; }
.blank.block.active:not(.filled) { border-color: var(--accent); }

.row-zone { min-height: 64px; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; background: var(--surface); border-radius: 12px; border-bottom: 2px solid var(--line); align-content: flex-start; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { display: inline-block; border-radius: 8px; }
.slot.ghost { background: transparent; border: 1px dashed var(--line); }
.slot.ghost > * { visibility: hidden; }
.tile { width: auto; min-width: 56px; font-size: 21px; text-align: center; border-radius: 8px; transition: transform .28s var(--ease); touch-action: manipulation; }
.row-zone .tile { background: #fff; }
.row-zone.empty { background: transparent; border: 2px dashed var(--line); }
.end-punct { align-self: center; font: 600 21px var(--serif); color: var(--muted); }

.entering { animation: enter .24s var(--ease); }
.entering * { pointer-events: none; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.card.err { background: var(--errBg); border-color: #F0C9AF; }
.card .tok.bad { color: var(--err); text-decoration: line-through; text-decoration-thickness: 2px; }
.card .tok.fix { color: var(--good); }
.card .tok.fix, .card .tok.bad { font-weight: 700; }
.letter { display: inline-block; color: var(--err); font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--err); }

.map-wrap { position: relative; background: var(--surface); border-radius: 12px; padding: 4px; }
.map-wrap svg { width: 100%; height: auto; display: block; }
.map-pop { position: absolute; max-width: 240px; padding: 8px 12px; border-radius: 12px; background: var(--ink); color: var(--surface); font: 600 14px/1.3 var(--sans); box-shadow: 0 2px 8px rgba(0,0,0,.18); z-index: 2; pointer-events: none; }
.node, .wnode { cursor: pointer; }
.node text, .wnode text { font-weight: 500; font-family: var(--sans); fill: var(--ink); text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }   /* линия узла к своей подписи не режет буквы */
.node tspan.more, .wnode tspan.more { fill: var(--accent); font-weight: 700; }
.map-wrap text.legend { font: 500 12px var(--sans); fill: var(--ink); }
.map-wrap text.note { font: 500 11.5px var(--sans); fill: var(--muted); text-anchor: middle; }
.node text.more { fill: var(--accent); font-weight: 700; }
.node:focus-visible, .wnode:focus-visible { outline: none; }
.node:focus-visible .ring, .wnode:focus-visible .ring { stroke: var(--accent); stroke-width: 4; }
.hint { min-height: 28px; font-weight: 600; color: var(--accent); }

.home-grid { display: flex; flex-direction: column; gap: 16px; }
/* переключатель курса над картой: две кнопки в один ряд и на 320 px; высоты берутся из .btn / .btn.sec (>= 56 px) */
.course-switch { display: flex; gap: 8px; }
.course-switch .btn { flex: 1 1 0; min-width: 0; width: auto; font-size: 18px; padding: 8px; }
@media (min-width: 900px) { .home-grid { flex-direction: row; align-items: flex-start; } .home-grid > * { flex: 1; } .home-grid > :last-child { flex: 2; } }

.big-num { font: 600 56px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.gain { display: flex; gap: 12px; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--line); font-size: 20px; }
.gain::before { content: "↑"; color: var(--good); font-weight: 700; }
.link { font: 600 16px/1.3 var(--sans, sans-serif); word-break: break-all; user-select: all; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.code { white-space: nowrap; font: 600 clamp(22px, 7vw, 36px)/1.2 var(--serif); letter-spacing: .04em; text-align: center; padding: 24px 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; font-variant-numeric: tabular-nums; }
input.code-in { width: 100%; min-height: 64px; font: 600 clamp(20px, 6vw, 28px) var(--serif); letter-spacing: .06em; padding: 8px 16px; border: 2px solid var(--tile-line); border-radius: 12px; background: #fff; color: var(--ink); text-transform: uppercase; }
input.code-in[aria-invalid="true"] { border-color: var(--err); }
.word { font: 700 40px/1.2 var(--serif); }
.tr { font: 600 28px/1.3 var(--serif); color: var(--accent); }
.word-slot { height: min(200px, 19vh); display: flex; justify-content: center; align-items: center; }   /* место под картинку держится и без неё */
.word-slot .word-pic { display: block; width: min(200px, 19vh); height: min(200px, 19vh); max-width: 100%; object-fit: contain; border-radius: 12px; background: #fff; border: 1px solid var(--line); align-self: center; }
@media (min-width: 900px) { .word-slot, .word-slot .word-pic { height: min(200px, 17vh); } .word-slot .word-pic { width: min(200px, 17vh); } }   /* широкий экран: колонка 940 px, 800 px высоты, нижний отступ 32 - без прокрутки */
.err-text { color: var(--err); font-weight: 600; }
.skeleton { height: 64px; border-radius: 14px; background: var(--surface); }
.demo-stage { position: relative; background: var(--surface); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.finger { position: absolute; width: 36px; height: 36px; border-radius: 50%; background: rgba(31, 79, 209, .35); border: 2px solid var(--accent); pointer-events: none; transition: left .6s var(--ease), top .6s var(--ease), transform .15s; left: 20px; top: 20px; z-index: 5; }
.finger.tap { transform: scale(.7); }
.frames { display: flex; gap: 8px; }
.step-i { font-size: 16px; font-weight: 500; color: var(--muted); }

@media (max-width: 480px) { .sent { font-size: 22px; } .slot-line { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* сцена урока */
.scene { display: flex; flex-direction: column; gap: 12px; }
.scene-stage { position: relative; background: var(--surface); border-radius: 12px; padding: 20px 16px; min-height: 76px; }
.scene-line { font: 600 26px/1.8 var(--serif); }
.scene .tok { display: inline-block; }
.scene.has-links .scene-line { line-height: 2.2; }
.scene .tok[data-changed="1"] { color: var(--good); font-weight: 700; }
.pair-was { margin: 0; font: 600 20px/1.4 var(--serif); color: var(--err); text-decoration: line-through; text-decoration-thickness: 2px; }
.scene-cap { min-height: 1.4em; font-size: 16px; font-weight: 600; color: var(--ink); }
.scene-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.scene-link { fill: none; stroke: var(--accent); stroke-width: 2.5px; stroke-linecap: round; }
.scene-link-head { fill: var(--accent); }
/* выбор из двух, классы и таблица учителя */
.card.choice { text-align: left; width: 100%; gap: 8px; min-height: 96px; font: inherit; cursor: pointer; border: 1px solid var(--tile-line); box-shadow: 0 1px 0 var(--tile-line); }
.card.choice .h2 { font: 700 22px/1.3 var(--serif); }
input.name-in { text-transform: none; letter-spacing: 0; font-size: 22px; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 18px; }
.tbl th, .tbl td { padding: 12px; text-align: left; vertical-align: middle; border-top: 1px solid var(--line); font-weight: 400; }
.tbl thead th { border-top: 0; font-size: 16px; font-weight: 600; color: var(--muted); background: var(--surface); }
.tbl tbody th { font-weight: 600; }
.name-btn { border: 0; background: transparent; padding: 8px 0; min-height: 44px; font: 600 18px var(--serif); color: var(--accent); text-decoration: underline; text-align: left; }
@media (max-width: 600px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl th, .tbl td { display: block; }
  .tbl tr { padding: 8px 12px; border-top: 1px solid var(--line); }
  .tbl tr:first-child { border-top: 0; }
  .tbl th, .tbl td { border: 0; padding: 2px 0; }
  .tbl td:nth-of-type(1)::before { content: "За неделю: "; color: var(--muted); }
  .tbl td:nth-of-type(2)::before { content: "Темы: "; color: var(--muted); }
  .tbl td:nth-of-type(3)::before { content: "Занимался: "; color: var(--muted); }
}

/* диалог выхода */
dialog.confirm { border: 0; border-radius: 16px; padding: 24px; width: min(92vw, 420px); background: var(--bg); color: var(--ink); display: none; flex-direction: column; gap: 12px; }
dialog.confirm[open] { display: flex; }
dialog.confirm::backdrop { background: rgba(29, 36, 51, .5); }
dialog.confirm .code { white-space: normal; overflow-wrap: anywhere; }   /* код в диалоге переносится на 320px, а не обрезается */
/* цифры вариантов: на компьютере видно, что 1-4 работают */
@media (min-width: 1024px) { .opt[data-key]::before { content: attr(data-key) / ""; display: inline-block; min-width: 1.6em; margin-right: 8px; color: var(--muted); font-weight: 700; } }

/* страница «Конфиденциальность»: обычный документ, тот же каркас #app */
#app.doc { display: block; }
.doc > * + * { margin-top: 12px; }
.doc h2 { margin-top: 32px; }
.doc h3 { font: 700 18px/1.4 var(--sans); margin-top: 20px; }
.doc ul { margin: 0; padding-left: 22px; }
.doc li + li { margin-top: 6px; }
.doc a, .legal a { color: var(--accent); }
.doc code { font-size: 16px; background: var(--surface); padding: 1px 6px; border-radius: 6px; }
.legal { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 12px; }   /* без «·» между ссылками: при переносе он повисал одинокой точкой */
.legal a { display: inline-block; padding: 12px 6px; }   /* цель касания >= 44 px (WCAG 2.5.5), как у остальных кнопок */
/* объём на главной: числа Onest 18, подпись «за сегодня» 14/500; тон «знал» - оттенок стадии карты (DESIGN.md, 3-4), токена под него нет */
.volume { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; --known: #8FA8EE; }
.vol-line { font-variant-numeric: tabular-nums; }
.vol-item { white-space: nowrap; }
.vol-today { font: 500 14px/1.4 var(--sans); }
.vol-today.up { color: var(--good); }
.vol-today.down { color: var(--muted); }
.vol-bar { display: flex; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.vol-learned { background: var(--accent); }
.vol-known { background: var(--known); }
.gain-pct { font-size: 22px; font-weight: 600; color: var(--good); }
.gain-pct.down { color: var(--muted); }

.points { margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 8px; font-size: 19px; line-height: 1.4; overflow-wrap: anywhere; }
.col.pairs, .pairs { display: flex; flex-direction: column; gap: 24px; }   /* между парами 24, внутри пары 4: пояснение читается как подпись своей сцены */
.pair, .example { display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.scene .tok.wrong { text-decoration: line-through; color: var(--err); }
.scene-stage { padding-right: 64px; }
.scene-again { position: absolute; top: 4px; right: 4px; width: 56px; height: 56px; border-radius: 10px; border: 2px solid var(--accent); background: var(--bg); color: var(--accent); font-size: 26px; line-height: 1; cursor: pointer; }
.scene-again:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.scene-again:active { background: var(--accent); color: #fff; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lesson-nav { gap: 12px; }
/* Главное действие экрана задания закреплено у нижнего края окна, контент над ним прокручивается (DESIGN.md: цели касания, главная кнопка) */
.dock { position: sticky; bottom: var(--dock-edge); z-index: 5; box-shadow: 0 0 0 var(--dock-edge) var(--bg); }
/* экран задания занимает остаток окна: панель уходит вниз, а при длинном контенте страница растёт и панель прибита к низу окна */
[data-exercise-id] { flex: 1; }
[data-exercise-id] .dock { margin-top: auto; background: var(--bg); gap: var(--dock-gap); }
/* Tab и scrollIntoView не кладут последний вариант под панель: высота панели из переменных кнопок + отступ от края + зазор */
html:has([data-exercise-id]) { scroll-padding-bottom: calc(var(--btn-h) + var(--dock-gap) + var(--btn-sec-h) + 2 * var(--dock-edge)); }
.row.dock { background: var(--bg); } .row.dock .btn { flex: 1; min-width: 0; } .lesson-nav .btn { flex: 1; min-width: 0; }
/* экран стартового теста (панель - одна строка, row.dock): варианты 21 px; на окне ниже 660 px по высоте 18 px.
   Замер (tests/e2e/test_fit_360.py, пул bg и en, 320 и 390 px, высота 500..900 шагом 10): с 660 px 21 px целиком над панелью у всех
   упражнений; на 650 px у одного упражнения bg нижний вариант уходит под панель на 7 px, поэтому порог 660, а не 640 */
[data-exercise-id]:has(.row.dock) .opt { font-size: 21px; }
@media (max-height: 659px) { [data-exercise-id]:has(.row.dock) .opt { font-size: 18px; } }
[data-exercise-id]:has(.row.dock) .small:empty { display: none; }
.lesson-nav .btn:last-child:not(:first-child) { flex: 2; padding-inline: 8px; }   /* «Назад к заданию» в одну строку на 390 */
.demo-wrap { position: relative; }
@media (max-height: 640px) { .demo-stage { padding: 10px; gap: 6px; } .demo-stage > .col { gap: 6px; } .demo-stage .row-zone, .demo-stage .bank { gap: 4px; } .demo-stage .row-zone { min-height: 44px; padding: 4px; } .demo-stage .opt, .demo-stage .tile { min-height: 44px; padding: 4px 8px; } .demo-stage .verdict { min-height: 0; } .demo-stage .btn { min-height: 44px; } .demo-stage .verdict { scroll-margin-bottom: 96px; } }
.demo-wrap .scene-again { z-index: 6; }
.demo-wrap .demo-stage h2 { padding-right: 60px; }
.icon-btn[data-testid=help], .icon-btn.snd { width: 56px; height: 56px; padding: 0; border: 2px solid var(--accent); border-radius: 10px; background: var(--bg); color: var(--accent); font-weight: 600; cursor: pointer; }
.icon-btn.snd[aria-pressed="false"] { border-color: var(--line); color: var(--muted); }
.icon-btn[data-testid=help]:focus-visible, .icon-btn.snd:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon-btn[data-testid=help]:active, .icon-btn.snd:active { background: var(--accent); color: #fff; }
/* 200% на телефоне (195 px): шапка переносится, а не вылезает за край; длинная ссылка в нижней строке тоже */
@media (max-width: 260px) { .topbar { flex-wrap: wrap; } .mode { flex-basis: 100%; order: 3; } .legal a { overflow-wrap: anywhere; } h1, h2 { font-size: 20px; } }
@media (max-height: 640px) { .who-bar { padding: 0 20px; font-size: 13px; line-height: 1.2; } #app { padding-top: 4px; } }   /* низкое окно (<=640 px, напр. 320x568; проверочный 360x672 сюда не попадает): полоса ~17 px, четыре px сверху возвращены введению, чтобы оно осталось без прокрутки */

/* дрилл: слово над постоянной сеткой; вспышка верно - только цвет рамки (без анимации входа), знак ✓/✗ рядом с текстом */
.drill-ru { margin: 0; min-height: 72px; display: flex; align-items: center; justify-content: center; font: 600 44px/1.2 var(--serif); text-align: center; }
.drill-pos { margin: 0; text-align: center; }
.drill-grid .opt { text-align: center; font-size: 24px; }
.drill-grid .opt.right::after { content: " ✓"; }
.drill-grid .opt.wrong::after { content: " ✗"; }
