/* «Тетрадь»: токены, отступы и движение - DESIGN.md */
:root {
  --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; 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; margin: 0 auto; padding: 20px 20px 32px; min-height: 100dvh; display: flex; flex-direction: column; gap: 16px; outline: none; }
#app.wide { max-width: 940px; }
.net { position: sticky; top: 0; z-index: 10; background: var(--errBg); color: var(--err); border-bottom: 1px solid var(--err); padding: 12px 20px; text-align: center; font-weight: 600; }

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; }
.en { font-family: var(--serif); }

.btn { min-height: 64px; 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: 56px; }
.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.snd { font-size: 16px; 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); }
.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: 15px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.slot-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; font: 600 24px/1.7 var(--serif); }
.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 { background: var(--surface); border-radius: 12px; padding: 4px; }
.map-wrap svg { width: 100%; height: auto; display: block; }
.node, .wnode { cursor: pointer; }
.node text, .wnode text { font: 500 11px var(--sans); fill: var(--ink); text-anchor: middle; pointer-events: none; }
.wnode text { font-size: 15px; }
.node text.wordsign { font-size: 17px; font-weight: 700; fill: var(--accent); }
.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; }
@media (min-width: 900px) { .home-grid { flex-direction: row; align-items: flex-start; } .home-grid > * { flex: 1; } }

.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; }
.code { font: 600 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 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-pic { display: block; width: min(200px, 22vh); height: min(200px, 22vh); max-width: 100%; object-fit: contain; border-radius: 12px; background: #fff; border: 1px solid var(--line); align-self: center; }
.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: 112px; }
.scene-line { font: 600 26px/1.8 var(--serif); }
.scene .tok { display: inline-block; }
.scene .tok[data-changed="1"] { color: var(--good); font-weight: 700; }
.scene-cap { min-height: 3em; font-weight: 600; color: var(--ink); }
.scene-ctl { gap: 8px; }
.scene-btn { width: auto; min-width: 56px; padding: 8px 12px; }
.scene-btn.wide { flex: 1; }
/* выбор из двух, классы и таблица учителя */
.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); }
/* цифры вариантов: на компьютере видно, что 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 { text-align: center; }
