@font-face {
  font-family: "Unbounded";
  src: url("/static/fonts/unbounded.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* Основа страницы: глубокий зелёный */
  --base: #0f5a3e;
  --base-deep: #083624;
  --base-sheen: #1a7552;
  --gold: #e6bd57;
  --on-base: #f4fbf6;
  --on-base-muted: rgba(244, 251, 246, 0.76);

  /* Лист с формой */
  --paper: #fdfefc;
  --ink: #14261d;
  --muted: #5d7066;
  --line: #dde8e1;
  --field: #f3f8f4;
  --tint: rgba(21, 128, 82, 0.07);
  --accent: #15804f;
  --accent-press: #0f6a41;
  --focus: rgba(21, 128, 82, 0.24);
  --leaf: #15804f;
  --error: #c0312b;

  --display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --text: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --base: #0b3a29;
    --base-deep: #041a11;
    --base-sheen: #135238;
    --paper: #111c17;
    --ink: #e7f2ec;
    --muted: #9bb2a6;
    --line: #22362d;
    --field: #17251f;
    --tint: rgba(230, 189, 87, 0.08);
    --accent: #2fae70;
    --accent-press: #3cc481;
    --focus: rgba(230, 189, 87, 0.3);
    --leaf: #4cc98a;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 400 1rem/1.55 var(--text);
  color: var(--ink);
  background:
    radial-gradient(140% 70% at 50% -20%, var(--base-sheen) 0%, transparent 60%),
    linear-gradient(180deg, var(--base) 0%, var(--base-deep) 100%);
  background-color: var(--base);
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding:
    calc(28px + env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    calc(32px + env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}

/* ---------- шапка ---------- */

.masthead { color: var(--on-base); padding: 0 4px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--on-base);
  text-decoration: none;
}
.brand img {
  /* Светлая плашка, чтобы логотип читался на зелёном фоне */
  width: 40px;
  height: 40px;
  padding: 4px;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
}

.masthead h1 {
  margin: 28px 0 12px;
  font: 600 clamp(2.1rem, 8vw, 3.4rem)/1.04 var(--display);
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  max-width: 46ch;
  font-size: 1.0625rem;
  color: var(--on-base-muted);
}

/* ---------- прогресс: три вложенные матрёшки ---------- */

.progress {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 36px 4px 18px;
}
.dolls { display: flex; align-items: flex-end; gap: 8px; margin: 0; padding: 0; list-style: none; }
.doll {
  display: block;
  object-fit: contain;
  object-position: 50% 100%;
  opacity: 0.32;
  filter: saturate(0.5);
  transition: opacity 0.35s ease, filter 0.35s ease, transform 0.35s ease;
  transform-origin: 50% 100%;
}
.doll--1 { width: 64px; height: 64px; }
.doll--2 { width: 50px; height: 50px; }
.doll--3 { width: 38px; height: 38px; }
.doll.is-done { opacity: 1; filter: none; }
.doll.is-current {
  opacity: 1;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.28));
  transform: translateY(-4px);
}

.progress-text {
  margin: 0 0 2px;
  font-size: 0.9375rem;
  color: var(--on-base-muted);
}
.progress-text strong { display: block; color: var(--on-base); font-weight: 600; }

/* ---------- лист с формой ---------- */

.sheet {
  background: var(--paper);
  border-radius: 28px;
  padding: clamp(22px, 5vw, 40px);
  box-shadow: 0 40px 80px -40px rgba(0, 20, 10, 0.7);
}

.step h2,
.done h2 {
  margin: 0 0 6px;
  font: 600 clamp(1.3rem, 4.6vw, 1.6rem)/1.2 var(--display);
  letter-spacing: -0.01em;
  text-wrap: balance;
  outline: none;
}
.step-hint { margin: 0 0 24px; color: var(--muted); }

.step.is-entering { animation: enter 0.28s ease-out; }
@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* выбор темы */
.topics {
  margin: 20px -12px 0;
  padding: 0;
  border: 0;
}
.topic {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr 22px;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-radius: 16px;
  cursor: pointer;
}
.topic + .topic::before {
  content: "";
  position: absolute;
  top: 0; left: 70px; right: 12px;
  border-top: 1px solid var(--line);
}
.topic:hover { background: var(--tint); }
.topic:has(input:checked) { background: var(--tint); }
.topic:has(input:checked)::before,
.topic:has(input:checked) + .topic::before { border-color: transparent; }
.topic:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--focus); }

.topic-icon {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--field);
  color: var(--accent);
}
.topic-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.topic-title { display: block; font-weight: 600; font-size: 1.0625rem; line-height: 1.3; }
.topic-hint { display: block; color: var(--muted); font-size: 0.9375rem; line-height: 1.35; margin-top: 2px; }
.topic-mark {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.topic:has(input:checked) .topic-mark { border-color: var(--accent); box-shadow: inset 0 0 0 5px var(--accent); }

.sr-only,
.topic input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* поля */
.field { margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.field-label {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  font-weight: 600;
  font-size: 0.9875rem;
}
.field-label .optional { font-weight: 400; color: var(--muted); }

.input {
  display: block;
  width: 100%;
  padding: 13px 15px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { min-height: 132px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: var(--muted); opacity: 0.75; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }
.field.has-error .input { border-color: var(--error); }

.counter { margin: 6px 0 0; font-size: 0.8125rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.field-error { margin: 8px 0 0; font-size: 0.9rem; color: var(--error); }
.field-error:empty { display: none; }

/* варианты-«пилюли» */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input, .score input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill span {
  display: inline-block;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  font-size: 0.9875rem;
  line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pill input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill input:focus-visible + span { box-shadow: 0 0 0 4px var(--focus); }

/* оценка 1–5 */
.scores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.score { position: relative; }
.score span {
  display: grid;
  place-items: center;
  height: 54px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  font: 600 1.125rem var(--display);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.score input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.score input:focus-visible + span { box-shadow: 0 0 0 4px var(--focus); }
.scale { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.8125rem; color: var(--muted); }

/* ловушка для ботов */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* кнопки */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
}
.actions .btn-primary:only-child { margin-left: auto; }

.btn-primary,
.btn-back,
.btn-quiet {
  font: 600 1rem var(--text);
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  min-height: 52px;
  padding: 0 26px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent-press); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-back {
  min-height: 52px;
  padding: 0 6px;
  background: none;
  color: var(--muted);
}
.btn-back:hover { color: var(--ink); }
.btn-quiet {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--field);
  color: var(--ink);
  border: 1.5px solid var(--line);
}
:is(.btn-primary, .btn-back, .btn-quiet):focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.form-error {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
}
.form-error:empty { display: none; }

.reward-note {
  margin: -8px 0 22px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--tint);
  font-size: 0.9375rem;
}

/* готово */
.done { text-align: left; }
.done p { margin: 0 0 18px; color: var(--muted); max-width: 52ch; }
.ticket {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 22px 0 18px;
  padding: 18px 20px;
  border-radius: 18px;
  background: var(--field);
  border: 1.5px dashed var(--line);
}
.ticket-label { display: block; font-size: 0.875rem; color: var(--muted); }
.ticket-code { display: block; font: 600 clamp(1.4rem, 6vw, 1.9rem) var(--display); letter-spacing: 0.04em; color: var(--ink); }
.ticket .btn-quiet { margin-left: auto; }

.foot {
  margin: 22px 4px 0;
  font-size: 0.875rem;
  color: var(--on-base-muted);
}

.loading { color: var(--muted); margin: 0; }

@media (max-width: 420px) {
  .progress { gap: 10px; }
  .actions { flex-direction: column-reverse; align-items: stretch; }
  .actions .btn-primary { width: 100%; }
  .actions .btn-primary:only-child { margin-left: 0; }
  .ticket .btn-quiet { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
