/* Шрифты — системные, без внешних CDN (ТЗ 12.3). Экран от 360 CSS-пикселей (ТЗ 13). */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #e4e1da;
  --brand: #2f6fde;
  --brand-ink: #ffffff;
  --brand-soft: #e8f0fd;
  --ok: #1f8a4c;
  --ok-soft: #e4f5ea;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --kid-1: #ffcf4a;
  --kid-2: #ff8a5b;
  --kid-3: #5bc0eb;
  --kid-4: #9bc53d;
  --radius: 14px;
  --focus: 0 0 0 3px #ffffff, 0 0 0 6px #1d2433;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); min-width: 320px; }
img, video, iframe { max-width: 100%; }
a { color: var(--brand); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- шапка ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.logo-mark { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--kid-1), var(--kid-2)); display: inline-grid; place-items: center; color: #1d2433; font-weight: 900; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); min-height: 44px; display: inline-flex; align-items: center; }
.nav a[aria-current="page"], .nav a:hover { background: var(--brand-soft); }
.age-badge { border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px; font-weight: 700; font-size: .85rem; }

.site-footer { margin-top: 64px; padding: 32px 0; border-top: 1px solid var(--line); background: var(--surface); }
.site-footer .wrap { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.site-footer a { display: block; padding: 4px 0; }

main { padding: 24px 0 0; }

/* ---------- кнопки и формы ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; min-width: 48px;
  padding: 10px 20px; border-radius: 12px; border: 2px solid transparent; background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: var(--bad); }
.btn.big { min-height: 60px; font-size: 1.15rem; padding: 14px 28px; border-radius: 16px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px;
  font: inherit; background: var(--surface); color: var(--ink);
}
textarea { min-height: 120px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; max-width: 260px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.course-card { display: flex; flex-direction: column; gap: 8px; }
.course-card h3 { margin: 0; }
.course-card .price { font-weight: 800; font-size: 1.2rem; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .85rem; font-weight: 600; }
.cover { aspect-ratio: 16 / 9; border-radius: 12px; background: linear-gradient(135deg, var(--kid-3), var(--kid-4)); display: grid; place-items: center; font-size: 2.6rem; font-weight: 900; color: #fff; }

.notice { border-radius: 12px; padding: 14px 16px; margin: 0 0 16px; border: 1px solid; }
.notice.ok { background: var(--ok-soft); border-color: #b9e2c8; }
.notice.warn { background: var(--warn-soft); border-color: #f1d9a6; }
.notice.bad { background: var(--bad-soft); border-color: #f2c4c0; }
.notice.info { background: var(--brand-soft); border-color: #c9dbfb; }

.hero { display: grid; gap: 24px; grid-template-columns: 1.2fr 1fr; align-items: center; padding: 24px 0 32px; }
.hero-art { aspect-ratio: 4/3; border-radius: 24px; background: var(--kid-1); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 18px; }
.hero-art span { border-radius: 16px; display: grid; place-items: center; font-size: 2.2rem; font-weight: 900; background: #fff; }
.features { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .875rem; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 12px 14px; text-decoration: none; color: var(--ink); border-bottom: 3px solid transparent; min-height: 48px; display: inline-flex; align-items: center; }
.tabs a[aria-current="page"] { border-color: var(--brand); font-weight: 700; }

progress.progress { appearance: none; -webkit-appearance: none; width: 100%; height: 12px; border: 0; border-radius: 999px; overflow: hidden; background: var(--line); color: var(--ok); }
progress.progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress.progress::-webkit-progress-value { background: var(--ok); border-radius: 999px; }
progress.progress::-moz-progress-bar { background: var(--ok); border-radius: 999px; }
.status { font-weight: 700; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }

.pagination { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 48px; min-height: 48px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); text-decoration: none; }
.pagination [aria-current] { background: var(--brand); color: #fff; border-color: var(--brand); }

.filters { display: grid; gap: 12px; grid-template-columns: 2fr 1fr 1fr auto; align-items: end; margin-bottom: 24px; }
.program li { margin-bottom: 6px; }

/* ---------- детский режим ---------- */
body.kid { background: #fff8e6; }
body.kid .site-header { background: #fff; }
.kid-title { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 900; }
.kid-card { background: #fff; border-radius: 24px; padding: 20px; border: 3px solid #ffe7a3; }
.kid-next { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 24px; background: var(--kid-3); color: #0b2540; text-decoration: none; font-size: 1.3rem; font-weight: 800; min-height: 96px; }
.kid-next .play { width: 64px; height: 64px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 1.8rem; flex: none; }
.call-adult { background: #fff; border: 3px dashed var(--kid-2); color: var(--ink); }
.lesson-steps { display: grid; gap: 16px; }
.step { background: #fff; border-radius: 20px; padding: 18px; border: 3px solid #ffe7a3; }
.step h2 { display: flex; gap: 10px; align-items: center; font-size: 1.3rem; }
.step-num { width: 40px; height: 40px; border-radius: 50%; background: var(--kid-1); display: inline-grid; place-items: center; font-weight: 900; flex: none; }
.say-btn { min-width: 56px; min-height: 56px; border-radius: 50%; border: none; background: var(--kid-2); color: #fff; font-size: 1.4rem; cursor: pointer; }
.player-box { position: relative; aspect-ratio: 16/9; background: #0b2540; border-radius: 16px; overflow: hidden; }
.player-box > div, .player-box iframe { width: 100%; height: 100%; border: 0; }
.player-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 16px; }
.save-state { font-size: .9rem; color: var(--muted); min-height: 1.5em; }
.save-state.unsaved { color: var(--warn); font-weight: 700; }

/* ---------- алфавит ---------- */
.alphabet { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.letter { position: relative; min-width: 48px; min-height: 96px; border-radius: 18px; border: 3px solid #ffd76a; background: #fff;
  font: inherit; font-size: 2rem; font-weight: 900; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.letter .lower { font-weight: 600; margin-left: 4px; }
.letter[aria-pressed="true"] { background: var(--kid-1); border-color: #1d2433; border-style: double; border-width: 5px; }
.letter[aria-pressed="true"]::after { content: "♪"; position: absolute; top: 4px; right: 8px; font-size: 1rem; }
.letter.loading::before { content: "…"; position: absolute; bottom: 2px; font-size: 1rem; }
.letter-detail { display: grid; grid-template-columns: 160px 1fr; gap: 16px; align-items: center; }
.letter-detail img { width: 160px; height: 160px; object-fit: contain; border-radius: 16px; background: #fff; }
.letter-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- упражнения ---------- */
.q { background: #fff; border-radius: 20px; padding: 18px; border: 3px solid #e6eefc; margin-bottom: 16px; }
.q-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.q-img { max-height: 180px; border-radius: 12px; }
.options { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.opt { min-height: 72px; border-radius: 16px; border: 3px solid var(--line); background: #fff; font: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.opt img { max-height: 96px; }
.opt[aria-pressed="true"], .opt[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); outline: 3px solid var(--brand); outline-offset: -6px; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { border-radius: 16px; padding: 14px 16px; font-weight: 700; margin-top: 12px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.try { background: var(--warn-soft); }
.result-big { font-size: 2rem; font-weight: 900; }

/* ---------- админ ---------- */
body.admin { background: #f4f5f8; }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav a { padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.admin-nav a:hover { background: var(--brand-soft); }
.admin-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.problems li { color: var(--bad); }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; }
details.card summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .8rem; font-weight: 700; background: var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

@media (max-width: 760px) {
  .hero, .admin-grid, .filters { grid-template-columns: 1fr; }
  .letter-detail { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .site-header .wrap { padding-top: 8px; padding-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- утилиты (перенесены из inline-стилей: CSP style-src 'self') ---------- */
.u-flex-1 { flex:1; }
.u-flex-2 { flex:2; }
.u-fs-1-15rem { font-size:1.15rem; }
.u-fs-1-15rem-m-0 { font-size:1.15rem;margin:0; }
.u-fs-1-4rem-fw-700 { font-size:1.4rem;font-weight:700; }
.u-fs-1-6rem-fw-800 { font-size:1.6rem;font-weight:800; }
.u-fs-4rem { font-size:4rem; }
.u-jc-center { justify-content:center; }
.u-ls-none-p-0 { list-style:none;padding:0; }
.u-m-0 { margin:0; }
.u-m-0-auto { margin:0 auto; }
.u-m-12px-0 { margin:12px 0; }
.u-m-bottom-16px { margin-bottom:16px; }
.u-m-bottom-8px { margin-bottom:8px; }
.u-m-top-12px { margin-top:12px; }
.u-m-top-16px { margin-top:16px; }
.u-m-top-40px { margin-top:40px; }
.u-m-top-8px { margin-top:8px; }
.u-mw-420px-m-40px-auto { max-width:420px;margin:40px auto; }
.u-mw-480px-m-24px-auto { max-width:480px;margin:24px auto; }
.u-mw-480px-m-24px-auto-ta-center { max-width:480px;margin:24px auto;text-align:center; }
.u-mw-560px-m-24px-auto { max-width:560px;margin:24px auto; }
.u-mw-640px-m-16px-auto { max-width:640px;margin:16px auto; }
.u-mw-640px-m-16px-auto-ta-center { max-width:640px;margin:16px auto;text-align:center; }
.u-mw-640px-m-40px-auto-ta-center { max-width:640px;margin:40px auto;text-align:center; }
.u-mw-820px { max-width:820px; }
.u-p-top-16px { padding-top:16px; }
.u-p-top-20px { padding-top:20px; }
.u-w-100 { width:100%; }
.u-w-100-jc-flex-start { width:100%;justify-content:flex-start; }
.u-w-100px { width:100px; }
.u-w-140px { width:140px; }
.u-w-90px { width:90px; }
.u-w-auto { width:auto; }
