:root {
  --bg: #fceff3;
  --enamel: #ffffff;
  --gum: #d6407a;
  --gum-deep: #b02a60;
  --blush: #f8d3e0;
  --ink: #3b1230;
  --muted: #8e5a73;
  --line: #efcfdb;
  --tooth-line: #e3a9bf;
  --on-gum: #ffffff;
  --error: #c0262d;
  --error-soft: #fde3e3;
  --focus: #3b1230;

  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --font-text: "Onest", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  --measure: 680px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

::selection { background: var(--blush); color: var(--ink); }
html { scrollbar-color: #e6a6be transparent; }

body {
  margin: 0;
  /* Обои: зубики, искорки и пузырьки пасты */
  background: var(--bg) url("/pattern.svg") 0 0 / 220px 220px repeat;
  color: var(--ink);
  font: 400 17px/1.6 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- шапка с зубной формулой ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}
/* Нижний край шапки — волнистая «линия десны» */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  height: 9px;
  background: radial-gradient(circle at 9px 0, var(--bg) 8.4px, transparent 9px) 0 0 / 18px 9px repeat-x;
  filter: drop-shadow(0 1.5px 0 var(--line));
  pointer-events: none;
}
.topbar__inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar__text { min-width: 0; }
.brand { margin: 0; display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 15px; line-height: 1.3; }
.logo { width: 18px; height: 18px; flex: none; }
.step-label { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.3; }
.topbar .chart { width: 168px; flex: none; }
.topbar[data-hidden-chart] .chart { display: none; }

/* ---------- зубы ---------- */

.chart { display: block; height: auto; overflow: visible; }
.tooth {
  fill: var(--enamel);
  stroke: var(--tooth-line);
  stroke-width: 1.4;
  stroke-linejoin: round;
  transition: fill .25s ease, stroke .25s ease;
}
.tooth.is-current { stroke: var(--gum); }
.tooth.is-filled { fill: var(--gum); stroke: var(--gum-deep); }
.tooth-wrap { transform-box: fill-box; transform-origin: center; }
.tooth-wrap.is-pop { animation: pop .38s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

.chart__num {
  font: 500 5.6px var(--font-text);
  fill: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart__mid { stroke: var(--line); stroke-width: .8; stroke-dasharray: 2 2; }

.mini-tooth { width: 11px; height: 16px; flex: none; overflow: visible; }
.mini-tooth .tooth { stroke-width: 2.2; }
.mini-tooth.is-pop { animation: pop .38s cubic-bezier(.3, 1.6, .5, 1); }

/* ---------- искорки ---------- */

.sparkle { position: absolute; pointer-events: none; fill: var(--gum); }
.sparkle--soft { fill: #f2a3c0; }
.sparkle--twinkle { animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle {
  0%, 100% { transform: scale(.55) rotate(0deg); opacity: .45; }
  50% { transform: scale(1) rotate(25deg); opacity: 1; }
}
.sparkle--burst { opacity: 0; animation: burst 1.1s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes burst {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  55% { transform: scale(1.25) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ---------- иконки ---------- */

.icon {
  display: block;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon .ic-fill { fill: var(--gum); }
.icon .ic-soft { fill: var(--blush); }
.icon .ic-white { fill: var(--enamel); }
.icon .ic-shine { stroke: #fff; }
.icon .ic-gum { stroke: var(--gum); }

/* ---------- страница ---------- */

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 36px 16px 72px;
  outline: none;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.015em;
  text-wrap: balance;
}
h1 {
  margin: 0 0 20px;
  font-size: clamp(28px, 7vw, 44px);
  line-height: 1.12;
}
h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 5.5vw, 32px);
  line-height: 1.2;
}
.lead { color: var(--muted); margin: 0 0 32px; max-width: 60ch; }

/* ---------- первый экран ---------- */

.hero__chart {
  position: relative;
  margin: 0 0 28px;
  padding: 22px 18px 18px;
  background: var(--enamel);
  border-radius: 28px;
}
.hero__chart .chart { width: 100%; max-width: 420px; margin: 0 auto; }
.hero__caption {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.intro p { margin: 0 0 14px; max-width: 62ch; }
.intro .greeting { font-weight: 600; }

h3 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.35; }
.route__heading { margin-top: 32px; }
.route { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.route__item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  background: var(--enamel);
  border-radius: 16px;
}
.route__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg);
}
.route__title { font-weight: 500; }
.route__count { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- заголовок раздела ---------- */

.section-head { display: flex; align-items: center; gap: 16px; margin: 0 0 12px; }
.section-head h2 { margin: 0; }
.section-head__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: var(--enamel);
  position: relative;
}
.section-head__icon .sparkle { top: -5px; right: -5px; }
.section-head__count { margin: 0 0 2px; color: var(--muted); font-size: 14px; }

/* ---------- вопрос ---------- */

.question {
  border: 0;
  margin: 0;
  padding: 0 0 0 16px;
  border-left: 3px solid transparent;
  margin-left: -19px;
  scroll-margin-top: 96px;
  transition: border-color .2s;
}
.question + .question { margin-top: 40px; }
.question legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.45;
}
.question legend + * { clear: both; }
.question__num {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--gum);
  font-variant-numeric: tabular-nums;
}
.question__hint { color: var(--muted); font-size: 15px; margin: 4px 0 0; }
.question.is-missing { border-left-color: var(--error); }
.question__error { display: none; color: var(--error); font-size: 15px; font-weight: 500; margin: 10px 0 0; }
.question.is-missing .question__error { display: block; }

@media (max-width: 720px) {
  .question { margin-left: -16px; padding-left: 13px; }
}

.options { display: grid; gap: 8px; margin-top: 14px; }

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px 13px 12px;
  background: var(--enamel);
  border: 1.5px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.option:hover { border-color: var(--line); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option__mark {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.option--multi .option__mark { border-radius: 9px; }
.option__text { padding-top: 3px; line-height: 1.45; }

.option:has(input:checked) { background: var(--gum); color: var(--on-gum); }
.option input:checked ~ .option__mark { background: var(--on-gum); color: var(--gum); }
.option input:focus-visible ~ .option__mark { outline: 2px solid var(--focus); outline-offset: 3px; }

/* ---------- согласие ---------- */

.consent {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  margin: 26px 0 0;
  background: var(--enamel);
  border: 1.5px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 500;
}
.consent input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--gum); flex: none; }
.consent:has(input:checked) { border-color: var(--gum); }
.consent.is-missing { border-color: var(--error); }
.consent__error { display: none; color: var(--error); font-size: 15px; font-weight: 500; margin: 10px 0 0; }
.consent.is-missing + .consent__error { display: block; }

/* ---------- кнопки ---------- */

.nav {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 44px;
}
.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: 999px;
  padding: 14px 28px;
  font: 600 16px/1.2 var(--font-text);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn--primary { background: var(--gum); color: var(--on-gum); margin-left: auto; }
.btn--primary:hover { background: var(--gum-deep); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--enamel); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.form-error {
  margin: 20px 0 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--error-soft);
  color: var(--error);
  font-size: 15px;
}

/* ---------- финал ---------- */

.done { text-align: center; padding-top: 12px; }
.done .hero__chart { margin-bottom: 32px; }
.done .lead { margin: 0 auto; }
.done .btn { margin: 32px auto 0; }
.done .tooth.is-filled { animation: light .5s ease both; animation-delay: calc(var(--i) * 28ms); }
@keyframes light {
  from { fill: var(--enamel); stroke: var(--tooth-line); }
}

@media (max-width: 480px) {
  .page { padding-top: 24px; }
  .topbar .chart { width: 132px; }
  .btn { padding: 14px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .sparkle--burst { opacity: 1; }
}

/* ---------- подвал ---------- */

.footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.footer p { margin: 0; max-width: 60ch; }
