/* Флёр — Telegram Mini App. Цвета берутся из темы Telegram (--tg-theme-*),
   при запуске вне Telegram — из запасных значений светлой/тёмной темы. */
:root {
  --fb-bg: #ffffff;
  --fb-secondary-bg: #f0f0f5;
  --fb-section-bg: #ffffff;
  --fb-text: #000000;
  --fb-hint: #8e8e93;
  --fb-link: #2481cc;
  --fb-button: #2481cc;
  --fb-button-text: #ffffff;
  --fb-accent: #2481cc;
  --fb-destructive: #e53935;
  --fb-separator: #e3e3e8;
  --fb-header-bg: #ffffff;
  --fb-subtitle: #6d6d72;
  --card-tint: 0;

  --bg: var(--tg-theme-bg-color, var(--fb-bg));
  --secondary-bg: var(--tg-theme-secondary-bg-color, var(--fb-secondary-bg));
  --section-bg: var(--tg-theme-section-bg-color, var(--fb-section-bg));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --link: var(--tg-theme-link-color, var(--fb-link));
  --button: var(--tg-theme-button-color, var(--fb-button));
  --button-text: var(--tg-theme-button-text-color, var(--fb-button-text));
  --accent: var(--tg-theme-accent-text-color, var(--fb-accent));
  --destructive: var(--tg-theme-destructive-text-color, var(--fb-destructive));
  --separator: var(--tg-theme-section-separator-color, var(--fb-separator));
  --header-bg: var(--tg-theme-header-bg-color, var(--fb-header-bg));
  --subtitle: var(--tg-theme-subtitle-text-color, var(--fb-subtitle));
  --pink: #f06292;
  --radius: 14px;
}
html.theme-dark {
  --fb-bg: #17212b;
  --fb-secondary-bg: #0e1621;
  --fb-section-bg: #17212b;
  --fb-text: #f5f5f5;
  --fb-hint: #708499;
  --fb-link: #6ab3f3;
  --fb-button: #5288c1;
  --fb-button-text: #ffffff;
  --fb-accent: #6ab2f2;
  --fb-destructive: #ec3942;
  --fb-separator: #0b1218;
  --fb-header-bg: #17212b;
  --fb-subtitle: #8094a8;
  --pink: #f48fb1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Manrope", -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Liberation Sans", sans-serif;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: var(--text); }

/* ---------- Имитация шапки Telegram (только вне Telegram, ?chrome=1) ---------- */
.tg-chrome { display: none; }
body.with-chrome .tg-chrome { display: block; position: sticky; top: 0; z-index: 30; background: var(--header-bg); }
.statusbar { height: 47px; display: flex; align-items: center; justify-content: space-between; padding: 6px 30px 0 34px; font-weight: 700; font-size: 16px; }
.statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
.statusbar svg { fill: var(--text); }
.tg-header { height: 52px; display: grid; grid-template-columns: 96px 1fr 96px; align-items: center; padding: 0 14px; border-bottom: 0.5px solid var(--separator); }
.tg-header .tg-left { color: var(--link); font-size: 16px; display: flex; align-items: center; gap: 2px; }
.tg-header .tg-title { text-align: center; line-height: 1.15; }
.tg-header .tg-title b { display: block; font-size: 16px; }
.tg-header .tg-title span { font-size: 12.5px; color: var(--hint); }
.tg-header .tg-right { justify-self: end; width: 30px; height: 30px; border-radius: 50%; border: 1.6px solid var(--link); display: grid; place-items: center; color: var(--link); font-weight: 800; letter-spacing: 1px; font-size: 12px; }

/* ---------- Общее ---------- */
#app { padding-bottom: 96px; }
.screen { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section { background: var(--section-bg); border-radius: var(--radius); margin: 0 12px 12px; overflow: hidden; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--hint); margin: 18px 28px 7px; font-weight: 600; }
.hint { color: var(--hint); }
.price { font-weight: 800; }
.old-price { color: var(--hint); text-decoration: line-through; font-weight: 500; font-size: .85em; margin-left: 6px; }
.muted { color: var(--subtitle); font-size: 13.5px; }

/* ---------- Каталог ---------- */
.cat-top { background: var(--bg); padding: 12px 12px 10px; }
.hello { display: flex; align-items: center; gap: 10px; margin: 2px 4px 12px; }
.hello .ava { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #f8bbd0, #f06292); display: grid; place-items: center; font-size: 20px; }
.hello b { font-size: 17px; display: block; }
.hello span { font-size: 13px; color: var(--hint); }
.search { display: flex; align-items: center; gap: 8px; background: var(--secondary-bg); border-radius: 11px; padding: 0 12px; height: 38px; color: var(--hint); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; height: 100%; font-size: 15px; }
.search input::placeholder { color: var(--hint); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 12px 4px; scrollbar-width: none; background: var(--bg); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 18px; background: var(--secondary-bg); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.active { background: var(--button); color: var(--button-text); }
.banner { margin: 12px 12px 4px; border-radius: 16px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; background: linear-gradient(120deg, #ffe0ec, #fff3e0); color: #4a2a35; }
html.theme-dark .banner { background: linear-gradient(120deg, #3a2431, #33291f); color: #f6dbe5; }
.banner .b-emoji { font-size: 30px; }
.banner b { display: block; font-size: 15px; }
.banner span { font-size: 13px; opacity: .8; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
.card { background: var(--section-bg); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.card .pic { aspect-ratio: 1 / 1; display: grid; place-items: center; position: relative; }
.card .pic svg { width: 92%; height: 92%; }
.badge { position: absolute; top: 8px; left: 8px; font-size: 11.5px; font-weight: 800; padding: 3px 8px; border-radius: 8px; background: var(--pink); color: #fff; }
.badge.hit { background: #ff9f0a; }
.badge.new { background: #34c759; }
.card .info { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card .name { font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.card .sub { font-size: 12.5px; color: var(--hint); }
.card .row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.add-btn { height: 32px; min-width: 32px; padding: 0 12px; border-radius: 10px; background: var(--button); color: var(--button-text); font-weight: 700; font-size: 14px; }
.stepper { display: inline-flex; align-items: center; background: var(--secondary-bg); border-radius: 10px; height: 32px; }
.stepper button { width: 32px; height: 32px; font-size: 19px; font-weight: 700; color: var(--accent); }
.stepper span { min-width: 22px; text-align: center; font-weight: 800; font-size: 14px; }
.empty { text-align: center; padding: 48px 24px; color: var(--hint); }
.empty .e-emoji { font-size: 44px; display: block; margin-bottom: 8px; }

/* ---------- Карточка товара ---------- */
.p-hero { background: var(--bg); padding-bottom: 14px; }
.p-pic { margin: 0 12px; border-radius: 22px; aspect-ratio: 1.08 / 1; display: grid; place-items: center; position: relative; }
.p-pic svg { width: 82%; height: 92%; }
.fav { position: absolute; right: 12px; top: 12px; width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.75); display: grid; place-items: center; font-size: 18px; }
html.theme-dark .fav { background: rgba(0,0,0,.35); }
.p-head { padding: 14px 18px 0; }
.p-head h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.2; }
.p-meta { display: flex; gap: 12px; font-size: 13.5px; color: var(--hint); align-items: center; }
.p-meta .star { color: #ffb300; }
.p-price { font-size: 24px; font-weight: 800; margin-top: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }
.seg button { border-radius: 12px; padding: 9px 4px; background: var(--secondary-bg); text-align: center; border: 1.5px solid transparent; }
.seg button b { display: block; font-size: 14px; }
.seg button span { font-size: 12px; color: var(--hint); }
.seg button.active { border-color: var(--button); background: color-mix(in srgb, var(--button) 12%, var(--section-bg)); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 48px; position: relative; }
.list-row + .list-row::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; border-top: 0.5px solid var(--separator); }
.list-row.noicon + .list-row.noicon::before { left: 16px; }
.list-row .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; flex: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow small { display: block; color: var(--hint); font-size: 12.5px; }
.toggle { width: 51px; height: 31px; border-radius: 16px; background: var(--separator); position: relative; transition: .2s; flex: none; }
html.theme-dark .toggle { background: #3a4a5a; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: .2s; }
.toggle.on { background: #34c759; }
.toggle.on::after { left: 22px; }
.desc { padding: 12px 16px 14px; font-size: 14.5px; line-height: 1.5; }
.compo { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 14px; }
.compo span { font-size: 13px; padding: 5px 10px; border-radius: 9px; background: var(--secondary-bg); }

/* ---------- Корзина ---------- */
.cart-item { display: flex; gap: 12px; padding: 12px; align-items: center; position: relative; }
.cart-item + .cart-item::before { content: ""; position: absolute; top: 0; left: 90px; right: 0; border-top: 0.5px solid var(--separator); }
.cart-item .thumb { width: 66px; height: 66px; border-radius: 12px; flex: none; display: grid; place-items: center; }
.cart-item .thumb svg { width: 90%; height: 90%; }
.cart-item .grow { flex: 1; min-width: 0; }
.cart-item .name { font-weight: 700; font-size: 15px; }
.cart-item .sub { font-size: 12.5px; color: var(--hint); margin: 2px 0 6px; }
.cart-item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.del { color: var(--hint); font-size: 13px; }
.sum-row { display: flex; justify-content: space-between; padding: 10px 16px; font-size: 15px; }
.sum-row.total { font-size: 18px; font-weight: 800; border-top: 0.5px solid var(--separator); padding: 13px 16px; }
.sum-row .ok { color: #34c759; font-weight: 700; }
.progress { margin: 0 16px 12px; }
.progress .bar { height: 6px; border-radius: 3px; background: var(--secondary-bg); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: linear-gradient(90deg, #f48fb1, #f06292); border-radius: 3px; }
.progress small { display: block; font-size: 12.5px; color: var(--hint); margin-top: 6px; }
.promo { display: flex; gap: 8px; padding: 10px 12px; }
.promo input { flex: 1; height: 40px; border-radius: 10px; border: 0; background: var(--secondary-bg); padding: 0 12px; outline: none; }
.promo button { padding: 0 14px; border-radius: 10px; background: color-mix(in srgb, var(--button) 14%, transparent); color: var(--accent); font-weight: 700; }
.promo-msg { font-size: 12.5px; padding: 0 16px 10px; }
.promo-msg.ok { color: #34c759; }
.promo-msg.err { color: var(--destructive); }

/* ---------- Оформление ---------- */
.field { padding: 8px 16px; position: relative; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separator); }
.field label { display: block; font-size: 12.5px; color: var(--hint); margin-bottom: 2px; }
.field input, .field textarea { width: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; padding: 2px 0 3px; resize: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--hint); opacity: .7; }
.field.err label { color: var(--destructive); }
.err-text { color: var(--destructive); font-size: 12.5px; margin: -6px 28px 8px; }
.tabs2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--secondary-bg); border-radius: 10px; padding: 2px; margin: 0 12px 12px; }
html.theme-dark .tabs2 { background: #0e1621; }
.tabs2 button { height: 34px; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--hint); }
.tabs2 button.active { background: var(--section-bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
html:not(.theme-dark) .tabs2 { background: #e4e4ea; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 12px 12px; }
.slots button { height: 40px; border-radius: 10px; background: var(--secondary-bg); font-weight: 700; font-size: 13.5px; border: 1.5px solid transparent; }
.slots button.active { border-color: var(--button); color: var(--accent); background: color-mix(in srgb, var(--button) 12%, var(--section-bg)); }
.slots button:disabled { opacity: .4; text-decoration: line-through; }
.days { display: flex; gap: 8px; padding: 12px 12px 4px; }
.days button { flex: 1; border-radius: 10px; padding: 7px 0; background: var(--secondary-bg); border: 1.5px solid transparent; }
.days button b { display: block; font-size: 14px; }
.days button span { font-size: 12px; color: var(--hint); }
.days button.active { border-color: var(--button); background: color-mix(in srgb, var(--button) 12%, var(--section-bg)); }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--hint); flex: none; position: relative; }
.radio.on { border-color: var(--button); }
.radio.on::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--button); }

/* ---------- Заказ принят ---------- */
.done { text-align: center; padding: 34px 24px 10px; }
.done .check { width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 50%; background: linear-gradient(135deg, #5fd38a, #34c759); display: grid; place-items: center; box-shadow: 0 10px 30px rgba(52,199,89,.35); animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
.done .check svg { width: 48px; height: 48px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.done h1 { font-size: 24px; margin: 0 0 6px; }
.done p { color: var(--subtitle); margin: 0 auto; max-width: 300px; font-size: 15px; }
.order-no { display: inline-block; margin-top: 14px; padding: 6px 14px; border-radius: 10px; background: var(--section-bg); font-weight: 800; letter-spacing: .5px; }
.timeline { padding: 6px 16px 10px; }
.tl { display: flex; gap: 12px; position: relative; padding: 8px 0; }
.tl .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--separator); margin-top: 3px; flex: none; position: relative; z-index: 1; }
html.theme-dark .tl .dot { background: #34475a; }
.tl.on .dot, html.theme-dark .tl.on .dot { background: #34c759; box-shadow: 0 0 0 4px rgba(52,199,89,.2); }
.tl:not(:last-child)::after { content: ""; position: absolute; left: 6px; top: 22px; bottom: -6px; width: 2px; background: var(--separator); }
html.theme-dark .tl:not(:last-child)::after { background: #34475a; }
.tl b { display: block; font-size: 14.5px; }
.tl small { color: var(--hint); font-size: 12.5px; }
.sec-btn { display: block; width: calc(100% - 24px); margin: 0 12px; height: 46px; border-radius: 12px; background: var(--section-bg); color: var(--link); font-weight: 700; }

/* ---------- MainButton (эмуляция вне Telegram) ---------- */
.main-btn-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; padding: 10px 12px 26px; background: linear-gradient(to top, var(--secondary-bg) 70%, transparent); z-index: 40; }
.main-btn { width: 100%; height: 52px; border-radius: 13px; background: var(--button); color: var(--button-text); font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.main-btn .pill { background: rgba(255,255,255,.22); border-radius: 8px; padding: 2px 8px; font-size: 14px; }
.main-btn:disabled { opacity: .55; }
.main-btn-wrap.hidden { display: none; }
body.in-telegram .main-btn-wrap { display: none; }

.toast { position: fixed; left: 50%; top: 120px; transform: translate(-50%, -10px); background: rgba(30,30,30,.9); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; transition: .25s; pointer-events: none; z-index: 60; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
