:root {
  --velvet: #7a1424;
  --velvet-dk: #5a0d1a;
  --gold: #d4a23c;
  --gold-dk: #a87818;
  --gold-lt: #f6e6bf;
  --cream: #fbf6ec;
  --paper: #ffffff;
  --ink: #2b1d16;
  --muted: #7a6a5e;
  --line: #eadfcc;
  --sage: #3f8a5c;
  --sage-lt: #e2f2e7;
  --red: #c0392b;
  --red-lt: #fbe5e2;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 6px 20px rgba(60, 30, 10, .07);
  --serif: Georgia, "PT Serif", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 18px/1.45 var(--sans); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.good { color: var(--sage); font-weight: 600; } .bad { color: var(--red); font-weight: 600; }
.err { color: var(--red); }
.link { color: var(--velvet); }

/* шапка — бархатный занавес */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--velvet) 0%, var(--velvet-dk) 100%);
  border-bottom: 3px solid var(--gold);
  color: #fff;
}
.brand { color: #fff; text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.top-nav { display: flex; gap: 4px; }
.top-nav a { color: var(--gold-lt); text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: .95rem; }
.top-nav a.active { background: rgba(255,255,255,.14); color: #fff; }

.wrap { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.loading { text-align: center; padding: 60px 0; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--gold-dk); font-weight: 700; }
.section-title { margin: 24px 4px 10px; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 10px 18px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
  cursor: pointer; text-decoration: none; font-weight: 600; transition: transform .06s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--velvet); border-color: var(--velvet); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--velvet-dk); }
.btn-ghost { background: var(--gold-lt); border-color: var(--gold); width: 100%; }
.btn-big { width: 100%; justify-content: flex-start; text-align: left; padding: 14px 16px; font-weight: 400; }
.btn-big small { opacity: .8; }
.mode-ico { font-size: 1.6rem; width: 36px; text-align: center; }

/* вход */
.login { text-align: center; padding: 36px 20px; margin-top: 30px; }
.curtain-ico { font-size: 3.5rem; }
.login-form { display: flex; gap: 10px; max-width: 360px; margin: 18px auto 0; }
.login-form input { flex: 1; min-width: 0; min-height: 52px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--cream); }

/* главная */
.hello { margin: 4px 4px 16px; }
.streak { display: inline-block; background: var(--gold-lt); border: 1px solid var(--gold); padding: 4px 12px; border-radius: 999px; font-weight: 600; }
.book-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.ring-wrap { position: relative; width: 78px; height: 78px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 3.6; }
.ring-fg { fill: none; stroke: var(--sage); stroke-width: 3.6; stroke-linecap: round; transition: stroke-dasharray .6s; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.lv { font-size: .88rem; padding: 4px 10px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); }
.modes { display: grid; gap: 10px; }
.book-mini { display: flex; width: 100%; align-items: center; gap: 12px; text-align: left; cursor: pointer; }
.book-mini .pill { margin-left: auto; }
.book-emoji { font-size: 1.6rem; }
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.toggle input { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--velvet); flex: none; }
.pill { display: inline-block; font-size: .78rem; padding: 2px 9px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); white-space: nowrap; font-weight: 600; }
.pill-ok { background: var(--sage-lt); border-color: #b9dcc5; color: var(--sage); }
.pill-l { background: var(--gold-lt); border-color: var(--gold); color: var(--gold-dk); }

/* тест */
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.btn-x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); cursor: pointer; flex: none; }
.bar { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-dk)); border-radius: 999px; transition: width .3s; }
.count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; min-width: 44px; text-align: right; }
.qcard { padding: 20px 18px; }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { font-size: .75rem; padding: 3px 9px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); color: var(--muted); }
.chip-mode { background: transparent; }
.chip-retry { background: var(--gold-lt); border-color: var(--gold); color: var(--gold-dk); font-weight: 700; }
.qtext { font-size: 1.35rem; margin-bottom: 18px; }
.options { display: grid; gap: 10px; margin-bottom: 14px; }
.options.tf { grid-template-columns: 1fr 1fr; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 58px; padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--paper); cursor: pointer; transition: border-color .15s, background .15s;
}
.opt:hover:not(:disabled) { border-color: var(--gold); }
.opt .key { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--cream); font-weight: 700; font-size: .9rem; }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--sage); background: var(--sage-lt); }
.opt.right .key { background: var(--sage); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-lt); }
.opt.wrong .key { background: var(--red); color: #fff; }
.opt.chosen { border-color: var(--velvet); background: var(--gold-lt); }
.opt.sel { border-color: var(--velvet); background: var(--gold-lt); }
.opt.sel .key { background: var(--velvet); color: #fff; }
.opt.wrong-soft { border-color: #e7b3ab; }
.reveal { margin-bottom: 14px; }
.num-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.num-form input { width: 160px; min-height: 58px; padding: 0 16px; font-size: 1.4rem; font-weight: 700; border: 2px solid var(--line); border-radius: 14px; background: var(--cream); }
.num-form input.right { border-color: var(--sage); background: var(--sage-lt); }
.num-form input.wrong { border-color: var(--red); background: var(--red-lt); }
.unit { color: var(--muted); }
#orderOk { width: 100%; }

.feedback { border-radius: 14px; padding: 14px 16px; margin: 4px 0 14px; animation: pop .25s ease-out; }
.feedback.ok { background: var(--sage-lt); border: 1px solid #b9dcc5; }
.feedback.no { background: var(--red-lt); border: 1px solid #efc0b9; }
.fb-title { font-weight: 700; font-size: 1.15rem; margin-bottom: 4px; }
.fb-right { margin-bottom: 6px; }
.fb-exp { font-size: .95rem; }
.fb-page { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.fb-again { font-size: .85rem; color: var(--gold-dk); margin-top: 6px; font-weight: 600; }
.btn-next { width: 100%; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* результат */
.result { text-align: center; padding: 28px 18px; }
.stars { font-size: 2.6rem; letter-spacing: 6px; color: var(--line); margin: 6px 0; }
.stars .on { color: var(--gold); text-shadow: 0 2px 0 var(--gold-dk); }
.big-score { font-family: var(--serif); font-size: 3.4rem; font-weight: 700; line-height: 1; color: var(--velvet); }
.big-score small { font-size: 1.2rem; color: var(--muted); }
.lead { font-size: 1.1rem; margin: 12px 0 6px; }
.plus { color: var(--sage); font-weight: 700; }
.result-actions { display: grid; gap: 10px; margin-top: 18px; }
.review { padding: 14px 16px; }
.rv-q { font-weight: 600; margin-bottom: 6px; }
.rv-a { font-size: .95rem; }

/* прогресс */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.t-num { font-family: var(--serif); font-size: 1.9rem; font-weight: 700; color: var(--velvet); line-height: 1.1; }
.t-num small { font-size: 1rem; color: var(--muted); }
.t-lbl { font-size: .82rem; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { font-size: 11px; fill: var(--muted); font-family: var(--sans); }
.chart .cline { fill: none; stroke: var(--gold); stroke-width: 2.5; stroke-linejoin: round; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .82rem; color: var(--muted); margin: 6px 0 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-m { background: var(--sage); } .lg-l { background: var(--gold); } .lg-n { background: var(--line); }
.cat-row { margin: 10px 0; }
.cat-name { font-size: .95rem; margin-bottom: 4px; }
.cat-bar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; display: flex; }
.cat-bar .m { background: var(--sage); } .cat-bar .l { background: var(--gold); }
.hard { list-style: none; padding: 0; margin: 0; }
.hard li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.hard li:last-child { border: 0; }
.hist { width: 100%; border-collapse: collapse; font-size: .9rem; }
.hist th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.hist td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.select { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); }

/* список вопросов */
.inline-toggle { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; }
.inline-toggle input { width: 20px; height: 20px; accent-color: var(--velvet); }
.qlist { padding-left: 1.3em; margin: 0; }
.qlist li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.qlist li:last-child { border: 0; }
.qa { color: var(--sage); font-weight: 600; font-size: .95rem; margin-top: 2px; }
.hide-answers .qa { filter: blur(6px); cursor: pointer; }
.hide-answers .qa:hover, .hide-answers .qa:active { filter: none; }

@media (max-width: 420px) {
  body { font-size: 17px; }
  .brand { font-size: 1rem; }
  .qtext { font-size: 1.2rem; }
  .hist th:nth-child(4), .hist td:nth-child(4) { display: none; }
}
