/* Цвета берутся из темы Telegram, запасные значения — для светлой темы. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f5);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --separator: var(--tg-theme-section-separator-color, rgba(127, 127, 127, .2));
  --danger: var(--tg-theme-destructive-text-color, #d9534f);
  --radius: 14px;
  --top: var(--tg-content-safe-area-inset-top, 0px);
  --bottom: var(--tg-content-safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg2);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + var(--top)) 16px calc(24px + var(--bottom));
  min-height: 100vh;
}

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 20px; line-height: 1.25; margin: 0 0 14px; }
p { margin: 0 0 12px; }
.hint { color: var(--hint); font-size: 14px; }
.center { text-align: center; }

.btn {
  display: block; width: 100%;
  border: 0; border-radius: var(--radius);
  padding: 15px 16px;
  font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-text);
  cursor: pointer;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.secondary { background: var(--section); color: var(--link); }
.btn + .btn { margin-top: 10px; }
.link-btn {
  border: 0; background: none; padding: 8px 0; font: inherit;
  color: var(--link); cursor: pointer;
}

/* Старт */
.hero { padding: 28px 4px 8px; }
.hero-icon {
  width: 72px; height: 72px; border-radius: 22px;
  background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; margin-bottom: 22px;
}
.hero-icon svg { width: 40px; height: 40px; }
.hero .hint { font-size: 16px; margin-bottom: 28px; }

/* Шапка шага */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; min-height: 36px; }
.progress { display: flex; gap: 6px; margin-bottom: 14px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--separator); }
.progress span.on { background: var(--accent); }

/* Карточка сборки */
.build {
  background: var(--section); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 18px;
}
.build-title { font-size: 13px; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--bg2); border-radius: 999px; padding: 5px 10px; font-size: 14px;
  animation: pop .25s ease-out;
}
.chip b { font-weight: 600; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

/* Варианты */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.list { display: grid; gap: 8px; }
.opt {
  border: 2px solid transparent; border-radius: 12px;
  background: var(--section); color: var(--text);
  padding: 13px 8px; font: inherit; font-size: 15px;
  cursor: pointer; text-align: center; min-height: 50px;
  overflow-wrap: anywhere;
}
.list .opt { text-align: left; padding: 14px 14px; }
.opt.on { border-color: var(--accent); font-weight: 600; }
.opt.any { color: var(--hint); }
.section-label { font-size: 13px; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.row-actions { margin-top: 12px; display: grid; gap: 8px; }
.sticky-bottom { position: sticky; bottom: calc(8px + var(--bottom)); margin-top: 18px; }

/* Экран подписки */
.gate { background: var(--section); border-radius: var(--radius); padding: 22px 18px; text-align: center; }
.gate-icon { font-size: 44px; line-height: 1; margin-bottom: 12px; }
.msg-fail { color: var(--danger); margin-top: 12px; font-size: 15px; }

/* Карточки машин */
.car { background: var(--section); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.photo { aspect-ratio: 4 / 3; width: 100%; background: var(--bg2); display: block; object-fit: cover; }
.photo-stub { aspect-ratio: 4 / 3; width: 100%; background: var(--bg2); display: grid; place-items: center; color: var(--hint); }
.photo-stub svg { width: 64px; height: 64px; opacity: .5; }
.car-body { padding: 12px 14px 14px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px;
  padding: 3px 8px; margin-bottom: 8px;
  background: var(--accent); color: var(--accent-text);
}
.badge.closest { background: var(--bg2); color: var(--text); font-weight: 500; }
.car-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.price { font-size: 22px; font-weight: 700; }
.price small { font-size: 13px; color: var(--hint); font-weight: 400; margin-left: 6px; }
.specs { margin: 10px 0; padding: 0; list-style: none; font-size: 14px; }
.specs li { padding: 3px 0; border-bottom: 1px solid var(--separator); display: flex; justify-content: space-between; gap: 12px; }
.specs li:last-child { border-bottom: 0; }
.specs span:first-child { color: var(--hint); }
.specs span:last-child { text-align: right; }
.order { font-size: 14px; color: var(--hint); margin-bottom: 12px; }

/* Заявка */
.lead { background: var(--section); border-radius: var(--radius); padding: 20px 16px; }
.consent { font-size: 13px; color: var(--hint); margin-top: 14px; }
.consent a { color: var(--link); }
.done-icon { font-size: 48px; margin: 12px 0; }

.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--separator); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 370px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .chip, .spinner { animation: none; }
}
