/* Мобильный подход: один столбец, крупные цели для пальца, нижние панели с учётом safe-area.
   На широком экране — та же колонка по центру. */
:root {
  --bg: #f6f8f3; --card: #ffffff; --line: #d9e3d7; --text: #102c31; --muted: #60716b;
  --accent: #179653; --accent-ink: #ffffff; --accent-soft: #e2f3e8; --danger: #e5484d; --danger-soft: #ffe9ea;
  --user-bubble: #eef2e9; --tutor-bubble: #e2f3e8;
  --ball-hi: #fff6a8; --ball: #ffd92e; --ball-lo: #f2b705; --ink: #2b2b2b; --tongue: #7a2e1f;
  --sv-body: #5cc8ec; --sv-edge: #2a9ccc; --sv-maze: #8fdcf5; --sv-limb: #1f2fa8; --sv-white: #f7f7f5; --sv-shade: #d9dbe0;
  --font: "Manrope", "Segoe UI", system-ui, sans-serif;
  --radius: 20px; --tap: 48px;
  color-scheme: light;
}
/* Тема: как на телефоне (авто), ручной выбор в шапке перекрывает: <html data-theme="light|dark">. */
:root[data-theme="dark"] {
  --bg: #14221c; --card: #1b2d24; --line: #354b3e; --text: #eef5ee; --muted: #b2c2b7;
  --accent: #3fbf7f; --accent-ink: #0d1f15; --accent-soft: #1f3a2b; --danger-soft: #4a2224; --user-bubble: #22324a; --tutor-bubble: #1f3a2b;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14221c; --card: #1b2d24; --line: #354b3e; --text: #eef5ee; --muted: #b2c2b7;
    --accent: #3fbf7f; --accent-ink: #0d1f15; --accent-soft: #1f3a2b; --danger-soft: #4a2224; --user-bubble: #22324a; --tutor-bubble: #1f3a2b;
    color-scheme: dark;
  }
}
.theme-btn { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted); display: grid; place-items: center; padding: 0; }
.theme-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .ic { display: none; } .theme-btn[data-mode="auto"] .ic-auto, .theme-btn[data-mode="light"] .ic-sun, .theme-btn[data-mode="dark"] .ic-moon { display: block; }
.brand-right { display: flex; align-items: center; gap: 10px; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
.app { max-width: 560px; margin: 0 auto; min-height: 100%; }
.hidden { display: none !important; }
button, input, select { font: inherit; }
button { font-weight: 800; min-height: var(--tap); padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer; background: var(--line); color: var(--text); }
button:focus-visible, input:focus-visible, select:focus-visible, .card:has(input:focus-visible), .chip:has(input:focus-visible) {
  outline: 3px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); font-size: 19px; width: 100%; min-height: 56px; }
.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Экран подготовки ---------- */
.setup { display: grid; gap: 22px; padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 96px); }
#parentLogin[hidden], #accountBar[hidden], #parentCodeGroup[hidden], #accountError[hidden] { display: none; }
#parentLoginForm { display: grid; gap: 18px; }
#parentLoginForm input { width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); font: inherit; }
#accountBar { border-bottom: 1px solid var(--line); padding-bottom: 12px; overflow-wrap: anywhere; }
.brand h1 { margin: 0; font-size: 28px; font-weight: 900; }
.brand p { margin: 4px 0 0; color: var(--muted); }
.group { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 0; }
.group legend, .group .legend, .more summary { font-weight: 800; font-size: 17px; padding: 0; }
input, select { width: 100%; min-height: var(--tap); padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); }
.more summary { cursor: pointer; color: var(--muted); }
.legend-sm { font-weight: 700; font-size: 14px; color: var(--muted); }
.more .group { margin-bottom: 10px; }
.voice-row { display: flex; gap: 8px; }
.voice-row select { flex: 1; min-width: 0; }
.preview { flex: none; background: var(--accent-soft); color: var(--accent); }
.more[open] summary { margin-bottom: 10px; }

.picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Персонажи: по три в ряд, остальные — листать вбок (snap); стрелка справа, пока есть что листать (Жорик — 2026-10-03). */
.heroes { position: relative; }
/* Сетка, а не flex: в Safari на iPhone flex-basis в процентах внутри прокручиваемого контейнера считался неверно —
   помещалось два персонажа вместо трёх (стенд 2026-10-03). grid-auto-columns от ширины контейнера работает везде. */
#picker { display: grid; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: calc((100% - 20px) / 3); gap: 10px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px 2px 4px; -webkit-overflow-scrolling: touch; }
#picker::-webkit-scrollbar { display: none; }
#picker .card { min-width: 0; width: 100%; scroll-snap-align: start; overflow: hidden; }
#picker .card .avatar { --k: .62; }
#picker .card b { font-size: 14px; max-width: 100%; text-align: center; line-height: 1.15; overflow-wrap: anywhere; }
.heroes .more-arrow { position: absolute; right: -6px; top: 50%; translate: 0 -50%; width: 34px; height: 34px; border: 0; padding: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.18); pointer-events: none; opacity: 0; transition: opacity .2s; z-index: 2; }
.heroes.can-scroll .more-arrow:not(.back) { pointer-events: auto; }
.heroes .more-arrow.back { right: auto; left: -6px; }
.heroes.can-back .more-arrow.back { opacity: 1; pointer-events: auto; }
.heroes .more-arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.heroes.can-scroll .more-arrow:not(.back) { opacity: 1; animation: nudge 1.4s infinite ease-in-out; }
@keyframes nudge { 0%, 100% { translate: 0 -50%; } 50% { translate: 4px -50%; } }
.card { position: relative; display: grid; justify-items: center; gap: 8px; padding: 18px 8px 14px; border-radius: var(--radius);
  background: var(--card); border: 3px solid var(--line); cursor: pointer; transition: border-color .15s, transform .15s; }
.card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.card:active { transform: scale(.97); }
.card input { position: absolute; opacity: 0; pointer-events: none; }
.card .avatar { --k: .8; }
.card b { font-size: 17px; }
/* Карточки режимов занятия: крупный значок, название, одна строка пояснения */
.card.mode { gap: 4px; padding: 14px 8px 12px; }
.card.mode .ico { font-size: 40px; line-height: 1.1; }
.card.mode small { font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.25; }

/* Режим «В чате»: переписка — основное поле, строка ввода над кнопками */
/* Панель ввода: узкая, под одну строку, растёт до 4 строк при наборе; иконки — минималистичные (линии), не эмодзи. */
.composer { display: flex; flex: 0 0 auto; gap: 6px; padding: 6px 12px 0; align-items: center; }
.composer[hidden] { display: none; }
.composer textarea { flex: 1; min-width: 0; min-height: 44px; height: 44px; max-height: 110px; padding: 9px 12px; border-radius: 19px; border: 1.5px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 16px; line-height: 22px; resize: none; overflow-y: auto; }
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer .icon-btn, .composer .send { flex: 0 0 38px; width: 38px; height: 38px; min-height: 38px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.composer .icon-btn { background: transparent; border: 1.5px solid var(--line); color: var(--muted); }
.composer .icon-btn svg, .composer .send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer .ic-stop { display: none; }
.composer .icon-btn[aria-pressed="true"] .ic-mic { display: none; } .composer .icon-btn[aria-pressed="true"] .ic-stop { display: block; }
.composer .send { background: var(--accent); color: var(--accent-ink); border: 0; }
.composer .send:disabled { opacity: .45; }
@keyframes pulse { 50% { transform: scale(.94); } }
.session.chat-mode .chat { flex: 1 1 auto; height: auto; min-height: 0; }
.session.chat-mode > .board { --board-height: min(50dvh, max(0px, calc(100dvh - 300px))); flex: 0 0 auto; height: var(--board-height); max-height: var(--board-height); } /* половина окна, с запасом для последних сообщений и ввода */
.session.chat-mode .bar { display: none; } /* в чате всё в одной строке ввода; «Закончить» — в шапке */
.session.chat-mode .composer { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6px); border-top: 1px solid var(--line); padding-top: 6px; }
.composer .icon-btn, .composer .send { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.stop-chat { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 16px; min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 999px;
  background: var(--danger-soft); color: var(--danger); }
.stop-chat[hidden] { display: none; }
.stage { position: relative; }
.msg.typing { display: flex; gap: 5px; align-items: center; min-height: 20px; padding: 14px 18px; }
.msg.typing .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: typing-dot 1.2s infinite ease-in-out; }
.msg.typing .dot:nth-child(2) { animation-delay: .15s; } .msg.typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }
#dictateBtn[aria-pressed="true"] { --lvl: 0; background: var(--danger-soft) !important; color: var(--danger) !important; border-color: var(--danger) !important;
  box-shadow: 0 0 0 calc(3px + var(--lvl) * 14px) rgba(229, 72, 77, .25); animation: dict-pulse 1.4s infinite ease-in-out; transition: box-shadow .08s; }
@keyframes dict-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { #dictateBtn[aria-pressed="true"], .msg.typing .dot { animation: none; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { position: relative; flex: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: grid; place-items: center; min-width: var(--tap); min-height: var(--tap); padding: 0 16px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--line); font-weight: 800; cursor: pointer; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.start-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: linear-gradient(transparent, var(--bg) 30%); }
.start-bar button { display: block; max-width: 528px; margin: 0 auto; }
/* fieldset по умолчанию не ужимается уже содержимого (min-width: min-content) — длинное название учебника в select
   растягивало страницу вправо на iPhone (2026-10-02). */
fieldset.group, .textbook-row { min-width: 0; }
.textbook-row { display: flex; gap: 8px; }
.textbook-row select { width: 100%; max-width: 100%; }
.textbook-row select { flex: 1; min-width: 0; min-height: var(--tap); padding: 0 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--text); font: inherit; }
.textbook-row input { flex: 0 0 90px; min-height: var(--tap); padding: 0 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 17px; text-align: center; }
.balance-note { margin: 6px auto 0; max-width: 528px; text-align: center; font-size: 13px; color: var(--muted); }
.balance-note[hidden] { display: none; }
.error { margin: 0; color: var(--danger); background: var(--danger-soft); padding: 12px 14px; border-radius: 14px; }

.demo-note { margin: 0; padding: 10px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* ---------- Экран занятия ---------- */
.session { height: 100dvh; display: flex; flex-direction: column; }
/* Занятие занимает ровно экран: страница под ним не прокручивается (иначе после экрана подготовки, прокрученного к кнопке «Начать», сверху была пустота) */
body:has(.session:not(.hidden)) { overflow: hidden; height: 100dvh; } /* доска может быть скрыта — раскладка от неё не зависит */
.session > .stage, .session > .bar { flex: none; }
/* Доска занимает всё, что осталось, и листается внутри */
.session > .board { flex: 1 1 auto; min-height: 0; }
/* Открытая переписка — невысокая полоса на 2–3 последних сообщения (проверить, что тебя поняли); остальное — доске */
.chat { position: relative; flex: 0 0 auto; height: min(30dvh, 260px); display: flex; }
.session:not(:has(.board:not([hidden]))) .chat { flex: 1 1 auto; height: auto; min-height: 150px; }
.chat .transcript { flex: 1; min-height: 0; }
.stage { display: grid; justify-items: center; gap: 6px; padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px 8px; }
.stage .avatar { --k: 1.25; transition: width .25s, height .25s; }
/* Когда видна доска — персонаж совсем маленький, имя·статус·таймер в одну строку: доске и переписке нужно место */
.session:has(.board:not([hidden])) .stage { padding: calc(env(safe-area-inset-top, 0px) + 4px) 16px 2px; gap: 0; grid-template-columns: auto 1fr; align-items: center; justify-items: start; column-gap: 10px; }
.session:has(.board:not([hidden])) .stage .avatar { --k: .45; grid-row: 1 / span 2; }
.session:has(.board:not([hidden])) .stage .who { font-size: 14px; }
.session:has(.board:not([hidden])) .stage .timer { font-size: 12px; padding: 1px 10px; justify-self: start; }
.who { color: var(--muted); font-weight: 600; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 14px; padding: 2px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); }
.timer:empty { display: none; }
.timer.ending { background: var(--danger-soft); color: var(--danger); }
.who span:first-child { color: var(--text); font-weight: 800; }
.transcript { overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 18px; max-width: 85%; line-height: 1.4; }
.msg.user { background: var(--user-bubble); align-self: flex-end; border-bottom-right-radius: 6px; }
.msg.hint { align-self: center; background: var(--accent-soft); color: var(--text); font-size: 14px; text-align: center; }
.msg.system { align-self: center; background: var(--danger-soft); color: var(--danger); font-size: 14px; text-align: center; }
.msg.tutor { background: var(--tutor-bubble); align-self: flex-start; border-bottom-left-radius: 6px; }
.msg.user, .msg.tutor { position: relative; padding-right: 44px; }
.msg .copy-message { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; min-height: 32px; padding: 7px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; user-select: none; touch-action: manipulation; }
.copy-message svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.copy-message:hover, .copy-message:focus-visible { background: var(--accent-soft); color: var(--text); }
.bar { display: flex; gap: 10px; padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 12px); border-top: 1px solid var(--line); background: var(--bg); }
.bar button { flex: 1; min-height: 56px; }
.bar .photo { flex: 0 0 56px; padding: 0; font-size: 24px; background: var(--accent-soft); }
.bar .photo:disabled { opacity: .5; }
.bar .photo[aria-pressed="true"] { background: var(--accent); }

/* ---------- Переписка скрыта (по умолчанию): занятие — это голос и доска, текст — по кнопке 💬 ---------- */
.session.chat-hidden .chat { display: none; }
.session.chat-hidden > .board { flex: 1 1 auto; max-height: none; }
/* Нет ни доски, ни переписки — персонаж большой по центру */
.session.chat-hidden:not(:has(.board:not([hidden]))) .stage { flex: 1 1 auto; align-content: center; }
.session.chat-hidden:not(:has(.board:not([hidden]))) .stage .avatar { --k: 1.7; }
/* Системные сообщения (ошибки связи) при скрытой переписке — всплывашкой над кнопками */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); z-index: 5; padding: 12px 14px; border-radius: 14px;
  background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: 14px; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast[hidden] { display: none; }
.toast[data-tone="success"] { background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent); }
.msg.photo-msg { display: grid; gap: 6px; }
.msg.photo-msg img { max-width: 180px; max-height: 180px; border-radius: 10px; justify-self: end; object-fit: cover; }
.round.resume { background: var(--accent); color: var(--accent-ink); }
.round[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* Кнопки прокрутки переписки: появляются, только когда полезны */
.jump { position: absolute; right: 16px; min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 999px;
  background: var(--card); color: var(--text); border: 2px solid var(--line); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.jump-top { top: 8px; } .jump-down { bottom: 8px; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- Доска ---------- */
.board { margin: 4px 16px 8px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 2px solid var(--line);
  overflow-y: auto; display: grid; grid-auto-rows: max-content; gap: 10px; align-content: start; }
.board[hidden] { display: none; }
.bd-title { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bd-hourglass { display: block; width: fit-content; margin: 18px auto; font-size: 42px; line-height: 1.3; animation: preparation-hourglass 1.6s ease-in-out infinite; }
@keyframes preparation-hourglass { 0%,35% { transform: rotate(0deg); } 65%,100% { transform: rotate(180deg); } }
@media (prefers-reduced-motion: reduce) { .bd-hourglass { animation: none; } }
.bd-math { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 800; line-height: 1.35; }
.bd-line { padding: 0 8px; border-radius: 8px; }
.bd-current { background: var(--accent-soft); color: var(--accent); }
.bd-table { border-collapse: collapse; font-size: 18px; font-weight: 700; width: 100%; }
.bd-table th { font-size: 13px; color: var(--muted); text-align: left; padding: 4px 8px; border-bottom: 2px solid var(--line); }
.bd-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.bd-q { color: var(--accent); }
.bd-syl { font-size: 28px; font-weight: 800; display: flex; gap: 4px; align-items: baseline; flex-wrap: wrap; }
.bd-part { padding: 2px 10px; border-radius: 10px; background: var(--accent-soft); }
.bd-dash { color: var(--muted); }
.bd-reading { display: flex; flex-direction: column; gap: 8px; }
.bd-read-line { font-size: 30px; font-weight: 800; line-height: 1.35; display: flex; flex-wrap: wrap; gap: 0 14px; padding: 2px 8px; border-radius: 10px; opacity: .55; }
.bd-read-cur { opacity: 1; background: var(--accent-soft); }
.bd-read-word { white-space: nowrap; }
.bd-read-dash { color: var(--muted); font-weight: 400; margin: 0 1px; }
.bd-caption { color: var(--muted); font-size: 13px; }
.bd-text { margin: 0; font-size: 20px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.bd-text-long { font-size: 16px; line-height: 1.45; }
.bd-text mark { background: var(--accent-soft); color: var(--accent); font-weight: 800; border-radius: 4px; padding: 0 2px; }
.bd-underline { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.bd-list { margin: 0; padding-left: 20px; font-size: 18px; font-weight: 600; line-height: 1.5; }
.bd-tiles { display: flex; gap: 8px; flex-wrap: wrap; }
.bd-image img { display: block; width: 100%; max-height: 42dvh; object-fit: contain; object-position: top; border-radius: 10px; background: #fff; cursor: zoom-in; }
.bd-crop { width: 100%; overflow: hidden; border-radius: 10px; background: #fff; cursor: zoom-in; } /* высота не режется: ширина подбирается так, чтобы вырезка влезла целиком */
.bd-crop img { display: block; transform-origin: 0 0; max-height: none; border-radius: 0; }
.bd-image-full .bd-crop { max-height: none; overflow: auto; cursor: zoom-out; }
.bd-image-full .bd-crop img { width: 100%; }
.bd-image-full { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 12px; overflow: auto; }
.bd-image-full img { max-height: none; width: auto; max-width: 100%; cursor: zoom-out; }
.bd-groups { display: grid; gap: 6px; }
.bd-groups.bd-schematic .bd-grow { flex-wrap: wrap; }
.bd-gscheme { font-style: italic; }
.bd-grow { display: flex; gap: 6px; align-items: center; }
.bd-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }
.bd-grow.bd-dim .bd-dot { opacity: .25; }
.bd-gnum { margin-left: 8px; font-weight: 800; color: var(--accent); min-width: 20px; }
.bd-gcap { font-size: 16px; color: var(--muted); margin-top: 4px; }
.bd-tile { width: 44px; height: 48px; display: grid; place-items: center; border-radius: 10px; background: var(--ball);
  color: var(--ink); font-size: 26px; font-weight: 900; box-shadow: 0 3px 0 var(--ball-lo); }
.bd-words { display: flex; gap: 8px 16px; flex-wrap: wrap; margin-top: 10px; font-size: 22px; font-weight: 800; }
.bd-word { padding: 2px 10px; border-radius: 10px; background: var(--accent-soft); }
.bd-word.bd-q { background: transparent; border: 2px dashed var(--line); color: var(--muted); }
.bd-nline { width: 100%; height: auto; }
.bd-axis { stroke: var(--muted); stroke-width: 2; }
.bd-nl { font: 700 12px var(--font); fill: var(--muted); }
.bd-nl-on { font: 800 14px var(--font); fill: var(--accent); }
.bd-dot { fill: var(--accent); }
.bd-jump { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.bd-piano { width: 100%; max-width: 480px; height: auto; }
.bd-white { fill: #fff; stroke: #303833; stroke-width: 1.1; }
.bd-black { fill: #2b2b2b; stroke: #1b211d; stroke-width: 1.5; }
.bd-white, .bd-black { vector-effect: non-scaling-stroke; paint-order: fill stroke; }
.bd-key-mark { fill: #fff; stroke: #1b211d; stroke-width: 1; vector-effect: non-scaling-stroke; }
.bd-k-accent { fill: var(--accent); }
.bd-k-ok { fill: #8fd3a8; }
.bd-k-muted { fill: #d9dedb; }
.bd-klabel { font: 700 9px var(--font); fill: #66756b; }
.bd-klabel-on { fill: var(--text); font-size: 10px; }
.bd-white.bd-k-accent + .bd-klabel { fill: var(--accent-ink); }

/* ---------- Персонажи ---------- */
.avatar { --k: 1; position: relative; width: calc(120px * var(--k)); height: calc(120px * var(--k)); }
.avatar > * { position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px; scale: var(--k); }

/* Шарик */
.ball { position: relative; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--ball-hi), var(--ball) 45%, var(--ball-lo));
  box-shadow: inset -8px -10px 0 rgba(0,0,0,.08), 0 8px 18px rgba(242,183,5,.35); transition: transform .15s; }
.ball.ball-pink { --ball-hi: #ffe1ee; --ball: #ff82b5; --ball-lo: #ec4e91;
  box-shadow: inset -8px -10px 0 rgba(0,0,0,.08), 0 8px 18px rgba(236,78,145,.35); }
/* Бантик Лавити движется вместе с шариком. */
.ball-pink .laviti-bow { position: absolute; z-index: 1; top: -7px; right: 9px; width: 44px; height: 27px;
  transform: rotate(12deg); pointer-events: none; }
.laviti-bow::before, .laviti-bow::after { content: ""; position: absolute; top: 1px; width: 21px; height: 25px;
  box-sizing: border-box; border: 2px solid #a93679; background: linear-gradient(135deg, #ffe4f4, #d98ac0); }
.laviti-bow::before { left: 0; border-radius: 6px 13px 13px 6px; transform: rotate(-8deg); }
.laviti-bow::after { right: 0; border-radius: 13px 6px 6px 13px; transform: rotate(8deg); }
.laviti-bow .bow-knot { position: absolute; z-index: 1; top: 7px; left: 17px; width: 10px; height: 14px;
  box-sizing: border-box; border: 2px solid #a93679; border-radius: 4px; background: #edb0d5; }
.ball .eye { position: absolute; top: 38px; width: 14px; height: 20px; background: var(--ink); border-radius: 50%; animation: blink 4s infinite; }
.ball .eye.left { left: 36px; } .ball .eye.right { right: 36px; }
.ball .mouth { position: absolute; left: 50%; bottom: 28px; width: 50px; height: 22px; transform: translateX(-50%);
  border: 5px solid var(--ink); border-top: none; border-radius: 0 0 50px 50px; transition: height .15s; }
.avatar.speaking .ball { animation: bounce .6s infinite alternate; }
.avatar.speaking .ball .mouth { animation: talk .25s infinite alternate; background: var(--tongue); }
.avatar.listening .ball { transform: scale(1.08); }
.avatar.listening .ball .eye { height: 24px; top: 34px; }

/* Шесть-Семь */
.sv { overflow: visible; }
.maze-bg { fill: var(--sv-body); }
.maze-line { stroke: var(--sv-maze); stroke-width: 1.6; fill: none; }
.sv .digits { font: 900 132px "Nunito", var(--font); fill: url(#maze); stroke: var(--sv-edge); stroke-width: 3; paint-order: stroke; }
.sv .limb { stroke: var(--sv-limb); stroke-width: 11; stroke-linecap: round; fill: none; }
.sv .glove, .sv .shoe { fill: var(--sv-white); stroke: var(--sv-shade); stroke-width: 2; }
.sv .eye-w { fill: var(--sv-white); stroke: #222; stroke-width: 1.5; }
.sv .pupil { fill: #111; transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.sv .armL { transform-origin: 44px 98px; } .sv .armR { transform-origin: 158px 98px; }
.sv .body { transform-origin: 100px 180px; }
.avatar.speaking .sv .body { animation: hop .35s infinite alternate ease-in-out; }
.avatar.speaking .sv .armL { animation: wave .35s infinite alternate; }
.avatar.listening .sv .pupil { transform: scale(1.25); }
.avatar.listening .sv .body { rotate: -4deg; }
.avatar.sixseven .sv .armL, .avatar.sixseven .sv .armR { animation: scales .45s infinite alternate ease-in-out; }
.avatar.sixseven .sv .body { animation: sway .45s infinite alternate ease-in-out; }

@keyframes bounce { from { translate: 0 0 } to { translate: 0 -10px } }
@keyframes talk { from { height: 10px } to { height: 26px } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1) } 97% { transform: scaleY(.1) } }
@keyframes hop { from { translate: 0 0 } to { translate: 0 -8px } }
@keyframes wave { from { rotate: 0deg } to { rotate: 25deg } }
@keyframes scales { from { rotate: 30deg } to { rotate: -30deg } }
@keyframes sway { from { rotate: -4deg } to { rotate: 4deg } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; } }

/* «Домашку сам» — единая визуальная система с лендингом. */
body { line-height: 1.55; }
.app { max-width: 720px; }
.setup { gap: 20px; padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px calc(env(safe-area-inset-bottom, 0px) + 150px); }
.brand { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.wordmark { display: flex; align-items: center; font-size: 28px; font-weight: 800; letter-spacing: -.06em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; margin-right: 9px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 26px; letter-spacing: 0; }
.brand-caption { font-size: 12px; color: var(--muted); }
.setup-intro { padding: 14px 0 6px; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; margin: 0 0 14px; }
.eyebrow > span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.setup-intro h1 { font-size: clamp(29px, 5.4vw, 40px); font-weight: 800; letter-spacing: -.045em; line-height: 1.16; margin: 0 0 14px; max-width: 540px; }
.setup-intro h1 em { font-style: normal; color: var(--accent); }
.setup-intro > p:last-child { color: var(--muted); font-size: 14px; margin: 0; max-width: 510px; }
.setup-panel { display: grid; gap: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 24px; box-shadow: 0 5px 24px #102c3103; min-width: 0; }
.panel-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; letter-spacing: -.025em; margin: 0; }
.panel-title > span { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 11px; letter-spacing: 0; }
.group { gap: 12px; }
.group legend, .group .legend, .more summary { font-size: 14px; font-weight: 700; }
.group legend { margin-bottom: 12px; }
input, select { border-width: 1px; border-radius: 12px; font-size: 16px; }
.card { border-width: 1px; border-radius: 14px; background: var(--bg); gap: 12px; transition: border-color .18s, background .18s, box-shadow .18s; }
.card:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.card::after { content: ''; position: absolute; right: 12px; top: 12px; width: 16px; height: 16px; border: 1px solid var(--line); background: var(--card); border-radius: 50%; }
.card:has(input:checked)::after { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px var(--accent-soft); }
.card.mode { text-align: left; justify-items: start; padding: 18px 16px; gap: 8px; }
.card.mode .ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--card); font-size: 25px; }
.card.mode b { font-size: 15px; line-height: 1.4; padding-right: 3px; }
.card.mode small { text-align: left; line-height: 1.5; font-size: 12px; }
#picker .card { padding: 24px 8px 16px; }
#picker .avatar { --k: .85; margin-bottom: 6px; }
.chips { flex-wrap: wrap; overflow: visible; gap: 8px; padding-bottom: 0; }
.chip span { border-width: 1px; border-radius: 10px; font-size: 14px; font-weight: 700; }
#grade { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); }
#grade .chip span { min-width: 0; padding: 0; }
.more { padding: 18px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.more summary { min-height: 28px; border-radius: 4px; }
.more summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.more .group { margin-top: 8px; }
.preview { border-radius: 12px; font-size: 13px; padding: 0 14px; }
.start-bar { z-index: 4; left: 50%; transform: translateX(-50%); width: min(100%, 720px); padding: 16px 20px calc(env(safe-area-inset-bottom, 0px) + 16px); background: var(--bg); border-top: 1px solid var(--line); }
.start-bar button { max-width: none; display: flex; justify-content: center; gap: 16px; align-items: center; border-radius: 14px; box-shadow: 0 7px 20px #17965318; font-size: 16px; }
.start-bar button span { font-size: 22px; }
.balance-note { font-size: 12px; line-height: 1.5; }
.session { background: var(--bg); }
.stage { padding-top: calc(env(safe-area-inset-top, 0px) + 22px); padding-bottom: 16px; }
.who { font-size: 14px; text-align: center; }
.session:has(.board:not([hidden])) .stage { padding: calc(env(safe-area-inset-top, 0px) + 10px) 20px 10px; }
.session:has(.board:not([hidden])) .who { text-align: left; overflow-wrap: anywhere; }
.board { border-width: 1px; border-radius: 20px; padding: 20px; background-image: radial-gradient(var(--line) .7px, transparent .7px); background-size: 20px 20px; margin: 6px 20px 12px; }
.bd-title { font-size: 11px; letter-spacing: .08em; padding-bottom: 8px; }
.bd-text, .bd-list { line-height: 1.6; }
.bd-table { background: var(--card); border-radius: 10px; }
.msg { padding: 12px 16px; border: 1px solid var(--line); font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.transcript { padding: 12px 20px; gap: 12px; }
.bar { padding-left: 20px; padding-right: 20px; gap: 8px; background: var(--card); }
.bar button { min-height: 52px; border-radius: 12px; font-size: 14px; padding: 0 12px; }
.bar .photo { flex-basis: 48px; font-size: 23px; }
.composer { padding-left: 16px; padding-right: 16px; gap: 6px; background: var(--card); }
.composer input { border-width: 1px; border-radius: 12px; }
.composer .photo, .composer .send { border-radius: 12px; }
.stop-chat { min-height: 44px; font-size: 12px; border-radius: 10px; }
.session.chat-mode .stage { grid-template-columns: auto 1fr; align-items: center; justify-items: start; padding: calc(env(safe-area-inset-top, 0px) + 12px) 116px 12px 20px; gap: 10px; border-bottom: 1px solid var(--line); background: var(--card); }
.session.chat-mode .stage .avatar { --k: .4; grid-row: auto; }
.session.chat-mode .stage .who { text-align: left; font-size: 13px; }
.session.chat-mode .stage .timer { display: none; }
.toast { width: min(calc(100% - 32px), 680px); left: 50%; right: auto; transform: translateX(-50%); }
@media (hover: hover) { .card:hover { border-color: var(--accent); } .chip span:hover { border-color: var(--accent); } .primary:hover:not(:disabled) { background: #117b43; } }
@media (min-width: 760px) { .setup { padding-top: 36px; } .session { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
@media (max-width: 420px) { .setup { padding-left: 16px; padding-right: 16px; } .setup-panel { padding: 20px 16px; } .brand-caption { font-size: 11px; } .picker { gap: 8px; } .card.mode { padding: 16px 12px; } #grade { grid-template-columns: repeat(5, minmax(0, 1fr)); } .bar { padding-left: 12px; padding-right: 12px; } .bar button { font-size: 13px; padding: 0 8px; } .composer { padding-left: 10px; padding-right: 10px; } .composer .photo, .composer .send { flex-basis: 44px; } .board { margin-left: 12px; margin-right: 12px; padding: 16px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
/* Рисунок не должен увеличивать размер своей ячейки в компактной шапке. */
.avatar > .ball { position: absolute; }
.session.chat-mode .stage,
.session.chat-mode:has(.board:not([hidden])) .stage { grid-template-columns: 48px minmax(0, 1fr); align-items: center; justify-items: start; padding: calc(env(safe-area-inset-top, 0px) + 12px) 112px 12px 16px; gap: 10px; border-bottom: 1px solid var(--line); background: var(--card); }
.session.chat-mode .stage .avatar,
.session.chat-mode:has(.board:not([hidden])) .stage .avatar { --k: .4; grid-row: 1; }
.session.chat-mode .stage .who,
.session.chat-mode:has(.board:not([hidden])) .stage .who { font-size: 12px; text-align: left; }
.session.chat-mode .stage .who .status { display: block; }
/* Геометрические фигуры на доске */
.bd-figure { width: 100%; }
.bd-fig { width: 100%; max-height: 38dvh; display: block; font-family: inherit; }
.bd-fpoly { fill: rgba(31, 122, 77, .10); stroke: #1f7a4d; stroke-width: 1.4; stroke-linejoin: round; }
.bd-fseg { stroke: #1f7a4d; stroke-width: 1.4; fill: none; stroke-linecap: round; }
.bd-fdash { stroke-dasharray: 3 2; }
.bd-fangle { stroke: #b7791f; stroke-width: 1.2; }
.bd-fpoint { fill: #1f7a4d; }
.bd-fbody { stroke: rgba(0,0,0,.25); stroke-width: .6; } .bd-fglow { opacity: .25; } .bd-farrow { stroke: #c0392b; stroke-width: 1.6; } .bd-farrowhead { fill: #c0392b; }
.bd-flbl { font-size: 6px; font-weight: 700; fill: #14312a; }
.bd-fvert { font-size: 6px; font-weight: 800; fill: #1f7a4d; }
.bd-flbl-sm { font-size: 4.6px; fill: #c0392b; }
/* Таблица Менделеева */
.bd-periodic { width: 100%; }
.bd-ptgrid { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); grid-auto-rows: auto; gap: 2px; width: 100%; }
.bd-pt { display: grid; place-items: center; aspect-ratio: 1; border-radius: 3px; font-size: clamp(7px, 1.9vw, 12px); line-height: 1; color: #14312a; min-width: 0; position: relative; }
.bd-pt .bd-ptn { display: none; position: absolute; top: 1px; left: 2px; font-size: .6em; opacity: .7; }
@media (min-width: 640px) { .bd-pt .bd-ptn { display: block; } }
.bd-pt .bd-pts { font-weight: 800; }
.bd-pt[style*="grid-row: 9"], .bd-pt[style*="grid-row: 10"] { margin-top: 0; }
.bd-pt[style*="grid-row: 9"] { margin-top: 6px; }
.bd-pt-a { background: #ffd1d1; } .bd-pt-e { background: #ffe2b8; } .bd-pt-t { background: #fff3b0; } .bd-pt-p { background: #d7f0d2; }
.bd-pt-m { background: #c9ecec; } .bd-pt-n { background: #cfe3ff; } .bd-pt-h { background: #e2d4ff; } .bd-pt-g { background: #f3d1f0; }
.bd-pt-l { background: #e8e8c8; } .bd-pt-c { background: #e0d6c6; }
.bd-pt-hl { outline: 2.5px solid var(--accent, #1f7a4d); outline-offset: -1px; z-index: 1; transform: scale(1.12); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.bd-pt-dim { opacity: .45; }
.bd-ptlegend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; font-size: 11px; }
.bd-ptkey { padding: 2px 7px; border-radius: 999px; color: #14312a; }
.bd-pt, .bd-ptkey { color: #14312a; }
/* Графики функций */
.bd-graph { width: 100%; }
.bd-gsvg { width: 100%; max-height: 42dvh; display: block; background: #fff; border-radius: 10px; }
.bd-ggrid { stroke: #e3e9e3; stroke-width: .6; }
.bd-gaxis { stroke: #33443d; stroke-width: 1.2; }
.bd-gtick { font-size: 7px; fill: #5b6b7a; }
.bd-glbl { font-size: 8px; font-weight: 700; fill: #14312a; }
.bd-gfn { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bd-gseg { stroke: #b7791f; stroke-width: 1.6; stroke-dasharray: 3 2; }
.bd-gpt { fill: #c0392b; stroke: #fff; stroke-width: 1; }
.bd-glegend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 12px; }
.bd-gkey { padding: 2px 8px; border: 1.5px solid; border-radius: 999px; font-weight: 700; }
/* Дроби */
.bd-fractions { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.bd-fractions .bd-gcap { flex-basis: 100%; }
.bd-frac { display: grid; justify-items: center; gap: 4px; }
.bd-fsvg { width: 96px; height: auto; }
.bd-frac .bd-fsvg[viewBox="0 0 120 30"] { width: 160px; }
.bd-fcell { fill: #fff; stroke: #1f7a4d; stroke-width: 1.5; }
.bd-ffill { fill: #8fd3a8; }
.bd-flabel { font-weight: 800; font-size: 15px; }
/* Часы */
.bd-clocksvg { width: 170px; height: auto; display: block; }
.bd-clkface { fill: #fff; stroke: #1f7a4d; stroke-width: 2.5; }
.bd-clktick { stroke: #14312a; stroke-width: 1.6; } .bd-clkmin { stroke: #9aa8a0; stroke-width: .7; }
.bd-clknum { font-size: 8.5px; font-weight: 800; fill: #14312a; }
.bd-clkhour { stroke: #14312a; stroke-width: 4; stroke-linecap: round; } .bd-clkminute { stroke: #1f7a4d; stroke-width: 2.6; stroke-linecap: round; }
.bd-clkcenter { fill: #14312a; }
.bd-clklbl { font-size: 5.5px; font-weight: 700; fill: #1f7a4d; }
/* Разряды */
.bd-pvtable { border-collapse: collapse; } .bd-pvtable th { font-size: 12px; color: var(--muted); padding: 4px 12px; border: 1px solid var(--line); background: var(--bg); }
.bd-pvtable td { font-size: 26px; font-weight: 800; text-align: center; padding: 6px 12px; border: 1px solid var(--line); min-width: 48px; }
.bd-pvtable td.bd-pvhide { color: var(--accent); }
/* Термометр */
.bd-thermosvg { height: 230px; width: auto; display: block; }
.bd-thtube { fill: #fff; stroke: #33443d; stroke-width: 1.5; } .bd-thbulb { fill: #c0392b; stroke: #33443d; stroke-width: 1.5; }
.bd-thfill { fill: #c0392b; } .bd-thtick { stroke: #33443d; stroke-width: 1; } .bd-thzero { stroke: #1f7a4d; stroke-width: 1.5; }
.bd-thlbl { font-size: 8px; fill: #33443d; } .bd-thval { font-size: 10px; font-weight: 800; fill: #c0392b; } .bd-thmark { stroke: #1f7a4d; stroke-width: 1.5; }
/* Диаграммы */
.bd-chartsvg { width: 100%; max-height: 40dvh; display: block; background: #fff; border-radius: 10px; }
.bd-chlbl { font-size: 8px; fill: #14312a; } .bd-chval { font-size: 8px; font-weight: 800; fill: #14312a; } .bd-pie { stroke: #fff; stroke-width: 1; }
/* Единичная окружность */
.bd-ucsvg { width: 100%; max-width: 300px; display: block; background: #fff; border-radius: 10px; }
.bd-uccircle { fill: none; stroke: #33443d; stroke-width: 1.4; } .bd-ucmark { fill: #33443d; }
.bd-ucradius { stroke: #1f7a4d; stroke-width: 2; } .bd-uccos { stroke: #2457c5; stroke-width: 2.4; } .bd-ucsin { stroke: #c0392b; stroke-width: 2.4; }
.bd-ucarc { fill: none; stroke: #b7791f; stroke-width: 1.4; }
/* Нотный стан */
.bd-staffsvg { width: 100%; height: auto; display: block; background: #fff; border-radius: 10px; }
.bd-stline { stroke: #33443d; stroke-width: 1; } .bd-stclef { font-size: 44px; fill: #14312a; }
.bd-sthead { fill: #14312a; } .bd-sthollow { fill: #fff; stroke: #14312a; stroke-width: 1.6; } .bd-staccent { fill: #1f7a4d; }
.bd-ststem { stroke: #14312a; stroke-width: 1.3; } .bd-stflag { fill: #14312a; stroke: #14312a; stroke-width: 0.6; }
.bd-stacc { font-size: 11px; fill: #14312a; } .bd-sthole { font-size: 16px; font-weight: 800; fill: #1f7a4d; }
.bd-stname { font-size: 9px; font-weight: 700; fill: #33443d; }
/* Столбиком */
.bd-column { display: inline-block; }
.bd-colgrid { display: grid; gap: 2px 0; font-variant-numeric: tabular-nums; }
.bd-colcell { width: 34px; height: 40px; display: grid; place-items: center; font-size: 28px; font-weight: 800; line-height: 1; }
.bd-colsign { color: var(--muted); font-weight: 700; }
.bd-colcarry { height: 18px; font-size: 12px; color: var(--accent); align-items: end; }
.bd-colq { color: var(--accent); }
.bd-colres { color: var(--text); }
.bd-colrule { height: 3px; background: var(--text); border-radius: 2px; margin: 4px 0; }
/* Деление уголком */
.bd-divpre { margin: 0; font: 800 26px/1.25 "SF Mono", Menlo, Consolas, "Courier New", monospace; color: var(--text); }
.bd-divquot { color: var(--accent); }

/* Единый вид с чатом: нижняя панель голосового урока — те же круглые контурные кнопки-иконки, «Закончить» — в шапке. */
.bar { align-items: center; gap: 8px; padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 8px); background: var(--card); border-top: 1px solid var(--line); }
.bar button { min-height: 44px; }
.bar .icon-btn, .bar .photo { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; border: 1.5px solid var(--line); color: var(--muted); font-size: 0; }
.bar .icon-btn svg, .bar .round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bar .photo[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.bar .round { flex: 1; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 700; background: var(--accent-soft); color: var(--accent); border: 0; }
.bar .round .ic-play { display: none; fill: currentColor; }
.bar .round.resume { background: var(--accent); color: var(--accent-ink); }
.bar .round.resume .ic-play { display: block; } .bar .round.resume .ic-pause { display: none; }
.bar #stopBtn { display: none; }
/* Голос с доской — та же компактная шапка, что в чате: аватар 48 px, имя и статус слева, таймер под ними, «Закончить» справа. */
.session:not(.chat-mode):has(.board:not([hidden])) .stage { grid-template-columns: 48px minmax(0, 1fr); align-items: center; justify-items: start; column-gap: 10px; row-gap: 2px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 112px 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.session:not(.chat-mode):has(.board:not([hidden])) .stage .avatar { --k: .4; grid-row: 1 / span 2; grid-column: 1; }
.session:not(.chat-mode):has(.board:not([hidden])) .stage .who { grid-column: 2; font-size: 12px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.session:not(.chat-mode):has(.board:not([hidden])) .stage .timer { grid-column: 2; font-size: 11px; padding: 1px 8px; justify-self: start; white-space: nowrap; }

/* Жорик — бутылка воды */
.bt { overflow: visible; }
.bt .plastic { fill: #dff3ff; stroke: #7cc4ea; stroke-width: 3; }
.bt .water { fill: #58b6ea; } .bt .wave { fill: #7fcdf4; }
.bt .cap { fill: #2f8fd6; stroke: #1f6ea8; stroke-width: 2; } .bt .capline { stroke: #1f6ea8; stroke-width: 2; }
.bt .label { fill: #fff; stroke: #7cc4ea; stroke-width: 2; } .bt .drop { fill: #2f8fd6; }
.bt .eye-w { fill: #fff; stroke: #222; stroke-width: 1.5; }
.bt .pupil { fill: #111; transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.bt .shine { fill: #fff; opacity: .85; }
.bt .mouth { fill: #a33; stroke: #222; stroke-width: 2; } .bt .tongue { fill: #f27d9c; }
.bt .cheek { fill: #ff9fb0; opacity: .7; }
.bt .arm { stroke: #2f8fd6; stroke-width: 9; stroke-linecap: round; fill: none; } .bt .hand { fill: #fff; stroke: #2f8fd6; stroke-width: 2; }
.bt .gloss { fill: #fff; opacity: .55; }
.bt .body { transform-origin: 100px 190px; }
.bt .waterwrap { transform-origin: 100px 150px; }
.bt .mouthwrap { transform-origin: 100px 104px; }
.bt .armL { transform-origin: 62px 124px; } .bt .armR { transform-origin: 138px 124px; }
.bt .eyes { transform-box: fill-box; transform-origin: center; transition: transform .25s; }
/* молчит: лёгкое дыхание */
.bt .body { animation: breathe 3s infinite ease-in-out; }
/* говорит: покачивается, вода плещется, рот открывается, ручки машут */
.avatar.speaking .bt .body { animation: sway .5s infinite alternate ease-in-out; }
.avatar.speaking .bt .waterwrap { animation: slosh .45s infinite alternate ease-in-out; }
.avatar.speaking .bt .mouthwrap { animation: chatter .22s infinite alternate; }
.avatar.speaking .bt .armL { animation: wave .4s infinite alternate; }
.avatar.speaking .bt .armR { animation: waveR .4s infinite alternate; }
/* слушает: глаза больше, наклон головы, вода чуть дрожит */
.avatar.listening .bt .eyes { transform: scale(1.18); }
.avatar.listening .bt .body { animation: none; rotate: -5deg; }
.avatar.listening .bt .waterwrap { animation: slosh 1.2s infinite alternate ease-in-out; }
@keyframes breathe { 0%, 100% { scale: 1 1; } 50% { scale: 1.02 .985; } }
@keyframes slosh { from { rotate: -5deg; translate: 0 1px; } to { rotate: 5deg; translate: 0 -1px; } }
@keyframes chatter { from { scale: 1 .35; } to { scale: 1 1.15; } }
@keyframes waveR { from { rotate: 0deg } to { rotate: -25deg } }

/* Статус «Подключаюсь…» — с крутящимся кольцом, пока модель не на связи. */
.status.busy::before { content: ''; display: inline-block; width: 11px; height: 11px; margin: 0 5px -1px 0; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Камо — пирог */
.pie { overflow: visible; }
.pie .crust { fill: #d98c2e; stroke: #a8611a; stroke-width: 3; }
.pie .wall { fill: #c0392b; stroke: #8e2a1f; stroke-width: 2; }
.pie .top { fill: #f6c66b; stroke: #b86f1f; stroke-width: 3; }
.pie .lattice { stroke: #e0a24a; stroke-width: 5; stroke-linecap: round; fill: none; }
.pie .berry { fill: #b22; }
.pie .eye-w { fill: #fff; stroke: #222; stroke-width: 1.5; }
.pie .pupil { fill: #111; transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.pie .shine { fill: #fff; opacity: .9; }
.pie .mouth { fill: #7a2a1a; stroke: #222; stroke-width: 2; } .pie .tongue { fill: #f27d9c; }
.pie .cheek { fill: #ff9fb0; opacity: .7; }
.pie .limb { stroke: #a8611a; stroke-width: 9; stroke-linecap: round; fill: none; }
.pie .hand { fill: #fff; stroke: #a8611a; stroke-width: 2; }
.pie .shoe { fill: #e74c3c; stroke: #8e2a1f; stroke-width: 2; }
.pie .steam { stroke: #bbb; stroke-width: 3; stroke-linecap: round; fill: none; opacity: .7; }
.pie .steamwrap { animation: steam 2.4s infinite ease-in-out; }
.pie .body { transform-origin: 100px 206px; animation: breathe 3s infinite ease-in-out; }
.pie .mouthwrap { transform-origin: 87px 118px; }
.pie .armL { transform-origin: 34px 126px; } .pie .armR { transform-origin: 166px 126px; }
.pie .eyes { transform-box: fill-box; transform-origin: center; transition: transform .25s; }
.avatar.speaking .pie .body { animation: hop .35s infinite alternate ease-in-out; }
.avatar.speaking .pie .mouthwrap { animation: chatter .22s infinite alternate; }
.avatar.speaking .pie .armL { animation: wave .4s infinite alternate; }
.avatar.speaking .pie .armR { animation: waveR .4s infinite alternate; }
.avatar.listening .pie .eyes { transform: scale(1.18); }
.avatar.listening .pie .body { animation: none; rotate: -5deg; }
@keyframes steam { 0%, 100% { translate: 0 0; opacity: .7; } 50% { translate: 0 -4px; opacity: .35; } }

/* Миша — розовый плюшевый медведь */
.misha { overflow: visible; }
.misha .body { transform-origin: 100px 195px; animation: breathe 3s infinite ease-in-out; }
.misha .head { transform-origin: 100px 95px; transition: transform .25s; }
.misha .eye { transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.misha .eyes { transform-box: fill-box; transform-origin: center; transition: transform .25s; }
.misha .mouthwrap { transform-origin: 100px 103px; }
.misha .armL { transform-origin: 65px 135px; }
.misha .armR { transform-origin: 140px 135px; }
.avatar.speaking .misha .body { animation: sway .6s infinite alternate ease-in-out; }
.avatar.speaking .misha .mouthwrap { animation: chatter .25s infinite alternate; }
.avatar.speaking .misha .armR { animation: waveR .55s infinite alternate; }
.avatar.listening .misha .eyes { transform: scale(1.12); }
.avatar.listening .misha .head { transform: rotate(-4deg); }
.avatar.listening .misha .body { animation: none; }
/* Сосисонка — котик */
.cat { overflow: visible; }
.cat .fur { fill: #f7e3b5; stroke: #d9b97a; stroke-width: 2.5; }
.cat .ear-in { fill: #f3cfa0; }
.cat .stripe { fill: #b9773a; stroke: #8e5526; stroke-width: 1.5; }
.cat .emb { stroke: #5a3523; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.cat .eye { fill: #5a3523; transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.cat .nose, .cat .pad { fill: #5a3523; }
.cat .cheek { fill: #ffb3b3; opacity: .55; }
.cat .shine { fill: #fff; opacity: .9; }
.cat .body { transform-origin: 100px 240px; animation: breathe 3s infinite ease-in-out; }
.cat .head { transform-origin: 100px 120px; transition: transform .25s; }
.cat .mouthwrap { transform-origin: 100px 100px; }
.cat .armL { transform-origin: 60px 124px; } .cat .armR { transform-origin: 140px 124px; }
.cat .eyes { transform-box: fill-box; transform-origin: center; transition: transform .25s; }
.avatar.speaking .cat .body { animation: sway .5s infinite alternate ease-in-out; }
.avatar.speaking .cat .mouthwrap { animation: chatter .22s infinite alternate; }
.avatar.speaking .cat .armL { animation: wave .4s infinite alternate; }
.avatar.speaking .cat .armR { animation: waveR .4s infinite alternate; }
.avatar.listening .cat .eyes { transform: scale(1.2); }
.avatar.listening .cat .head { transform: translateY(-4px) rotate(-5deg); }
.avatar.listening .cat .body { animation: none; }

/* Котик нарисован в более высоком поле (200×250) — чуть увеличиваем, чтобы был вровень с остальными. */
.avatar > .cat { scale: calc(var(--k) * 1.12); translate: 0 calc(-6px * var(--k)); } /* ножки не должны нависать на подпись */

/* Длительности нот */
.bd-stok { fill: #1f7a4d; }
.bd-durs { display: grid; gap: 6px; }
.bd-dur { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; background: #fff; border-radius: 10px; padding: 4px 8px; }
.bd-dursvg { width: 40px; height: 56px; }
.bd-durinfo { display: grid; gap: 3px; }
.bd-durinfo b { font-size: 15px; }
.bd-durbar { position: relative; height: 12px; border-radius: 6px; background: var(--accent-soft); overflow: hidden; }
.bd-durfill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .3s; }
.bd-durtick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0,0,0,.18); }
.bd-durtxt { font-size: 13px; color: var(--muted); font-weight: 700; }

/* Энергия: на экране подготовки персонажи в карточках не анимируются (пять постоянных анимаций грели телефон);
   анимации идут только у персонажа на занятии. Скрытая вкладка — все анимации стоят. */
.card .avatar * { animation: none !important; }
.bd-flbl-body { font-size: 4.6px; fill: #14312a; }

/* Десктоп (мышь, широкий экран): всё крупнее на четверть, как при масштабе 125 % в Chrome, — просьба пользователя 2026-10-03.
   Кнопка «Начать занятие» остаётся прежнего размера (на 125 % она была слишком большой). */
@media (min-width: 760px) and (pointer: fine) {
  /* zoom на body ломал экран занятия: его высота 100dvh в увеличенных пикселях вылезала за окно, и строка ввода чата уезжала
     вниз. Поэтому увеличиваем экраны по отдельности, а занятию уменьшаем высоту на тот же коэффициент. */
  .setup { zoom: 1.125; }
  .start-bar { zoom: 1.125; }
  .start-bar button { zoom: 0.89; }
  .session { zoom: 1.125; height: calc(100dvh / 1.125); }
  .session.chat-mode > .board { --board-height: min(calc(50dvh / 1.125), max(0px, calc(100dvh / 1.125 - 300px))); }
}

/* Measure boundaries and numbers remain readable on wrapped music lines. */
.bd-staffsvg + .bd-staffsvg { margin-top: 8px; }
.bd-stbar { stroke: #18382f; stroke-width: 1.7; }
.bd-stfinal { stroke-width: 3; }
.bd-stmeasure { font-size: 12px; font-weight: 700; fill: #365d50; }
.bd-strest { font-size: 28px; fill: #18382f; }

.bd-sttitle { font-weight: 700; color: var(--ink); margin: 8px 0 4px; }
.bd-staff + .bd-staff { margin-top: 16px; }

/* Model-selected musical focus; native disclosure keeps the full score accessible. */
.bd-stfull { margin-top: 2px; }
.bd-stfull > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }
.bd-stfull > summary:hover, .bd-stfull > summary:focus-visible { color: var(--ink); }
.bd-stfull[open] > .bd-staff { margin-top: 6px; }
.bd-stbeam { fill: #14312a; }

/* Keep whole/half note heads hollow in every teaching highlight. */
.bd-sthead.bd-sthollow.bd-staccent, .bd-sthead.bd-sthollow.bd-stok { fill: #fff; stroke: #1f7a4d; }

/* Generated portrait shares the existing avatar frame in picker and lesson. */
.avatar .character-portrait { object-fit: contain; display: block; }

/* An expression stays on one row; the renderer fits its font to the available width. */
.bd-math, .bd-list { min-width: 0; }
.bd-line, .bd-list-math { white-space: nowrap; overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.bd-list { list-style: none; padding-left: 0; }
.bd-list > li { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 6px; align-items: baseline; }
.bd-list-content { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.bd-list-marker { text-align: center; }
.bd-list-done > .bd-list-marker { color: var(--accent); font-weight: 800; }

/* Mathematical typography only; prose retains the application font. */
.bd-formula { display: inline-block; max-width: 100%; vertical-align: middle; }
.bd-formula .katex { font-size: 1em; font-weight: normal; }
.bd-math { font-size: 30px; font-weight: 600; }
.bd-line { padding-block: 3px; }
.bd-line.bd-line-prose { white-space: normal; overflow: visible; overflow-wrap: anywhere; font-size: 20px; font-weight: 400; line-height: 1.5; }
.bd-line-prose .bd-formula { font-size: 26px; }
.bd-text .bd-formula, .bd-list-content.bd-list-math { font-size: 20px; }
.bd-list-content .bd-formula { font-size: inherit; }
.bd-text:has(.bd-formula) { overflow-x: auto; }
@media (max-width: 600px) { .bd-math { font-size: 26px; } }

.bd-variable { font-weight: 700; }

/* Existing literacy blocks: typography only, no inferred syllables or stress. */
.bd-syl, .bd-letters { font-family: 'PT Sans', sans-serif; }
.bd-syl { font-size: 32px; font-weight: 700; gap: 6px; line-height: 1.55; }
.bd-part { padding: 1px 8px; }
.bd-tile { font-family: 'PT Sans', sans-serif; font-size: 40px; }
.bd-word { font-size: 30px; font-weight: 700; line-height: 1.6; overflow-wrap: anywhere; }
.bd-reading { font-family: 'Literata', Georgia, serif; width: 100%; max-width: none; min-width: 0; box-sizing: border-box; }
.bd-read-line { font-size: 24px; font-weight: 400; line-height: 1.8; gap: 0 10px; opacity: 1; }
.bd-read-cur { color: var(--ink); }
.bd-read-word { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 600px) {
  .bd-syl { font-size: 28px; }
  .bd-word { font-size: 26px; }
  .bd-tile { font-size: 36px; }
  .bd-read-line { font-size: 22px; }
}

/* Keep arithmetic operators quieter than the numbers; leave fraction rules intact. */
.bd-formula .katex-html .mbin, .bd-formula .katex-html .mrel { font-size: .85em; }

/* Единый бренд и вход с лендинга; учебная доска не затрагивается. */
.wordmark { text-decoration: none; color: var(--text); gap: 9px; }
.wordmark .brand-symbol { flex: none; width: 40px; height: 40px; }
.wordmark .brand-name { display: flex; flex-direction: column; gap: 2px; line-height: 1; letter-spacing: -.035em; }
.wordmark .brand-name > span { font-size: 24px; }
.wordmark em { font-size: 17px; font-weight: 800; font-style: normal; color: var(--accent); letter-spacing: -.025em; }
.account-intro h1 { margin: 8px 0 12px; font-size: clamp(28px, 6vw, 36px); letter-spacing: -.04em; line-height: 1.2; }
.account-intro p { color: var(--muted); line-height: 1.6; }
.account-intro .account-step { color: var(--accent); font-size: 13px; font-weight: 800; }
#parentLoginForm { padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
#parentMailHint { color: var(--muted); line-height: 1.6; margin: 0; }
.account-confirm #loginEmail { overflow-wrap: anywhere; font-weight: 700; }
.account-confirm #confirmLogin[hidden] { display: none; }
@media (max-width: 400px) { #parentLoginForm { padding: 18px; } .wordmark { font-size: 25px; } }

/* Профиль в шапке с постраничной историей занятий. */
.parent-profile { position: relative; margin-left: auto; }
.parent-profile[hidden] { display: none; }
.parent-profile > summary { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--text); cursor: pointer; list-style: none; }
.parent-profile > summary::-webkit-details-marker { display: none; }
.parent-profile > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.profile-popover { position: absolute; right: 0; top: 54px; z-index: 10; width: min(300px, calc(100vw - 32px)); padding: 18px; display: grid; gap: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 12px 32px #102c3114; }
.profile-popover #parentEmail { overflow-wrap: anywhere; font-size: 14px; }
#accountBar.account-history { border-bottom: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
.account-history summary { cursor: pointer; font-weight: 700; }
.account-history ul { padding-left: 22px; line-height: 1.7; color: var(--muted); }
.account-history li { margin-bottom: 14px; }
.lesson-id-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 4px; font-size: 13px; }
.lesson-id-row input { min-width: 0; width: 18ch; max-width: 100%; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); font: inherit; font-family: monospace; }
.lesson-id-copy { width: auto; min-height: 36px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--accent); font-size: 13px; cursor: pointer; }
.lesson-id-status { flex-basis: 100%; }
.lesson-id-status:empty { display: none; }

/* Display-only attribution: pseudo-element stays out of lesson transcripts/copy. */
.msg.tutor[data-author]::before {
  content: attr(data-author);
  display: block;
  padding-left: 25px;
  margin-bottom: 5px;
  background: url('/brand/logo-mark.svg') left center / 18px 18px no-repeat;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
}

.bd-clock-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0; font-size: 13px; font-weight: 700; }
.bd-clock-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bd-clock-legend span::before { content: ''; display: inline-block; width: 18px; height: 4px; border-radius: 3px; background: #14312a; }
.bd-clock-legend .bd-clock-minute-label::before { width: 28px; height: 3px; background: #1f7a4d; }
.bd-formula .katex .text { font-family: var(--font); }

/* Keep the composer inside the visible lesson viewport, including iOS keyboard. */
.session:not(.hidden) { position: fixed; left: 0; right: 0; max-width: 720px; margin-inline: auto; top: var(--lesson-viewport-top, 0px); height: var(--lesson-viewport-height, 100dvh); overflow: hidden; }
.session.chat-mode > .board { --board-height: min(calc(var(--lesson-viewport-height, 100dvh) * .45), max(80px, calc(var(--lesson-viewport-height, 100dvh) - 210px))); }
.session.chat-mode .chat { min-height: 0; overflow: hidden; }
.session .composer { flex-shrink: 0; }
.session .board, .session .transcript { overscroll-behavior: contain; }
@media (min-width: 760px) and (pointer: fine) {
  .session:not(.hidden) { height: calc(var(--lesson-viewport-height, 100dvh) / 1.125); }
  .session.chat-mode > .board { --board-height: min(calc(var(--lesson-viewport-height, 100dvh) * .45 / 1.125), max(80px, calc(var(--lesson-viewport-height, 100dvh) / 1.125 - 210px))); }
}

/* Recovery belongs next to the board, separate from the teacher's conversation. */
.board-notice { flex: none; margin: 0 20px 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: .85rem; display: flex; align-items: center; gap: 8px; }
.board-notice[hidden] { display: none; }
.board-notice span { flex: 1; min-width: 0; }
@media(max-width:420px) { .board-notice { margin-inline:12px; flex-wrap:wrap; } }

/* Public model-selected syllables: no syllable/stress inference in the renderer. */
.bd-part-stressed { position: relative; }
.bd-part-stressed::before { content: ''; position: absolute; top: -.12em; left: 52%; width: .1em; height: .32em; background: currentColor; border-radius: 2px; transform: rotate(30deg); }
.bd-syllable-scheme { margin: 12px 0; font-family: 'PT Sans', sans-serif; }
.bd-scheme-label { font-size: 18px; color: var(--muted, #61716c); margin-bottom: 5px; }
.bd-scheme-word { font-size: 30px; font-weight: 700; overflow-wrap: anywhere; }
.bd-scheme-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-start; }
.bd-scheme-cell { display: flex; flex-direction: column; align-items: center; min-width: 52px; max-width: 100%; flex: 0 1 auto; }
.bd-scheme-arc { width: 72px; max-width: 100%; height: 52px; overflow: visible; }
.bd-scheme-curve, .bd-scheme-stress { fill: none; stroke: var(--ink, #163a35); stroke-width: 3; stroke-linecap: round; }
.bd-scheme-part { font-size: 28px; line-height: 1.35; font-weight: 700; overflow-wrap: anywhere; max-width: 100%; }
@media (max-width: 600px) { .bd-scheme-row { gap: 8px; } .bd-scheme-arc { width: 60px; } .bd-scheme-part { font-size: 25px; } }

.bd-scheme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.bd-scheme-grid .bd-syllable-scheme { margin: 0; min-width: 0; padding: 8px 0; }
.bd-scheme-grid .bd-scheme-label { font-size: 17px; margin: 0; }
.bd-scheme-grid .bd-scheme-row { gap: 2px; }
.bd-scheme-grid .bd-scheme-cell { min-width: 34px; flex: 0 1 44px; }
.bd-scheme-grid .bd-scheme-arc { width: 44px; height: 40px; }
.bd-scheme-grid .bd-scheme-part { font-size: 22px; }
@media (max-width: 340px) { .bd-scheme-grid { gap: 8px; } .bd-scheme-grid .bd-scheme-cell { flex-basis: 36px; } }

.lesson-history-pager { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.lesson-history-pager[hidden] { display: none; }
.lesson-history-pager button { width: auto; min-height: 40px; padding: 6px 14px; }

.parent-profile .profile-popover { width: min(460px, calc(100vw - 32px)); max-height: min(72vh, calc(100dvh - 110px)); overflow-y: auto; overscroll-behavior: contain; }
.profile-popover #accountBar.account-history { padding-top: 14px; }
.profile-popover .account-history ul { margin-bottom: 0; font-size: 14px; }
.profile-popover .lesson-id-row input { width: 15ch; }

/* Public words: printed by default, local handwriting only for Russian lessons. */
.bd-copybook-label { display: inline-block; max-width: 100%; line-height: 0; vertical-align: middle; }
.bd-copybook-svg { display: block; width: auto; max-width: 100%; height: 86px; overflow: visible; }
.bd-copybook-ink { font: 64px 'PT Sans', sans-serif; fill: var(--ink, #163a35); stroke: none; }
[data-board-script="copybook"] .bd-copybook-ink {
  font-family: 'Tutor Copybook', 'PT Sans', sans-serif;
  fill: var(--ink, #163a35); stroke: var(--ink, #163a35); stroke-width: .65;
  stroke-dasharray: none; stroke-linecap: round; stroke-linejoin: round;
}
[data-board-script="print"] .bd-copybook-svg { height: 72px; }
@media (max-width:600px) { [data-board-script="print"] .bd-copybook-svg { height: 64px; } }
.bd-syl { align-items: flex-start; }
.bd-syl .bd-part { display: inline-flex; flex-direction: column; align-items: center; padding: 0 3px; background: transparent; max-width: 100%; }
.bd-syl .bd-dash { margin-top: 30px; }
.bd-part-arc { display: block; width: 100%; min-width: 42px; height: 34px; margin-top: -12px; }
.bd-scheme-part .bd-copybook-svg { margin-bottom: -12px; }
.bd-scheme-word .bd-copybook-svg { width: auto; max-height: 96px; }
@media print { .bd-copybook-ink { fill: #111; stroke: none; } }

.bd-scheme-grid .bd-word-scheme .bd-scheme-cell { flex: 0 1 auto; min-width: 48px; }
.bd-scheme-grid .bd-word-scheme .bd-scheme-arc { width: 100%; height: 34px; }
.bd-scheme-grid .bd-word-scheme .bd-scheme-part { max-width: 100%; }
.bd-scheme-grid .bd-word-scheme .bd-scheme-row { gap: 1px; }
.bd-part-stressed:has(.bd-copybook-label)::before { content: none; }
@media (max-width: 600px) { .bd-copybook-svg { height: 72px; } }

/* Old reading text is not the next teacher-selected excerpt during preparation. */
.board.reading-updating { position: relative; }
.board.reading-updating > * { visibility: hidden; }
.board.reading-updating::after { content: "Обновляю отрывок для чтения…"; position: absolute; inset: 24px; color: var(--muted); font: 16px/1.5 sans-serif; }

/* Requested learning rules: one calm notebook card, safe DOM text/formula rendering. */
.bd-rule { border: 2px solid #80b99e; border-radius: 14px; padding: 14px 18px; background: #f2faf5; margin: 6px 0; min-width: 0; }
.bd-rule-title { color: #307654; font-size: 13px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.bd-rule .bd-text { font-size: 19px; line-height: 1.55; }
@media(max-width:480px) { .bd-rule { padding: 12px; } .bd-rule .bd-text { font-size: 17px; } }

/* Prepared ё́: keep the exact accent in DOM and draw it above the diaeresis. */
.bd-read-yo { position: relative; display: inline-block; }
.bd-read-yo-acute { font-size: 0; }
.bd-read-yo::after { content: ''; position: absolute; width: .065em; height: .27em; top: .20em; left: 64%; background: currentColor; transform: rotate(28deg); border-radius: 2px; pointer-events: none; }

/* Drawing on paper: stable source grid, completed edges and the current teacher-selected segment. */
.bd-drawing {min-width:0;}
.bd-drawing-grid {display:grid;gap:12px;align-items:start;min-width:0;}
.bd-drawing-cell {min-width:0;}
.bd-drawing-number {font:600 14px 'PT Sans',sans-serif;color:var(--ink);margin-bottom:6px;}
.bd-drawing-svg {display:block;width:100%;min-height:72px;max-height:250px;overflow:visible;}
.bd-drawing-gridline {stroke:#d8e8e1;stroke-width:.025;}
.bd-drawing-reference {fill:none;stroke:#244c44;stroke-width:.09;stroke-linejoin:round;}
.bd-drawing-reference-faint {stroke:#a8bbb2;stroke-width:.055;stroke-dasharray:.15 .13;}
.bd-drawing-done {stroke:#15965a;stroke-width:.105;stroke-linecap:round;}
.bd-drawing-current {fill:none;stroke:#dd7526;stroke-width:.11;stroke-linecap:round;stroke-linejoin:round;}
.bd-drawing-start {fill:#dd7526;}
.bd-drawing-instruction {font:18px/1.4 'PT Sans',sans-serif;margin-top:10px;overflow-wrap:anywhere;}
@media(max-width:600px){.bd-drawing-grid{gap:8px;}.bd-drawing-number{font-size:12px;}.bd-drawing-svg{max-height:220px;}.bd-drawing-instruction{font-size:17px;}}

.bd-drawing-axis {font:0.5px sans-serif;fill:#54706a;}
.bd-drawing-coordinates {font:14px/1.3 'PT Sans',sans-serif;color:var(--muted);margin-top:4px;}

/* Give a single construction room alongside its short instruction on desktop. */
@media(min-width:601px){.bd-drawing-focus{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:18px;align-items:start;}.bd-drawing-focus>.bd-drawing-grid{grid-row:1 / 3;}.bd-drawing-focus>.bd-drawing-instruction{grid-column:2;grid-row:1;margin-top:28px;}.bd-drawing-focus>.bd-drawing-coordinates{grid-column:2;grid-row:2;}}

.bd-drawing-focus .bd-drawing-svg{min-height:128px;}
.board:has(.bd-drawing)>.bd-list,.board:has(.bd-drawing)>.bd-text{font-size:16px;line-height:1.4;}

/* Typed public records: preserve every selected line; compact layout is visual only. */
.bd-record-content { display:grid; grid-auto-rows:max-content; align-content:start; gap:8px; min-width:0; }
.bd-record-content > * { min-width:0; }
.bd-record-content .bd-math { line-height:1.25; }

/* Model-selected spelling words: separate from instructions and explanations. */
.bd-spelling-word { margin: 6px 0 10px; max-width: 100%; }
.bd-spelling-word .bd-copybook-svg { height: 100px; }
@media (max-width:600px) { .bd-spelling-word .bd-copybook-svg { height: 84px; } }
@media print { [data-board-script="copybook"] .bd-copybook-ink { fill: #111; stroke: #111; } }
.bd-workspace-path { font-size:14px; line-height:1.5; color:var(--muted, #5c736d); overflow-wrap:anywhere; }
.bd-workspace-heading { margin:8px 0; font-size:13px; font-weight:600; color:var(--muted, #5c736d); }
.bd-workspace-summary, .bd-workspace-history { margin-top:16px; border-top:1px solid #d6e5dc; padding-top:12px; }
.bd-workspace-summary > summary, .bd-workspace-history > summary { cursor:pointer; color:var(--ink, #163a35); }
.bd-workspace-event { margin-top:14px; padding:8px; border-left:2px solid #d6e5dc; }
.bd-workspace-superseded { opacity:.7; border-left:2px solid #c17878; padding-left:8px; }

/* Compact workspace heading; wrapping keeps every label readable on narrow screens. */
.bd-workspace-header { display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 18px; padding-bottom:8px; }
.bd-workspace-header .bd-title { padding-bottom:0; }
.bd-workspace-header .bd-workspace-path { font-size:12px; line-height:1.4; }
.bd-record-content .bd-math > .bd-line + .bd-line { margin-top:14px; }

.active-lessons {margin:12px 0;padding:12px;border:1px solid var(--border, #d5e2d8);border-radius:12px;}
.active-lessons-heading,.lesson-history-actions {display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.active-lessons-heading {justify-content:space-between;}
.lesson-history-actions {margin:10px 0;}
.lesson-history-actions button,.active-lessons-heading button {min-height:40px;padding:8px 14px;cursor:pointer;}

.lesson-recover {margin:8px 16px;padding:12px;border:1px solid var(--line);border-radius:12px;cursor:pointer;}
.bd-workspace-focus { display:grid; grid-auto-rows:max-content; gap:8px; min-width:0; padding:0; border:0; border-radius:0; background:transparent; }
.bd-workspace-focus:empty { display:none; }
.bd-workspace-focus > * { min-width:0; }
.bd-workspace-group { display:grid; gap:8px; min-width:0; }
.bd-workspace-group > * { min-width:0; }
.bd-workspace-focus > .bd-workspace-group + .bd-workspace-group { margin-top:12px; padding-top:14px; border-top:1px solid #d6e5dc; }
.bd-workspace-history > .bd-workspace-group { margin-top:18px; }
.bd-workspace-teacher { white-space:pre-wrap; }
.bd-workspace-condition, .bd-workspace-saved-records { display:grid; gap:8px; min-width:0; }
.bd-workspace-condition > *, .bd-workspace-saved-records > * { min-width:0; }
.bd-workspace-focus .bd-math > .bd-line + .bd-line { margin-top:8px; }
@media(max-width:420px) { .bd-workspace-focus .bd-line { padding-inline:4px; } }

/* Assignment headings anchor the history; conditions and dialogue are subordinate. */
.bd-workspace-group-title { margin:4px 0 6px; font-size:18px; line-height:1.35; font-weight:700; color:var(--ink, #163a35); }
.bd-workspace-history > .bd-workspace-group { margin-top:22px; padding-top:14px; border-top:1px solid #d6e5dc; }
.bd-workspace-history .bd-workspace-group-title { font-size:21px; padding-left:10px; border-left:3px solid var(--accent, #12966c); }
.bd-workspace-history .bd-workspace-condition .bd-text { font-size:16px; line-height:1.5; margin-block:4px; }
.bd-workspace-history .bd-workspace-event { margin-left:10px; }

/* Full-lesson archive is a read-only overlay; the current lesson stays in place. */
.lesson-archive {width:min(900px,calc(100vw - 24px));max-width:none;max-height:calc(100dvh - 32px);padding:0;border:1px solid var(--line);border-radius:20px;background:var(--card,#fff);color:var(--text,#163a35);overflow:auto;box-sizing:border-box;}
.lesson-archive::backdrop {background:rgba(12,35,29,.48);}
.lesson-archive-header {display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 18px;position:sticky;top:0;z-index:2;background:var(--card,#fff);border-bottom:1px solid var(--line);}
.lesson-archive-header h2 {margin:0;font-size:21px;}
.lesson-archive-close,.lesson-archive-retry {min-height:44px;padding:8px 14px;cursor:pointer;}
.lesson-archive-body {padding:8px 18px 20px;overflow-wrap:anywhere;}
.lesson-archive-entry {margin-top:16px;border:1px solid var(--line);border-radius:14px;padding:12px;min-width:0;}
.lesson-archive-entry-title {font-weight:700;font-size:19px;line-height:1.4;cursor:pointer;}
.lesson-archive-version,.lesson-archive-entry-state,.lesson-archive-state {color:var(--muted);font-size:14px;}
.lesson-archive-warning,.lesson-archive-error {padding:12px;border:1px solid #d8b673;border-radius:10px;background:#fff9e9;color:#604711;}
.lesson-archive-board {margin:10px 0!important;max-height:none;overflow:visible;min-width:0;}
.lesson-archive-unbound {margin-block:16px;}
.lesson-archive-step {margin:12px 0;padding:10px;border-left:2px solid var(--line);min-width:0;}
.lesson-archive-turn {width:fit-content;max-width:88%;margin-top:10px;padding:10px;border-radius:14px;white-space:pre-wrap;background:var(--bg,#f4f9f5);}
.lesson-archive-assistant {margin-left:0;margin-right:auto;border-left:3px solid var(--accent,#12966c);border-bottom-left-radius:4px;background:var(--tutor-bubble);}
.lesson-archive-user {margin-left:auto;margin-right:0;border-bottom-right-radius:4px;background:var(--user-bubble);}
@media(max-width:600px){.lesson-archive{max-height:calc(100dvh - 16px);}.lesson-archive-header,.lesson-archive-body{padding-left:12px;padding-right:12px;}.lesson-archive-entry{padding:10px;}.lesson-archive-entry-title{font-size:17px;}.lesson-archive-board{padding:12px;}}

/* Family profiles use the existing compact parent cabinet and mint palette. */
.child-profiles {border-top:1px solid var(--line);padding-top:14px;min-width:0;}
.child-profiles-heading,.child-profile-actions,.child-profile-row {display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.child-profiles-heading,.child-profile-row {justify-content:space-between;}
.child-profiles ul {list-style:none;padding:0;margin:10px 0;display:grid;gap:10px;}
.child-profile-row span {overflow-wrap:anywhere;min-width:0;flex:1;}
.child-profile-actions button,.child-profiles button {min-height:40px;}
.child-profile-form {padding:12px 0;}
.child-profile-form[hidden],.child-profile-selection[hidden],.child-profiles[hidden],#guestChildNameGroup[hidden] {display:none;}
.child-profile-form .group {margin-bottom:6px;}
.child-profile-form .legend-sm {margin-top:4px;}
.child-profile-selection {margin-bottom:20px;}
.child-profile-selection select,.history-child-filter select {width:100%;min-width:0;max-width:100%;}
.history-child-filter {display:grid;gap:6px;margin:12px 0;font-size:14px;}
.family-access {font-size:14px;color:var(--muted);border-top:1px solid var(--line);padding-top:8px;}
#childProfileStatus {overflow-wrap:anywhere;}

/* Profiles and lesson history are independent, keyboard-accessible cabinet sections. */
:is(.child-profiles,#parentHistory,#pilotReview) > summary {display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px;cursor:pointer;font-weight:700;list-style:none;}
:is(.child-profiles,#parentHistory,#pilotReview) > summary::-webkit-details-marker {display:none;}
:is(.child-profiles,#parentHistory,#pilotReview) > summary::after {content:'';width:8px;height:8px;flex:none;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg);margin-right:4px;transition:transform .15s;}
:is(.child-profiles,#parentHistory,#pilotReview)[open] > summary::after {transform:rotate(225deg);}
:is(.child-profiles,#parentHistory,#pilotReview) > summary:focus-visible {outline:3px solid var(--accent);outline-offset:2px;border-radius:6px;}
.pilot-review {border-top:1px solid var(--line);margin-top:8px;}
.pilot-review li {overflow-wrap:anywhere;}
.pilot-review .lesson-id-copy {margin-top:4px;min-height:44px;}
.child-profiles-heading {margin-top:8px;color:var(--muted);font-size:14px;}
.profile-archive-badge {display:inline-block;margin-left:8px;padding:3px 7px;background:var(--bg);border:1px solid var(--line);border-radius:8px;color:var(--muted);font-size:12px;white-space:nowrap;}
.archived-profile-choice {margin-top:12px;padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--bg);}
.archived-profile-choice label {display:grid;gap:6px;font-size:14px;}
.archived-profile-choice select {width:100%;min-width:0;max-width:100%;margin-bottom:12px;}
.archived-profile-choice button {white-space:normal;text-align:left;}
.archived-profile-choice[hidden], .mail-success-panel[hidden], #parentLoginForm[hidden] {display:none;}
.mail-success-panel {padding:24px;border:1px solid var(--line);border-radius:20px;background:var(--card);}
.mail-success-panel h2 {font-size:24px;line-height:1.25;margin:12px 0;}
.mail-success-panel p {line-height:1.6;overflow-wrap:anywhere;}
.mail-success-icon {display:grid;place-items:center;width:54px;height:54px;border-radius:16px;background:var(--bg);color:var(--accent);font-size:30px;}
.mail-success-panel .child-profile-actions {margin-top:20px;}
.mail-success-panel .child-profile-actions button {white-space:normal;}
@media (max-width:520px) {.mail-success-panel {padding:18px;}.child-profile-row > span {flex-basis:100%;}.child-profile-row > button {flex:1;}}


/* RHFX-190: flat actions keep the existing palette and full touch targets. */
.setup { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 112px); }
.setup-intro { padding: 0 0 4px; }
.setup-intro > p:last-child { font-size: 15px; line-height: 1.55; max-width: 64ch; }
.setup .preview,
.profile-popover button:not(.primary),
#session .lesson-header-actions > button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: none;
}
.setup .primary {
  min-height: 46px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: none;
}
.setup .start-bar { padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 10px); }
.setup .start-bar button { gap: 12px; }
.setup .start-bar button span { font-size: 20px; }
.setup .balance-note { margin: 6px 0 0; }
.child-profile-selection { margin-bottom: 0; }
.child-profile-selection > .child-profile-actions { margin-top: 12px; }
/* A long archive-choice label must wrap inside the narrow parent cabinet. */
.archived-profile-choice button {
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
@media (hover: hover) {
  .setup .preview:hover:not(:disabled),
  .profile-popover button:not(.primary):hover:not(:disabled),
  #session .lesson-header-actions > button:hover:not(:disabled) { background: var(--bg); border-color: var(--muted); }
}
@media (max-width: 420px) {
  .setup .start-bar { padding-left: 16px; padding-right: 16px; }
}

/* Owner refinement: light controls, without permanent button outlines. */
:root { --control-line-soft: var(--line); --control-surface-soft: var(--card); }
:root button,
:root .setup .primary,
:root .setup .preview,
:root .profile-popover button,
:root .composer button,
:root .bar button,
:root #session button { border-width: 0; }
:root .parent-profile > summary { border-color: transparent; }
:root :is(input, select, textarea),
:root #parentLoginForm input,
:root #session .composer textarea {
  border-width: 1px;
  border-color: var(--control-line-soft);
  background: var(--control-surface-soft);
}
:root .card,
:root .card:has(input:checked),
:root .chip span,
:root .chip input:checked + span {
  border-color: transparent;
  box-shadow: none;
}
:root .chip input:checked + span {
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
}
@media (hover: hover) {
  :root .setup .preview:hover:not(:disabled),
  :root .profile-popover button:not(.primary):hover:not(:disabled) {
    background: var(--accent-soft);
  }
}

.bd-solution-steps{margin:10px 0;padding:8px 12px;border-left:2px solid #cbded4}.bd-solution-steps>summary{cursor:pointer}.bd-visual-notice{font-size:.85em;color:#687970;margin:6px 0}

/* A native checkbox keeps label/touch/keyboard behavior, with a switch surface.
   Explicit dimensions/appearance override the full-width form input on iOS. */
.lesson-capture { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.lesson-capture[hidden] { display: none; }
.lesson-capture-control { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; cursor: pointer; }
.lesson-capture-label { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; line-height: 1.4; }
.lesson-capture-label small { display: block; margin-top: 3px; font-size: 13px; font-weight: 400; color: var(--muted); }
.lesson-capture-status { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.lesson-capture-control:has(input:disabled) { cursor: default; }
#lessonCaptureToggle { -webkit-appearance: none; appearance: none; position: relative; display: block; flex: 0 0 52px; width: 52px; min-width: 52px; max-width: 52px; height: 32px; min-height: 32px; padding: 0; margin: 0; border: 0; border-radius: 999px; background: var(--line); cursor: pointer; touch-action: manipulation; transition: background .15s; }
#lessonCaptureToggle::before { content: ""; position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0002; pointer-events: none; transition: transform .15s; }
#lessonCaptureToggle:checked { background: var(--accent); }
#lessonCaptureToggle:checked::before { transform: translateX(20px); }
#lessonCaptureToggle:disabled { opacity: .55; cursor: default; }
@media (prefers-reduced-motion: reduce) { #lessonCaptureToggle, #lessonCaptureToggle::before { transition: none; } }
