/* app.css v2 — учебная платформа, «премиум» язык.
   Чёрный фон, карточки на 1px рамках, Manrope + JetBrains Mono, белая главная кнопка со стрелкой,
   статусы-пилюли с точкой, пунктир для неизвестного. CSP-safe: без inline, без CDN.
   Адаптив — контейнерные запросы (контейнер = body или .app). */

/* Шрифты: @fontsource-variable 5.3.0 (OFL 1.1, лицензии в static/fonts), только cyrillic + latin. */
@font-face { font-family: Manrope; src: url("../fonts/manrope-cyrillic-wght-normal.e58febde317b.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: Manrope; src: url("../fonts/manrope-latin-wght-normal.938c6e8019b6.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-cyrillic-wght-normal.615bf869ebeb.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: swap; unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-latin-wght-normal.b058178d7f30.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: swap; unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ---------- 1. Токены ---------- */
:root {
  color-scheme: light;
  --bg: #eef0f2;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --field-bg: #f4f5f7;
  --text: #000000;
  --muted: #62656f;
  --muted-2: #646771;
  --border: #e1e3e7;
  --border-strong: #c9ccd3;
  --accent: #087f76;
  --accent-hover: #0a9a8f;
  --accent-text: #ffffff;
  --accent-bg: #dcf3f0;
  --btn: #000000;        --btn-text: #ffffff;  --btn-hover: #1b1c1f;
  --btn-square: #ffffff; --btn-arrow: #000000;
  --ok: #1f8a4c;        --ok-bg: #e0f3e6;
  --warn: #9a5b00;      --warn-bg: #fdf0d5;
  --bad: #c8302a;       --bad-bg: #fde4e2;
  --info: #62656f;      --info-bg: #f4f5f7;
  --pending: #5f4bd8;   --pending-bg: #ebe8fb;
  --focus: #087f76;
  --radius: 20px; --radius-sm: 12px; --radius-xs: 8px; --radius-lg: 28px;
  --space: 8px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --tap: 44px;
  --font: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 18px;
  --fs-xl: 22px; --fs-2xl: 28px; --fs-3xl: 36px; --fs-display: 48px; --fs-stat: 56px;
  --lh: 1.5; --lh-tight: 1.1;
  --shadow-1: none; --shadow-2: none;
  --page-max: 1120px;
  --gutter: var(--space-4);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #000000; --surface: #111214; --surface-2: #16171a; --field-bg: #0c0d0f;
    --text: #ffffff; --muted: #a8abb7; --muted-2: #7d808b; --border: #26272c; --border-strong: #34363c;
    --accent: #19d3c5; --accent-hover: #5fe8dd; --accent-text: #000000; --accent-bg: #0e2a28;
    --btn: #ffffff; --btn-text: #000000; --btn-hover: #e3e5e9; --btn-square: #000000; --btn-arrow: #19d3c5;
    --ok: #5ad27f; --ok-bg: #0f2418; --warn: #f0b24a; --warn-bg: #2a1f0b;
    --bad: #ff6b6b; --bad-bg: #2c1212; --info: #a8abb7; --info-bg: #16171a;
    --pending: #c3b6ff; --pending-bg: #1a1730; --focus: #19d3c5;
  }
}
.theme-light {
  color-scheme: light;
  --bg: #eef0f2; --surface: #ffffff; --surface-2: #f4f5f7; --field-bg: #f4f5f7;
  --text: #000000; --muted: #62656f; --muted-2: #646771; --border: #e1e3e7; --border-strong: #c9ccd3;
  --accent: #087f76; --accent-hover: #0a9a8f; --accent-text: #ffffff; --accent-bg: #dcf3f0;
  --btn: #000000; --btn-text: #ffffff; --btn-hover: #1b1c1f; --btn-square: #ffffff; --btn-arrow: #000000;
  --ok: #1f8a4c; --ok-bg: #e0f3e6; --warn: #9a5b00; --warn-bg: #fdf0d5;
  --bad: #c8302a; --bad-bg: #fde4e2; --info: #62656f; --info-bg: #f4f5f7;
  --pending: #5f4bd8; --pending-bg: #ebe8fb; --focus: #087f76;
}
.theme-dark {
  color-scheme: dark;
  --bg: #000000; --surface: #111214; --surface-2: #16171a; --field-bg: #0c0d0f;
  --text: #ffffff; --muted: #a8abb7; --muted-2: #7d808b; --border: #26272c; --border-strong: #34363c;
  --accent: #19d3c5; --accent-hover: #5fe8dd; --accent-text: #000000; --accent-bg: #0e2a28;
  --btn: #ffffff; --btn-text: #000000; --btn-hover: #e3e5e9; --btn-square: #000000; --btn-arrow: #19d3c5;
  --ok: #5ad27f; --ok-bg: #0f2418; --warn: #f0b24a; --warn-bg: #2a1f0b;
  --bad: #ff6b6b; --bad-bg: #2c1212; --info: #a8abb7; --info-bg: #16171a;
  --pending: #c3b6ff; --pending-bg: #1a1730; --focus: #19d3c5;
}

/* ---------- 2. База ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Компоненты задают display (grid/flex); атрибут hidden должен всё равно скрывать */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: var(--fs-md) / var(--lh) var(--font);
  container-type: inline-size;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.app { background: var(--bg); color: var(--text); font: var(--fs-md) / var(--lh) var(--font); container-type: inline-size; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, figure, fieldset { margin: 0; }
h1 { font-size: 30px; line-height: var(--lh-tight); font-weight: 500; letter-spacing: -.015em; text-wrap: balance; }
h1 .dim, h2 .dim { display: block; color: var(--muted); }
h2 { font-size: var(--fs-xl); line-height: 1.15; font-weight: 500; letter-spacing: -.01em; }
h3 { font-size: var(--fs-lg); line-height: 1.25; font-weight: 500; }
p { text-wrap: pretty; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
p a, .j-detail a, td a { text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-xs); }
code, .code { font-family: var(--font-mono); font-size: .86em; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.mono { font-family: var(--font-mono); font-size: .92em; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.row.between { justify-content: space-between; }
.eyebrow { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@container (min-width: 640px) { h1 { font-size: var(--fs-3xl); } h2 { font-size: 26px; } }

/* ---------- 3. Шапка: бренд + плавающая пилюля навигации ---------- */
/* Шапка, страница и подвал стоят в одной колонке: одна ширина (--page-max) и одни поля (--gutter)
   на всех страницах, поэтому край логотипа совпадает с краем заголовка и контент не «гуляет». */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); }
.topbar-inner {
  max-width: var(--page-max); margin: 0 auto;
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 72px; padding: var(--space-3) var(--gutter);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -.01em; color: var(--text); text-decoration: none; margin-right: auto; white-space: nowrap; }
.brand .logo-mark { flex: none; width: 32px; height: 32px; }
.brand-name span { color: var(--muted); font-weight: 500; margin-left: .25em; }
.brand:hover { color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.topbar nav a, .topbar nav button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px;
  border: 0; background: none; border-radius: var(--radius-xs);
  color: var(--muted); text-decoration: none; font: 500 15px / 1 var(--font); cursor: pointer;
  transition: background-color .25s, color .25s;
}
.topbar nav a:hover, .topbar nav button:hover { color: var(--text); }
.topbar nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
/* Кнопка «Выйти» — POST-форма внутри пилюли; форма не должна ломать flex-ряд */
.topbar nav form { display: contents; }
.topbar nav .who { display: inline-flex; align-items: center; gap: 8px; color: var(--muted-2); font-family: var(--font-mono); font-size: 13px; padding: 0 var(--space-3); white-space: nowrap; }
.who-text { display: grid; line-height: 1.2; text-align: left; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar.lg { width: 88px; height: 88px; }
.avatar.empty { display: inline-flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 600; color: var(--accent); background: var(--accent-bg); }
.profile-photo { display: flex; align-items: center; gap: var(--space-4); }
.theme-toggle .icon-sun { display: none; }
.theme-dark .theme-toggle .icon-sun { display: block; }
.theme-dark .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .theme-toggle .icon-sun { display: block; }
  :root:not(.theme-light) .theme-toggle .icon-moon { display: none; }
}
/* Имя, язык, тема и «Выйти»: в ряду пилюли на широком экране; на телефоне — в маленьком меню (popover),
   его кнопка показывает первую букву имени (под кем вошли — видно и на общем телефоне). */
.topbar-more { display: contents; }
.topbar nav .menu-toggle, .topbar .in-menu { display: none; }
.menu-toggle { gap: 4px; }
.menu-initial { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent); font: 700 14px / 1 var(--font); }
.menu-chevron { color: var(--muted-2); }
.music-link { gap: 6px; }
.topbar-more:popover-open {
  display: grid; gap: 2px; position: fixed; inset: calc(env(safe-area-inset-top, 0px) + 60px) var(--space-3) auto auto;
  margin: 0; width: min(280px, calc(100vw - 24px)); padding: 6px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
}
.topbar-more:popover-open .who { padding: 10px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); white-space: normal; overflow-wrap: anywhere; }
.topbar-more:popover-open button { justify-content: flex-start; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; color: var(--text); font-size: var(--fs-md); }
.topbar-more:popover-open button:hover { background: var(--surface-2); }
.topbar-more:popover-open .in-menu { display: inline; }
.topbar-more::backdrop { background: transparent; }
/* Телефон: шапка в одну строку и не липнет на страницах заданий (там нужен весь экран) */
@container (max-width: 639px) {
  .topbar-inner { gap: var(--space-2); min-height: 60px; padding-block: 8px; }
  .brand { font-size: 17px; min-height: 40px; }
  .topbar.signed-in .brand-name { display: none; }
  .topbar nav { flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
  .topbar nav a, .topbar nav button { font-size: var(--fs-sm); padding: 0 7px; }
  .topbar nav .music-link { padding: 0 6px; }
  .music-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar.task-page { position: static; }
}
/* Меню — до 960px: на планшете пилюля с именем, языком, темой и «Выйти» в ряд не помещалась */
@supports selector(:popover-open) {
  @container (max-width: 959px) {
    .topbar nav .menu-toggle { display: inline-flex; }
    .topbar-more[popover]:not(:popover-open) { display: none; }
  }
  @container (max-width: 639px) {
    .topbar nav .menu-toggle { padding: 0 4px; }
    .menu-chevron { display: none; }
  }
}
/* Без popover (старый браузер): прежний перенос — имя первой строкой пилюли, кнопки ниже */
@supports not selector(:popover-open) {
  @container (max-width: 639px) {
    .topbar-inner { flex-wrap: wrap; }
    .topbar nav { flex: 1 0 100%; }
    .topbar nav a, .topbar nav button { flex: 1; padding: 0 8px; }
    .topbar nav .who { flex: 1 0 100%; order: -1; justify-content: flex-start; padding: 6px 10px 2px; font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
  }
}

/* body — контейнер, поэтому поля задаются его потомкам (элемент не может спрашивать сам себя) */
@container (min-width: 640px) { .topbar, .page, .page-foot { --gutter: var(--space-5); } .topbar-inner { padding-block: var(--space-4); } }
@container (min-width: 960px) { .topbar, .page, .page-foot { --gutter: var(--space-6); } }

/* ---------- 4. Страница и карточка ---------- */
.page { max-width: var(--page-max); margin: 0 auto; padding: var(--space-5) var(--gutter) 96px; display: grid; gap: var(--space-6); }
.page.wide { max-width: var(--page-max); }
.page-head { display: grid; gap: var(--space-3); }
.page-head p { max-width: 640px; }
.block { display: grid; gap: var(--space-4); }
.two-col { display: grid; gap: var(--space-4); align-items: start; }
.card {
  display: flex; flex-direction: column; gap: var(--space-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-5);
}
.card.row { flex-direction: row; }
.prose p { max-width: 60ch; font-size: 17px; line-height: 1.6; }
@container (min-width: 640px) {
  .page { padding: var(--space-6) var(--gutter) 120px; gap: 40px; }
  .page-head { gap: var(--space-4); }
  .card { padding: 28px; }
}
@container (min-width: 960px) {
  .page { padding: var(--space-7) var(--gutter) 140px; gap: var(--space-7); }
  .two-col { grid-template-columns: 1fr 1fr; gap: var(--space-4); }
}

/* ---------- 5. Кнопки ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--btn); color: var(--btn-text);
  font: 600 var(--fs-md) / 1.2 var(--font); text-decoration: none; text-align: left;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: background-color .25s, border-color .25s, color .25s, transform .06s;
}
.btn:hover { background: var(--btn-hover); color: var(--btn-text); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn.link { background: none; border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn.link:hover { background: none; color: var(--accent-hover); text-decoration: underline; text-underline-offset: .18em; }
.btn.lg { min-height: 56px; padding: 0 24px; font-size: var(--fs-lg); }
.btn.block { width: 100%; }
/* Стрелка в квадрате — для действий «вперёд» (Открыть, Сдать, Дальше) */
.btn.arrow { justify-content: space-between; padding-right: 54px; }
.btn.arrow::before { content: ""; position: absolute; right: 5px; top: 5px; bottom: 5px; width: 36px; border-radius: var(--radius-xs); background: var(--btn-square); transition: transform .4s cubic-bezier(.2,1,.68,1); }
.btn.arrow::after { content: ""; position: absolute; right: 21px; top: 50%; width: 8px; height: 8px; border-top: 2px solid var(--btn-arrow); border-right: 2px solid var(--btn-arrow); transform: translateY(-50%) rotate(45deg); transition: transform .4s cubic-bezier(.2,1,.68,1); }
.btn.arrow:hover::after { transform: translate(2px, -50%) rotate(45deg); }
.btn.lg.arrow { padding-right: 68px; }
.btn.lg.arrow::before { right: 6px; top: 6px; bottom: 6px; width: 44px; }
.btn.lg.arrow::after { right: 26px; width: 9px; height: 9px; }
.btn.secondary.arrow::before { background: var(--surface-2); }
.btn.secondary.arrow::after { border-color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
@container (max-width: 479px) { .actions .btn:not(.link) { flex: 1 1 100%; } }

/* ---------- 6. Бейджи (пилюли с точкой), плашки, коды правил ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 11px 0 9px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: middle;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); flex: none; }
.badge.ok::before { background: var(--ok); }
.badge.warn::before { background: var(--warn); }
.badge.bad::before { background: var(--bad); }
.badge.info::before { background: var(--accent); }
.badge.pending { border-style: dashed; border-color: var(--border-strong); color: var(--muted); }
.badge.pending::before { background: var(--pending); }
.badge.quiet { color: var(--muted); border-color: transparent; background: var(--surface-2); }
.badge.quiet::before { display: none; }

.notice {
  display: grid; gap: var(--space-2); padding: var(--space-4) 20px;
  border-radius: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
}
.notice p { color: var(--muted); max-width: 64ch; }
.notice .eyebrow { color: var(--accent); }
.notice.ok { border-color: color-mix(in oklab, var(--ok) 45%, transparent); }
.notice.ok .eyebrow { color: var(--ok); }
.notice.warn { border-color: color-mix(in oklab, var(--warn) 50%, transparent); }
.notice.warn .eyebrow { color: var(--warn); }
.notice.bad { background: var(--bad-bg); border-color: color-mix(in oklab, var(--bad) 55%, transparent); }
.notice.bad .eyebrow { color: var(--bad); }
.notice.bad p { color: var(--text); }
.notice.pending { border: 1px dashed var(--border-strong); background: transparent; }
.notice.pending .eyebrow { color: var(--pending); }
.notice.plain { background: var(--surface-2); border-color: transparent; }
.notice.plain .eyebrow { color: var(--muted); }
.notice ul { padding-left: 1.2em; display: grid; gap: 4px; color: var(--muted); }
.notice .actions { margin-top: var(--space-2); }

.rule { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-family: var(--font-mono); font-size: 12px; color: var(--muted-2); }
.rule code { padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); font-size: 12px; color: var(--muted); }

/* ---------- 7. Формы ---------- */
label { display: block; font-weight: 500; margin-bottom: 8px; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], input:not([type]), textarea, select {
  width: 100%; min-height: 48px; padding: 12px 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--field-bg); color: var(--text); font: inherit; font-size: var(--fs-md);
  transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
textarea { min-height: 112px; resize: vertical; line-height: var(--lh); }
textarea.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 20px; height: 20px; margin: 0; flex: none; }
.field { display: grid; gap: 8px; }
.field label { margin: 0; }
.field .hint { font-size: var(--fs-sm); color: var(--muted); }
.field.short input { max-width: 200px; }
.field.invalid input { border-color: var(--warn); }
.field .error-text { font-size: var(--fs-sm); color: var(--warn); }

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: var(--space-2); }
fieldset.plain legend { font-weight: 500; padding: 0; margin-bottom: var(--space-3); }
label.radio, label.check {
  display: flex; align-items: flex-start; gap: 14px;
  min-height: 52px; padding: 14px 16px; margin: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-weight: 500; cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
label.radio input, label.check input { margin-top: 2px; }
label.radio:has(input:checked), label.check:has(input:checked) { border-color: var(--text); background: var(--surface-2); }
label.radio .sub { display: block; color: var(--muted); font-size: var(--fs-sm); font-weight: 400; margin-top: 2px; }

/* Поле ответа */
.answer { display: grid; gap: var(--space-3); }
.answer input { font-size: var(--fs-2xl); font-weight: 500; min-height: 64px; padding: 12px 20px; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.answer .actions { margin-top: var(--space-2); }

/* Индикатор сохранения */
.save-state { display: inline-flex; align-items: center; gap: 10px; min-height: 24px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.save-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex: none; }
.save-state[data-state="saved"] { color: var(--muted); }
.save-state[data-state="saved"]::before { background: var(--ok); }
.save-state[data-state="saving"]::before { background: var(--muted-2); animation: ss-pulse 1.2s ease-in-out infinite; }
.save-state[data-state="error"], .save-state[data-state="conflict"] { color: var(--bad); }
.save-state[data-state="error"]::before { background: var(--bad); }
.save-state[data-state="conflict"]::before { background: transparent; box-shadow: inset 0 0 0 2px var(--bad); }
@keyframes ss-pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.copy-state { font-family: var(--font-mono); font-size: 13px; min-height: 22px; color: var(--muted); }
.copy-state[data-state="ok"] { color: var(--ok); }
.copy-state[data-state="fail"] { color: var(--warn); }

/* ---------- 8. Условие задачи и дроби ---------- */
.statement { font-size: 36px; line-height: 1.15; font-weight: 500; letter-spacing: -.015em; font-variant-numeric: lining-nums; }
.statement.sm { font-size: var(--fs-2xl); }
.statement-en { color: var(--muted-2); font-family: var(--font-mono); font-size: 13px; }
.protected { -webkit-user-select: none; user-select: none; }
.op { margin: 0 .18em; }
@container (min-width: 640px) { .statement { font-size: var(--fs-display); } .statement.sm { font-size: 30px; } }

.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: .55em; margin: 0 .1em; font-size: .8em; line-height: 1.05; font-variant-numeric: lining-nums tabular-nums; }
.statement .frac { font-size: .64em; vertical-align: .62em; }
.frac > :first-child { border-bottom: .08em solid currentColor; padding: 0 .18em .06em; }
.frac > :last-child { padding: .04em .18em 0; }
/* В мелком тексте (14px) вертикальная дробь выходит ~11px — там дробь в строку через U+2044 */
.frac-inline .frac, .small .frac { display: inline; vertical-align: baseline; font-size: inherit; line-height: inherit; margin: 0; }
.frac-inline .frac > *, .small .frac > * { padding: 0; border: 0; }
.frac-inline .frac > :first-child::after, .small .frac > :first-child::after { content: "\2044"; margin: 0 .04em; }

/* Подвал: служебные ссылки (смена пароля, семья) */
.page-foot { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter) var(--space-6); color: var(--muted); font-size: var(--fs-sm); }

/* Чертёж задания (генерируется сервером, currentColor — работает в обеих темах) и текст для чтения */
.figure { margin: 0; max-width: 320px; color: var(--text); }
.figure svg { display: block; width: 100%; height: auto; }
.figure.sm { max-width: 220px; }
.figure.wide { max-width: 520px; }
.figure figcaption { margin-top: 8px; color: var(--muted); font-size: var(--fs-sm); }
.figure .replay { margin-top: 6px; }
/* Цвета чертежа — классы генератора (apps/content/bank/figures.py), в обеих темах */
.figure .f-a { stroke: var(--accent); }
.figure .f-af { fill: var(--accent); stroke: none; }
.figure .f-s { fill: var(--accent-bg); stroke: none; }
.figure .f-m { stroke: var(--muted-2); stroke-width: 1.5; }
.figure .f-sh { fill: var(--accent); fill-opacity: .42; stroke: none; }
.figure .f-dot { fill: var(--border-strong); stroke: none; }
.figure .f-half { opacity: .55; }
.figure text.f-a { fill: var(--accent); stroke: none; }
.figure text.f-mt { fill: var(--muted); }
.figure text.f-on { fill: var(--accent-text); }
.lesson-figures { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
/* Движение — только классы a-*: без JS и при «уменьшить движение» чертёж сразу в конечном виде */
@media (prefers-reduced-motion: no-preference) {
  .figure.armed:not(.play) :is(.a-in, .a-pop, .a-fill) { opacity: 0; }
  .figure.play .a-in { animation: fig-in .5s ease both; }
  .figure.play .a-pop { transform-box: fill-box; transform-origin: center; animation: fig-pop .45s cubic-bezier(.2, .8, .3, 1.3) both; }
  .figure.play .a-draw, .figure.play .a-in [pathLength] { stroke-dasharray: 1; animation: fig-draw .9s ease both; }
  .figure.play .a-drive { animation: fig-drive 2.4s ease-in-out both; }
  .figure.play .a-fill { animation: fig-fill .35s ease both; }
  .figure.play .d1, .figure.play .d1 [pathLength] { animation-delay: .5s; }
  .figure.play .d2, .figure.play .d2 [pathLength] { animation-delay: 1.3s; }
  .figure.play .d3, .figure.play .d3 [pathLength] { animation-delay: 2.1s; }
  .figure.play .d4, .figure.play .d4 [pathLength] { animation-delay: 2.9s; }
  .figure.play .d5, .figure.play .d5 [pathLength] { animation-delay: 3.7s; }
  .figure.play .d6, .figure.play .d6 [pathLength] { animation-delay: 4.5s; }
  .figure.play .d7, .figure.play .d7 [pathLength] { animation-delay: 5.3s; }
  .figure.play .d8, .figure.play .d8 [pathLength] { animation-delay: 6.1s; }
  .figure.play .d9, .figure.play .d9 [pathLength] { animation-delay: 6.9s; }
}
@keyframes fig-in { from { opacity: 0; } }
@keyframes fig-pop { from { opacity: 0; transform: scale(.4); } }
@keyframes fig-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fig-drive { from { transform: translateX(-150px); } }
@keyframes fig-fill { from { opacity: 0; } }
.passage { padding: var(--space-4) 20px; border-radius: 14px; background: var(--surface-2); line-height: 1.6; }
.passage p { max-width: 64ch; }

/* Учебный пакет — «терминальная» карточка */
.pack { border: 1px solid var(--border); border-radius: var(--radius); background: var(--field-bg); overflow: hidden; }
.pack-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px; color: var(--muted-2); }
.pack-text {
  display: block; width: 100%; min-height: 220px; max-height: 400px; overflow: auto; margin: 0;
  padding: 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--field-bg); color: var(--text);
  font: 13.5px / 1.75 var(--font-mono); white-space: pre-wrap; word-break: break-word; resize: vertical;
  -webkit-user-select: text; user-select: text;
}
.pack .pack-text { border: 0; border-radius: 0; }
.pack-text:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- 9. Результат ---------- */
.answers { display: grid; gap: var(--space-3); }
.answer-cell { display: grid; gap: 4px; padding: 18px 20px; border-radius: 14px; background: var(--surface-2); border: 1px solid transparent; }
.answer-cell .val { font-size: var(--fs-2xl); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.answer-cell.key { border-color: color-mix(in oklab, var(--ok) 45%, transparent); }
.score { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.score-num { font-size: var(--fs-stat); font-weight: 500; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
@container (min-width: 640px) { .answers { grid-template-columns: 1fr 1fr; } .answer-cell .val { font-size: 32px; } }

/* ---------- 10. Списки шагов ---------- */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; counter-reset: step; border-top: 1px solid var(--border); }
.steps > li {
  display: grid; grid-template-columns: 40px 1fr; gap: var(--space-3); align-items: start;
  padding: 20px 0; counter-increment: step; border-bottom: 1px solid var(--border);
  transition: background-color .25s;
}
.steps > li::before { content: counter(step, decimal-leading-zero); font-family: var(--font-mono); font-size: 13px; color: var(--muted-2); padding-top: 5px; }
.steps > li[data-status="done"] { color: var(--muted); }
.steps > li[data-status="done"]::before { content: "\2713"; color: var(--ok); font-size: 15px; }
.steps > li[data-status="done"] .step-title { font-weight: 500; color: var(--muted); }
.steps > li[data-status="current"] { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 12px 0; }
.steps > li[data-status="current"]::before { color: var(--accent); }
.steps > li[data-status="none"] { border-bottom-style: dashed; color: var(--muted); }
.steps > li[data-status="none"]::before { content: "\2014"; }
.step-body { display: grid; gap: 6px; min-width: 0; }
.step-title { font-size: 19px; line-height: 1.25; font-weight: 500; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; letter-spacing: -.01em; }
.step-title .min { color: var(--muted-2); font-family: var(--font-mono); font-weight: 400; font-size: 13px; }
.step-note { color: var(--muted); font-size: 15px; max-width: 56ch; }
.step-foot { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: 4px; }
.step-action { grid-column: 1 / -1; }
@container (min-width: 640px) {
  .steps > li { grid-template-columns: 56px 1fr auto; align-items: center; padding: 24px 0; }
  .steps > li[data-status="current"] { padding: 24px; }
  .step-action { grid-column: auto; }
}
.steps.compact { border-top: 0; }
.steps.compact > li { padding: 12px 0; grid-template-columns: 32px 1fr; }
.steps.compact > li:last-child { border-bottom: 0; }
.steps.compact > li[data-status="current"] { background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 12px 0; margin: 0; }
.steps.compact .step-title { font-size: var(--fs-md); font-weight: 500; }

/* ---------- 11. Раскрывающиеся блоки ---------- */
details.disclosure { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
details.disclosure > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px;
  min-height: 52px; padding: 14px 20px; font-weight: 500;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before {
  content: ""; width: 8px; height: 8px; flex: none; margin: 0 2px 0 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .25s;
}
details.disclosure[open] > summary::before { transform: rotate(45deg); }
details.disclosure .disclosure-body { padding: 0 20px 20px; display: grid; gap: var(--space-3); }

/* ---------- 12. Таблицы ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); padding: 14px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 16px 20px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
@container (max-width: 639px) {
  .table-wrap.stack thead { display: none; }
  .table-wrap.stack table, .table-wrap.stack tbody, .table-wrap.stack tr, .table-wrap.stack td { display: block; }
  .table-wrap.stack tr { padding: 16px 20px; border-bottom: 1px solid var(--border); }
  .table-wrap.stack tr:last-child { border-bottom: 0; }
  .table-wrap.stack td { padding: 2px 0; border: 0; }
  .table-wrap.stack td:first-child { font-weight: 500; font-size: 17px; margin-bottom: 6px; }
  .table-wrap.stack td[data-label]::before { content: attr(data-label); display: block; font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .06em; margin-top: 8px; }
  .table-wrap.stack td:first-child[data-label]::before { display: none; }
}

/* ---------- 13. Журнал ---------- */
.journal { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.journal > li { display: grid; grid-template-columns: 1fr; gap: 4px var(--space-5); padding: 18px 0; border-bottom: 1px solid var(--border); }
.journal > li.j-day { display: block; padding: 28px 0 10px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); }
.journal > li.j-day:first-child { padding-top: 12px; }
.j-time { font-family: var(--font-mono); font-size: 13px; color: var(--muted-2); display: flex; gap: 12px; }
.j-title { font-weight: 500; font-size: 16px; }
.j-detail { color: var(--muted); font-size: var(--fs-sm); }
@container (min-width: 640px) {
  .journal > li { grid-template-columns: 128px 1fr; padding: 20px 0; }
  .j-time { flex-direction: column; gap: 2px; }
  .j-title, .j-detail { grid-column: 2; }
  .j-title { font-size: 17px; }
}

/* ---------- 14. Прочее ---------- */
.kv { display: grid; grid-template-columns: 1fr; gap: 4px var(--space-4); }
.kv dt { font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); }
.kv dd { margin: 0 0 var(--space-3); }
.kv dd:last-child { margin-bottom: 0; }
.kv.small dd { font-size: 15px; color: var(--muted); }
@container (min-width: 640px) {
  .kv { grid-template-columns: 150px 1fr; gap: 10px var(--space-5); }
  .kv dt { padding-top: 4px; }
  .kv dd { margin: 0; }
}
.examples { display: grid; gap: var(--space-3); }
.example { display: grid; gap: var(--space-3); padding: 20px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.example p { color: var(--muted); }
@container (min-width: 720px) { .examples { grid-template-columns: 1fr 1fr; } }
.decision { display: grid; gap: 6px; }
.decision strong { font-weight: 500; font-size: 16px; }
.decision + .decision { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.reasons { padding-left: 1.2em; display: grid; gap: 6px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; transition: color .2s, background-color .2s; }
.filters a:hover { color: var(--text); }
.filters a[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.auth { max-width: 440px; width: 100%; margin: 0 auto; }
.auth-page { display: grid; gap: var(--space-5); align-items: center; justify-items: center; }
/* Форма без заставки (смена пароля, способы входа) стоит у того же левого края, что и заголовки */
.auth-page:not(:has(> .hero3d)) { justify-items: start; }
.auth-page:not(:has(> .hero3d)) .auth { margin: 0; }
.auth-page .hero3d { width: min(100%, 320px); aspect-ratio: 4 / 3; }
/* На телефоне форма — первой: заставка не должна сдвигать вход под сгиб */
@container (max-width: 639px) { .auth-page .hero3d { order: 1; width: min(100%, 220px); } }
@container (min-width: 640px) { .card.auth { padding: 36px; } .auth-page .hero3d { width: min(100%, 440px); } }
@container (min-width: 960px) {
  .auth-page:has(> .hero3d) { grid-template-columns: minmax(0, 1fr) 440px; gap: var(--space-7); min-height: 560px; }
  .auth-page .hero3d { width: 100%; max-width: 560px; justify-self: start; }
}

/* 3D-объект: <canvas data-hero3d aria-hidden="true"> внутри .hero3d; рисует hero3d.js */
.hero3d { position: relative; }
.hero3d canvas { display: block; width: 100%; height: 100%; }
.page-head.with-hero { grid-template-columns: minmax(0, 1fr) 112px; grid-template-rows: auto auto; align-items: center; column-gap: var(--space-4); }
.page-head.with-hero > h1 { grid-column: 1; grid-row: 1; }
.page-head.with-hero > .hero3d { grid-column: 2; grid-row: 1; width: 112px; height: 112px; }
.page-head.with-hero > p { grid-column: 1 / -1; grid-row: 2; }
@container (min-width: 640px) { .page-head.with-hero { grid-template-columns: minmax(0, 1fr) 200px; } .page-head.with-hero > .hero3d { width: 200px; height: 200px; } .page-head.with-hero > p { grid-column: 1; } }
@container (min-width: 960px) { .page-head.with-hero { grid-template-columns: minmax(0, 1fr) 260px; grid-template-rows: auto 1fr; align-items: start; row-gap: var(--space-4); } .page-head.with-hero > .hero3d { width: 260px; height: 260px; grid-row: 1 / 3; align-self: center; } }

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

/* Day progress on «Сегодня» and the step-by-step solution of a worked example */
.day-progress { display: grid; gap: 6px; margin-top: var(--space-3); max-width: 420px; }
/* <progress>, not a width in a style attribute: the CSP (style-src 'self') drops inline styles. */
.day-progress-bar { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; border: 0;
  border-radius: 999px; background: var(--border); overflow: hidden; color: var(--accent); }
.day-progress-bar::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
.day-progress-bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .3s; }
.day-progress-bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.solution-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; }
.next-step { display: grid; gap: var(--space-2); }
.next-step .step-what { color: var(--muted); }

/* Sections of one learner in the parent area */
.subnav { display: flex; gap: 2px; padding: 4px; margin: 0 0 var(--space-4); overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.subnav a { flex: 1 0 auto; text-align: center; padding: 8px 10px; border-radius: calc(var(--radius-sm) - 4px);
  color: var(--muted); text-decoration: none; font-size: var(--fs-sm); white-space: nowrap; }
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.summary-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.tile { padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); display: grid; gap: 4px; align-content: start; }
.tile .num { font-size: 1.4rem; font-weight: 600; color: var(--text); }
.tile .lbl { font-size: var(--fs-sm); color: var(--muted); }
.work + .work { margin-top: var(--space-3); }
.work summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: baseline; }
.work .when { color: var(--muted); font-size: var(--fs-sm); }

/* Sign-up and recovery */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.auth .auth-links { margin-top: var(--space-4); }
.auth label.check { margin-top: var(--space-3); }
.auth label.check + .btn, .auth label.check + button { margin-top: var(--space-5); }
.prose h2 { margin-top: var(--space-6); }
.prose h2:first-child { margin-top: 0; }
.prose li { max-width: 60ch; line-height: 1.55; margin-bottom: var(--space-2); }
.auth-alt { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border); display: grid; gap: var(--space-3); }
.auth-alt p { margin: 0; }
.stack-cards { display: grid; gap: var(--space-5); }
.stack-cards h2 { margin-top: var(--space-4); }
.stack-cards h1 + h2 { margin-top: var(--space-3); }
.auth .tg-login { margin-top: var(--space-3); }
.auth .tg-login + .small { margin-top: var(--space-2); }
.auth-or { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-5) 0 var(--space-2); color: var(--muted); font-size: var(--fs-sm); }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.stack-buttons { display: grid; gap: var(--space-3); margin-top: var(--space-4); }
.stack-cards .card > h2:first-child { margin-top: 0; }

/* Landing for visitors */
.landing-cta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-5) 0 var(--space-6); }
.landing-cta .btn { flex: 1 1 220px; }
.landing .summary-tiles { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 0; }
.landing .tile strong { font-weight: 500; line-height: 1.4; }
.plain-list { margin: 0; padding-left: 1.2em; display: grid; gap: var(--space-2); }
.landing .block + .block { margin-top: var(--space-6); }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.family-layout { display: flex; flex-direction: column; gap: var(--space-6); }
.family-layout.first-run .add-forms { order: -1; }

/* Согласие на статистику посещений (static/js/consent.js) */
.consent-box { position: fixed; left: var(--space-4); right: var(--space-4); bottom: var(--space-4); z-index: 50; max-width: 560px; margin: 0 auto; padding: var(--space-4); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 30px rgba(0, 0, 0, .18); }
.consent-box p { margin: 0 0 var(--space-3); }
.consent-box .actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.page-foot a { color: inherit; }
.legal h2 { margin-top: var(--space-5); }
.legal table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.legal th, .legal td { text-align: left; vertical-align: top; padding: var(--space-2); border-bottom: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }
.password-row { display: flex; gap: var(--space-2); }
.password-row input { flex: 1; min-width: 0; }
.who-sub { display: block; font-size: var(--fs-xs); color: var(--muted); }
.consent-box { bottom: max(var(--space-4), env(safe-area-inset-bottom)); }
.has-consent-banner .page { padding-bottom: 280px; }

/* Учебная программа для родителей */
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); counter-reset: flow; }
.flow li { counter-increment: flow; display: grid; grid-template-columns: 36px 1fr; column-gap: var(--space-3); align-items: start; }
.flow li::before { content: counter(flow); grid-row: 1 / 3; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.flow li span { color: var(--muted); font-size: var(--fs-sm); }
.program-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.program-skill h3 a { color: var(--text); }
.program-skill h3 a:hover { color: var(--accent); }
@container (min-width: 960px) { .flow { grid-template-columns: repeat(5, 1fr); } .flow li { grid-template-columns: 1fr; row-gap: 6px; } .flow li::before { grid-row: auto; } }
/* Главная: 3D-сцена крупнее, чем в заголовках кабинета */
@container (min-width: 960px) {
  .landing .page-head.with-hero { grid-template-columns: minmax(0, 1fr) 440px; }
  .landing .page-head.with-hero > .hero3d { width: 440px; height: 440px; }
}

/* Длинные ссылки и коды (ссылка для Telegram ребёнка) переносятся на телефоне, а не раздвигают страницу */
.mono { overflow-wrap: anywhere; }
.figure .replay { display: none; }
.motion-ok .figure .replay { display: inline-flex; }

/* ---------- Страницы ребёнка: «Как это устроено», результат, навыки по разделам, музыка, праздник ---------- */
.howto { gap: var(--space-4); }
.howto-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.howto-head .btn.link { min-height: 40px; }
.how-steps li { align-content: start; }
.how-steps li strong { font-weight: 600; }
.how-steps li span { font-size: 15px; }
@container (min-width: 960px) { .flow.how-steps { grid-template-columns: repeat(4, 1fr); } }
h1[tabindex="-1"]:focus { outline: none; }

.score-lead { display: grid; gap: 6px; }
.score-lead .score-num { font-size: 34px; }
@container (min-width: 640px) { .score-lead .score-num { font-size: 44px; } }

.course-progress { max-width: 520px; }
.skill-section summary { justify-content: space-between; flex-wrap: wrap; row-gap: 8px; }
.skill-section .section-name { display: grid; gap: 2px; flex: 1 1 220px; min-width: 0; }
.skill-section .section-title { font-size: var(--fs-lg); line-height: 1.3; }
.skill-section .section-count { display: grid; gap: 6px; justify-items: end; flex: 0 0 auto; min-width: 96px; }
.skill-section .section-count .day-progress-bar { width: 96px; }
.skill-section[open] { border-color: var(--border-strong); }
.skill-section .steps > li.is-next { border-bottom-color: var(--accent); }
.skills-planet canvas { cursor: default; }

/* Музыка: маленькое отдельное окно (~380×460) или вкладка на телефоне */
.music-page { min-height: 100dvh; }
.music { max-width: 520px; margin: 0 auto; padding: var(--space-3) var(--space-3) var(--space-4); display: grid; gap: var(--space-2); }
.music-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.music-head h1 { font-size: var(--fs-xl); }
.music .notice { padding: 10px 14px; border-radius: var(--radius-sm); }
.music .notice.small { font-size: var(--fs-sm); color: var(--text); }
.music-screen { position: relative; aspect-ratio: 16 / 9; min-height: 200px; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); }
.music-screen iframe, .music-screen #music-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.music-idle { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--space-4); text-align: center; }
.music-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.music-controls .btn { min-height: 44px; padding: 0 10px; font-size: var(--fs-sm); justify-content: center; text-align: center; }
.music-controls [data-music-play] { font-size: var(--fs-md); }
.music-controls [data-music-next] { grid-column: span 2; }

/* Праздник «всё сделано»: поверх страницы, не ловит нажатия */
.celebrate { position: fixed; inset: 0; width: 100vw; height: 100dvh; pointer-events: none; z-index: 40; }
.j-adult summary { cursor: pointer; color: var(--muted-2); font-size: 13px; }
.j-adult[open] summary { margin-bottom: 4px; }
.know-it .know-it-lead { color: var(--text); font-size: var(--fs-lg); font-weight: 600; }

/* ---------- Справочник (/reference/, apps/study/reference.py) ---------- */
/* Ссылка в шапке — внутри блока меню: на широком экране стоит в ряду сразу после разделов,
   на телефоне и планшете — первым пунктом маленького меню, под именем. */
/* В ряду места мало (имя с семьёй, язык, тема, «Выйти»), поэтому там видна только книжка с подсказкой; имя ссылки — «Справочник».
   С ней ряд ученика занимает ~1010 px, поэтому маленькое меню работает до 1040 px, а не до 960 (иначе ряд вылезал за экран). */
.ref-nav { gap: 8px; }
@supports selector(:popover-open) {
  @container (min-width: 960px) and (max-width: 1039px) {
    .topbar nav .menu-toggle { display: inline-flex; }
    .topbar-more[popover]:not(:popover-open) { display: none; }
  }
}
@container (min-width: 1040px) {
  .topbar-more > .who, .topbar-more button { order: 1; }
  .topbar nav .ref-nav { padding: 0 11px; }
  .ref-nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.topbar-more:popover-open .ref-nav { justify-content: flex-start; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; color: var(--text); font-size: var(--fs-md); }
.topbar-more:popover-open .ref-nav:hover, .topbar-more:popover-open .ref-nav[aria-current="page"] { background: var(--surface-2); }
/* Ссылка на странице урока */
.ref-hint a { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px 0 5px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); text-decoration: none; font-weight: 500; }
.ref-hint a:hover { border-color: var(--border-strong); color: var(--text); }
.ref-hint-label { padding: 4px 9px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
/* Оглавление и страницы */
.page.ref { gap: var(--space-5); }
.ref-head { display: grid; gap: var(--space-4); }
.ref-head .subnav { margin: 0; }
.ref-up { justify-self: start; color: var(--accent); }
.ref-up::before { content: "\2190"; margin-right: 6px; }
.ref-toc ul, .ref-card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ref-toc a, .ref-card-list a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; transition: color .2s, border-color .2s; }
.ref-toc a:hover, .ref-card-list a:hover { color: var(--text); border-color: var(--border-strong); }
.ref-card-list a { background: var(--surface-2); border-color: transparent; }
.ref-index { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); }
.ref-card { gap: var(--space-3); }
.ref-card h2 a { color: var(--text); }
.ref-card h2 a:hover { color: var(--accent); }
@container (min-width: 720px) { .ref-index { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 1040px) { .ref-index { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Раздел: формула слева, слова справа (на телефоне — друг под другом) */
.ref-sec { scroll-margin-top: 88px; min-width: 0; }
.ref-sec:target { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ref-sec h3 { margin-top: var(--space-2); }
.ref-rules { list-style: none; margin: 0; padding: 0; display: grid; }
.ref-rules > li { display: grid; gap: 2px var(--space-5); padding: 12px 0; border-top: 1px solid var(--border); align-items: baseline; min-width: 0; }
.ref-rules > li:first-child { border-top: 0; padding-top: 0; }
.ref-rules > li:last-child { padding-bottom: 0; }
@container (min-width: 720px) { .ref-rules > li { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.ref .f { font-size: 18px; font-weight: 500; line-height: 1.75; font-variant-numeric: lining-nums; overflow-wrap: anywhere; }
.ref .w { color: var(--muted); font-size: 15px; line-height: 1.5; }
.ref .u { white-space: nowrap; font-family: var(--font-mono); font-size: 12px; color: var(--muted-2); }
.ref sup, .ref sub { font-size: .72em; line-height: 0; }
.ref .frac { font-size: .84em; }
.ref-steps { margin: 0; padding-left: 1.4em; display: grid; gap: 4px; }
.ref-example, .ref-tip { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 15px; line-height: 1.55; }
.ref-example { background: var(--surface-2); }
.ref-tip { background: var(--warn-bg); border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent); }
.ref-tip strong { font-weight: 600; }
.ref-foot { max-width: 72ch; }
/* Таблицы */
/* relative: the hidden plain-text copy of a fraction (.sr-only, absolute) stays inside the scrolling table */
.ref .table-wrap { position: relative; }
.ref-table { font-size: 15px; }
.ref-table caption { caption-side: top; text-align: left; padding: 14px 14px 6px; font-weight: 600; color: var(--text); }
.ref-table th, .ref-table td { padding: 10px 14px; }
.ref-table th { white-space: normal; }
.ref-table thead th { text-transform: none; letter-spacing: .01em; font-size: 13px; }  /* «ρ, кг/м³» must not become «Р, КГ/М³» */
.ref-table th[scope="row"] { font-family: var(--font); font-size: 15px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text); }
.ref-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ref-table td.f { font-size: 16px; line-height: 1.7; }
.ref-table .frac { font-size: .8em; }
.ref-squares td, .ref-trig td { text-align: center; font-variant-numeric: tabular-nums; }
.ref-quads td { min-width: 180px; }
.ref-verbs td, .ref-verbs th[scope="row"] { white-space: nowrap; }
.ref-verbs td:last-child { white-space: normal; color: var(--muted); min-width: 160px; }
.ref-grid { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); align-items: start; }
@container (min-width: 720px) { .ref-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 1040px) { .ref-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ref-tables { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
@container (min-width: 960px) { .ref-tables { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ref-table-block { display: grid; gap: 8px; scroll-margin-top: 88px; min-width: 0; }
.ref-table-block:target .table-wrap, .ref-table-block:target .ref-sat { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
.ref-sat { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.ref-sat li { display: flex; justify-content: space-between; gap: 6px; padding: 6px 10px; border-radius: var(--radius-xs); background: var(--surface-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.ref-sat span { color: var(--muted); }
.ref-sat b { font-weight: 600; }
/* Графики и рисунки (inline SVG, цвет — через currentColor) */
.ref-split { display: grid; gap: var(--space-5); align-items: start; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 960px) { .ref-split { grid-template-columns: minmax(0, 1fr) 280px; } }
.ref-graphs { display: grid; gap: var(--space-5) var(--space-4); grid-template-columns: minmax(0, 1fr); }
@container (min-width: 600px) { .ref-graphs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 1000px) { .ref-graphs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ref-graph { margin: 0; display: grid; gap: 8px; align-content: start; color: var(--text); scroll-margin-top: 88px; }
.ref-graph svg { display: block; width: auto; max-width: 100%; height: auto; }  /* one scale for every graph: 22 px a unit */
.ref-graph figcaption { font-size: 14px; color: var(--muted); line-height: 1.5; }
.ref-graph figcaption strong { color: var(--text); font-weight: 600; }
.ref-graph figcaption ul { margin: 6px 0 0; padding-left: 1.1em; display: grid; gap: 2px; }
.ref-graph .g-grid { color: var(--text); }
.ref-graph .g-axis, .ref-graph .g-axis-head { color: var(--muted); }
.ref-graph .g-text { color: var(--muted); font-family: var(--font); }
.ref-graph .g-curve, .ref-graph .g-dot, .ref-graph .g-label, .ref-graph .g-fill { color: var(--accent); }
.ref-graph .g-curve2, .ref-graph .g-label2 { color: var(--pending); }
.ref-graph .g-label, .ref-graph .g-label2 { font-family: var(--font); font-weight: 600; }
/* Обозначения на схемах */
.ref-symbols { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.ref-symbols li { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 15px; line-height: 1.35; }
.ref-symbols svg { flex: none; color: var(--text); }
/* Времена английского глагола */
.ref-tenses { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); }
@container (min-width: 900px) { .ref-tenses { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ref-tense { display: grid; gap: 8px; align-content: start; padding: 16px 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); scroll-margin-top: 88px; min-width: 0; }
.ref-tense:target { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ref-forms { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 16px; }
.ref-forms dt { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }
.ref-forms dd { margin: 0; overflow-wrap: anywhere; }
.ref-forms b { font-weight: 650; }
.ref-markers { font-size: 14px; color: var(--muted); }
.ref-markers > span:first-child { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-right: 4px; }
/* Same-origin study audio: a quiet record, real native audio, no video surface. */
.music-record { width: 140px; height: 140px; margin: 24px auto; border-radius: 50%; display: grid; place-items: center; background: repeating-radial-gradient(circle, #252b2c 0 2px, #343a3b 3px 4px); box-shadow: 0 5px 22px #0002; }
.music-record-label { width: 65px; height: 65px; display: grid; align-content: center; text-align: center; border-radius: 50%; background: var(--accent, #c8d89c); color: #273129; font-size: 18px; line-height: 1.1; letter-spacing: .08em; }
.music-record-label small { font-size: 7px; margin-top: 5px; }
.music-track { font-size: 18px; margin: 16px 0 5px; font-weight: 600; }
.music select { width: 100%; margin-top: 5px; }
.music-slider { display: flex; align-items: center; gap: 16px; margin: 22px 0; }
.music-slider input { flex: 1; min-width: 0; accent-color: var(--accent, #6e7852); }
.music.is-playing .music-record { animation: study-record 18s linear infinite; }
@keyframes study-record { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .music.is-playing .music-record { animation: none; } }

.music-link.is-playing { color: var(--accent); }
.music-link.is-playing .music-text::after { content: " ·"; }

/* Password fallback stays discoverable without competing with Telegram or child invitations. */
.auth-password { margin-top: var(--space-5); }
.auth-password[open] summary { margin-bottom: var(--space-4); }
.auth-password form { margin: 0; }

/* Same-tab study shell: the player takes its own row and never covers an answer field. */
.study-shell { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; padding: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.study-content { display: block; width: 100%; height: 100%; min-height: 0; border: 0; background: var(--bg); }
.music-dock { background: var(--surface); border-top: 1px solid var(--border); padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)); box-shadow: 0 -4px 24px #0000000b; }
.music-dock[hidden], .music-options[hidden] { display: none; }
.music-dock-bar { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: auto minmax(80px, 1fr) minmax(140px, 210px) auto auto; gap: 12px; align-items: center; }
.music-dock .btn { min-height: 44px; padding: 0 14px; }
.music-brief { min-width: 0; display: grid; gap: 2px; }
.music-brief strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-brief [data-music-state] { font-size: 12px; }
.music-dock-volume { display: flex; align-items: center; gap: 8px; min-width: 0; }
.music-dock-volume input { flex: 1; min-width: 64px; width: 100%; height: 44px; margin: 0; accent-color: var(--accent); touch-action: pan-y; }
.music-dock-volume output { width: 4ch; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.music-dock .music-close { width: 44px; padding: 0; font-size: 24px; }
.music-options { max-width: 1120px; margin: 12px auto 0; padding-top: 12px; border-top: 1px solid var(--border); max-height: 32dvh; overflow: auto; }
.music-options-controls { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.music-options-controls label { display: grid; gap: 4px; font-size: 13px; flex: 1 1 200px; }
.music-options select { width: 100%; min-height: 44px; }
.music-options p { margin: 8px 0; }
.music-dock .music-play { min-width: 88px; }
@media (max-width: 639px) {
  .music-dock { padding-top: 8px; }
  .music-dock-bar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 8px; }
  .music-brief { grid-column: 2; }
  .music-close { grid-column: 3; grid-row: 1; }
  .music-dock-volume { grid-column: 2 / 4; grid-row: 2; }
  .music-dock .music-settings { grid-column: 1; grid-row: 2; padding: 0 8px; font-size: 11px; max-width: 110px; }
  .music-dock .music-play { min-width: 88px; padding: 0 10px; }
  .music-options { max-height: 28dvh; }
}

/* Clear learning route and factual reports. The existing visual language stays consistent. */
.parent-navigation {display:flex;gap:8px;align-items:stretch;margin:0 0 28px;position:relative;flex-wrap:wrap}
.parent-navigation>a {flex:1 1 160px;border:1px solid var(--border);border-radius:14px;padding:13px 16px;text-decoration:none;display:flex;flex-direction:column;gap:3px;background:var(--surface)}
.parent-navigation>a span,.parent-nav-more a span {font-size:12px;color:var(--muted)}
.parent-navigation>a[aria-current],.parent-nav-more a[aria-current] {border-color:var(--accent);background:var(--accent-bg)}
.parent-navigation>a:hover {border-color:var(--border-strong)}
.parent-nav-more {position:relative;flex:0 0 auto}
.parent-nav-more summary {min-height:68px;padding:22px 16px;border-radius:14px;border:1px solid var(--border);cursor:pointer;list-style:none}
.parent-nav-more summary::after {content:"⌄";margin-left:8px}
.parent-nav-more>div {position:absolute;right:0;top:calc(100% + 6px);z-index:5;min-width:280px;background:var(--surface);border:1px solid var(--border-strong);border-radius:14px;padding:8px;box-shadow:0 12px 35px #0002}
.parent-nav-more a {display:flex;flex-direction:column;gap:4px;padding:12px;border-radius:8px;text-decoration:none}
.parent-nav-more a:hover {background:var(--surface-2)}
.learning-compass {display:grid;grid-template-columns:minmax(0,1.55fr) minmax(260px,1fr);border:1px solid var(--border-strong);border-radius:24px;overflow:hidden;background:var(--surface);margin-bottom:18px}
.compass-main {padding:32px}.compass-main h2 {font-size:clamp(24px,3vw,36px);letter-spacing:-.035em;line-height:1.15;margin:15px 0}
.compass-topic {font-size:20px;font-weight:650;color:var(--accent);margin:16px 0 10px}.compass-main>p:not(.compass-topic){max-width:53ch}
.compass-aside {padding:32px;background:var(--accent-bg);border-left:1px solid var(--border)}
.compass-aside>p {margin-top:18px}.compass-aside strong {display:block;margin-bottom:8px;font-size:18px}
.learning-route {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;list-style:none;padding:0;margin:0 0 32px}
.learning-route li {display:grid;grid-template-columns:28px 1fr;column-gap:12px;align-items:start;padding:16px;border-bottom:2px solid var(--border);color:var(--muted)}
.learning-route li>span {font-family:var(--font-mono);font-size:12px;padding-top:3px}.learning-route small {grid-column:2;font-size:12px;margin-top:4px}.learning-route .is-current {color:var(--text);border-color:var(--accent)}.learning-route .is-done>span {color:var(--ok)}
.wayfinding-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.wayfinding-grid>a {display:flex;flex-direction:column;gap:12px;padding:22px;background:var(--surface);border:1px solid var(--border);border-radius:16px;text-decoration:none}.wayfinding-grid>a:hover {border-color:var(--accent)}.wayfinding-grid>a>strong {display:flex;justify-content:space-between;gap:12px}.wayfinding-grid>a>span {color:var(--muted);font-size:14px}
.parent-detail {margin:16px 0}.parent-detail>summary {font-weight:650}.parent-detail>.block,.parent-detail>.two-col {margin-top:20px}
.learner-focus {border-color:var(--accent);margin-bottom:24px}.learner-focus h2 {font-size:clamp(24px,4vw,34px);letter-spacing:-.025em;margin:12px 0}.learner-focus h2 .sub{font-size:.7em;font-weight:500;color:var(--accent);margin-top:10px}.learner-focus>p {max-width:65ch}.day-plan {scroll-margin-top:16px}
.insights-grid {display:grid;grid-template-columns:minmax(0,1.65fr) minmax(250px,1fr);gap:16px}.insights-grid .card {margin:0;min-width:0}.chart-card h3,.skill-chart h3 {font-size:19px;margin:0 0 10px}.chart-card>p {min-height:3em}
.learning-chart {position:relative;margin:16px 0 0}.learning-chart svg {display:block;width:100%;height:auto;overflow:visible}.learning-chart canvas {position:absolute;top:0;left:0;width:100%;height:auto;aspect-ratio:640/240;pointer-events:none}.chart-enhanced .chart-fill-ok,.chart-enhanced .chart-fill-warn,.chart-enhanced .chart-fill-pending,.chart-enhanced .chart-fill-muted {opacity:0}
.chart-axis {stroke:var(--border-strong);stroke-width:1}.chart-label {fill:var(--muted);font-family:var(--font-mono);font-size:11px}.chart-fill-ok {fill:var(--ok)}.chart-fill-warn {fill:var(--warn)}.chart-fill-pending {fill:var(--pending)}.chart-fill-muted {fill:var(--muted-2)}
.chart-legend {display:flex;gap:8px 16px;flex-wrap:wrap;font-size:12px;margin-top:8px}.chart-key {display:inline-flex;align-items:center;gap:7px}.chart-key::before {content:"";width:8px;height:8px;background:var(--muted-2);border-radius:2px;flex-shrink:0}.chart-key.ok::before {background:var(--ok)}.chart-key.warn::before {background:var(--warn)}.chart-key.pending::before {background:var(--pending)}
.chart-days {display:flex;gap:4px;flex-wrap:wrap;margin-top:10px}.chart-day {border:1px solid var(--border);border-radius:8px;min-height:40px;padding:8px;background:var(--surface);color:var(--muted);font:12px var(--font-mono);cursor:pointer}.chart-day[aria-pressed=true] {background:var(--accent-bg);border-color:var(--accent);color:var(--text)}.chart-detail {display:block;color:var(--muted);min-height:3em;margin-top:16px}.chart-data {margin:12px 0 0}.chart-data summary {font-size:13px}.chart-empty {font-size:14px;color:var(--muted)}
.skill-counts {list-style:none;margin:24px 0;padding:0;display:grid;gap:18px}.skill-counts li {display:grid;grid-template-columns:1fr auto;gap:8px;font-size:14px}.skill-counts strong {font:20px var(--font-mono);font-variant-numeric:tabular-nums}.skill-counts progress {grid-column:1/-1;width:100%;height:5px;accent-color:var(--accent);border:none;border-radius:10px;overflow:hidden}.skill-counts progress::-webkit-progress-bar{background:var(--border)}.skill-counts progress::-webkit-progress-value{background:var(--accent)}
.report-metadata {margin-top:16px}.summary-tiles .num {font-variant-numeric:tabular-nums}
@media(max-width:760px){.learning-compass,.insights-grid {grid-template-columns:1fr}.compass-main,.compass-aside {padding:22px}.compass-aside{border-left:0;border-top:1px solid var(--border)}.learning-route {gap:4px}.learning-route li {display:flex;flex-direction:column;gap:5px;padding:10px 5px;font-size:12px}.learning-route small{font-size:11px}.wayfinding-grid{grid-template-columns:1fr}.parent-navigation {gap:6px}.parent-navigation>a {flex:1 1 calc(33% - 22px);padding:11px 9px;min-width:0;font-size:12px}.parent-navigation>a span{display:none}.parent-nav-more{flex:0 0 auto}.parent-nav-more summary {min-height:44px;padding:12px;font-size:12px}.parent-nav-more>div{min-width:260px}.chart-card>p {min-height:0}.chart-days {gap:6px}.chart-day {min-height:44px}.learning-route li>span{font-size:10px}}
@media print {.learning-chart canvas,.chart-days,.chart-detail {display:none!important}.chart-enhanced rect {opacity:1!important}}

/* Compact music: one 44px control row; extra controls are opt-in. */
.music-dock {padding:4px max(8px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom))}
.music-dock-bar {grid-template-columns:44px minmax(0,1fr) 44px 44px;gap:8px;max-width:1120px}
.music-dock .music-play {min-width:44px;width:44px;padding:0;font-size:16px;border-radius:50%}
.music-dock .music-settings {grid-column:auto;grid-row:auto;width:44px;min-width:44px;max-width:none;padding:0;font-size:24px;background:none;border-color:transparent}
.music-dock .music-close {grid-column:auto;grid-row:auto;border-color:transparent;background:none}
.music-brief {grid-column:auto}.music-brief strong {font-size:12px}.music-brief [data-music-state] {font-size:10px;line-height:1.2}
.music-options {max-width:680px;margin-top:4px;padding-top:8px;max-height:min(230px,32dvh)}
.music-options-controls {display:grid;grid-template-columns:minmax(140px,1fr) auto auto;gap:6px 8px;align-items:center}
.music-options-controls label {font-size:12px}.music-options-controls .music-dock-volume {grid-column:1/-1;grid-row:auto;display:flex;gap:10px}
.music-options-controls .music-dock-volume input {height:36px}.music-options select {min-height:38px;font-size:12px;padding:6px 8px}.music-options .btn {min-height:36px;font-size:12px;padding:5px 8px}
.music-options-controls [data-music-down],.music-options-controls [data-music-up] {display:none}.music-options .disclosure {margin:6px 0}.music-options .disclosure>summary {font-size:11px}.music-options>p {font-size:11px;line-height:1.35;margin:5px 0}
@media(max-width:639px){.music-dock-bar {grid-template-columns:40px minmax(0,1fr) 40px 40px;gap:4px}.music-dock .music-play,.music-dock .music-close,.music-dock .music-settings {min-width:40px;width:40px;min-height:44px}.music-options {max-height:28dvh}.music-options-controls{grid-template-columns:minmax(110px,1fr) auto auto}}

/* Parent tasks need a compact working view, with detail available on demand. */
.page.parent-space {gap:24px;padding-top:28px}.parent-space .parent-navigation {margin:0}.parent-space .learning-compass {margin:0}.parent-space .learning-route {margin:0 0 6px}.parent-space .page-head h1 {font-size:32px}.parent-space .page-head h1 .dim {font-size:18px;margin-top:8px}.parent-space .parent-detail {margin:0}.parent-space .compass-main h2 {font-size:30px}
.chat-handoff h2 {font-size:22px;margin:12px 0}.chat-handoff>p {max-width:65ch}.chat-handoff .pack-text {min-height:220px;max-height:360px}
@media(max-width:639px){.page.parent-space{gap:20px;padding-top:20px}.parent-space .page-head h1{font-size:26px}.parent-space .compass-main h2{font-size:25px}.parent-space .page-head h1 .dim{font-size:16px}.chat-handoff h2{font-size:20px}}

@media(max-width:639px){.parent-navigation>a {flex:1 1 80px}.parent-nav-more summary {width:40px;min-height:58px;padding:10px 8px;display:flex;align-items:center;justify-content:center;font-size:0}.parent-nav-more summary::after{content:"⋯";font-size:22px;margin:0}.parent-space .summary-tiles .tile{padding:14px 10px;min-width:0}.parent-space .summary-tiles .lbl{font-size:11px;overflow-wrap:break-word;line-height:1.45}.parent-space .summary-tiles .num{font-size:27px}}

/* The expanded player stays a small tool drawer, not a second screen. */
.music-options-controls label {margin:0}.music-options-controls label>[data-music-text="mix"] {display:none}.music-options>.disclosure {border:0;border-radius:0;margin:4px 0 0;padding:0}.music-options>.disclosure>summary {padding:4px;min-height:28px;border:0;font-size:11px}.music-options>.disclosure>.disclosure-body {padding:6px 4px}.music-options-controls {align-items:center}.music-options {max-height:min(190px,28dvh)}
@media(max-width:639px){.statement:not(.sm) {font-size:26px;line-height:1.3}.music-options-controls {grid-template-columns:minmax(110px,1fr) auto auto}}

.account-actions {flex-basis:100%;padding:0!important;border:0!important;border-radius:0!important;margin:6px 0 0!important}.account-actions>summary{font-size:12px;padding:8px 0!important;min-height:36px}.family-add>.add-forms {margin-top:18px}.family-layout.first-run>.family-add {order:-1}

/* Long report tables and programme titles must not widen the page grid. */
.page {grid-template-columns:minmax(0,1fr)}
.page > * {min-width:0}
.report-title .mono,.report-item .mono {overflow-wrap:anywhere}
@media(max-width:359px){.parent-navigation{display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) 40px}.parent-navigation>a{font-size:11px;padding:10px 6px}}
.program-list {grid-template-columns:minmax(0,1fr)}
.program-subject > *,.program-list > * {min-width:0}
.program-skill {overflow-wrap:anywhere}
.page h1 {overflow-wrap:anywhere}
.program-subject {grid-template-columns:minmax(0,1fr)}
.program-skill .row > * {min-width:0;max-width:100%}
.program-skill .badge {white-space:normal}
/* Keep long formulae inside nested lesson/example grids. */
.block,.example {grid-template-columns:minmax(0,1fr)}
.examples {grid-template-columns:minmax(0,1fr)}
.block > *,.example > *,.examples > * {min-width:0}
.statement.sm,.solution,.statement-en {overflow-wrap:anywhere}
@container (min-width:720px){.examples{grid-template-columns:repeat(2,minmax(0,1fr))}}
.learner-focus h2 .sub {display:block;margin-top:10px;font-size:20px;line-height:1.4;color:var(--accent)}
@media(max-width:480px){
  .page-head.with-hero{grid-template-columns:minmax(0,1fr)}
  .page-head.with-hero>.hero3d{display:none}
  .page-head.with-hero>h1,.page-head.with-hero>p{grid-column:1}
  .page-head h1 .dim{font-size:22px;line-height:1.35;overflow-wrap:normal}
}

/* Topic drilldown and closed-work review. Keep long answers inside their own cards. */
.tile-link {color:var(--text);text-decoration:none;min-width:0;transition:border-color .2s,background-color .2s}
.tile-link:hover {color:var(--text);border-color:var(--accent);background:var(--surface-2)}
.tile-action {font-size:12px;color:var(--accent);margin-top:8px}
.support-topics,.report-item {scroll-margin-top:24px}
.support-topic-list {display:grid;grid-template-columns:minmax(0,1fr);gap:16px}
.support-topic {display:grid;gap:12px;min-width:0}
.support-topic h3,.support-topic p {margin:0}
.support-topic .actions {margin:0;gap:12px 20px}
.support-lesson {display:inline-flex;align-items:center;min-height:44px;font-size:14px}
.skill-counts a {text-underline-offset:4px;min-height:32px;align-items:center}
.attempt-review {display:grid;grid-template-columns:minmax(0,1fr);gap:20px}
.attempt-review h2 {margin:0}
.answers {grid-template-columns:minmax(0,1fr)}
.answer-cell {min-width:0}
.answer-cell .val {overflow-wrap:anywhere;white-space:pre-wrap;line-height:1.45}
.answer-cell .text-answer {font-size:var(--fs-md);font-weight:400}
@container (min-width:640px){.answers{grid-template-columns:repeat(2,minmax(0,1fr))}}
@container (min-width:800px){.support-topic-list{grid-template-columns:repeat(2,minmax(0,1fr))}}

.nav-label-short {display:none}
.support-topics,.report-item {scroll-margin-top:100px}
@container (max-width:639px){.nav-label-full{display:none}.nav-label-short{display:inline}}
/* Responsive labels must wrap rather than widening their grid or clipping at the viewport. */
.page-head {grid-template-columns:minmax(0,1fr)}
.badge {max-width:100%;white-space:normal;overflow-wrap:anywhere;line-height:1.45}
.btn {max-width:100%;overflow-wrap:anywhere;padding-block:10px}
.actions>form {min-width:0;max-width:100%}
@container (max-width:479px){.attempt-review .statement.sm{font-size:24px}.answer-cell{padding:14px 16px}.answer-cell .val{font-size:26px}.answer-cell .text-answer{font-size:16px}}
.skill-counts li:has(a) {position:relative}
.skill-counts li a::after {content:"";position:absolute;inset:0}

@container (max-width:479px){.statement.sm{font-size:24px}}
.disclosure > summary {overflow-wrap:anywhere;min-width:0;line-height:1.45}
.disclosure > .disclosure-body {min-width:0;grid-template-columns:minmax(0,1fr)}
.disclosure > .disclosure-body > * {min-width:0}
.disclosure:not(.account-actions):not(.family-add) > :is(.two-col,.block,.support-topic-list,.kv,.reasons,.table-wrap,.steps,.journal) {margin:0 20px 20px;min-width:0}
.disclosure > .table-wrap {border-radius:10px}
.parent-nav-more > div {max-width:calc(100vw - 32px)}
@container (max-width:479px){details.disclosure > summary{padding:12px 14px;gap:10px;min-height:48px}details.disclosure > .disclosure-body{padding:0 14px 14px}.disclosure:not(.account-actions):not(.family-add) > :is(.two-col,.block,.support-topic-list,.kv,.reasons,.table-wrap,.steps,.journal){margin:0 14px 14px}}
.review-items > .card {border:0;border-top:1px solid var(--border);border-radius:0;margin:0;padding:20px}
@container (max-width:479px){.review-items > .card{padding:18px 14px}.disclosure .statement.sm{font-size:22px}}
@supports selector(:popover-open){@container (max-width:359px){.topbar nav{flex-wrap:nowrap}.topbar nav>a,.topbar nav>button{font-size:12px;padding-inline:4px}.topbar nav .music-link,.topbar nav .menu-toggle{min-width:32px}}}
.parent-nav-more.is-current > summary{border-color:var(--accent);background:var(--accent-bg)}

/* Programme intro has several paragraphs; each occupies its own row. */
.page-head.with-hero > .program-intro {grid-column:1/-1;grid-row:2;display:grid;gap:var(--space-3);min-width:0}
@container (min-width:640px){.page-head.with-hero > .program-intro{grid-column:1}}
