/* Единый визуальный язык веб-приложения ATTUNE.
   Этап 1 редизайна по docs/v2/ТЗ-ДИЗАЙН-v1.md: тёплый редакционный минимализм —
   молочный фон, засечки в заголовках, пастельные семейства rose/blue/sage/sand.
   Экраны в этом этапе не переверстаны: меняются токены, шрифты, типографика,
   сетка/размеры, состояния и движение — существующая разметка продолжает работать.

   Тема одна и светлая: тёмных интерфейсов в продукте нет намеренно.
   Поэтому здесь нет ни блоков prefers-color-scheme, ни переключателя,
   а все цвета заданы явно. */

/* --- Шрифты: локальная поставка, без внешнего CDN в сеансе ------------- *
 * Источник: google/fonts (github.com/google/fonts, зеркало Google Fonts), *
 * лицензия SIL Open Font License 1.1 — текст в этой же папке              *
 * (OFL-CormorantGaramond.txt, OFL-Inter.txt). Подмножество latin+cyrillic *
 * + ₽ + типографские кавычки/тире, статические начертания из вариативных  *
 * исходников (инструмент: fontTools instancer + subset).                 */

@font-face {
  font-family: "Cormorant Garamond";
  src: url("/static/fonts/CormorantGaramond-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("/static/fonts/CormorantGaramond-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* Совместимость: webapp/psy, webapp/call, webapp/relia — чужое оформление
   вне этого этапа редизайна (не трогаем их файлы), но их собственные CSS
   явно называют "PT Serif"/"PT Sans" и получали шрифт через общий
   base.html. Раз ссылку на Google Fonts убрали из base.html для всего
   документа, эти три модуля без локальной копии остались бы на системном
   fallback (Georgia/system-ui) вместо своего шрифта — здесь только та же
   локальная поставка PT Serif/PT Sans, что была, без внешнего CDN. */
@font-face {
  font-family: "PT Serif";
  src: url("/static/fonts/PTSerif-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "PT Serif";
  src: url("/static/fonts/PTSerif-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "PT Sans";
  src: url("/static/fonts/PTSans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "PT Sans";
  src: url("/static/fonts/PTSans-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* --- Цветовые токены: ТЗ §5, имена и HEX дословно --------------------- */
  --background:        #FBF8F4;
  --surface:            #FFFDFA;
  --text-primary:       #363330;
  --text-secondary:     #67615C;
  --text-muted:         #716A64;
  --border-decorative:  #E6DED6;
  --border-control:     #8E837B;

  --rose-soft:  #F4DFDE;
  --rose-brand: #DDA2A1;
  --rose-ink:   #925456;

  --blue-soft:  #E4EFF4;
  --blue-brand: #9EBFD0;
  --blue-ink:   #486D7F;

  --sage-soft:  #E8ECE2;
  --sage-brand: #B6C2AC;
  --sage-ink:   #56694C;

  --sand-soft:  #F1E7D8;
  --sand-ink:   #7B6246;

  --danger-ink: #A04040;
  /* Мягкая подложка для danger — в таблице §5 её нет как отдельного токена
     (есть только danger-ink), выведена по аналогии с rose/blue/sage/sand-soft
     для плашек и фонов ошибок; это отступление от буквы ТЗ, не от цвета. */
  --danger-soft: #F7E9E7;

  /* Основной градиент §5: на нём тёмная надпись text-primary, не белая. */
  --gradient-brand: linear-gradient(100deg, #EDBCBE 0%, #DCCDD2 48%, #9BBFCE 100%);

  /* --- Обратная совместимость: старые имена токенов, которыми пользуются
     несколько шаблонов напрямую (inline style="color: var(--stop)" и т.п.).
     Не удаляем и не переименовываем в шаблонах — просто указываем на новую
     палитру, чтобы страницы, которые этот этап не переверстывает, не
     сломались и получили новый вид автоматически. */
  --paper:     var(--background);
  --card:      var(--surface);
  --ink:       var(--text-primary);
  --ink-soft:  var(--text-secondary);
  --ink-faint: var(--text-muted);
  --line:      var(--border-decorative);
  --accent:    var(--rose-ink);
  --accent-dk: #7A4547;   /* вручную затемнённый rose-ink для hover/active, не отдельный токен ТЗ */
  --accent-bg: var(--rose-soft);
  --done:      var(--sage-ink);
  --done-bg:   var(--sage-soft);
  --wait:      var(--sand-ink);
  --wait-bg:   var(--sand-soft);
  --stop:      var(--danger-ink);
  --stop-bg:   var(--danger-soft);

  /* --- Шкала отступов §4: 4/8/12/16/20/24/32/40/48 ----------------------- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s4-5: 20px;
  --s5: 24px; --s6: 32px; --s6-5: 40px; --s7: 48px;

  /* --- Радиусы §4: поля 12, карточки 20, большие карточки 24, кнопки 999 - */
  --radius-s:  12px;
  --radius:    20px;
  --radius-l:  24px;
  --radius-pill: 999px;

  --shadow:   0 1px 2px rgba(54,51,48,.05), 0 10px 26px -20px rgba(54,51,48,.30);
  --shadow-l: 0 1px 2px rgba(54,51,48,.05), 0 14px 34px -20px rgba(54,51,48,.28);

  /* --- Высоты §4: основная кнопка мин. 52, поля/капсулы выровнены рядом -- */
  --h-control: 52px;
  --h-pill:    24px;
  --tap-min:   48px;   /* минимальная зона нажатия иконки */

  /* --- Верхняя/нижняя панель §4 ------------------------------------------ */
  --topbar-h: 56px;
  --bottomnav-h: 4rem;

  /* --- Движение §19: длительности-токены и единая кривая ----------------- */
  --ease-standard: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-press: 140ms;     /* 120–160 */
  --dur-tab: 180ms;       /* 160–200 */
  --dur-screen: 240ms;    /* 220–260 */
  --dur-sheet: 300ms;     /* 260–320 */
}

* { box-sizing: border-box; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  min-height: 100vh; /* fallback для браузеров без dvh */
  background: var(--background);
  color: var(--text-primary);
  font: 400 1rem/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- Типографическая шкала: ТЗ §6 дословно ------------------------------ */

h1, h2, h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500;
  margin: 0;
  text-wrap: balance;
}
/* Заголовок экрана: 30/34 — базовый h1 вне onboarding. */
h1 { font-size: 1.875rem; line-height: 2.125rem; }
/* Заголовок крупной карточки: 24/28. */
h2 { font-size: 1.5rem; line-height: 1.75rem; }
/* Название секции — Inter 18/24/500, не Cormorant: своя разметка. */
h3 { font-family: "Inter", system-ui, sans-serif; font-size: 1.125rem; line-height: 1.5rem; font-weight: 500; }
p  { margin: 0; }

/* Модификаторы под остальные роли таблицы §6, для точечного использования
   там, где h1/h2 по разметке не подходят (например заголовок onboarding
   крупнее заголовка обычного экрана). */
.text-onboarding-title { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500; font-size: 2.25rem; line-height: 2.5rem; }
.text-screen-title     { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500; font-size: 1.875rem; line-height: 2.125rem; }
.text-card-title       { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500; font-size: 1.5rem; line-height: 1.75rem; }
.text-section-title    { font-family: "Inter", system-ui, sans-serif; font-weight: 500; font-size: 1.125rem; line-height: 1.5rem; }
.text-question          { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500; font-size: 1.875rem; line-height: 2.25rem; }
.text-body               { font-family: "Inter", system-ui, sans-serif; font-weight: 400; font-size: 1rem; line-height: 1.5rem; }
.text-control            { font-family: "Inter", system-ui, sans-serif; font-weight: 500; font-size: 0.9375rem; line-height: 1.25rem; }
.text-secondary          { font-family: "Inter", system-ui, sans-serif; font-weight: 400; font-size: 0.875rem; line-height: 1.25rem; color: var(--text-secondary); }
.text-meta               { font-family: "Inter", system-ui, sans-serif; font-weight: 400; font-size: 0.8125rem; line-height: 1.125rem; color: var(--text-muted); }
.text-nav-label           { font-family: "Inter", system-ui, sans-serif; font-weight: 500; font-size: 0.75rem; line-height: 1rem; }
.text-metric-large        { font-family: "Inter", system-ui, sans-serif; font-weight: 400; font-size: 3rem; line-height: 3.25rem; font-variant-numeric: tabular-nums; }

a { color: var(--rose-ink); text-underline-offset: 3px; }

.eyebrow {
  font-size: 0.8125rem; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--rose-ink);
}
.muted { color: var(--text-secondary); }
.faint { color: var(--text-muted); font-size: 0.875rem; }

/* Показатели и таймеры — только моноширинные цифры (§6, §12 карты). */
.tabular-nums, .figure__value, .progress__label, .rec__time,
.code-input, .row-item__value, .facts .n { font-variant-numeric: tabular-nums; }

/* --- Каркас страницы ----------------------------------------------------
   Боковые поля §4: 24 при ≥375, 20 при 360–374, 16 ниже 360. */

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: var(--s5) var(--s7);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  min-height: 100dvh;
  min-height: 100vh;
  padding-bottom: calc(var(--s7) + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 360px) {
  .shell { padding-inline: 20px; }
}
@media (min-width: 375px) {
  .shell { padding-inline: 24px; }
}
.shell--wide { max-width: 1120px; }

/* Экран с постоянной нижней навигацией: контенту нужен запас под неё
   (высота панели + safe-area + 16, как требует §4 ТЗ). BottomNavigation —
   следующий этап; правило уже заложено в переменной, чтобы не переписывать
   при подключении меню. */
.shell--with-bottomnav {
  padding-bottom: 0;
}
.shell { --shell-pad: 16px; }
@media (min-width: 360px) { .shell { --shell-pad: 20px; } }
@media (min-width: 375px) { .shell { --shell-pad: 24px; } }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(251,248,244,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-decorative);
}
.topbar__in {
  max-width: 720px; margin: 0 auto;
  min-height: var(--topbar-h);
  padding-inline: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
@media (min-width: 375px) { .topbar__in { padding-inline: 24px; } }
.brand { display: flex; align-items: center; gap: 8px; }
.brand__mark { display: block; width: 24px; height: 22px; flex: none; }
.brand__name { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; font-size: 1.125rem; letter-spacing: .01em; }

/* --- Планшет / desktop §4: интерфейс не растягивается «огромным телефоном» */
@media (min-width: 900px) {
  .shell { max-width: 1120px; padding-inline: 32px; }
  .shell--interview { max-width: 520px; }
  /* Шапка выравнивается по тому же контейнеру, что и контент — иначе на
     широком экране бренд «плавает» отдельно от карточек под ним. */
  .topbar__in { max-width: 1120px; padding-inline: 32px; }
}

/* --- Поверхности -------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--s5);
  box-shadow: var(--shadow);
}
.card--accent {
  background: linear-gradient(180deg, var(--rose-soft), var(--surface) 72%);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-l);
}
.card--quiet { background: transparent; box-shadow: none; padding: 0; }
/* Карточка на градиентном бренд-фоне: текст обязательно тёмный (§5 ТЗ). */
.card--brand-gradient {
  background: var(--gradient-brand);
  color: var(--text-primary);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-l);
}

.stack   { display: grid; gap: var(--s3); }
.stack-l { display: grid; gap: var(--s5); }
.row     { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.spread  { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* --- Ход прохождения ---------------------------------------------------- */

.progress { display: grid; gap: var(--s2); }
.progress__bar { height: 6px; border-radius: var(--radius-pill); background: var(--border-decorative); overflow: hidden; }
.progress__fill {
  height: 100%; background: var(--rose-ink); border-radius: var(--radius-pill);
  transition: width var(--dur-screen) var(--ease-standard);
}
.progress__label { font-size: 0.8125rem; color: var(--text-muted); }

/* --- Кнопки: состояния default/pressed/focus/disabled/loading (§18) ----- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--h-control); padding: 0 var(--s5);
  border: 1px solid transparent; border-radius: var(--radius-pill);
  font: 500 0.9375rem/1.25rem "Inter", system-ui, sans-serif;
  cursor: pointer; text-decoration: none; position: relative;
  transition: background-color var(--dur-press) var(--ease-standard),
              border-color var(--dur-press) var(--ease-standard),
              transform var(--dur-press) var(--ease-standard),
              opacity var(--dur-press) var(--ease-standard);
}
/* pressed: видимый, но не прыгающий отклик на нажатие */
.btn:active { transform: translateY(1px) scale(.99); }
.btn--primary {
  background: var(--gradient-brand);
  color: var(--text-primary);
}
.btn--primary:hover { filter: brightness(.97); }
.btn--ghost { background: var(--surface); color: var(--text-primary); border-color: var(--border-control); }
.btn--ghost:hover { border-color: var(--text-secondary); background: var(--rose-soft); }
/* Текстовая кнопка: третье по значимости действие — без заливки и рамки,
   но с той же зоной нажатия и теми же состояниями pressed/focus/disabled/loading. */
.btn--text { background: transparent; color: var(--rose-ink); padding-inline: var(--s3); }
.btn--text:hover { background: var(--rose-soft); }
.btn--wide { width: 100%; }

/* focus: клавиатурный фокус обязателен и виден (§20). */
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible,
button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--rose-ink); outline-offset: 2px;
}

/* disabled: не только прозрачность — курсор и снятая интерактивность. */
.btn[disabled], .btn.is-disabled {
  opacity: .5; cursor: not-allowed; pointer-events: none;
}

/* loading: ширина кнопки не меняется (§18) — текст скрывается видимостью,
   не удалением из потока, крутилка накладывается поверх по центру. */
.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border-radius: 999px; border: 2px solid currentColor; border-top-color: transparent;
  color: var(--text-primary); opacity: .55;
  animation: btn-spin .8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after { animation-duration: 1.6s; }
}

/* Варианты ответа: крупная область нажатия, читается на телефоне одной рукой. */
.choices { display: grid; gap: var(--s2); }
.choice {
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--h-control);
  padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius-s);
  font-size: 1rem; text-align: left; cursor: pointer; width: 100%;
  transition: border-color var(--dur-press) var(--ease-standard),
              background-color var(--dur-press) var(--ease-standard);
}
.choice:hover { border-color: var(--rose-ink); }
.choice:active { transform: translateY(1px); }
/* Выбранный элемент: рамка 1.5 + подложка + галочка — не только цвет (§11 ТЗ). */
.choice[aria-pressed="true"], .choice.is-picked {
  border-color: var(--rose-ink); border-width: 1.5px; background: var(--rose-soft);
}

/* --- Поля ввода --------------------------------------------------------- */

.field { display: grid; gap: var(--s2); }
.field > label { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }
.input, .textarea {
  width: 100%; min-height: var(--h-control);
  padding: var(--s3) var(--s4);
  background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border-control); border-radius: var(--radius-s);
  font: 400 1rem/1.5 "Inter", system-ui, sans-serif;
  transition: border-color var(--dur-press) var(--ease-standard);
}
.textarea { min-height: 120px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus-visible, .textarea:focus-visible { border-color: var(--rose-ink); }
.input[disabled], .textarea[disabled] { opacity: .5; cursor: not-allowed; background: var(--background); }

/* Подсказка под полем и состояние ошибки (§18): подпись и рамка меняют
   цвет вместе, ошибка объясняет, что делать, а не просто «неверно». */
.field__hint { font-size: 0.8125rem; color: var(--text-muted); }
.field.has-error > label { color: var(--danger-ink); }
.field.has-error .input, .field.has-error .textarea { border-color: var(--danger-ink); }
.field__error {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 0.8125rem; color: var(--danger-ink);
}
.field__error svg { flex: none; margin-top: 1px; }

/* --- Чипы: выбор из набора, компактнее кнопки и варианта ответа --------- */

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 var(--s4);
  border: 1px solid var(--border-control); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text-primary);
  font: 500 0.875rem/1.25rem "Inter", system-ui, sans-serif; cursor: pointer;
  transition: border-color var(--dur-press) var(--ease-standard),
              background-color var(--dur-press) var(--ease-standard),
              color var(--dur-press) var(--ease-standard);
}
.chip:hover { border-color: var(--rose-ink); }
/* Выбранный чип: рамка + подложка + цвет текста — тот же принцип, что у .choice (§11 ТЗ). */
.chip[aria-pressed="true"], .chip.is-active {
  border-color: var(--rose-ink); background: var(--rose-soft); color: var(--rose-ink);
}
.chip[disabled], .chip.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* --- Капсулы состояния -------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center;
  height: var(--h-pill); padding: 0 10px;
  border-radius: 6px; font-size: 0.75rem; font-weight: 500; white-space: nowrap;
}
.pill--done { background: var(--sage-soft); color: var(--sage-ink); }
.pill--wait { background: var(--sand-soft); color: var(--sand-ink); }
.pill--stop { background: var(--danger-soft); color: var(--danger-ink); }
.pill--quiet { background: var(--background); color: var(--text-muted); }

/* --- Иконка в цветной плитке: зона нажатия минимум 48×48 (§4) ----------- */

.tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap-min); height: var(--tap-min); border-radius: var(--radius-s);
  background: var(--rose-soft); color: var(--rose-ink); flex: none;
}
.tile svg { width: 20px; height: 20px; }

/* --- Нижняя навигация §9 ТЗ: четыре равных раздела, safe-area снизу ------ */

.bottomnav {
  /* Панель не «fixed», а «sticky» в конце экрана: при крупном тексте она
     растёт вместе с подписями и никогда не закрывает кнопки под собой. */
  position: sticky; bottom: 0; z-index: 20; margin-top: auto;
  margin-inline: calc(-1 * var(--shell-pad, 16px));
  background: rgba(255,253,250,.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-decorative);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav__in {
  max-width: 720px; margin: 0 auto;
  display: flex;
}
@media (min-width: 900px) { .bottomnav__in { max-width: 1120px; } }
.bottomnav__item {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: var(--bottomnav-h);
  color: var(--text-muted); text-decoration: none;
  transition: color var(--dur-tab) var(--ease-standard);
}
.bottomnav__icon-wrap {
  width: 40px; height: 26px; border-radius: var(--radius-s);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color var(--dur-tab) var(--ease-standard);
}
.bottomnav__label { font: 500 0.75rem/1rem "Inter", system-ui, sans-serif; }
/* Активный раздел: цвет + подложка + текст одновременно (§9 ТЗ — не только цвет). */
.bottomnav__item[aria-current="page"] { color: var(--rose-ink); }
.bottomnav__item[aria-current="page"] .bottomnav__icon-wrap { background: var(--rose-soft); }
.bottomnav__item[aria-current="page"] .bottomnav__label { font-weight: 600; }

/* --- Чипы-вкладки как ссылки: та же плашка, без подчёркивания (§15) ------ */
.chip { text-decoration: none; }

/* --- Строка списка покрупнее: программы, практики (§15 — мин. высота 96) - */
.row-item--lg { min-height: 96px; }

/* --- Плитка-иконка покрупнее: миниатюра списка программ 72×72 (§15) ------ */
.tile--lg { width: 72px; height: 72px; border-radius: var(--radius-s); }
.tile--lg svg { width: 28px; height: 28px; }

/* --- StageCard: экран «Этап отношений» §11 ------------------------------- */

.stage-grid {
  display: grid; gap: var(--s3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
/* §4: ниже 360 — одна колонка, а не сжатый шрифт. */
@media (max-width: 359px) {
  .stage-grid { grid-template-columns: 1fr; }
}

.stage-card {
  position: relative;
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--s3);
  min-height: 124px; padding: var(--s4);
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius);
  cursor: pointer; text-align: left;
  transition: border-color var(--dur-press) var(--ease-standard),
              background-color var(--dur-press) var(--ease-standard);
}
.stage-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.stage-card:hover { border-color: var(--rose-ink); }
/* Выбрано: рамка 1.5 + подложка + галочка — не только цвет (§11). */
.stage-card:has(input:checked) {
  border-width: 1.5px; border-color: var(--rose-ink); background: var(--rose-soft);
}
.stage-card__top { display: flex; }
.stage-card__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; color: var(--rose-ink);
}
.stage-card__label { font: 500 0.9375rem/1.25rem "Inter", system-ui, sans-serif; color: var(--text-primary); }
.stage-card__check {
  position: absolute; top: var(--s3); right: var(--s3);
  width: 22px; height: 22px; border-radius: 999px;
  border: 2px solid var(--border-decorative); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; color: var(--surface);
}
.stage-card:has(input:checked) .stage-card__check { border-color: var(--rose-ink); background: var(--rose-ink); }
.stage-card__check svg { opacity: 0; transition: opacity var(--dur-press) var(--ease-standard); }
.stage-card:has(input:checked) .stage-card__check svg { opacity: 1; }

/* Группа «Мы в браке»: снаружи та же карточка, внутри — раскрывающийся
   список вариантов (native <details>, без JS). */
.stage-card--group { padding: 0; cursor: default; }
.stage-card--group[open] { grid-column: 1 / -1; }
.stage-card--group:has(input:checked) { border-width: 1.5px; border-color: var(--rose-ink); }
.stage-card__summary {
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--s3);
  min-height: 124px; padding: var(--s4); cursor: pointer; list-style: none; position: relative;
}
.stage-card__summary::-webkit-details-marker { display: none; }
.stage-card__chev {
  position: absolute; top: var(--s3); right: var(--s3); color: var(--text-muted);
  display: inline-flex; transform: rotate(90deg);
  transition: transform var(--dur-press) var(--ease-standard);
}
.stage-card--group[open] .stage-card__chev { transform: rotate(-90deg); }
.stage-subgroup { padding: 0 var(--s4) var(--s4); }

/* --- TopicCard: экран «Разговоры» §14 ------------------------------------ */

.topic-card__photo {
  display: block; width: 100%; aspect-ratio: 16 / 7; object-fit: cover;
  border-radius: var(--radius);
}

/* --- ProgramHeroCard: экран «Программы» §15 ------------------------------ */

.program-hero {
  background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-l);
  overflow: hidden;
}
.program-hero__photo {
  display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover;
}
.program-hero__body { padding: var(--s5); display: grid; gap: var(--s3); }
@media (max-width: 620px) { .program-hero__body { padding: var(--s4); } }

/* --- VoiceRecorder: запись голоса — единственный способ ответить на вопрос ----- *
 * теста (решение владельца 29.09.2026). Круг записи крупный и главный на экране; *
 * состояние «Распознаём ответ» другого цвета и без волны, состояние blocked ---- *
 * объясняет, почему микрофон недоступен, и что сделать. ------------------------ */

/* [hidden] — UA-правило с обычным приоритетом, author-правило display:flex/grid
   его перебивает независимо от специфичности. Без явного [hidden]{display:none}
   состояния показывались бы одновременно (поймано скриншотом). */
.voicebox { display: grid; gap: var(--s4); }
.voicebox[hidden], .voicebox [hidden] { display: none !important; }
.voicebox__stage { display: grid; justify-items: center; gap: var(--s3); padding-block: var(--s3); }
.voicebox__row { display: flex; align-items: center; justify-content: center; gap: var(--s3); width: 100%; }

.voicebox__waves {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  width: 32px; height: 40px; flex: none;
  opacity: 0; transition: opacity var(--dur-tab) var(--ease-standard);
}
.voicebox__waves i {
  display: block; width: 3px; height: 6px; border-radius: 999px;
  background: var(--rose-brand); transition: height 90ms linear;
}
[data-state="recording"] .voicebox__waves,
[data-state="paused"] .voicebox__waves { opacity: 1; }

.voicebox__ring {
  flex: none; width: 200px; height: 200px; border-radius: 999px;
  background: var(--rose-soft); display: flex; align-items: center; justify-content: center;
  transition: background-color var(--dur-tab) var(--ease-standard);
}
[data-state="recording"] .voicebox__ring { animation: vb-halo 1.6s ease-in-out infinite; }
[data-state="processing"] .voicebox__ring { background: var(--sage-soft); }
@keyframes vb-halo {
  0%, 100% { box-shadow: 0 0 0 0 rgba(146, 84, 86, .20); }
  50%      { box-shadow: 0 0 0 16px rgba(146, 84, 86, 0); }
}

.voicebox__control {
  position: relative; width: 120px; height: 120px; border-radius: 999px;
  border: 2px solid var(--rose-ink); background: var(--surface); color: var(--rose-ink);
  box-shadow: var(--shadow-l);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background-color var(--dur-press) var(--ease-standard),
              color var(--dur-press) var(--ease-standard),
              transform var(--dur-press) var(--ease-standard);
}
.voicebox__control:hover { background: var(--rose-soft); }
.voicebox__control:active { transform: scale(.97); }
.voicebox__control:focus-visible { outline: 2px solid var(--rose-ink); outline-offset: 4px; }
[data-state="recording"] .voicebox__control,
[data-state="paused"] .voicebox__control { background: var(--rose-ink); color: var(--surface); }

/* processing: свой индикатор обработки — зелёный круг с вращающейся дугой, без
   волны и без «Слушаю»: человек сразу видит, что запись закончена и идёт разбор. */
.voicebox__spinner {
  display: none; position: absolute; inset: -2px; border-radius: 999px;
  border: 3px solid var(--sage-soft); border-top-color: var(--sage-ink);
  animation: btn-spin .9s linear infinite;
}
[data-state="processing"] .voicebox__control {
  border-color: var(--sage-ink); color: var(--sage-ink); background: var(--surface);
  cursor: default; pointer-events: none;
}
[data-state="processing"] .voicebox__spinner { display: block; }
[data-state="processing"] .voicebox__control svg { opacity: .35; }
@media (prefers-reduced-motion: reduce) { .voicebox__spinner { animation-duration: 2.4s; } }

.voicebox__status {
  font-size: 1.125rem; line-height: 1.5rem; font-weight: 500; color: var(--text-primary);
  min-height: 1.5rem; text-align: center;
}
[data-state="processing"] .voicebox__status { color: var(--sage-ink); }
.voicebox__time {
  font: 500 1.5rem/1 "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.voicebox__actions { display: flex; gap: var(--s3); flex-wrap: wrap; justify-content: center; }
.voicebox__hint { text-align: center; }

.voicebox__problem {
  display: flex; gap: var(--s4); align-items: flex-start; text-align: left;
  padding: var(--s5); background: var(--sand-soft); border-radius: var(--radius-s);
  border: 1px solid var(--sand-ink);
}
.voicebox__problem-title { font: 600 1.0625rem/1.5rem "Inter", system-ui, sans-serif; margin: 0 0 var(--s1); color: var(--sand-ink); }
.voicebox__problem p { font-size: 0.9375rem; color: var(--text-primary); }
.voicebox__problem .tile { background: var(--surface); color: var(--sand-ink); }
.voicebox__problem-noscript { font-size: 0.9375rem; color: var(--danger-ink); text-align: center; }
[data-state="blocked"] .voicebox__hint { display: none; }

/* --- Один индикатор вопроса: «Вопрос 3 из 9», блок и сегменты --------------------- */

.qprog { display: grid; gap: var(--s3); }
.qprog__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.qprog__now {
  font: 500 1.5rem/1.25 "Inter", system-ui, sans-serif; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.qprog__now strong { font-weight: 700; }
.qprog__where { font-size: 0.875rem; color: var(--text-muted); }
.qprog__segs { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; min-height: 14px; }
.qprog__seg {
  flex: 1 1 0; min-width: 0; height: 8px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--border-control);
  transition: background-color var(--dur-tab) var(--ease-standard);
}
.qprog__seg.is-done { background: var(--sage-ink); box-shadow: none; }
.qprog__seg.is-skipped {
  background: repeating-linear-gradient(135deg, var(--sand-soft) 0 4px, var(--surface) 4px 8px);
  box-shadow: inset 0 0 0 1.5px var(--sand-ink);
}
.qprog__seg.is-current { height: 12px; background: var(--rose-ink); box-shadow: 0 0 0 3px var(--rose-soft); }
.qprog__legend { display: flex; align-items: center; gap: var(--s2); font-size: 0.8125rem; color: var(--text-muted); }
.qprog__swatch {
  display: inline-block; width: 18px; height: 8px; border-radius: 999px;
  background: repeating-linear-gradient(135deg, var(--sand-soft) 0 4px, var(--surface) 4px 8px);
  box-shadow: inset 0 0 0 1.5px var(--sand-ink);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Экран после записи: «Вы сказали» и «Похоже на вариант» ---------------------- */

.said { display: grid; gap: var(--s1); }
.said__label { font-size: 0.8125rem; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.said__text { font-size: 1.0625rem; line-height: 1.6rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.pick {
  display: grid; gap: var(--s2); padding: var(--s5);
  background: var(--surface); border: 1.5px solid var(--rose-ink); border-radius: var(--radius-l);
  box-shadow: var(--shadow);
}
.pick__label { font-size: 0.8125rem; letter-spacing: .04em; text-transform: uppercase; color: var(--rose-ink); font-weight: 600; }
.pick__value {
  font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500;
  font-size: 1.875rem; line-height: 2.25rem; color: var(--text-primary); overflow-wrap: anywhere;
}
.pick--fail { border-color: var(--border-control); border-style: dashed; box-shadow: none; }
.pick--fail .pick__label { color: var(--text-muted); }

/* Запасной текстовый путь (только при ATTUNE_TEXT_FALLBACK=1): неброская ссылка. */
.textfallback { border-top: 1px solid var(--border-decorative); padding-top: var(--s3); }
.textfallback > summary {
  cursor: pointer; font-size: 0.875rem; color: var(--text-muted); text-decoration: underline;
  text-underline-offset: 3px; list-style: none; width: fit-content;
}
.textfallback > summary::-webkit-details-marker { display: none; }
.textfallback[open] > summary { margin-bottom: var(--s4); }

/* --- MetricRing: §13/§17 ТЗ-ДИЗАЙН — одно честное число, одна дуга на экран --- */

.metric-ring { position: relative; width: 216px; height: 216px; margin-inline: auto; }
.metric-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.metric-ring__track { fill: none; stroke: var(--border-decorative); stroke-width: 9; }
.metric-ring__value {
  fill: none; stroke: var(--rose-ink); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-screen) var(--ease-standard);
}
.metric-ring__center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; text-align: center;
}
.metric-ring__label { font-size: 0.875rem; color: var(--text-secondary); }
@media (max-width: 380px) { .metric-ring { width: 176px; height: 176px; } }

/* --- Экран 01 — знакомство: §10 ТЗ-ДИЗАЙН -------------------------------- *
 * Фотографий из §8 в проекте нет (не найдено ни одного файла с лицензией),
 * поэтому вместо фото — контейнерный градиент бренда с одной декоративной
 * волной поверх (§7: 1–2 кривые, прозрачность 6–12%, только на onboarding). */

.onboard__hero {
  position: relative; min-height: 200px; border-radius: var(--radius-l);
  overflow: hidden; background: var(--gradient-brand); box-shadow: var(--shadow-l);
}
.onboard__hero { min-height: 280px; }
/* Кадр закрывает всю зону; точка кадрирования — из ИСТОЧНИКИ.md, иначе при
   низком контейнере срезает головы. */
.onboard__photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 30%;
}
@media (min-width: 720px) { .onboard__hero { min-height: 360px; } }
.onboard__skip {
  position: absolute; top: var(--s3); right: var(--s3);
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s3);
  font: 500 0.8125rem/1 "Inter", system-ui, sans-serif; color: var(--text-primary);
  background: rgba(255, 253, 250, .78); border-radius: var(--radius-pill); text-decoration: none;
}

.onboard__pages { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.onboard__pages::-webkit-scrollbar { display: none; }
.onboard__page { flex: 0 0 100%; scroll-snap-align: start; display: grid; gap: var(--s3); padding-block: var(--s2); min-width: 0; }

.onboard__dots { display: flex; gap: var(--s2); justify-content: center; }
.onboard__dot {
  width: 8px; height: 8px; padding: 0; border: none; border-radius: 999px;
  background: var(--border-decorative); cursor: pointer;
  transition: background-color var(--dur-tab) var(--ease-standard), width var(--dur-tab) var(--ease-standard);
}
.onboard__dot[aria-current="step"] { background: var(--rose-ink); width: 20px; }

.onboard__actions { display: grid; gap: var(--s2); justify-items: center; }

/* --- Пустое состояние --------------------------------------------------- */

.empty { display: grid; gap: var(--s3); justify-items: center; text-align: center; padding: var(--s6) var(--s4); }
.empty svg { width: 96px; height: 96px; }
.empty h2, .empty h3 { margin: 0; }

/* --- Крупное число со шкалой -------------------------------------------- */

.figure { display: grid; gap: var(--s2); }
.figure__value {
  font-family: "Inter", system-ui, sans-serif; font-weight: 400;
  font-size: 3rem; line-height: 3.25rem;
}
.figure__scale { height: 8px; border-radius: var(--radius-pill); background: var(--border-decorative); overflow: hidden; }
.figure__fill { height: 100%; border-radius: var(--radius-pill); background: var(--rose-ink); }
.figure__fill--quiet { background: var(--text-muted); }

/* --- Движение: §19 — только opacity/transform, единая кривая ----------- */

.appear { animation: appear var(--dur-screen) var(--ease-standard) both; }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Появление нижней панели / bottom sheet (следующий этап уже опирается
   на этот токен движения). */
.sheet-in { animation: sheet-in var(--dur-sheet) var(--ease-standard) both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  /* Декоративные циклы и масштабирование выключаются; статичные индикаторы,
     таймер и текст состояния остаются читаемыми без анимации (§19, §20). */
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .topbar, .btn { display: none !important; }
  .appear { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* --- Телефон ------------------------------------------------------------ */

@media (max-width: 620px) {
  .card, .card--accent, .card--brand-gradient { padding: var(--s4); }
  .shell { padding-block: var(--s4) var(--s6); }
  .btn--stack-mobile { width: 100%; }
}

/* --- Приёмка адаптивности (ТЗ-ДИЗАЙН §23 п.4-5) ----------------------------
   Узкие экраны 320-430 и текст 200 %: содержимое сетки и строк обязано
   сжиматься, а не выталкивать страницу вширь; длинные слова переносятся;
   элементы с фиксированной высотой растут вместе с текстом. */
.stack > *, .stack-l > *, .card > *, .head > *, .empty > *, .rows > *,
.section__head > *, .tests > *, .price-strip > *, .actions > *, .spread > *, .row > * { min-width: 0; }
h1, h2, h3, h4, .btn, .row-item__title, .row-item__note, .field__hint, .pill { overflow-wrap: anywhere; }
.pill { height: auto; min-height: var(--h-pill); text-align: center; white-space: normal; flex-shrink: 0; max-width: 100%; }
body { overflow-wrap: anywhere; }
:where(body) * { min-width: 0; }
:where(svg, img, input[type="radio"], input[type="checkbox"], .tile, .brand__mark) { flex-shrink: 0; }
.bottomnav__label { text-align: center; }

/* Контраст (ТЗ-ДИЗАЙН §23 п.16): на розовой подложке приглушённый текст
   (4.17:1) берёт следующий по тёмности токен text-secondary (4.78:1). */
.card--accent { --text-muted: var(--text-secondary); --ink-faint: var(--text-secondary); }
.card--accent .input, .card--accent .textarea { border-color: var(--text-secondary); }
/* Зона нажатия не меньше 24 px (WCAG 2.2, 2.5.8): ссылка «Выйти» и точки onboarding. */
.topbar a.faint { display: inline-flex; align-items: center; min-height: 44px; padding-inline: var(--s2); }
.onboard__dot { width: 24px; height: 24px; padding: 8px; background-clip: content-box; }
.onboard__dot[aria-current="step"] { width: 36px; }
.choice:has(input:checked) .row-item__note, .choice.is-picked .row-item__note,
.choice[aria-pressed="true"] .row-item__note { color: var(--text-secondary); }

/* Варианты-кнопки (<button class="choice">) не наследуют цвет и шрифт страницы:
   без явных значений текст брал системный цвет кнопки и на части устройств
   (айпад с тёмным оформлением системы) становился светлым на светлой карточке. */
.choice { color: var(--text-primary); font-family: inherit; line-height: 1.5; -webkit-text-fill-color: currentColor; }
.choice > svg { color: var(--text-secondary); flex-shrink: 0; }
.choice strong { color: var(--text-primary); font-weight: 600; }

/* --- Необязательное согласие и список условий (сохранение записей голоса) - */
.optional {
  display: grid; gap: var(--s4);
  padding: var(--s5);
  background: var(--surface);
  border: 1px solid var(--border-decorative);
  border-radius: var(--radius);
}
.optional__title { font-size: 1.25rem; line-height: 1.3; }
.cterms { display: grid; gap: 0; margin: 0; border-top: 1px solid var(--border-decorative); }
.cterms__row {
  display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: var(--s4);
  padding: var(--s3) 0; border-bottom: 1px solid var(--border-decorative);
}
.cterms dt { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); }
.cterms dd { margin: 0; font-size: 0.9375rem; line-height: 1.55; color: var(--text-secondary); }
@media (max-width: 599px) {
  .optional { padding: var(--s4); }
  .cterms__row { grid-template-columns: 1fr; gap: var(--s1); }
}

/* Переключатель: кнопка с role="switch", состояние видно и словом, и положением. */
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.switch {
  display: inline-flex; align-items: center; gap: var(--s3);
  min-height: 48px; padding: 0; background: none; border: 0; cursor: pointer;
  font: 500 1rem/1.4 "Inter", system-ui, sans-serif; color: var(--text-primary);
}
.switch__track {
  position: relative; width: 52px; height: 30px; border-radius: 15px; flex: none;
  background: var(--border-decorative); border: 1px solid var(--border-control);
  transition: background-color var(--dur-press) var(--ease-standard);
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(54, 51, 48, .3);
  transition: transform var(--dur-press) var(--ease-standard);
}
.switch[aria-checked="true"] .switch__track { background: var(--sage-ink); border-color: var(--sage-ink); }
.switch[aria-checked="true"] .switch__track::after { transform: translateX(22px); }
.switch:focus-visible .switch__track { outline: 2px solid var(--rose-ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .switch__track, .switch__track::after { transition: none; }
}
.details-plain { border-top: 1px solid var(--border-decorative); padding-top: var(--s3); }
.details-plain > summary { cursor: pointer; font-weight: 500; min-height: 44px; display: flex; align-items: center; }
.note-inline {
  margin: 0; padding: var(--s3) var(--s4); border-radius: var(--radius-s);
  background: var(--sage-soft); color: var(--sage-ink); font-size: 0.9375rem;
}
