/* Шрифты лежат у нас, а не у Google: в Telegram внутри РФ так надёжнее */
@font-face { font-family: Unbounded; src: url(fonts/unbounded-cyrillic.woff2) format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Unbounded; src: url(fonts/unbounded-latin.woff2) format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: Onest; src: url(fonts/onest-cyrillic.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; src: url(fonts/onest-latin.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2212; }

:root {
  --fog: #F3F1EE;        /* фон — тёплая бумага */
  --sheet: #FFFFFF;
  --ink: #141312;
  --muted: #77716A;
  --line: #E0DBD4;
  --accent: #E8531E;     /* оранжевый Спутника: всё, что нажимается, и «НТИ» */
  --on-ink: #FFFFFF;
  --hero: #141312;       /* тёмная панель — одна на экран */
  --on-hero: #FFFFFF;
  --hero-dim: rgba(255, 255, 255, .6);
  --low: #D93A40;        /* уровни 1–3 */
  --mid: #F2A71B;        /* 4–6 */
  --high: #0B8C6E;       /* 7–9 */

  --display: Unbounded, 'Onest', system-ui, sans-serif;
  --text: Onest, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --spring: cubic-bezier(.2, .9, .25, 1.15);
  --ease: cubic-bezier(.3, .7, .2, 1);
  --glide: cubic-bezier(.22, 1, .36, 1);
  --safe-top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}
:root[data-theme="dark"] {
  --fog: #121110;
  --sheet: #1E1C1A;
  --ink: #F4F1EC;
  --muted: #9B948B;
  --line: #34302C;
  --accent: #FF6B35;
  --on-ink: #121110;
  --hero: #26221F;
  --low: #FF6B70;
  --high: #3FCDA5;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0 auto; max-width: 520px; background: var(--fog); color: var(--ink);
  font: 400 16px/1.4 var(--text); padding: var(--safe-top) 0 0;
  overscroll-behavior-y: none; -webkit-font-smoothing: antialiased;
}
:root.ready body, :root.ready .hero { transition: background-color .35s, color .35s; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: var(--ink); caret-color: var(--accent); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }

/* ── шапка ─────────────────────────────────────────────────────────────── */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 6px; }
.home-btn { display: flex; align-items: center; gap: 10px; transition: opacity .15s; }
.home-btn:active { opacity: .6; }
.mark-mini svg { display: block; width: 26px; height: 26px; }
.app-name { font: 700 17px/1 var(--display); letter-spacing: -.02em; }
.theme-btn { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; transition: transform .15s; }
.theme-btn:active { transform: scale(.88); }
.theme-btn svg { grid-area: 1 / 1; width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; transition: opacity .35s var(--ease), transform .55s var(--glide); }
.theme-btn .moon { fill: var(--ink); stroke: none; }
.theme-btn .moon, :root[data-theme="dark"] .theme-btn .sun { opacity: 0; transform: rotate(-70deg) scale(.6); }
:root[data-theme="dark"] .theme-btn .moon { opacity: 1; transform: none; }

#view { padding: 0 0 calc(170px + var(--safe-bottom)); min-height: 70vh; }
.pane { padding: 0 20px; }
.screen { animation: enter .5s var(--glide) both; }
.screen.back { animation-name: enter-back; }
@keyframes enter { from { opacity: 0; transform: translateX(28px); } }
@keyframes enter-back { from { opacity: 0; transform: translateX(-28px); } }

/* ── знак Спутника ─────────────────────────────────────────────────────── */
.mark .petal path { fill: none; stroke: currentColor; stroke-width: 7; stroke-linejoin: miter; }
.mark .petal.dash path { stroke-dasharray: 16 11; stroke-width: 5.5; }
.mark .dot { fill: var(--accent); }
.mark-mini .mark .petal path { stroke-width: 16; }
.mark-mini .mark .petal.dash path { stroke-dasharray: 34 22; stroke-width: 12; }

/* ── заставка ──────────────────────────────────────────────────────────── */
.splash {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 26px;
  background: var(--hero); color: var(--on-hero); transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.splash.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.splash .mark { width: min(44vw, 170px); overflow: visible; }
/* веер раскрывается из верхнего лепестка: каждый поворачивается на своё место с отскоком */
.splash .petal { transform: rotate(var(--from)); opacity: 0; animation: fan .7s var(--spring) both; animation-delay: calc(120ms + var(--i) * 95ms); }
@keyframes fan { 0% { opacity: 0; transform: rotate(var(--from)) scale(.6); } 25% { opacity: 1; } 100% { opacity: 1; transform: rotate(var(--to)); } }
.splash .dot { transform-box: fill-box; transform-origin: center; animation: pop .45s var(--spring) both; animation-delay: calc(760ms + var(--i) * 55ms); }
@keyframes pop { from { transform: scale(0); } }
.splash-name { text-align: center; animation: rise .55s var(--ease) 1.05s both; }
.splash-name b { display: block; font: 700 22px/1.05 var(--display); letter-spacing: -.02em; }
.splash-name small { display: block; margin-top: 10px; font: 500 11px/1.3 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--hero-dim); }
.splash-name small i { font-style: normal; color: var(--accent); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ── главная ───────────────────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden; margin: 12px 14px 0; padding: 24px 20px 20px;
  border-radius: 26px; background: var(--hero); color: var(--on-hero);
}
.hero .mark { position: absolute; right: -54px; top: 50%; width: 190px; translate: 0 -50%; color: rgba(255, 255, 255, .1); }
.hero .mark .dot { fill: rgba(232, 83, 30, .5); }
.hero h1 { position: relative; font: 700 26px/1.12 var(--display); letter-spacing: -.025em; max-width: 11em; text-wrap: balance; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { position: relative; margin-top: 10px; color: var(--hero-dim); font-size: 15px; max-width: 21em; }
.field { margin: 18px 14px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 6px 6px; }
.field input {
  width: 100%; padding: 15px 16px; font: 500 16px/1.2 var(--text);
  background: var(--sheet); border: 1.5px solid var(--line); border-radius: 16px; outline: 0; transition: border-color .2s;
}
.field input:focus { border-color: var(--ink); }
.field input::placeholder { color: var(--muted); font-weight: 400; }
.steps { margin: 22px 20px 0; display: grid; gap: 14px; }
.steps li { list-style: none; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; animation: settle .6s var(--glide) both; animation-delay: calc(150ms + var(--i) * 70ms); }
.steps .n { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--ink); font: 700 13px/1 var(--display); }
.steps b { display: block; font-weight: 600; }
.steps span { font-size: 14px; color: var(--muted); }
@keyframes settle { from { opacity: 0; transform: translateY(8px); } }
.section-cap { margin: 28px 20px 4px; font: 700 13px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.past { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; width: calc(100% - 28px); margin: 8px 14px 0; padding: 14px 16px; text-align: left; background: var(--sheet); border: 1.5px solid var(--line); border-radius: 18px; transition: transform .15s; }
.past:active { transform: scale(.98); }
.past b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.past small { grid-column: 1; font-size: 13px; color: var(--muted); }
.past .lv { grid-column: 2; grid-row: 1 / 3; font: 700 15px/1 var(--display); }

/* ── нижняя кнопка действия ───────────────────────────────────────────── */
.dock { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); z-index: 5; max-width: 496px; margin-inline: auto; display: grid; gap: 8px; }
body::after { content: ''; position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; pointer-events: none; height: calc(100px + var(--safe-bottom)); background: linear-gradient(to bottom, rgba(0,0,0,0), var(--fog) 62%); }
.go { width: 100%; padding: 17px; border-radius: 18px; background: var(--ink); color: var(--on-ink); font: 700 16px/1 var(--display); letter-spacing: -.01em; box-shadow: 0 10px 28px -10px rgba(20, 19, 18, .4); transition: transform .15s, opacity .2s; }
.go:active { transform: scale(.97); }
.go.accent { background: var(--accent); color: #fff; }
.go[disabled] { opacity: .35; pointer-events: none; }
.go.ghost { background: var(--sheet); color: var(--ink); border: 1.5px solid var(--ink); box-shadow: none; }

/* ── вопрос ────────────────────────────────────────────────────────────── */
.progress { display: flex; align-items: center; gap: 12px; padding: 4px 20px 0; }
.progress .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: calc(var(--p) * 100%); border-radius: 3px; background: var(--accent); transition: width .5s var(--glide); }
.progress .cnt { font: 600 12px/1 var(--display); color: var(--muted); font-variant-numeric: tabular-nums; }
.back-btn { width: 32px; height: 32px; margin-left: -8px; display: grid; place-items: center; border-radius: 10px; transition: background .15s; }
.back-btn:active { background: var(--line); }
.back-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.back-btn[disabled] { opacity: .25; }
.q-wrap { position: relative; margin: 12px 14px 0; }
.q-card {
  padding: 24px 20px 22px; border-radius: 26px; background: var(--sheet); border: 1.5px solid var(--ink);
  animation: q-in .45s var(--glide) both;
}
.q-card.back { animation-name: q-in-back; }
.q-card.out { animation: q-out .28s var(--ease) both; }
.q-card.out.back { animation-name: q-out-back; }
@keyframes q-in { from { opacity: 0; transform: translateX(40px) rotate(1.5deg); } }
@keyframes q-in-back { from { opacity: 0; transform: translateX(-40px) rotate(-1.5deg); } }
@keyframes q-out { to { opacity: 0; transform: translateX(-60px) rotate(-2deg); } }
@keyframes q-out-back { to { opacity: 0; transform: translateX(60px) rotate(2deg); } }
.q-tag { display: inline-flex; align-items: center; gap: 8px; font: 600 12px/1 var(--display); letter-spacing: .02em; color: var(--muted); }
.q-tag .lv { padding: 5px 8px 4px; border-radius: 8px; color: #fff; background: var(--c, var(--ink)); }
.q-tag .key { color: var(--accent); }
.q-text { margin-top: 16px; font: 600 21px/1.28 var(--display); letter-spacing: -.02em; text-wrap: pretty; }
.q-hint { margin-top: 12px; font-size: 14px; color: var(--muted); }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 14px 0; }
.answers button {
  padding: 18px 10px; border-radius: 18px; border: 1.5px solid var(--ink); background: var(--sheet);
  font: 700 17px/1 var(--display); transition: transform .15s var(--spring), background-color .2s, color .2s;
}
.answers button:active { transform: scale(.94); }
.answers .na { grid-column: 1 / 3; padding: 13px; font: 600 14px/1 var(--text); border-style: dashed; border-color: var(--muted); color: var(--muted); }
.answers button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.answers .yes[aria-pressed="true"] { background: var(--high); border-color: var(--high); color: #fff; }
.answers .no[aria-pressed="true"] { background: var(--low); border-color: var(--low); color: #fff; }
.skip { display: block; margin: 18px auto 0; font-size: 14px; color: var(--muted); border-bottom: 1px dashed var(--muted); }

/* ── промежуточный итог / результат ───────────────────────────────────── */
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 14px 0; }
.lvl { position: relative; overflow: hidden; padding: 18px 16px 16px; border-radius: 22px; background: var(--hero); color: var(--on-hero); }
.lvl small { font: 600 12px/1 var(--display); letter-spacing: .04em; color: var(--hero-dim); }
.lvl b { display: block; margin-top: 10px; font: 800 52px/.9 var(--display); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.lvl b sup { font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--hero-dim); vertical-align: top; margin-left: 2px; }
.lvl span { display: block; margin-top: 8px; font-size: 13px; line-height: 1.3; color: var(--hero-dim); min-height: 2.6em; }
.lvl .cond { color: var(--mid); }
.scale { display: flex; gap: 3px; margin-top: 12px; }
.scale i { flex: 1; height: 8px; border-radius: 3px; background: rgba(255, 255, 255, .12); transform-origin: left; }
.scale i.on { background: var(--c); animation: fill .5s var(--glide) both; animation-delay: calc(250ms + var(--k) * 70ms); }
@keyframes fill { from { transform: scaleX(0); opacity: 0; } }
.pgt { display: flex; align-items: center; gap: 16px; margin: 10px 14px 0; padding: 16px; border-radius: 22px; border: 1.5px solid var(--ink); background: var(--sheet); }
.pgt b { font: 800 40px/1 var(--display); color: var(--c); }
.pgt div { font-size: 14px; color: var(--muted); }
.pgt div strong { display: block; color: var(--ink); font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.stop { margin: 14px 14px 0; padding: 20px; border-radius: 22px; background: var(--low); color: #fff; }
.stop h2 { font: 700 20px/1.2 var(--display); letter-spacing: -.02em; }
.stop p { margin-top: 8px; opacity: .9; }
.flag { margin: 10px 14px 0; padding: 14px 16px; border-radius: 18px; border: 1.5px dashed var(--mid); font-size: 14px; }
.block { margin: 12px 14px 0; padding: 18px 18px 10px; border-radius: 22px; background: var(--sheet); border: 1.5px solid var(--line); }
.block h3 { font: 700 16px/1.25 var(--display); letter-spacing: -.02em; }
.block .sub { margin-top: 4px; font-size: 13px; color: var(--muted); }
.block ul { margin: 10px 0 0; padding: 0; list-style: none; }
.block li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.block li:first-child { border-top: 0; }
.block li::before { content: ''; width: 8px; height: 8px; margin: 7px 0 0 4px; border-radius: 50%; background: var(--c, var(--accent)); }
.block li.key { font-weight: 600; }
.block .more { display: block; margin: 4px 0 8px; color: var(--accent); font-weight: 600; font-size: 14px; }
.lvl-rows { margin-top: 10px; }
.lvl-row { display: grid; grid-template-columns: 54px 1fr 44px; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.lvl-row .l { font: 600 12px/1 var(--display); color: var(--muted); }
.lvl-row .t { height: 8px; border-radius: 4px; background: var(--line); position: relative; overflow: hidden; }
.lvl-row .t i { position: absolute; inset: 0 auto 0 0; width: calc(var(--p) * 100%); border-radius: 4px; background: var(--c); animation: fill .6s var(--glide) both; }
.lvl-row .t::after { content: ''; position: absolute; top: 0; bottom: 0; left: 70%; width: 2px; background: var(--ink); opacity: .35; }
.lvl-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.lvl-row.ok .v { color: var(--ink); font-weight: 600; }

/* ── риск ──────────────────────────────────────────────────────────────── */
.stage { margin: 10px 14px 0; padding: 14px 16px; border-radius: 18px; background: var(--sheet); border: 1.5px solid var(--line); animation: settle .5s var(--glide) both; animation-delay: calc(var(--i) * 40ms); }
.stage.done { opacity: .55; }
.stage-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stage-h b { font-weight: 600; font-size: 15px; }
.stage-h small { font: 600 12px/1 var(--display); color: var(--muted); }
.seg { display: flex; gap: 4px; margin-top: 10px; }
.seg button { flex: 1; padding: 8px 0; border-radius: 10px; border: 1.5px solid var(--line); font-size: 13px; font-weight: 600; transition: background .2s, color .2s, border-color .2s; }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.trio label { font-size: 11px; color: var(--muted); }
.trio input, .plan input { width: 100%; margin-top: 4px; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--fog); font: 600 16px/1 var(--display); text-align: center; outline: 0; }
.trio input:focus, .plan input:focus { border-color: var(--ink); }
.plan { margin: 14px 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan label { font-size: 13px; color: var(--muted); }
.plan input { text-align: left; font: 600 15px/1 var(--text); }

/* ── нижний лист ───────────────────────────────────────────────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 10; }
.sheet-shade { position: absolute; inset: 0; background: #0B0A09; opacity: .5; animation: fade .4s ease-out both; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow: auto; max-width: 520px; margin-inline: auto;
  padding: 0 20px calc(24px + var(--safe-bottom)); background: var(--fog);
  border-radius: 26px 26px 0 0; animation: up .6s var(--glide) both; box-shadow: 0 -12px 40px -12px rgba(0, 0, 0, .35);
}
.sheet > h2 { position: sticky; top: 0; z-index: 2; margin: 0 -20px; padding: 10px 20px 12px; font: 700 22px/1.1 var(--display); letter-spacing: -.02em; background: var(--fog); }
.sheet > h2::before { content: ''; display: block; width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 2px; background: var(--line); }
.sheet-wrap.closing .sheet { animation: down .3s var(--ease) both; }
.sheet-wrap.closing .sheet-shade { animation: fade .3s reverse both; }
#sheetBody > * { animation: settle .6s var(--glide) both; animation-delay: calc(200ms + var(--i, 0) * 60ms); }
#sheetBody p { margin-top: 10px; color: var(--muted); font-size: 15px; }
#sheetBody p b { color: var(--ink); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); z-index: 20; translate: -50% 0; padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--on-ink); font-weight: 600; font-size: 14px; animation: toast 2.4s var(--ease) both; white-space: nowrap; }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px); } 12%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .splash .petal { opacity: 1; transform: rotate(var(--to)); }
}
