:root {
  --bg: #fbf6ee; --surface: #ffffff; --surface-2: #f4ede1; --ink: #1d2433; --muted: #667085; --line: #e7dccb;
  --primary: #3b5bdb; --primary-ink: #ffffff; --primary-soft: #e7ecff;
  --accent: #f08c2e; --accent-soft: #fff0e0;
  --ok: #1f9d55; --ok-soft: #e3f6ea; --bad: #d9480f; --bad-soft: #fdecea; --warn: #b7791f; --warn-soft: #fdf3dc;
  --axis: #e03131; --fig: #1d2433; --grid: #d9cfbf; --cell-on: #3b5bdb; --cell-fixed: #1d2433; --cell-tgt: #37b24d;
  --radius: 18px; --shadow: 0 1px 2px rgba(29, 36, 51, .06), 0 6px 20px rgba(29, 36, 51, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c; --surface: #1d2029; --surface-2: #262a35; --ink: #eef0f5; --muted: #9aa3b5; --line: #323746;
    --primary: #7c93ff; --primary-ink: #0f1320; --primary-soft: #26305a; --accent: #ffa94d; --accent-soft: #3a2a17;
    --ok: #51cf66; --ok-soft: #173424; --bad: #ff8a65; --bad-soft: #3b1f1a; --warn: #fcc419; --warn-soft: #3a3016;
    --fig: #eef0f5; --grid: #3a3f4e; --cell-on: #7c93ff; --cell-fixed: #eef0f5; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161c; --surface: #1d2029; --surface-2: #262a35; --ink: #eef0f5; --muted: #9aa3b5; --line: #323746;
  --primary: #7c93ff; --primary-ink: #0f1320; --primary-soft: #26305a; --accent: #ffa94d; --accent-soft: #3a2a17;
  --ok: #51cf66; --ok-soft: #173424; --bad: #ff8a65; --bad-soft: #3b1f1a; --warn: #fcc419; --warn-soft: #3a3016;
  --fig: #eef0f5; --grid: #3a3f4e; --cell-on: #7c93ff; --cell-fixed: #eef0f5; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
a { color: var(--primary); }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 96px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 18px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 14px; } .center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; } .row.wrap-row { flex-wrap: wrap; } .grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hide { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* шапка */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; min-height: 44px; }
.top .title { font-weight: 700; font-size: 18px; flex: 1; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; font-size: 20px; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }

/* карточки и кнопки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; padding: 12px 18px; border-radius: 16px; border: 0; background: var(--primary); color: var(--primary-ink); font-weight: 700; font-size: 18px; cursor: pointer; text-decoration: none; transition: transform .08s ease, filter .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.accent { background: var(--accent); color: #1d1206; }
.btn.ghost { background: transparent; color: var(--primary); min-height: 44px; font-weight: 600; font-size: 16px; }
.btn.small { min-height: 44px; font-size: 16px; width: auto; }
.big-choice { display: grid; gap: 12px; }
.tile { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.tile .em { font-size: 30px; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); flex: none; }
.tile.accent .em { background: var(--accent-soft); }
.tile b { display: block; font-size: 18px; } .tile span.sub { color: var(--muted); font-size: 14px; }

/* главная */
.hello { display: flex; gap: 14px; align-items: center; margin: 4px 0 18px; }
.hello .owl { font-size: 44px; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 24px; } .stat span { font-size: 13px; color: var(--muted); }
.goal { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.goal > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.nums { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.num { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 10px; cursor: pointer; text-align: left; min-height: 88px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.num .n { font-weight: 800; font-size: 20px; } .num .t { font-size: 13px; color: var(--muted); line-height: 1.25; }
.num .bar { margin-top: auto; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; } .num .bar > i { display: block; height: 100%; }
.lvl-good { background: var(--ok); } .lvl-mid { background: var(--warn); } .lvl-low { background: var(--bad); } .lvl-none { background: transparent; }

/* задание */
.progress { flex: 1; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); transition: width .3s; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.badge { display: inline-flex; gap: 8px; align-items: baseline; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.badge b { background: var(--primary); color: var(--primary-ink); border-radius: 10px; padding: 2px 10px; font-size: 16px; }
.task p { font-size: 18px; }
.expr { font-weight: 700; white-space: nowrap; font-size: 20px; }
.part { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.part:first-of-type { border-top: 0; padding-top: 0; }
.part .q { font-weight: 600; margin-bottom: 8px; }
.answer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inp { width: 100%; max-width: 220px; min-height: 56px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 22px; font-weight: 700; }
.inp.short { max-width: 96px; text-align: center; }
.inp:focus { border-color: var(--primary); outline: none; }
.unit { color: var(--muted); font-weight: 600; }
.part.ok .inp { border-color: var(--ok); background: var(--ok-soft); } .part.bad .inp { border-color: var(--bad); background: var(--bad-soft); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.choices { display: grid; gap: 10px; }
.choice { text-align: left; min-height: 52px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-size: 17px; color: var(--ink); }
.choice.sel { border-color: var(--primary); background: var(--primary-soft); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); } .choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.verdict { margin-top: 8px; font-weight: 700; } .verdict.ok { color: var(--ok); } .verdict.bad { color: var(--bad); }

.price-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.price-card { display: flex; gap: 10px; align-items: center; border: 1.5px solid var(--ink); border-radius: 12px; padding: 8px 10px; background: var(--surface); font-size: 15px; line-height: 1.3; }
.pc-e { font-size: 26px; } .pc-n { font-weight: 700; } .pc-l { color: var(--ink); }
.tbl-wrap { overflow-x: auto; margin: 12px 0; -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--surface); }
.tbl th, .tbl td { border: 1px solid var(--muted); padding: 6px 8px; text-align: center; }
.tbl th[scope="row"] { text-align: left; font-weight: 600; }
.tbl thead th { background: var(--surface-2); }

svg.grid { width: 100%; height: auto; display: block; margin: 12px 0; max-width: 520px; touch-action: manipulation; }
svg.grid .gl { stroke: var(--grid); stroke-width: 1; }
svg.grid .scale { stroke: var(--fig); stroke-width: 3; }
svg.grid .gt { font-size: 11px; fill: var(--fig); }
svg.grid .fig { fill: none; stroke: var(--fig); stroke-width: 3; stroke-linejoin: miter; }
svg.sym .cell { fill: transparent; stroke: var(--grid); stroke-width: 1; }
svg.sym .cell.edit { cursor: pointer; fill: var(--surface); }
svg.sym .cell.edit:hover { fill: var(--primary-soft); }
svg.sym .cell.fixed { fill: var(--cell-fixed); }
svg.sym .cell.on { fill: var(--cell-on); }
svg.sym .cell.tgt { fill: var(--cell-tgt); }
svg.sym .cell.bad { fill: var(--bad); }
svg.sym .cell.miss { fill: var(--ok-soft); stroke: var(--cell-tgt); stroke-width: 2.5; stroke-dasharray: 4 3; }
svg.sym .axis { stroke: var(--axis); stroke-width: 4; }

.feedback { margin-top: 16px; border-radius: var(--radius); padding: 16px; }
.feedback.ok { background: var(--ok-soft); } .feedback.bad { background: var(--bad-soft); } .feedback.mid { background: var(--warn-soft); }
.feedback .head { font-weight: 800; font-size: 20px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
details.sol { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; }
details.sol summary { cursor: pointer; font-weight: 700; padding: 10px 0; min-height: 44px; display: flex; align-items: center; }
.steps { margin: 4px 0 10px; padding-left: 22px; } .steps li { margin: 6px 0; }
.rule { background: var(--primary-soft); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
.note { font-size: 14px; color: var(--muted); margin-top: 8px; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); margin-top: 16px; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.dot { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; font-size: 14px; color: var(--ink); }
.dot.cur { border-color: var(--primary); border-width: 2px; } .dot.done { background: var(--primary-soft); }

/* формы */
label.f { display: block; margin-bottom: 14px; } label.f span { display: block; font-weight: 600; margin-bottom: 6px; }
label.f input[type=text], label.f input[type=tel], label.f input[type=password], label.f input[type=number] { width: 100%; min-height: 52px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 18px; }
label.f input:focus { border-color: var(--primary); outline: none; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; } .check input { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.err { color: var(--bad); font-weight: 600; margin: 8px 0; }
.pin { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.pin i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--primary); } .pin i.on { background: var(--primary); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; }
.keypad button { min-height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); font-size: 26px; font-weight: 700; cursor: pointer; color: var(--ink); }
.kid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kid-list button { min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 17px; font-weight: 600; cursor: pointer; color: var(--ink); }
.big-code { font-size: 44px; font-weight: 800; letter-spacing: .2em; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }

/* отчёт */
.report-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.mark { font-size: 48px; font-weight: 800; line-height: 1; }
.tbl-rep { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl-rep td, .tbl-rep th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl-rep th { font-size: 13px; color: var(--muted); font-weight: 600; }
.meter { width: 100%; min-width: 60px; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; } .meter > i { display: block; height: 100%; }
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; margin-top: 8px; }
.days i { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); } .days i.on { background: var(--ok); } .days i.today { outline: 2px solid var(--primary); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.confetti { font-size: 56px; text-align: center; animation: pop .5s ease; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 560px) { .price-grid { grid-template-columns: repeat(3, 1fr); } }

/* подсказка, разбор ошибки, минутка отдыха, наклейки */
.tip { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: var(--primary-soft); font-size: 16px; }
.tip p { margin: 6px 0 0; }
.why { margin: 6px 0 8px; font-weight: 600; }
.rest-banner { display: block; width: 100%; margin: 0 0 10px; padding: 10px 14px; border: 0; border-radius: 12px; background: var(--primary-soft); color: var(--ink); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.rest-banner.hide { display: none; }
.rest-list { text-align: left; margin: 0 auto; padding-left: 22px; max-width: 420px; }
.rest-list li { margin: 8px 0; }
.rest-note { margin-bottom: 14px; }
.badges { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.bdg { width: 100%; aspect-ratio: 1; padding: 0; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; cursor: pointer; filter: grayscale(1); opacity: .35; }
.bdg.on { filter: none; opacity: 1; background: var(--surface-2); }
.task { font-size: 18px; }
.countdown { letter-spacing: 0; font-variant-numeric: tabular-nums; }
label.f textarea { width: 100%; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; resize: vertical; }
label.f textarea:focus { border-color: var(--primary); outline: none; }
.err-list { margin: 6px 0 8px; padding-left: 20px; } .err-list li { margin-bottom: 4px; }
/* решение по действиям */
.steps-box { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.steps-title { font-weight: 700; margin-bottom: 6px; }
.steps-expr { font-size: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 10px; font-variant-numeric: tabular-nums; }
.steps-expr .op { min-width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--primary); background: var(--surface); color: inherit; font-size: 24px; font-weight: 700; cursor: pointer; }
.steps-expr .op.sel { background: var(--primary); color: #fff; }
.steps-expr .op:disabled:not(.sel) { opacity: .45; cursor: default; }
.steps-done { margin: 4px 0 6px; padding-left: 22px; font-size: 17px; }
.step-calc { display: flex; align-items: center; gap: 8px; font-size: 22px; flex-wrap: wrap; }
.step-calc .inp { width: 110px; }
.step-calc .btn { padding: 0 18px; }
.ok-line { color: var(--ok); }
