/* Colours come from Telegram so the shop looks native in light and dark. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #f4f4f7);
  --text: var(--tg-theme-text-color, #14161a);
  --muted: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2f7ce0);
  --accent: var(--tg-theme-button-color, #2f7ce0);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--muted) 24%, transparent);
  --danger: #d64545;
  --ok: #2e9e5b;
  --radius: 14px;
  --gap: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#root { max-width: 720px; margin: 0 auto; padding: 12px 12px 92px; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: var(--gap); }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: var(--gap); }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- controls --- */
button, input, select, textarea { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--text); }
.btn.quiet { background: transparent; color: var(--link); min-height: 36px; padding: 0 8px; }
.btn.danger { background: transparent; color: var(--danger); }
.btn.block { width: 100%; }

.field {
  width: 100%; min-height: 46px; padding: 11px 14px;
  background: var(--surface); border: 1px solid transparent; border-radius: 12px;
  outline: none;
}
.field:focus { border-color: var(--accent); }
textarea.field { min-height: 88px; resize: vertical; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-text); border-color: transparent;
}

.scroller {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 12px 4px;
  margin: 0 -12px; scrollbar-width: none;
}
.scroller::-webkit-scrollbar { display: none; }

/* --- catalogue --- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; display: flex; flex-direction: column; text-align: left;
  border: 0; padding: 0; color: inherit;
}
/* Своя подложка: снимки в каталоге разных пропорций, и без неё поля от
   object-fit читаются как съехавшая вёрстка, а не как рамка кадра. */
.card .shot { aspect-ratio: 1; background: var(--bg); position: relative; }
.card .shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .body { padding: 9px 10px 11px; display: grid; gap: 3px; }
.card .name { font-size: 13px; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.card .price { font-weight: 650; font-size: 15px; }

.badge {
  position: absolute; left: 8px; top: 8px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(0, 0, 0, 0.62); color: #fff;
}

.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
.gallery img {
  flex: 0 0 100%; scroll-snap-align: center;
  /* Без min-width флекс-элемент не может стать уже своей натуральной ширины,
     и снимок 1280px рисовался шириной 1280px внутри экрана телефона. */
  min-width: 0; max-width: 100%;
  /* Многие снимки в каталоге -- широкие баннеры с текстом, поэтому показываем
     их целиком, а не обрезаем по рамке. */
  aspect-ratio: 4 / 3; object-fit: contain; border-radius: var(--radius); background: var(--bg);
}

/* --- lines and panels --- */
.panel { background: var(--surface); border-radius: var(--radius); padding: 14px; }
.line { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line img {
  width: 56px; height: 56px; border-radius: 10px; flex: none;
  object-fit: contain; background: var(--bg);
}

.total { display: flex; justify-content: space-between; padding: 5px 0; }
.total.grand {
  font-size: 17px; font-weight: 650;
  padding-top: 11px; border-top: 1px solid var(--line); margin-top: 5px;
}
.total .off { color: var(--ok); }

.stepper { display: inline-flex; align-items: center; background: var(--bg); border-radius: 10px; }
.stepper button {
  width: 34px; height: 34px; border: 0; background: transparent;
  font-size: 18px; cursor: pointer; border-radius: 10px;
}
.stepper span { min-width: 26px; text-align: center; font-weight: 600; font-size: 14px; }

.status {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--bg);
}
.status.live { color: var(--accent); }
.status.done { color: var(--ok); }
.status.dead { color: var(--danger); }

.steps { display: flex; gap: 5px; margin-bottom: 4px; }
.steps i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--accent); }

/* --- tab bar --- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; border: 0; background: transparent; cursor: pointer; position: relative;
  padding: 9px 0 11px; display: grid; gap: 2px; justify-items: center;
  font-size: 10px; color: var(--muted);
}
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs .ico { font-size: 19px; line-height: 1; }
.tabs .dot {
  position: absolute; left: 50%; top: 4px; transform: translateX(2px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

/* --- states --- */
.empty { text-align: center; padding: 56px 24px; display: grid; gap: 8px; justify-items: center; }
.empty .ico { font-size: 34px; }

.skeleton { background: var(--surface); border-radius: var(--radius); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
  animation: sweep 1.15s infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 40; margin: 0 auto; max-width: 480px;
  padding: 12px 14px; border-radius: 12px; font-size: 14px;
  background: var(--text); color: var(--bg);
  animation: rise 0.18s ease-out;
}
.toast.bad { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* --- gallery dots --- */
.dots { display: flex; gap: 5px; justify-content: center; }
.dots i { width: 6px; height: 6px; border-radius: 999px; background: var(--line); transition: background 0.15s; }
.dots i.on { background: var(--accent); }

/* --- price on a catalogue tile --- */
.card .price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.card .was { color: var(--muted); font-size: 12px; font-weight: 400; }
.sale {
  position: absolute; right: 8px; top: 8px;
  padding: 3px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--danger); color: #fff;
}

/* --- what happens next --- */
.timeline { display: grid; gap: 14px; text-align: left; width: 100%; }
.step { display: flex; gap: 11px; align-items: flex-start; opacity: 0.55; }
.step.done { opacity: 1; }
.step-ico {
  width: 30px; height: 30px; flex: none; border-radius: 999px;
  display: grid; place-items: center; font-size: 15px; background: var(--surface);
}
.step.done .step-ico { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.step-title { font-weight: 600; font-size: 14px; }

/* --- thank-you screen --- */
.cheer {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: grid; place-items: center; overflow-y: auto;
  animation: cheer-in 0.22s ease-out;
}
.cheer .confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cheer-body {
  position: relative; z-index: 1; width: min(420px, 100%);
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  display: grid; gap: 14px; justify-items: center; text-align: center;
}
.cheer-mark { font-size: 56px; line-height: 1; animation: pop 0.42s cubic-bezier(0.2, 1.4, 0.4, 1); }
.cheer-body h1 { font-size: 24px; }
.cheer-body .timeline { margin-top: 6px; }
.cheer-body .btn { margin-top: 6px; }
@keyframes cheer-in { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .cheer, .cheer-mark { animation: none; }
}
