/* ===================== Ясно — оформление ===================== */

/* ----- Цветовые токены ----- */
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --ink: #1b1f3b;
  --muted: #5d6483;
  --line: #e2e5ef;
  --accent: #5b5bd6;
  --accent-2: #f0567a;
  --accent-ink: #ffffff;
  --accent-soft: #ececff;
  --ok: #138a4a;
  --ok-soft: #e3f6eb;
  --bad: #c43c4a;
  --bad-soft: #fdeaec;
  --warn: #9a5800;
  --warn-soft: #fff3dd;
  --def: #7044c8;
  --def-soft: #f2ecff;
  --mark: #ffe28a;
  --mark-ink: #1b1f3b;
  --fig-a: #a5b4fc;
  --fig-b: #fdba74;
  --fig-c: #5b5bd6;
  --fig-d: #e8590c;
  --math: #5b5bd6;
  --math-soft: #ececff;
  --rus: #e5484d;
  --rus-soft: #ffeced;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(27, 31, 59, .05), 0 8px 24px rgba(27, 31, 59, .06);
  --shadow-lg: 0 12px 40px rgba(27, 31, 59, .14);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1220; --surface: #181c2e; --surface-2: #21263b; --ink: #e8eaf6; --muted: #a4abc8; --line: #2e3450;
    --accent: #8f8cff; --accent-ink: #0f1220; --accent-soft: #262a4d;
    --ok: #4ade80; --ok-soft: #14301f; --bad: #ff8a95; --bad-soft: #3a1c22;
    --warn: #fbbf5c; --warn-soft: #33270f; --def: #c4a8ff; --def-soft: #2a2245;
    --mark: #7a5b00; --mark-ink: #fff4cc;
    --fig-a: #4f5bd5; --fig-b: #b45f2a; --fig-c: #a5a8ff; --fig-d: #ff9a5c;
    --math: #8f8cff; --math-soft: #262a4d; --rus: #ff7a80; --rus-soft: #3a1d24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1220; --surface: #181c2e; --surface-2: #21263b; --ink: #e8eaf6; --muted: #a4abc8; --line: #2e3450;
  --accent: #8f8cff; --accent-ink: #0f1220; --accent-soft: #262a4d;
  --ok: #4ade80; --ok-soft: #14301f; --bad: #ff8a95; --bad-soft: #3a1c22;
  --warn: #fbbf5c; --warn-soft: #33270f; --def: #c4a8ff; --def-soft: #2a2245;
  --mark: #7a5b00; --mark-ink: #fff4cc;
  --fig-a: #4f5bd5; --fig-b: #b45f2a; --fig-c: #a5a8ff; --fig-d: #ff9a5c;
  --math: #8f8cff; --math-soft: #262a4d; --rus: #ff7a80; --rus-soft: #3a1d24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* Цвета классов (градиенты) */
.g4 { --g1: #ff8a3d; --g2: #ffc24b; }
.g5 { --g1: #f0567a; --g2: #ff9a76; }
.g6 { --g1: #8b5cf6; --g2: #d07cf5; }
.g7 { --g1: #3b82f6; --g2: #38bdf8; }
.g8 { --g1: #0f9f75; --g2: #4ad6a0; }
.g9 { --g1: #4f46e5; --g2: #0ea5e9; }
.s-math { --s: var(--math); --s-soft: var(--math-soft); }
.s-russian { --s: var(--rus); --s-soft: var(--rus-soft); }
.s-physics { --s: #0e8a7a; --s-soft: #e0f5f1; }
.s-english { --s: #c2410c; --s-soft: #fff0e6; }
:root[data-theme="dark"] .s-physics { --s: #4fd1bf; --s-soft: #12332f; }
:root[data-theme="dark"] .s-english { --s: #fb923c; --s-soft: #3a2414; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .s-physics { --s: #4fd1bf; --s-soft: #12332f; } :root:not([data-theme="light"]) .s-english { --s: #fb923c; --s-soft: #3a2414; } }

/* Размер шрифта из настроек */
html { font-size: 100%; }
html[data-font="l"] { font-size: 112.5%; }
html[data-font="xl"] { font-size: 125%; }

/* ----- Основа ----- */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.65 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 750; }
h3 { font-size: 1.12rem; }
p { margin: 0 0 .9em; }
img, svg { max-width: 100%; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; border-radius: 8px; }
.skip:focus { left: 8px; }

/* Возрастные режимы */
body[data-age="young"] main { font-size: 1.07rem; }
body[data-age="young"] .btn, body[data-age="young"] .option { padding: .8rem 1.25rem; }

/* ----- Шапка ----- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6e6af0, #f0567a); color: #fff; font-weight: 800; font-size: 1.35rem;
  box-shadow: 0 4px 12px rgba(110, 106, 240, .35);
}
.brand-text { font-weight: 800; font-size: 1.3rem; line-height: 1; display: flex; flex-direction: column; }
.brand-text small { font-weight: 500; font-size: .72rem; color: var(--muted); margin-top: 3px; }
.search { position: relative; flex: 1 1 260px; min-width: 0; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; color: var(--muted); pointer-events: none; }
.search-icon .ico { width: 18px; height: 18px; }
.search input {
  width: 100%; padding: .6rem .9rem .6rem 2.2rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
.search input:focus { background: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 30;
}
.search-results button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: .65rem 1rem; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.search-results button:last-child { border-bottom: 0; }
.search-results button:hover, .search-results button:focus-visible { background: var(--accent-soft); outline: none; }
.search-results .sr-meta { display: block; font-size: .84rem; color: var(--muted); }
.search-results .sr-empty { padding: .8rem 1rem; color: var(--muted); }
.topnav { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.navlink { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; font-weight: 650; color: var(--ink); padding: .45rem .8rem; border-radius: 10px; }
.navlink:hover { background: var(--surface-2); }
.stats { display: inline-flex; gap: 6px; }
.chip-stat { position: relative; display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border-radius: 99px; padding: .3rem .7rem .3rem .45rem; font-weight: 700; font-size: .9rem; color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .search { order: 3; flex-basis: 100%; }
  .topnav { margin-left: auto; gap: 2px; }
  .navlink { padding: .45rem .55rem; }
  .nl-text { display: none; } /* на телефоне в шапке только значки, иначе меню не помещается */
  .brand-text small { display: none; }
}
@media (max-width: 380px) {
  .brand-text { display: none; }
  .chip-stat { padding: .3rem .5rem; }
}

/* ----- Раскладка ----- */
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 56px; outline: none; }
.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { max-width: 1080px; margin: 0 auto; padding: 24px 16px 32px; font-size: .92rem; display: grid; gap: 4px; }

.crumbs { font-size: .9rem; margin-bottom: 14px; opacity: .9; }
.crumbs a { color: inherit; }
.crumbs span[aria-hidden] { margin: 0 .4em; opacity: .7; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 40px 0 16px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
a.card { display: block; color: inherit; text-decoration: none; transition: transform .18s, box-shadow .18s, border-color .18s; }
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: transparent; }
.card-title { font-weight: 750; font-size: 1.12rem; margin-bottom: 4px; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 16px; margin: 12px 0; }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--ok), #34d399); }

/* ----- Главная: герой ----- */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: clamp(28px, 6vw, 56px);
  background: linear-gradient(130deg, #5b5bd6 0%, #8b5cf6 45%, #f0567a 100%);
  color: #fff; box-shadow: var(--shadow-lg);
}
.hero h1 { font-size: clamp(2rem, 6vw, 3.3rem); max-width: 14em; margin-bottom: .35em; }
.hero p { font-size: clamp(1.02rem, 2.2vw, 1.2rem); max-width: 34em; opacity: .95; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero .btn { background: #fff; color: #3b2fb0; border-color: #fff; }
.hero .btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .45); }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-stats span { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); padding: .35rem .85rem; border-radius: 99px; font-weight: 650; font-size: .92rem; }
.floaty { position: absolute; font-weight: 800; color: #fff; opacity: .14; pointer-events: none; user-select: none; line-height: 1; }
.floaty.f1 { right: 6%; top: 10%; font-size: 6rem; transform: rotate(-12deg); }
.floaty.f2 { right: 22%; bottom: 6%; font-size: 4.5rem; transform: rotate(10deg); }
.floaty.f3 { right: 4%; bottom: 18%; font-size: 3.5rem; }
.floaty.f4 { right: 32%; top: 6%; font-size: 3rem; transform: rotate(8deg); }
@media (max-width: 640px) { .floaty.f2, .floaty.f4 { display: none; } }

.continue, a.card.continue { display: flex; align-items: center; gap: 16px; margin-top: 20px; }
.continue .ic { font-size: 1.6rem; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); flex: none; }

/* Плитки классов */
.grades { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.grade-tile {
  position: relative; overflow: hidden; display: block; text-decoration: none; color: #fff;
  border-radius: 22px; padding: 18px 18px 16px; min-height: 170px;
  background: linear-gradient(140deg, var(--g1), var(--g2));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--g1) 35%, transparent);
  transition: transform .18s, box-shadow .18s;
}
.grade-tile:hover { transform: translateY(-4px) rotate(-.5deg); box-shadow: 0 14px 32px color-mix(in srgb, var(--g1) 45%, transparent); }
.grade-tile .num { font-size: 3.6rem; font-weight: 900; line-height: .95; }
.grade-tile .lbl { font-weight: 700; font-size: 1.05rem; opacity: .95; }
.grade-tile .meta { font-size: .86rem; opacity: .9; margin-top: 10px; }
.grade-tile .bar { background: rgba(255, 255, 255, .3); }
.grade-tile .bar > i { background: #fff; }
.grade-tile::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .14); }

/* Как устроен урок */
.steps4 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); counter-reset: s; }
.step4 { position: relative; padding-top: 22px; }
.step4 .ic { font-size: 1.8rem; }
.step4 .n { position: absolute; top: 16px; right: 18px; font-weight: 900; font-size: 2rem; color: var(--line); }

/* Карточки предметов */
.subject-card { display: flex; gap: 16px; align-items: flex-start; }
.subject-ic { flex: none; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.7rem; background: var(--s-soft); }
.subject-card .card-title { color: var(--s); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: .8rem; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); font-weight: 650; }
.chip.s { background: var(--s-soft); color: var(--s); font-weight: 650; }

/* ----- Баннер страниц (класс, предмет, урок) ----- */
.banner {
  position: relative; overflow: hidden; border-radius: 26px; padding: clamp(22px, 5vw, 40px); margin-bottom: 24px;
  color: #fff; background: linear-gradient(130deg, var(--g1, #5b5bd6), var(--g2, #8b5cf6));
  box-shadow: 0 10px 30px color-mix(in srgb, var(--g1, #5b5bd6) 30%, transparent);
}
.banner::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.banner h1 { margin-bottom: .3em; }
.banner p { opacity: .95; margin: 0; max-width: 42em; font-size: 1.06rem; }
.banner .chips { margin-top: 14px; position: relative; z-index: 1; }
.banner .chip { background: rgba(255, 255, 255, .2); color: #fff; }
.banner .chip.ok { background: #fff; color: var(--ok); }
.banner .crumbs { position: relative; z-index: 1; }

/* ----- Список тем ----- */
.sec-card { margin-bottom: 18px; padding: 8px; }
.sec-card h2 { font-size: 1.15rem; margin: 12px 14px 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 750; }
.topics { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.topic {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px;
  text-decoration: none; color: inherit; transition: background .15s;
}
a.topic:hover { background: var(--surface-2); }
.topic .tn { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; background: var(--s-soft, var(--accent-soft)); color: var(--s, var(--accent)); }
.topic.done .tn { background: var(--ok-soft); color: var(--ok); }
.topic .tt { flex: 1; min-width: 0; }
.topic .tt b { display: block; font-weight: 700; }
.topic .tt span { display: block; font-size: .88rem; color: var(--muted); }
.topic .arrow { color: var(--muted); font-size: 1.2rem; }
.topic.soon { opacity: .6; }

/* ----- Кнопки и поля ----- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: .65rem 1.1rem; border-radius: 12px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.input { padding: .65rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); min-width: 0; flex: 1 1 160px; }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.answer-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ----- Урок ----- */
.status { display: inline-block; margin-top: 14px; font-size: .9rem; padding: 6px 12px; border-radius: 10px; background: rgba(255, 255, 255, .2); position: relative; z-index: 1; }
.status.done { background: #fff; color: var(--ok); font-weight: 650; }
.toc {
  position: sticky; top: 64px; z-index: 10; display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 20px; padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.toc button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: .4rem 1rem; cursor: pointer; font-weight: 650; }
.toc button:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) { .toc { position: static; margin-top: 0; } .lsec { scroll-margin-top: 120px; } }

.lsec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 4vw, 30px); margin-bottom: 20px; box-shadow: var(--shadow); scroll-margin-top: 130px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; display: flex; align-items: center; gap: 12px; }
.section-head h2 .sn { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 1.05rem; color: #fff; background: linear-gradient(135deg, var(--g1, #5b5bd6), var(--g2, #8b5cf6)); flex: none; }
.lead-note { color: var(--muted); margin-top: -4px; }

.box { border-radius: 14px; padding: 14px 18px; margin: 0 0 16px; border-left: 5px solid; }
.box-title { font-weight: 750; margin-bottom: 4px; }
.box-rule { background: var(--accent-soft); border-color: var(--accent); }
.box-def { background: var(--def-soft); border-color: var(--def); }
.box-warn { background: var(--warn-soft); border-color: var(--warn); }
.box-hint { background: var(--warn-soft); border-color: var(--warn); margin-top: 12px; }
.box-answer { background: var(--ok-soft); border-color: var(--ok); margin-top: 12px; }
.box-sum { background: linear-gradient(135deg, var(--accent-soft), var(--def-soft)); border-color: var(--accent-2); }
.box-sum li { margin-bottom: 4px; }
.mini-ex { border: 1px dashed var(--line); border-radius: 14px; padding: 12px 16px; margin: 0 0 16px; background: var(--surface-2); }
.mini-ex-title { font-weight: 750; color: var(--accent); margin-bottom: 4px; }
.box > :last-child, .box div > :last-child { margin-bottom: 0; }
.box ol, .box ul { margin: .3em 0 0; padding-left: 1.3em; }

.table-wrap { position: relative; overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 14px; }
.table-wrap .tcap { font-weight: 750; padding: 12px 14px 0; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 750; font-size: .94rem; }
tr:last-child td { border-bottom: 0; }

mark.orf { background: var(--mark); color: var(--mark-ink); font-weight: 750; border-radius: 4px; padding: 0 2px; }
.stress { font-weight: 750; color: var(--accent); }

.fig { margin: 4px 0 18px; text-align: center; background: var(--surface-2); border-radius: 16px; padding: 14px; }
.fig svg { width: 100%; max-width: 460px; height: auto; }
.fig figcaption { font-size: .9rem; color: var(--muted); margin-top: 6px; }
.fig .ln { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.fig .ln.thin { stroke-width: 1.4; }
.fig .ln.c { stroke: var(--fig-c); }
.fig .dot { fill: var(--ink); }
.fig .pan { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.fig .cell { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; }
.fig .cell.a { fill: var(--fig-a); }
.fig .cell.b { fill: var(--fig-b); }
.fig .cell.c { fill: var(--ok-soft); }
.fig .arc { fill: none; stroke: var(--fig-c); stroke-width: 2.2; }
.fig .arc.d { stroke: var(--fig-d); }
.fig .arc.e { stroke: var(--ok); }
.fig .grid { stroke: var(--line); stroke-width: 1; }
.fig .axis { stroke: var(--ink); stroke-width: 1.6; fill: none; }
.fig .graph { fill: none; stroke: var(--fig-c); stroke-width: 2.8; stroke-linejoin: round; }
.fig .graph.d { stroke: var(--fig-d); }
.fig .pt { fill: var(--fig-d); }
.fig text { fill: var(--ink); font: 600 15px "Segoe UI", system-ui, sans-serif; }
.fig text.vx { font-size: 17px; font-weight: 800; }
.fig text.lbl { fill: var(--fig-c); }
.fig text.lbl.d { fill: var(--fig-d); }
.fig text.ax { font-size: 12px; fill: var(--muted); }
.fig text.big { font-size: 19px; }

.example, .task, .q { margin-bottom: 14px; box-shadow: none; background: var(--surface-2); border-color: transparent; }
.example h3 { display: flex; gap: 8px; align-items: center; }
.example .problem, .task-text, .q-text { font-size: 1.05rem; }
.steps { list-style: none; padding: 0; margin: 14px 0 0; counter-reset: st; }
.steps li { position: relative; padding: 10px 12px 10px 52px; margin-bottom: 8px; background: var(--surface); border-radius: 12px; counter-increment: st; }
.steps li::before { content: counter(st); position: absolute; left: 12px; top: 10px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .9rem; }
.step-why { color: var(--muted); font-size: .93rem; margin-top: 2px; }
.step-why::before { content: "💡 "; }
.answer-line { margin-top: 10px; font-weight: 750; color: var(--ok); background: var(--ok-soft); display: inline-block; padding: 6px 14px; border-radius: 10px; }

.task-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; align-items: center; }
.task-num { font-weight: 750; }
.level { color: #f2a900; letter-spacing: 2px; }
.task.solved { background: var(--ok-soft); }
.task-status { margin-top: 10px; font-weight: 750; color: var(--ok); }
.task-status:empty { display: none; }
.feedback { margin-top: 10px; font-weight: 600; }
.feedback:empty { display: none; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }

.q-num { font-size: .82rem; color: var(--muted); margin-bottom: 4px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.options { display: grid; gap: 8px; margin-top: 12px; }
.option {
  text-align: left; padding: .7rem 1rem; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 550; transition: border-color .15s, transform .1s;
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateX(2px); }
.option:disabled { cursor: default; }
.option.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.option.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.quiz-result { margin-top: 10px; text-align: center; background: var(--accent-soft); border: 0; }
.quiz-result .big { font-size: 2.4rem; font-weight: 900; color: var(--accent); }

.lesson-nav { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ----- Настройки и прогресс ----- */
fieldset { border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; margin: 0 0 14px; background: var(--surface); }
legend { font-weight: 750; padding: 0 6px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.opt-row label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }

.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin-bottom: 24px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 2rem; font-weight: 900; }

/* Формулы KaTeX: длинные не ломают страницу */
.katex-display { position: relative; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.08em; }
.table-wrap .katex-html { white-space: nowrap; }

/* ----- Новое: значок, тренажёр, интерактивы, тесты ----- */
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 99px; background: var(--accent-2); color: #fff; font-size: .75rem; font-weight: 800; }
.btn-sm { padding: .4rem .8rem; font-size: .9rem; }
.chip-inline { margin-left: 6px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-right: 10px; }
.btn.on-banner { background: #fff; color: #3b2fb0; border-color: #fff; position: relative; z-index: 1; }

.trainer { margin-top: 18px; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); border: 2px dashed var(--accent); box-shadow: none; }
.trainer-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 10px; }
.trainer-body .task-text { font-size: 1.12rem; font-weight: 600; }

.ix { border: 2px solid var(--accent-soft); border-radius: 18px; padding: 16px 18px; margin: 4px 0 18px; background: var(--surface); }
.ix-title { font-weight: 800; color: var(--accent); font-size: 1.05rem; }
.ix-hint { font-size: .92rem; margin-bottom: 10px; }
.ix-row { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.ix-slider { display: grid; gap: 4px; margin: 8px 0; font-size: .95rem; }
.ix-slider input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.ix-figure { text-align: center; background: var(--surface-2); border-radius: 14px; padding: 10px; margin: 8px 0; }
.ix-figure svg { width: 100%; max-width: 440px; height: auto; }
.ix-result { font-size: 1.05rem; text-align: center; padding: 6px; }
.ix .ix-piece { fill: var(--surface); stroke: var(--ink); stroke-width: 2; cursor: pointer; transition: fill .15s; }
.ix .ix-piece:hover { fill: var(--accent-soft); }
.ix .ix-piece.on { fill: var(--fig-a); }
.ix-figure .ln { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.ix-figure .grid { stroke: var(--line); stroke-width: 1; }
.ix-figure .axis { stroke: var(--ink); stroke-width: 1.6; fill: none; }
.ix-figure .graph { fill: none; stroke: var(--fig-c); stroke-width: 3; stroke-linecap: round; }
.ix-figure .graph.d { stroke: var(--fig-d); }
.ix-figure .arc { fill: none; stroke: var(--fig-c); stroke-width: 2.2; }
.ix-figure .arc.d { stroke: var(--fig-d); }
.ix-figure .arc.e { stroke: var(--ok); }
.ix-figure .cell { fill: var(--fig-a); stroke: var(--ink); stroke-width: 1.4; }
.ix-figure .pt { fill: var(--fig-d); }
.ix-figure .dot { fill: var(--ink); }
.ix-figure text { fill: var(--ink); font: 600 15px "Segoe UI", system-ui, sans-serif; }
.ix-figure text.lbl { fill: var(--fig-c); }
.ix-figure text.lbl.d { fill: var(--fig-d); }
.ix-figure text.ax { font-size: 12px; fill: var(--muted); }

.lesson-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.report { margin-bottom: 16px; }
.report-text { width: 100%; resize: vertical; font: inherit; }

/* ----- Пошаговая практика ----- */
.px [hidden] { display: none !important; }
.px-task { color: var(--muted); margin-bottom: 6px; }
.px-steps { list-style: none; padding: 0; margin: 12px 0 0; counter-reset: pst; }
.px-step { position: relative; padding: 12px 14px 12px 54px; margin-bottom: 10px; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; counter-increment: pst; }
.px-step::before { content: counter(pst); position: absolute; left: 12px; top: 12px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .9rem; }
.px-step.ok { border-color: var(--ok); }
.px-step.ok::before { content: "✓"; background: var(--ok); }
.px-step.shown { border-color: var(--warn); }
.px-step.shown::before { background: var(--warn); }
.px-step .answer-form { margin-top: 10px; }
.px-step .btn-row:empty { display: none; }
.px-q { font-weight: 600; }
.px-options { margin-top: 10px; }
.px-hints:empty { display: none; }
.px-text { font-size: 1.12rem; line-height: 2.3; background: var(--surface); border-radius: 14px; padding: 12px 16px; margin-top: 8px; }
.px-choice { display: inline-flex; gap: 2px; padding: 2px; margin: 0 2px; border-radius: 10px; border: 2px dashed var(--accent); background: var(--accent-soft); vertical-align: middle; line-height: 1.2; }
.px-choice.ok { border: 2px solid var(--ok); background: var(--ok-soft); }
.px-choice.shown { border: 2px solid var(--warn); background: var(--warn-soft); }
.px-choice.bad { border: 2px solid var(--bad); background: var(--bad-soft); }
.px-pick { min-width: 32px; padding: .25rem .55rem; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.px-pick:hover:not(:disabled) { background: var(--surface); }
.px-pick[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.px-choice.ok .px-pick[aria-pressed="true"] { background: var(--ok); }
.px-choice.shown .px-pick[aria-pressed="true"] { background: var(--warn); color: #fff; }
.px-choice.bad .px-pick[aria-pressed="true"] { background: var(--bad); color: #fff; }
.px-pick:disabled { cursor: default; }
.px-sort { display: grid; gap: 8px; margin-top: 10px; }
.px-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; background: var(--surface); border-radius: 12px; padding: 8px 12px; }
.px-word { font-weight: 700; font-size: 1.05rem; }
.px-sort .px-choice { flex-wrap: wrap; }
.px-sort .px-pick { font-size: .92rem; font-weight: 650; }
.px-why { margin: 10px 0 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.px-why li { background: var(--warn-soft); border-left: 4px solid var(--warn); border-radius: 10px; padding: 8px 12px; }
.px .task-status .btn-sm { margin-left: 6px; }
@media (max-width: 480px) { .px-step { padding: 10px 10px 10px 44px; } .px-step::before { left: 8px; top: 10px; width: 26px; height: 26px; } .px-text { padding: 10px 12px; } }

/* ----- Печать ----- */
@media print {
  .topbar, .footer, .toc, .lesson-nav, .lesson-tools, .report, .btn, .btn-row, .answer-form, .feedback, .task-status,
  .trainer, .ix, .lsec-practice, .box-hint, .box-answer, .skip, .status, .quiz-result { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  main { padding: 0; max-width: none; }
  .banner { background: none !important; color: #000; box-shadow: none; padding: 0 0 8pt; border-bottom: 2px solid #000; border-radius: 0; }
  .banner::after { display: none; }
  .banner .chip { background: none; color: #000; border: 1px solid #999; }
  .lsec, .card, .example, .task, .q { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; background: #fff; }
  .example [hidden] { display: block !important; }
  .option { border: 1px solid #999; background: #fff; color: #000; }
  .section-head h2 .sn { background: #000; }
  a { color: #000; text-decoration: none; }
  body.print-summary main .lesson > *:not(.lesson-head-print):not(.banner):not(.lsec) { display: none !important; }
  body.print-summary .lsec:not(:first-of-type) { display: none !important; }
  body.print-summary .lsec > *:not(.box-sum):not(.section-head) { display: none !important; }
  body.print-summary .section-head button { display: none !important; }
}

/* ----- Разделы: плитки, задание дня, достижения, справочник, карточки, контрольные ----- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); margin: 20px 0; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px; }
.tile-ic { font-size: 1.8rem; line-height: 1.2; }
.tile .muted { font-size: .86rem; }
.daily { margin: 16px 0; border: 2px solid var(--accent-2); }
.daily.solved { border-color: var(--ok); background: var(--ok-soft); }
.weak { margin: 16px 0; }
.chip-link { text-decoration: none; }
.chip-link:hover { filter: brightness(.95); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow-lg); transition: all .3s; max-width: calc(100% - 32px); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.ach-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.ach { display: flex; gap: 14px; align-items: flex-start; opacity: .55; }
.ach.got { opacity: 1; border-color: var(--ok); }
.ach-ic { font-size: 2.2rem; line-height: 1; }

.ref-tools { margin-bottom: 16px; }
.select { flex: 0 1 180px; }
.ref { margin-bottom: 12px; }
.ref-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.ref-head .card-title { text-decoration: none; color: var(--s, var(--ink)); }
.ref ul { margin: 0; padding-left: 1.2em; }
.ref li { margin-bottom: 3px; }

.flash-wrap { max-width: 560px; margin: 0 auto; text-align: center; }
.flash { position: relative; display: block; width: 100%; min-height: 220px; border: 0; padding: 0; background: none; cursor: pointer; perspective: 1000px; }
.flash-face { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; border-radius: 22px; font-size: 1.45rem; font-weight: 700;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .45s; box-shadow: var(--shadow-lg); }
.flash-face.front { background: var(--surface); color: var(--ink); border: 2px solid var(--line); }
.flash-face.back { background: linear-gradient(135deg, var(--s, var(--accent)), var(--accent-2)); color: #fff; transform: rotateY(180deg); }
.flash.flipped .front { transform: rotateY(-180deg); }
.flash.flipped .back { transform: rotateY(0); }
.flash-hint { margin-top: 12px; }
.flash-actions { justify-content: center; }
.flash-actions .btn { min-width: 140px; justify-content: center; }

.exam-start ul { margin: 8px 0 14px; }
.exam-bar { position: sticky; top: 64px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.exam-timer { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.exam-timer.low { color: var(--bad); }
.option.chosen { border-color: var(--accent); background: var(--accent-soft); }
.exam-item.right { border-left: 5px solid var(--ok); }
.exam-item.wrong { border-left: 5px solid var(--bad); }
.big-count { font-size: 2.6rem; font-weight: 900; color: var(--accent); margin-top: 10px; }
.plan-week { margin: 10px 8px 16px; }
.plan-title { font-weight: 800; margin: 0 6px 6px; }
@media (max-width: 640px) { .exam-bar { top: 108px; } }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; } .footer-nav a { text-decoration: none; font-weight: 600; }
.reading { background: var(--surface-2); border-radius: 16px; padding: 20px 24px; margin: 0 0 18px; border-left: 5px solid var(--accent-2); }
.reading-title { font-weight: 800; font-size: 1.15rem; margin-bottom: 10px; }
.reading-body { font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; line-height: 1.75; }
.reading-body p { margin: 0 0 .8em; text-indent: 1.5em; }
.reading-author { text-align: right; color: var(--muted); font-style: italic; margin-top: 6px; }
/* Цвета новых предметов */
.s-chemistry { --s: #7c3aed; --s-soft: #f1e9ff; }
.s-biology { --s: #15803d; --s-soft: #e3f6e9; }
.s-informatics { --s: #0369a1; --s-soft: #e0f2fe; }
.s-history { --s: #a16207; --s-soft: #fdf3dc; }
.s-world { --s: #0f766e; --s-soft: #ddf6f2; }
:root[data-theme="dark"] .s-chemistry { --s: #c4a5ff; --s-soft: #2a2145; }
:root[data-theme="dark"] .s-biology { --s: #6ee7a0; --s-soft: #15301f; }
:root[data-theme="dark"] .s-informatics { --s: #7dd3fc; --s-soft: #10293a; }
:root[data-theme="dark"] .s-history { --s: #fcd06b; --s-soft: #33270f; }
:root[data-theme="dark"] .s-world { --s: #5eead4; --s-soft: #10302c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .s-chemistry { --s: #c4a5ff; --s-soft: #2a2145; }
  :root:not([data-theme="light"]) .s-biology { --s: #6ee7a0; --s-soft: #15301f; }
  :root:not([data-theme="light"]) .s-informatics { --s: #7dd3fc; --s-soft: #10293a; }
  :root:not([data-theme="light"]) .s-history { --s: #fcd06b; --s-soft: #33270f; }
  :root:not([data-theme="light"]) .s-world { --s: #5eead4; --s-soft: #10302c; }
}
a.card.tile { display: flex; }
/* Кабинет учителя */
.assign { padding: 12px 14px; }
.assign-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.class-code { display: flex; align-items: baseline; gap: 10px; margin: 8px 0; }
.class-code b { font-size: 2rem; letter-spacing: .18em; color: var(--accent); font-family: ui-monospace, Consolas, monospace; }
.secret { background: var(--surface-2); padding: 6px 10px; border-radius: 8px; font-size: .9rem; align-self: center; word-break: break-all; }
.small { font-size: .85rem; }
.pick-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); margin: 10px 0; max-height: 260px; overflow: auto; padding: 8px; background: var(--surface-2); border-radius: 12px; }
.pick-list label { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
.new-assign { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
td.cell-ok { color: var(--ok); font-weight: 700; }

/* ----- Аккаунт: вход и регистрация ----- */
.auth-card { max-width: 520px; margin: 0 auto; display: grid; gap: 14px; }
.auth-fields { display: grid; gap: 10px; }
.auth-fields[hidden] { display: none; }
.auth-fields .input { flex: none; width: 100%; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.tab { flex: 1; text-align: center; padding: .55rem; border-radius: 10px; font-weight: 700; color: var(--muted); text-decoration: none; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.role-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-btn { display: grid; justify-items: center; gap: 4px; padding: 12px 6px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-weight: 700; cursor: pointer; }
.role-btn.active { border-color: var(--accent); background: var(--accent-soft); }
.role-ic { font-size: 1.8rem; line-height: 1; }
.btn-big { padding: .85rem 1.4rem; font-size: 1.05rem; justify-content: center; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.profile-card { margin-bottom: 16px; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 2.2rem; background: var(--accent-soft); flex: none; }
.sync-dot { margin-left: 4px; font-size: .8rem; }
.link-btn { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); text-align: left; }
.link-btn:hover b { text-decoration: underline; }
.chip.late { background: var(--bad-soft); color: var(--bad); font-weight: 650; }
td.cell-bad { color: var(--bad); font-weight: 700; }
td.nowrap { white-space: nowrap; }
details summary { cursor: pointer; font-weight: 650; margin-top: 14px; }

/* ----- Ясик, монетки, марафон, олимпиада, рейтинг, родители ----- */
.mascot { display: flex; align-items: flex-end; gap: 12px; margin: 16px 0; }
.mascot-owl { width: 86px; flex: none; animation: owl-bob 3s ease-in-out infinite; transform-origin: bottom center; }
.mascot.happy .mascot-owl { animation: owl-jump 1.2s ease-in-out infinite; }
.owl-svg { display: block; width: 100%; height: auto; }
.bubble { position: relative; background: var(--surface); border: 2px solid var(--accent-soft); border-radius: 20px 20px 20px 6px; padding: 12px 16px; box-shadow: var(--shadow); font-weight: 600; display: grid; gap: 10px; justify-items: start; }
.bubble::before { content: ''; position: absolute; left: -10px; bottom: 10px; border: 8px solid transparent; border-right-color: var(--accent-soft); }
@keyframes owl-bob { 50% { transform: translateY(-4px) rotate(-2deg); } }
@keyframes owl-jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10px) scale(1.04); } }
.home-fun { display: grid; gap: 4px; margin-top: 20px; }
.fun-tiles { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
a.card.fun-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-width: 2px; }
.fun-tile:nth-child(1) { border-color: #ffc9a8; } .fun-tile:nth-child(2) { border-color: #ffe08a; } .fun-tile:nth-child(3) { border-color: #c9c5ff; }
.coin-stat { text-decoration: none; color: inherit; }
.coin-chip { font-weight: 800; font-size: 1rem !important; }
.shop-sec h2 { margin: 24px 0 12px; }
.shop-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.shop-item { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 16px 10px; }
.shop-item.on { border-color: var(--ok); background: var(--ok-soft); }
.shop-ic { font-size: 2.6rem; line-height: 1; }
.shop-item .btn[disabled] { opacity: .5; cursor: not-allowed; }
.marathon { display: grid; gap: 10px; margin: 16px 0; }
.goal { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.goal.got { border-color: var(--ok); }
.goal-ic { font-size: 2rem; }
.goal-body { flex: 1; display: grid; gap: 4px; }
.goal-body .bar { margin-top: 2px; }
.btn-prize { background: linear-gradient(135deg, #ff8a3d, #f0567a); border-color: transparent; color: #fff; animation: owl-jump 1.4s ease-in-out infinite; }
table.rating tr.me td { background: var(--accent-soft); }
td.place { font-size: 1.2rem; text-align: center; }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); margin: 12px 0; }
.kpi { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.kpi-val { font-weight: 800; font-size: 1.25rem; }
.child-card { margin-bottom: 16px; }
ul.plain { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { top: 105%; transform: translateX(40px) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { .mascot-owl, .mascot.happy .mascot-owl, .btn-prize { animation: none; } }
@media (max-width: 640px) { .mascot-owl { width: 68px; } .fun-tiles { gap: 8px; } a.card.fun-tile { padding: 12px 10px; } }

/* ----- Нижнее меню (телефон) ----- */
.tabbar { display: none; }
@media (max-width: 640px) {
  .topnav .navlink:not(.icon) { display: none; }
  .topnav { gap: 4px; }
  .chip-stat { padding: .25rem .55rem; font-size: .85rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { position: relative; display: grid; justify-items: center; gap: 1px; font-size: .7rem; font-weight: 700; color: var(--muted); text-decoration: none; padding: 4px 0; border-radius: 12px; }
  .tabbar a span { font-size: 1.35rem; line-height: 1.2; height: 1.6rem; display: grid; place-items: center; }
  .tabbar a .ico { width: 24px; height: 24px; }
  .tabbar a:not(.active) .ico { filter: saturate(.55); opacity: .85; }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
  .tab-badge { position: absolute; top: 0; right: calc(50% - 22px); background: var(--bad); color: #fff; font-size: .62rem; min-width: 16px; height: 16px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; }
  .tab-badge[hidden] { display: none; }
  .footer { padding-bottom: 72px; }
  .toast { bottom: 84px; }
  .role-pick { gap: 6px; }
  .role-btn { font-size: .85rem; padding: 10px 4px; }
}
@media print { .tabbar, .cheer { display: none !important; } }

/* ----- Ясик хвалит за верный ответ ----- */
.cheer { position: fixed; right: 16px; bottom: 24px; z-index: 90; display: flex; align-items: center; gap: 8px; pointer-events: none;
  opacity: 0; transform: translateY(30px) scale(.8); transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.cheer.show { opacity: 1; transform: none; }
.cheer svg { width: 64px; height: auto; }
.cheer span { background: var(--surface); border: 2px solid var(--ok); color: var(--ok); font-weight: 800; padding: 8px 14px; border-radius: 16px 16px 16px 4px; box-shadow: var(--shadow-lg); order: -1; }
@media (max-width: 640px) { .cheer { bottom: 84px; } }

/* ----- Яркое детское оформление ----- */
:root[data-look="kids"] { --radius: 24px; }
:root[data-look="kids"] body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 8% 12%, color-mix(in srgb, #ffc24b 16%, transparent) 0 120px, transparent 121px),
    radial-gradient(circle at 92% 30%, color-mix(in srgb, #f0567a 12%, transparent) 0 160px, transparent 161px),
    radial-gradient(circle at 15% 78%, color-mix(in srgb, #38bdf8 12%, transparent) 0 140px, transparent 141px),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, #4ad6a0 14%, transparent) 0 130px, transparent 131px),
    var(--bg);
  background-attachment: fixed;
}
:root[data-look="kids"] .btn { border-radius: 99px; font-weight: 800; box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000); transition: transform .08s, box-shadow .08s; }
:root[data-look="kids"] .btn:active:not([disabled]) { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 60%, #000); }
:root[data-look="kids"] .btn-ghost { box-shadow: 0 3px 0 var(--line); }
:root[data-look="kids"] .hero .btn, :root[data-look="kids"] .btn.on-banner { box-shadow: 0 4px 0 rgba(0, 0, 0, .18); }
:root[data-look="kids"] .card { border-width: 2px; }
:root[data-look="kids"] a.card:hover { transform: translateY(-4px) rotate(-.4deg); }
:root[data-look="kids"] .grade-tile:hover, :root[data-look="kids"] .fun-tile:hover, :root[data-look="kids"] .tile:hover { animation: wiggle .5s ease-in-out; }
:root[data-look="kids"] .option { border-radius: 16px; border-width: 2px; font-weight: 650; }
:root[data-look="kids"] .option:hover:not([disabled]) { transform: scale(1.02); }
:root[data-look="kids"] .option.ok { animation: pop .35s ease-out; }
:root[data-look="kids"] .option.bad { animation: shake .35s ease-in-out; }
:root[data-look="kids"] .input { border-radius: 14px; border-width: 2px; }
:root[data-look="kids"] .banner { border-radius: 28px; }
:root[data-look="kids"] .chip-stat { border: 2px solid var(--line); background: var(--surface); }
:root[data-look="kids"] .logo { animation: owl-bob 4s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: translateY(-4px) rotate(-1.5deg); } 75% { transform: translateY(-4px) rotate(1.5deg); } }
@keyframes pop { 50% { transform: scale(1.06); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) {
  :root[data-look="kids"] * { animation: none !important; }
  .cheer { transition: none; }
}

/* ----- Почта: коды из писем ----- */
.code-input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.email-required { border-color: var(--warn); background: var(--warn-soft); }
.code-input::placeholder { letter-spacing: normal; font-size: 1rem; }

/* ----- Иконки (js/icons.js): единый набор SVG и анимации ----- */
.ico { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: -4px; overflow: visible; }
.navlink .ico { width: 22px; height: 22px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .18)); }
.navlink.icon { padding: .45rem .55rem; }
.chip-stat .ico { width: 20px; height: 20px; }
.chip-plus { position: absolute; right: 6px; top: -4px; font-size: .78rem; font-weight: 900; color: #ffb21e; pointer-events: none; opacity: 0; }
.chip-coin .chip-plus { color: #f2a516; }
.chip-fire .chip-plus { color: #ff6a3d; }
.ico * { transform-box: fill-box; transform-origin: center; }
.ico-fire .i-flame { transform-origin: 50% 100%; }
.ico-chart .i-bar { transform-origin: 50% 100%; }
.ico-flag .i-wave { transform-origin: 0 50%; }
.chip-fire:not(.lit) .ico { filter: grayscale(1); opacity: .7; } /* серии ещё нет — огонёк не горит */

@media (prefers-reduced-motion: no-preference) {
  .navlink, .chip-stat, .tabbar a { transition: background .2s, transform .2s cubic-bezier(.3, 1.6, .5, 1); }
  .navlink:hover, a.chip-stat:hover { transform: translateY(-1px); }
  .navlink:active, .chip-stat:active, .tabbar a:active { transform: scale(.94); }

  /* Наведение: у каждой иконки своё движение */
  .chip-star:hover .ico { animation: ic-twinkle .7s ease; }
  .chip-coin:hover .i-spin, .chip-coin.bump .i-spin { animation: ic-flip .8s ease; }
  .navlink:hover .ico-review .i-rot, .tabbar a:hover .ico-review .i-rot { animation: ic-turn .7s cubic-bezier(.4, 1.4, .5, 1); }
  .navlink:hover .ico-gear .i-rot { animation: ic-turn 1.2s cubic-bezier(.4, 1.2, .5, 1); }
  .navlink:hover .ico-chart .i-bar { animation: ic-grow .6s cubic-bezier(.3, 1.6, .5, 1) backwards; }
  .navlink:hover .ico-chart .i-bar2 { animation-delay: .08s; }
  .navlink:hover .ico-chart .i-bar3 { animation-delay: .16s; }
  .navlink:hover .ico-user, .tabbar a:hover .ico-user { animation: ic-hop .6s ease; }

  /* Огонёк серии горит всегда, пока серия не прервалась */
  .chip-fire.lit .i-flame { animation: ic-flicker 1.6s ease-in-out infinite; }
  .chip-fire.lit .i-core { animation: ic-flicker 1.1s ease-in-out infinite reverse; }

  /* Число выросло: фишка подпрыгивает, рядом всплывает «+N» */
  .chip-stat.bump { animation: ic-bump .6s cubic-bezier(.3, 1.6, .5, 1); }
  .chip-star.bump .ico { animation: ic-twinkle .8s ease; }
  .chip-fire.bump .i-flame { animation: ic-blaze .8s ease; }
  .chip-stat .chip-plus { animation: ic-float 1.3s ease-out forwards; }

  /* Нижнее меню: выбранная вкладка подпрыгивает */
  .tabbar a.active .ico { animation: ic-hop .5s cubic-bezier(.3, 1.6, .5, 1); }
  .tabbar a.active .ico-flag .i-wave { animation: ic-wave 1.4s ease-in-out infinite; }
  .tabbar a.active .ico-trophy { animation: ic-twinkle .8s ease; }
}
@keyframes ic-twinkle { 0% { transform: scale(1) rotate(0); } 40% { transform: scale(1.3) rotate(-14deg); } 70% { transform: scale(.95) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes ic-flip { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }
@keyframes ic-turn { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes ic-grow { from { transform: scaleY(.2); } to { transform: scaleY(1); } }
@keyframes ic-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-4px) scale(1.08); } 70% { transform: translateY(1px) scale(.97); } }
@keyframes ic-flicker { 0%, 100% { transform: scale(1, 1) rotate(0); } 30% { transform: scale(.96, 1.06) rotate(-2deg); } 60% { transform: scale(1.03, .96) rotate(2deg); } }
@keyframes ic-blaze { 0% { transform: scale(1); } 40% { transform: scale(1.35, 1.5); } 100% { transform: scale(1); } }
@keyframes ic-bump { 0% { transform: scale(1); } 35% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes ic-float { 0% { opacity: 0; transform: translateY(4px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-18px); } }
@keyframes ic-wave { 0%, 100% { transform: skewY(0) scaleX(1); } 50% { transform: skewY(-6deg) scaleX(.92); } }

/* ===================== 1–3 классы: крупный детский режим ===================== */
.g1 { --g1: #16a34a; --g2: #84cc16; }
.g2 { --g1: #0891b2; --g2: #22d3ee; }
.g3 { --g1: #db2777; --g2: #f59e0b; }
body[data-age="little"] main { font-size: 1.2rem; line-height: 1.6; font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif; }
body[data-age="little"] .btn, body[data-age="little"] .option { padding: .9rem 1.4rem; font-size: 1.08rem; }
body[data-age="little"] .option { border-radius: 18px; border-width: 2px; }
body[data-age="little"] .input { font-size: 1.35rem; padding: .75rem 1rem; border-radius: 16px; border-width: 2px; }
body[data-age="little"] .task-text, body[data-age="little"] .q-text, body[data-age="little"] .problem { font-size: 1.22rem; }
body[data-age="little"] .box { font-size: 1.12rem; }
body[data-age="little"] .lesson h1, body[data-age="little"] .banner h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
/* Картинки для счёта */
.kpics { display: inline-flex; flex-wrap: wrap; gap: .1em .55em; font-size: 1.9rem; line-height: 1.25; vertical-align: middle; }
.kpics.s { font-size: 1.35rem; }
.kpics .grp { white-space: nowrap; letter-spacing: .04em; }
.kpics-row { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3em .7em; margin: .2em 0; }
.kop { font-size: 1.8rem; color: var(--accent); }
.kbig { display: inline-block; font-size: 2rem; font-weight: 900; line-height: 1.2; color: var(--accent); letter-spacing: .03em; }
/* Звуковые схемы: красный — гласный, синий — твёрдый, зелёный — мягкий */
.ksnds { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; padding: 2px 0; }
.ksnd { display: inline-block; width: 1.3em; height: 1.3em; border-radius: 4px; border: 2px solid var(--ink); position: relative; vertical-align: middle; }
.ksnd.v { background: #ef4444; }
.ksnd.h { background: #3b82f6; }
.ksnd.s { background: #22c55e; }
.ksnd.st::before { content: ""; position: absolute; left: 50%; top: -.75em; width: 2px; height: .55em; background: var(--ink); transform: translateX(-50%) rotate(30deg); }
.ksnd-sep { display: inline-block; width: 2px; height: 1.6em; background: var(--muted); margin: 0 4px; }
.ksnd-key { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .95rem; color: var(--muted); }
.ksnd-key .ksnd { width: 1em; height: 1em; }
/* Часы */
.fig .kclock, .kclock { max-width: 200px; }
.kclock text { font-size: 13px; }
.kclock .hand-h { stroke-width: 5; }
.kclock .hand-m { stroke-width: 3; }
.task-text .kclock, .q-text .kclock { display: block; width: 150px; margin: 8px 0; }
.task-text svg, .q-text svg, .problem svg { max-width: 100%; height: auto; }
.task-text .fig, .q-text .fig, .problem .fig { margin: 8px 0; }

/* ---------- 10–11 классы ---------- */
.g10 { --g1: #0e7490; --g2: #22c55e; }
.g11 { --g1: #9f1239; --g2: #f97316; }
.fig .ln.dash { stroke-dasharray: 6 5; }
.fig .area { fill: var(--fig-a); stroke: none; }

/* ---------- Навигация: меню «Разделы», кабинет по роли, подвал (js/nav.js) ---------- */
.navlink[hidden] { display: none; }
button.navlink { border: 0; background: none; font: inherit; font-weight: 650; cursor: pointer; }
.navlink-main { background: var(--accent-soft); color: var(--accent); }
.navlink-main:hover { background: var(--accent-soft); filter: brightness(.97); }
.navlink-menu.active { background: var(--surface-2); }
.menu-panel { position: fixed; inset: 0; z-index: 50; background: rgba(15, 18, 32, .35); display: flex; justify-content: center; align-items: flex-start; padding: 72px 16px 16px; overflow-y: auto; }
.menu-panel[hidden] { display: none; }
.menu-inner { width: 100%; max-width: 1080px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px 20px 20px; }
.menu-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 1.1rem; }
.menu-groups { display: grid; gap: 16px 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.menu-title { font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 4px 0 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.menu-item > span:last-child { display: grid; line-height: 1.25; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.mine { background: var(--accent-soft); }
.menu-item.mine .muted { color: var(--accent); font-weight: 700; }
.mi-ic { font-size: 1.35rem; width: 32px; text-align: center; flex: none; }
.footer-nav.footer-groups { display: grid; gap: 14px 24px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.footer-group { display: grid; gap: 4px; align-content: start; }
.footer-group b { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 640px) {
  .menu-panel { align-items: flex-end; padding: 16px 0 0; }
  .menu-inner { border-radius: var(--radius) var(--radius) 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 100%; overflow-y: auto; }
  .tabbar .tab-menu { position: relative; display: grid; justify-items: center; gap: 1px; font: inherit; font-size: .7rem; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 4px 0; border-radius: 12px; cursor: pointer; }
  .tabbar .tab-menu span { font-size: 1.35rem; line-height: 1.2; height: 1.6rem; display: grid; place-items: center; }
  .tabbar .tab-menu .ico { width: 24px; height: 24px; }
  .tabbar .tab-menu.active { color: var(--accent); background: var(--accent-soft); }
  body.menu-open { overflow: hidden; }
}

/* Кто вы? — выбор роли на главной и пустые экраны с шагами */
.who { margin-top: 20px; }
.who-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin-top: 10px; }
a.card.who-tile { display: flex; flex-direction: column; gap: 4px; padding: 16px; }
.who-tile .tile-ic { font-size: 2rem; }
a.card.role-main { border: 2px solid var(--accent); }
.steps-list { counter-reset: st; list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 10px; }
.steps-list li { counter-increment: st; display: flex; gap: 12px; align-items: center; }
.steps-list li::before { content: counter(st); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center; }
.class-code-big { font-size: 2rem; letter-spacing: .15em; font-weight: 900; color: var(--accent); }
.continue > .arrow { margin-left: auto; font-size: 1.6rem; color: var(--muted); }
