/* ===== ЦВЕТА: в Telegram берутся из темы пользователя, в браузере — запасные ===== */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #15171f);
  --hint: var(--tg-theme-hint-color, #8a8f9e);
  --accent: var(--tg-theme-button-color, #5b5bf0);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --danger: #e5484d;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) { --bg: #121420; --text: #eef0fa; --hint: #8e94b0; --card: #1d2033; --accent: #7c7cff; }
}

/* ===== БАЗА ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body.locked { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: var(--text); }
h1, h2 { margin: 0; line-height: 1.2; }
.tg .only-web { display: none; }

/* ===== ШАПКА КАТАЛОГА ===== */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 16px 10px; }
.top__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.top h1 { font-size: 1.35rem; font-weight: 800; }
.cart-btn { position: relative; width: 44px; height: 44px; border-radius: 50%; background: var(--card); font-size: 1.25rem; }
.cart-btn__count { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.search { width: 100%; padding: 11px 14px; border-radius: 12px; border: 0; background: var(--card); outline: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-top: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 999px; background: var(--card); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.chip.is-active { background: var(--accent); color: var(--accent-text); }

/* ===== СЕТКА ТОВАРОВ ===== */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 12px; padding: 4px 16px 110px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card { text-align: left; display: flex; flex-direction: column; gap: 4px; animation: fade .3s ease both; }
.card__img, .pimg, .line__img { position: relative; overflow: hidden; background: var(--card); }
.card__img { aspect-ratio: 4 / 5; border-radius: var(--radius); }
.card__img img, .pimg img, .line__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:active .card__img { transform: scale(.97); }
.card__img { transition: transform .15s; }
.card__title { font-weight: 600; font-size: .92rem; margin-top: 4px; }
.card__price { font-weight: 800; }
.card.is-out { opacity: .55; }
.badge { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.noimg { width: 100%; height: 100%; display: grid; place-items: center; font-size: 2.4rem; }
.loader, .empty { grid-column: 1 / -1; text-align: center; color: var(--hint); padding: 48px 0; }
.empty small { display: block; margin-top: 4px; }

/* ===== КАРТОЧКА ТОВАРА ===== */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fadeIn .2s ease; }
.sheet__panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding-bottom: 110px; animation: up .28s cubic-bezier(.2, .8, .2, 1); }
.sheet__grip { width: 40px; height: 5px; border-radius: 3px; background: var(--hint); opacity: .4; margin: 8px auto; }
.pimg { aspect-ratio: 1 / 1; max-height: 52vh; margin: 0 16px; border-radius: var(--radius); }
.gallery__track { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 16px; border-radius: var(--radius); }
.gallery__track::-webkit-scrollbar { display: none; }
.gallery__track .pimg { flex: 0 0 100%; margin: 0; scroll-snap-align: center; }
.dots { display: flex; justify-content: center; gap: 6px; padding-top: 10px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--hint); opacity: .35; transition: all .2s; }
.dots span.is-active { width: 20px; border-radius: 4px; background: var(--accent); opacity: 1; }
.pbody { padding: 16px; }
.pbody h2 { font-size: 1.3rem; font-weight: 800; }
.pprice { font-size: 1.4rem; font-weight: 800; margin: 6px 0 10px; }
.pdesc { color: var(--hint); margin: 0 0 14px; }
.label { font-weight: 700; font-size: .85rem; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 8px; }
.sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.size { min-width: 52px; padding: 10px 14px; border-radius: 12px; background: var(--card); font-weight: 700; }
.size.is-active { background: var(--accent); color: var(--accent-text); }
.out { color: var(--danger); font-weight: 700; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; }
.stepper button { width: 38px; height: 38px; border-radius: 10px; font-size: 1.2rem; font-weight: 700; }
.stepper button:active { background: var(--bg); }
.stepper span { min-width: 28px; text-align: center; font-weight: 800; }
.stepper--sm button { width: 30px; height: 30px; font-size: 1rem; }

/* ===== ЭКРАНЫ: КОРЗИНА И ОФОРМЛЕНИЕ ===== */
.screen { position: fixed; inset: 0; z-index: 15; background: var(--bg); overflow-y: auto; padding: 0 16px 120px; animation: slide .25s ease; }
.screen__head { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; gap: 8px; padding: 16px 0 12px; z-index: 1; }
.screen__head h2 { font-size: 1.3rem; font-weight: 800; }
.back { width: 38px; height: 38px; border-radius: 50%; background: var(--card); font-size: 1.1rem; }
.line { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--card); }
.line__img { width: 72px; height: 90px; border-radius: 12px; }
.line__img .noimg { font-size: 1.6rem; }
.line__title { font-weight: 700; }
.line__meta { color: var(--hint); font-size: .85rem; margin-bottom: 6px; }
.line__sum { font-weight: 800; white-space: nowrap; }
.total { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; font-size: 1.05rem; }
.total b { font-size: 1.3rem; }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.form input { padding: 13px 14px; border-radius: 12px; border: 2px solid transparent; background: var(--card); outline: none; }
.form input:focus { border-color: var(--accent); }
.form input.is-invalid { border-color: var(--danger); }
.form .label { margin: 4px 0 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--card); padding: 4px; border-radius: 14px; }
.seg button { padding: 11px; border-radius: 11px; font-weight: 700; }
.seg button.is-active { background: var(--bg); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.hint { color: var(--hint); margin: 0; }

/* ===== НИЖНЯЯ КНОПКА (браузер) И ВСПЛЫВАШКИ ===== */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.bottom-bar button { width: 100%; padding: 15px; border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 1rem; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 40; background: rgba(20, 22, 32, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; max-width: calc(100% - 32px); text-align: center; animation: fadeIn .2s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
