:root {
  --bg: #F7F2EE;
  --surface: #FFFFFF;
  --surface-2: #FAF6F3;
  --line: #ECE2DC;
  --line-strong: #E0D3CC;
  --text: #2F2826;
  --muted: #8C817C;
  --primary: #B4848C;
  --primary-press: #A2717A;
  --primary-soft: #F6E9E8;
  --primary-ink: #9A6670;
  --sage: #A9BFA8;
  --sage-deep: #8BA88B;
  --danger: #B85C5C;
  --radius: 18px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(80, 50, 40, 0.04), 0 6px 18px rgba(120, 80, 70, 0.06);
  --serif: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --script: 'Marck Script', 'Segoe Script', cursive;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; caret-color: var(--primary-ink); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .modal-title, .cal-month, .collapsed-label, .privilege-title { font-variant-numeric: lining-nums; }
b { font-weight: 700; }

/* --- Страница и переходы ---------------------------------------------------------- */
.page { min-height: 100vh; min-height: var(--tg-viewport-stable-height, 100vh); }
.page.nav-fwd { animation: in-right 0.34s var(--ease) backwards; }
.page.nav-back { animation: in-left 0.34s var(--ease) backwards; }
.page.nav-fade { animation: fade 0.3s ease backwards; }
@keyframes in-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes in-left { from { opacity: 0; transform: translateX(-28px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.screen {
  min-height: inherit;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
}
.footer { margin-top: auto; padding-top: 8px; display: flex; flex-direction: column; gap: 14px; }
.center { text-align: center; }
.center-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
}

/* --- Шапка ------------------------------------------------------------------------ */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; padding-top: 4px; }
.topbar-title {
  flex: 1; font: 600 27px/1.15 var(--serif); letter-spacing: 0.1px;
}
.topbar-aside { color: var(--muted); font-size: min(13px, 2.46vw); white-space: nowrap; }
.back {
  width: 36px; height: 36px; margin-left: -8px; border: 0; background: none; border-radius: 50%;
  display: grid; place-items: center; flex: none;
}
.back:active { background: var(--primary-soft); }
.intro { color: var(--muted); margin-top: -8px; }

/* --- Иконки ----------------------------------------------------------------------- */
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.type-icon {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink);
}
.type-icon .icon { width: 22px; height: 22px; }

/* --- Кнопки ----------------------------------------------------------------------- */
.btn {
  min-height: 52px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; letter-spacing: 0.2px; width: 100%;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn .icon { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(160, 105, 115, 0.25); }
.btn.primary:active:not(:disabled) { background: var(--primary-press); }
.btn.primary:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
.btn.outline { background: transparent; border-color: var(--primary); color: var(--text); min-height: 48px; }
.btn.outline:active { background: var(--primary-soft); }
.btn.danger-btn { border-color: rgba(184, 92, 92, 0.45); color: var(--danger); }
.btn.danger-btn:active { background: rgba(184, 92, 92, 0.08); }
.btn.small { min-height: 34px; padding: 0 14px; width: auto; font-size: 13px; background: var(--primary); color: #fff; }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--primary-ink);
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--primary-soft); }
.link {
  border: 0; background: none; padding: 0; color: var(--text); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; text-align: left;
}
.link .icon { width: 16px; height: 16px; }
.info-btn {
  border: 0; background: none; padding: 2px; margin: -2px 0; vertical-align: middle; color: var(--primary-ink);
  display: inline-grid; place-items: center;
}
.info-btn .icon { width: 17px; height: 17px; }

/* --- Прогресс --------------------------------------------------------------------- */
.progress { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.progress-bar { width: 100%; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.5s var(--ease); }
.progress-text { font-size: 12px; color: var(--muted); }

/* --- Поля ------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-weight: 600; font-size: 14px; }
.label-hint { font-weight: 400; color: var(--muted); }
.req { color: var(--primary-ink); }
.input-wrap { position: relative; }
.input {
  width: 100%; height: 50px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); outline: none; text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input::placeholder, .placeholder { color: #B6ABA6; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(180, 132, 140, 0.15); }
.with-icon .input { padding-left: 46px; }
.input-icon {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted);
  pointer-events: none; display: grid;
}
.input.select { display: flex; align-items: center; padding-right: 44px; }
.input-chev, .input-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--muted);
  width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: none; pointer-events: none;
}
.input-clear { pointer-events: auto; border-radius: 50%; }
.input-clear:active { background: var(--primary-soft); }
.has-error .input, .input.invalid { border-color: var(--danger); }
.error { color: var(--danger); font-size: 13px; animation: rise 0.2s ease backwards; }
.reveal { animation: rise 0.25s var(--ease) backwards; }

.note {
  display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: 13px; margin-top: 8px;
}
.note .icon { width: 18px; height: 18px; color: var(--primary-ink); margin-top: 1px; }
.note.soft { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 2px; }
.hint { color: var(--muted); font-size: 13px; }

/* --- Карточки --------------------------------------------------------------------- */
.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.event-card { padding: 18px 16px; display: flex; flex-direction: column; gap: 16px; animation: rise 0.3s var(--ease) backwards; }
.event-card-head { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.event-card-head h2, .collapsed-label { font: 600 21px/1.2 var(--serif); }
.event-fields { display: flex; flex-direction: column; gap: 16px; }
.badge {
  font: 600 11px/1 var(--sans); color: var(--primary-ink); background: var(--primary-soft);
  padding: 6px 10px; border-radius: 999px; letter-spacing: 0.2px;
}
.collapsed { display: flex; flex-direction: column; gap: 8px; animation: rise 0.3s var(--ease) backwards; }
.collapsed-label { font-size: 18px; display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.event-row {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px; text-align: left;
  animation: rise 0.35s var(--ease) backwards; transition: transform 0.12s ease;
}
.event-row:active { transform: scale(0.99); }
.event-row-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.event-row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.event-row-sub { font-size: 13px; color: var(--muted); }
.chev { color: var(--muted); display: grid; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--primary-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px;
  animation: rise 0.3s var(--ease) backwards;
}

/* --- Приветствие ------------------------------------------------------------------ */
.welcome { padding: 0 0 calc(20px + env(safe-area-inset-bottom)); gap: 0; }
/* Шапка сжимается под высоту экрана, чтобы кнопка «Начать» помещалась без прокрутки:
   ~530px занимает остальной контент. Обрезается верх фото (фон над букетом). */
.hero-photo {
  position: relative; overflow: hidden;
  height: clamp(170px, calc(var(--tg-viewport-stable-height, 100vh) - 530px), 300px);
}
.hero-photo .bouquet {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center bottom;
  animation: fade 0.8s ease backwards;
}
.hero-photo::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 120px;
  background: linear-gradient(to bottom, rgba(247, 242, 238, 0), var(--bg));
}
.welcome-body { display: flex; flex-direction: column; gap: 14px; padding: 0 22px; margin-top: -6px; position: relative; z-index: 1; flex: 1; }
.display { font: 600 34px/1.08 var(--serif); letter-spacing: 0.2px; }
.subtitle { font-weight: 600; margin-top: -4px; }
.display.welcome-title { font-size: min(44px, calc((100vw - 48px) / 9.45)); white-space: nowrap; }
.subtitle.welcome-subtitle { font-size: min(19px, 4.6vw); }
.lead { color: var(--muted); }
.features { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.features li { display: flex; gap: 12px; align-items: center; animation: rise 0.45s var(--ease) backwards; }
.features li:nth-child(2) { animation-delay: 0.08s; }
.features li:nth-child(3) { animation-delay: 0.16s; }
.features b { display: flex; align-items: center; gap: 6px; }
.features small { display: block; color: var(--muted); font-size: min(13px, 2.46vw); white-space: nowrap; }

/* --- Согласие --------------------------------------------------------------------- */
.consent-block { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.checkbox { display: flex; gap: 12px; align-items: flex-start; border: 0; background: none; padding: 0; text-align: left; }
.check {
  width: 24px; height: 24px; flex: none; border-radius: 7px; border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; color: #fff; transition: background 0.2s ease, border-color 0.2s ease;
}
.checkbox.on .check { background: var(--primary); border-color: var(--primary); }
.check .icon { width: 16px; height: 16px; stroke-width: 2.2; animation: pop 0.25s var(--ease) backwards; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
.checkbox-label { font-weight: 600; padding-top: 1px; }
.consent-block .link { margin-left: 36px; }

/* --- Готово ----------------------------------------------------------------------- */
.done { text-align: center; padding-top: 40px; position: relative; isolation: isolate; overflow-x: clip; }
/* Неброские узоры лепестков в углах: за контентом, не мешают тапам. */
.petals {
  position: absolute; z-index: -1; width: 210px; pointer-events: none; opacity: 0.85;
  animation: fade 1s 0.2s ease backwards;
}
.petals-tr { top: -6px; right: -34px; }
.petals-bl { bottom: 86px; left: -44px; transform: rotate(180deg); width: 190px; }
.done-check {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 8px; color: #fff;
  background: radial-gradient(circle at 35% 30%, #BFD1BD, var(--sage-deep));
  display: grid; place-items: center; box-shadow: 0 10px 24px rgba(120, 150, 120, 0.3);
  animation: pop 0.5s var(--ease) backwards, check-pulse 2.4s 0.7s ease-out infinite;
}
/* Мягкая пульсация: расходящееся кольцо вокруг галочки. */
@keyframes check-pulse {
  0% { box-shadow: 0 10px 24px rgba(120, 150, 120, 0.3), 0 0 0 0 rgba(150, 180, 145, 0.45); }
  70%, 100% { box-shadow: 0 10px 24px rgba(120, 150, 120, 0.3), 0 0 0 16px rgba(150, 180, 145, 0); }
}
.done-check .icon { width: 40px; height: 40px; stroke-width: 2; }
.done .display { font-size: 29px; }
.privilege {
  display: flex; gap: 12px; align-items: center; text-align: left; margin-top: 8px;
  background: linear-gradient(135deg, #FBEFEE, #F6E5E4); border-radius: var(--radius); padding: 18px 14px;
  animation: rise 0.5s 0.15s var(--ease) backwards;
}
.privilege-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--surface); color: var(--primary-ink);
  display: grid; place-items: center; flex: none;
}
.privilege-icon .icon { width: 22px; height: 22px; }
.privilege-title { font: 700 min(19px, 4.6vw)/1.25 var(--serif); white-space: nowrap; }
.privilege-title b { font-size: 1.2em; }
.privilege p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.signature { display: block; width: 230px; max-width: 66%; margin: 10px auto 0; animation: fade 0.8s 0.3s ease backwards; }

/* --- Кабинет ---------------------------------------------------------------------- */
.menu { display: flex; flex-direction: column; margin-top: 4px; }
.menu button {
  display: flex; align-items: center; gap: 14px; padding: 15px 4px; border: 0; background: none; text-align: left;
  border-bottom: 1px solid var(--line);
}
.menu button:active { background: var(--primary-soft); }
.menu button span { flex: 1; }
.menu button > .icon:last-child { color: var(--muted); width: 16px; }
.menu .danger { color: var(--danger); }
.logo-area { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 0 12px; }
.logo-bottom { width: min(250px, 64vw); opacity: 0.85; }

/* --- Документ --------------------------------------------------------------------- */
.doc { display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: #4A413E; }
.doc h3 { font: 600 19px/1.25 var(--serif); color: var(--text); margin-top: 8px; }
.doc ul { margin: 0; padding-left: 20px; }
.doc-meta { color: var(--muted); font-size: 13px; }

/* --- Модальные окна --------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(47, 40, 38, 0.32);
  display: flex; animation: fade 0.2s ease backwards;
  /* Попап может стоять внутри заголовка или абзаца — не наследуем их шрифт, цвет и nowrap. */
  font: 400 15px/1.45 var(--sans); color: var(--text); white-space: normal; text-align: left;
  letter-spacing: normal; font-variant-numeric: normal;
}
.overlay.closing { animation: fade-out 0.22s ease both; }
@keyframes fade-out { to { opacity: 0; } }
.modal { background: var(--surface); width: 100%; }
.sheet { align-items: flex-end; }
.sheet .modal {
  border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow: auto; animation: sheet-up 0.32s var(--ease) backwards;
}
.sheet.closing .modal { animation: sheet-down 0.22s ease both; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 0 auto 14px; }
.modal-title { font: 600 23px/1.2 var(--serif); margin-bottom: 14px; }
.dialog { align-items: center; justify-content: center; padding: 24px; }
.dialog .modal {
  max-width: 340px; border-radius: 24px; padding: 26px 22px 20px; text-align: center;
  animation: pop 0.3s var(--ease) backwards;
}
.dialog.closing .modal { animation: fade-out 0.2s ease both; }
.dialog-icon {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink);
  display: grid; place-items: center;
}
.dialog-icon .icon { width: 28px; height: 28px; }
.dialog .modal-title { margin-bottom: 8px; }
.dialog-text { color: var(--muted); margin-bottom: 20px; }

.type-list { display: flex; flex-direction: column; gap: 8px; }
.type-option {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius-sm); text-align: left; font-weight: 500;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
}
.type-option span:nth-child(2) { flex: 1; }
.type-option:active { transform: scale(0.98); background: var(--surface-2); }
.type-option.on { background: var(--primary-soft); border-color: var(--primary); }
.type-option.on .type-icon { background: var(--surface); }
.type-check { color: var(--primary-ink); display: grid; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-month { font: 600 20px/1 var(--serif); animation: fade 0.25s ease backwards; }
.round-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center;
}
.round-btn:active { background: var(--primary-soft); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; animation: fade 0.25s ease backwards; margin-bottom: 14px; }
.cal-day {
  aspect-ratio: 1; border: 0; border-radius: 50%; background: var(--surface-2); font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.cal-day:active { background: var(--primary-soft); }
.cal-day.selected { background: var(--primary); color: #fff; }

/* --- Тост и спиннер --------------------------------------------------------------- */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 999px; background: var(--text); color: #fff;
  font-size: 14px; box-shadow: var(--shadow); animation: toast 0.3s var(--ease) backwards; text-align: center;
}
.toast.err { background: var(--danger); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 12px); } }
.spinner {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.spinner.big { width: 34px; height: 34px; border-color: var(--line-strong); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* Название бренда в тексте: вордмарк из логотипа вместо обычного шрифта. */
.brand { display: inline-block; height: 0.86em; width: auto; vertical-align: -0.08em; margin-left: 0.05em; }
.display .brand { height: 0.7em; vertical-align: -0.02em; margin-left: 0.1em; }
/* Заголовок «Готово» в одну строку: шрифт ужимается под ширину экрана. */
.done .display.done-title { white-space: nowrap; font-size: min(32px, 8vw); line-height: 1.12; }
.features .type-icon { width: 38px; height: 38px; }
.features .type-icon .icon { width: 19px; height: 19px; }
