/* Прайм тур — квиз. Фирстиль: бирюза #00CFC5 / #00A79F, тёмно-синий #2E3D50.
   Цвета фона/текста берём у Telegram (переменные --tg-theme-*), иначе — свои. */

:root {
  --accent: #00CFC5;
  --accent-dark: #00A79F;
  --accent-soft: rgba(0, 207, 197, 0.14);
  --ink: #2E3D50;

  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-2: var(--tg-theme-secondary-bg-color, #f2f5f7);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1b2430);
  --hint: var(--tg-theme-hint-color, #7a8794);
  --line: rgba(127, 140, 155, 0.22);
  --danger: #e5484d;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 24px rgba(20, 40, 60, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #14181d);
    --bg-2: var(--tg-theme-secondary-bg-color, #1d232a);
    --card: var(--tg-theme-section-bg-color, #1d232a);
    --text: var(--tg-theme-text-color, #eef2f5);
    --hint: var(--tg-theme-hint-color, #8e9aa6);
    --line: rgba(160, 175, 190, 0.18);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Шапка с прогрессом ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 20px 8px; }
.progress { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); transition: width .35s ease; }
.top-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; min-height: 22px; }
.top-row .step { font-size: 13px; color: var(--hint); }
.back-link { background: none; border: 0; padding: 0; color: var(--accent-dark); font-size: 14px; }

/* ---------- Экран ---------- */
.screen { padding: 8px 20px 120px; flex: 1; animation: enter .28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.screen.leave { animation: leave .18s ease both; }
@keyframes leave { to { opacity: 0; transform: translateY(-8px); } }

h1 { font-size: 24px; line-height: 1.2; margin: 8px 0 6px; letter-spacing: -0.01em; }
.subtitle { margin: 0 0 18px; color: var(--hint); font-size: 15px; }
.group-title { font-size: 15px; font-weight: 600; margin: 18px 0 10px; }

/* ---------- Интро / финал ---------- */
.hero { border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; background: var(--bg-2); margin: 4px 0 18px; box-shadow: var(--shadow); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--hint); font-size: 13px; margin-bottom: 6px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.brand__site { margin-left: auto; color: var(--accent); text-decoration: none; font-size: 13px; }
.brand__site:hover { text-decoration: underline; }
.already { margin: -6px 0 18px; color: var(--hint); font-size: 14px; }
.already__label { display: block; margin-bottom: 2px; }
.already__link { color: var(--accent); text-decoration: none; font-weight: 500; white-space: nowrap; display: inline-block; padding: 4px 0; }
.already__link:hover { text-decoration: underline; }
.already__sep { color: var(--hint); }
.center { text-align: center; }
.lead { font-size: 16px; color: var(--text); margin: 0 0 16px; }
.lead a { color: var(--accent-dark); text-decoration: none; font-weight: 600; }

/* ---------- Карточки с фото ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  position: relative; padding: 0; border: 0; text-align: left; background: var(--card);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  outline: 3px solid transparent; outline-offset: -3px; transition: transform .15s ease, outline-color .15s ease;
}
.card:active { transform: scale(.97); }
.card.selected { outline-color: var(--accent); }
.card .img { aspect-ratio: 4 / 3; background: var(--bg-2); }
.card .img img { width: 100%; height: 100%; object-fit: cover; }
.card .txt { padding: 10px 12px 12px; }
.card .label { font-weight: 600; font-size: 15px; }
.card .hint { font-size: 12px; color: var(--hint); margin-top: 2px; }
.card .check {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; display: none; align-items: center; justify-content: center; font-size: 15px;
}
.card.selected .check { display: flex; }

/* ---------- Чипы ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 10px 14px; font-size: 15px; display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, border-color .15s, transform .1s;
}
.chip:active { transform: scale(.96); }
.chip.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.chip .emoji { font-size: 17px; }
.chips.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.chips.grid3 .chip { justify-content: center; border-radius: var(--radius-sm); padding: 12px 6px; }
.chips.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.chips.grid4 .chip { justify-content: center; border-radius: var(--radius-sm); padding: 12px 6px; }

/* ---------- Список (бюджет) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius-sm); padding: 14px 16px; text-align: left; font-size: 16px;
  transition: background .15s, border-color .15s;
}
.row.selected { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.row .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; position: relative; }
.row.selected .radio { border-color: var(--accent); }
.row.selected .radio::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--accent); }

/* ---------- Степперы ---------- */
.stepper-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stepper-row:last-of-type { border-bottom: 0; }
.stepper { display: inline-flex; align-items: center; gap: 14px; }
.stepper button { width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); font-size: 22px; line-height: 1; }
.stepper button:disabled { opacity: .35; }
.stepper .val { min-width: 22px; text-align: center; font-weight: 600; font-size: 18px; }

/* ---------- Форма ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 6px; }
.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius-sm);
  padding: 13px 14px; font-size: 16px; outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 84px; resize: vertical; }
.input.error { border-color: var(--danger); }
.err { color: var(--danger); font-size: 13px; margin-top: 6px; }
.btn-share {
  width: 100%; border: 1.5px solid var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600;
  border-radius: var(--radius-sm); padding: 13px 14px; font-size: 15px;
}
.link { background: none; border: 0; padding: 0; color: var(--accent-dark); font-size: 14px; text-decoration: underline; }
.phone-ok { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1.5px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.phone-ok b { font-weight: 600; }
.phone-ok small { display: block; color: var(--hint); font-size: 12px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin: 12px 0; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent-dark); flex: none; }
.check-row a { color: var(--accent-dark); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.muted { color: var(--hint); font-size: 13px; }

/* ---------- Нижняя кнопка ---------- */
.footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 10px 20px calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(255, 255, 255, 0));
}
.footer-inner { max-width: 520px; margin: 0 auto; }
.btn {
  width: 100%; border: 0; border-radius: 14px; padding: 15px 18px; font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  box-shadow: 0 8px 20px rgba(0, 167, 159, 0.28); transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; box-shadow: none; }
.btn.secondary { background: var(--bg-2); color: var(--text); box-shadow: none; margin-top: 10px; }
.server-err { margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(229, 72, 77, 0.1); color: var(--danger); font-size: 14px; }
.server-err a { color: inherit; }

.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 560px) {
  .app { padding-top: 12px; }
  .cards { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Окно на сайте (?embed=1, 05.10.2026) ----------
   Крестик «Закрыть» рисует страница сайта в правом верхнем углу — освобождаем под него место. */
.is-embed .top { padding-right: 60px; }
.is-embed .brand { padding-right: 44px; min-height: 28px; }
/* Сайт светлый — в окне квиз тоже всегда светлый, даже при тёмной теме устройства */
@media (prefers-color-scheme: dark) {
  :root.is-embed {
    --bg: #ffffff; --bg-2: #f2f5f7; --card: #ffffff; --text: #1b2430; --hint: #7a8794;
    --line: rgba(127, 140, 155, 0.22); --shadow: 0 6px 24px rgba(20, 40, 60, 0.08);
  }
}
