/* View Transitions API убраны 2026-05-22: на Android TG WebView (Huawei) при
 * навигации с `@view-transition { navigation: auto }` происходил crash WebView
 * → TG показывал утку "Ошибка не удалось загрузить" при тапе на любую
 * <a href>-ссылку. Возможно WebView не успевал сделать snapshot transition'а
 * до того как TG-launcher тайм-аутил pre-flight check. Безопаснее без них. */

/* Design tokens — Phase 3 SSR. Single CSS file inlined в head базы. */
:root {
  --bg-base: #0f0f10;
  --bg-elevated: #151517;
  --bg-input: #1b1b1e;
  --bg-modal: #222226;
  --border-hairline: rgba(255, 255, 255, 0.08);
  --label-base: #e9edf2;
  --label-muted: #9aa1ab;
  --label-faint: #6b727c;
  --accent: #1e88e5;
  --accent-bg: rgba(30, 136, 229, 0.12);
  --success: #3fb984;
  --success-bg: rgba(63, 185, 132, 0.12);
  --error: #ef6f6f;
  --error-bg: rgba(239, 111, 111, 0.12);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-md: 8px; --r-lg: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100vh;
  background: var(--bg-base); color: var(--label-base);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter",
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  /* Block TG Android pull-to-refresh ("Не удалось загрузить <bot>"). `none`
   * — самая жёсткая защита: даже на самом верху страницы pull-down НЕ
   * пробрасывается до TG-контейнера. `contain` оказался недостаточен —
   * Android TG продолжал ловить gesture. JS-handler в app.js — дополнительный
   * fallback для WebView без overscroll-behavior support. */
  overscroll-behavior: none;
}
/* Visual feedback на тап — без этого юзер не понимает что тап сработал. */
.product-card, .category-chip, .variant-chip, .cta-button, .btn-secondary, .qty-btn {
  -webkit-tap-highlight-color: rgba(30, 136, 229, 0.15);
  touch-action: manipulation;
}
.product-card:active, .category-chip:active, .cta-button:active {
  opacity: 0.7;
  transform: scale(0.98);
  transition: transform 80ms, opacity 80ms;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
.tnum { font-variant-numeric: tabular-nums; }

.app {
  display: flex; flex-direction: column;
  min-height: 100vh; max-width: 720px;
  margin: 0 auto; padding-bottom: 72px;
}
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-hairline);
  padding: var(--sp-3) var(--sp-4);
}
.app-header h1 { margin: 0; font-size: 18px; font-weight: 600; }
.app-main { flex: 1; padding: var(--sp-4); }

.bottom-nav {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 720px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-hairline);
  display: flex; height: 64px; z-index: 9;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 11px; color: var(--label-faint);
  gap: var(--sp-1); text-decoration: none;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav .icon { font-size: 20px; }
.bottom-nav .nav-icon {
  width: 22px; height: 22px;
  display: block;
}
.bottom-nav .nav-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cart-badge {
  position: absolute;
  top: -6px; right: -10px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--accent); color: #fff;
  border-radius: 999px;
  font-size: 10px; font-weight: 700; line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-elevated);
}

/* Search bar */
.search-bar {
  position: relative;
  display: flex; align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-3);
  height: 40px;
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.search-icon {
  width: 18px; height: 18px;
  color: var(--label-faint);
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  background: transparent; border: 0; outline: 0;
  color: var(--label-base);
  font-size: 15px;
  padding: 0 var(--sp-2);
  height: 100%;
  min-width: 0;
}
.search-input::placeholder { color: var(--label-faint); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-modal);
  color: var(--label-muted);
  border-radius: 999px;
  font-size: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

/* Catalog header (Категории — Все категории + sort) */
.catalog-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
  min-height: 28px;
}
.catalog-header-title {
  margin: 0;
  font-size: 13px; font-weight: 500;
  color: var(--label-muted);
  letter-spacing: 0.01em;
}
.catalog-header-sep { color: var(--label-faint); margin: 0 2px; }
.catalog-header-current { color: var(--label-base); font-weight: 600; }
.sort-form { margin: 0; }
.sort-label {
  display: inline-flex; align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  padding: 4px 4px 4px 10px;
  cursor: pointer;
}
.sort-icon {
  width: 14px; height: 14px;
  color: var(--label-muted);
}
.sort-select {
  background: transparent; border: 0; outline: 0;
  color: var(--label-base);
  font-size: 12px; font-weight: 500;
  appearance: none; -webkit-appearance: none;
  padding: 2px 18px 2px 4px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' fill='none' stroke='%239aa1ab' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 10px 10px;
}
.sort-select option { background: var(--bg-elevated); color: var(--label-base); }

/* Catalog grid */
.category-chips {
  display: flex; gap: 6px;
  overflow-x: auto;
  margin: 0 calc(-1 * var(--sp-4)) var(--sp-4);
  padding: 0 var(--sp-4);
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  /* Mask = градиент-фейд на правом крае — намёк "там ещё есть". */
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
          mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
}
.category-chips::-webkit-scrollbar { display: none; }
.category-chip {
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  font-size: 12.5px; color: var(--label-base);
  line-height: 1.4;
  white-space: nowrap;
  scroll-snap-align: start;
  scroll-margin-left: var(--sp-4);
  text-decoration: none;
}
.category-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}
.product-card-wrap {
  position: relative;
  display: flex; flex-direction: column;
}
.product-card {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  position: relative;
}
.product-card-image {
  aspect-ratio: 1; width: 100%;
  object-fit: contain; background: var(--bg-input);
}
.product-card-dots {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% / 2 + 22%);
  display: flex; justify-content: center;
  gap: 4px;
  pointer-events: none;
}
.product-card-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.product-card-dots span:first-child { background: #fff; }

.favorite-form { margin: 0; }
.favorite-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(20, 20, 22, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
}
.favorite-btn svg { width: 18px; height: 18px; }
.favorite-btn.is-fav { color: #ef4868; }
.favorite-btn:active { transform: scale(0.92); transition: transform 80ms; }
.product-card-body { padding: 10px var(--sp-3) 14px; }
.product-card-price { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.product-card-price .old {
  font-size: 13px; color: var(--label-faint);
  text-decoration: line-through; margin-left: 6px;
}
.product-card-name {
  margin-top: 4px; font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.product-card-stock { margin-top: 4px; font-size: 11px; color: var(--label-faint); }
.product-card-stock.in-stock { color: var(--success); font-weight: 500; }
.product-card-stock.out { color: var(--error); font-weight: 500; }
.product-card.out-of-stock { opacity: 0.65; }
.product-card.out-of-stock .product-card-image { filter: grayscale(0.4); }
.product-card-price-muted {
  margin-top: 4px;
  font-size: 13px;
  color: var(--label-faint);
  font-variant-numeric: tabular-nums;
  text-decoration: line-through;
}

/* Stepper visual (council reco — голый текст без визуала) */
.checkout-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0 var(--sp-4);
  font-size: 13px;
  color: var(--label-muted);
}
.checkout-stepper::before, .checkout-stepper::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-hairline);
  max-width: 60px;
}

/* Product detail */
.product-detail { display: flex; flex-direction: column; gap: var(--sp-4); }
.product-detail-carousel {
  display: flex; overflow-x: auto;
  gap: var(--sp-2);
  margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-4)) 0;
  padding: 0 var(--sp-4);
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scroll-padding: 0 var(--sp-4);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.product-detail-carousel::-webkit-scrollbar { display: none; }
.product-detail-carousel img {
  width: 100%; flex: 0 0 100%;
  aspect-ratio: 1; object-fit: contain;
  background: var(--bg-input);
  border-radius: var(--r-lg);
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

/* Dots indicator под каруселью — обновляется JS'ом по scroll. */
.carousel-dots {
  display: flex; justify-content: center; gap: 6px;
  margin: var(--sp-2) 0 var(--sp-3);
}
.carousel-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--label-faint);
  opacity: 0.4;
  transition: opacity 150ms, transform 150ms;
}
.carousel-dots span.active {
  background: var(--accent);
  opacity: 1;
  transform: scale(1.3);
}
.product-detail-title { font-size: 20px; font-weight: 600; margin: 0; }
.product-detail-price .current { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.product-detail-price .old {
  font-size: 16px; color: var(--label-faint);
  text-decoration: line-through; margin-left: var(--sp-2);
}
.product-detail-description { color: var(--label-muted); white-space: pre-wrap; }
.product-detail-variants { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.variant-chip {
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  font-size: 14px;
  text-decoration: none; color: var(--label-base);
}
.variant-chip.selected { border-color: var(--accent); background: var(--accent-bg); }
.variant-chip.out-of-stock { opacity: 0.4; text-decoration: line-through; }

/* CTAs */
.cta-button, button.cta-button {
  width: 100%; padding: 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-lg);
  font-size: 16px; font-weight: 600;
  text-align: center; text-decoration: none;
  display: block;
  cursor: pointer;
}
.cta-button[disabled], .cta-button.disabled { background: var(--bg-input); color: var(--label-faint); cursor: not-allowed; }
.btn-secondary {
  padding: 12px 16px;
  background: var(--bg-elevated);
  color: var(--label-base);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  cursor: pointer;
}

/* Cart — simple vertical rows */
.cart-row {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.cart-row-top {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}
.cart-row-img {
  width: 72px; height: 72px;
  object-fit: contain;
  background: var(--bg-input);
  border-radius: var(--r-md);
  flex: 0 0 72px;
}
.cart-row-info { flex: 1; min-width: 0; }
.cart-row-name { font-size: 14px; font-weight: 500; line-height: 1.3; }
.cart-row-variant { font-size: 12px; color: var(--label-muted); margin-top: 4px; }
.cart-row-price {
  font-size: 16px; font-weight: 600;
  margin-top: var(--sp-2);
  font-variant-numeric: tabular-nums;
}
.cart-row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-hairline);
}
.qty-form { display: inline-flex; align-items: center; gap: var(--sp-2); margin: 0; }

/* Inline stepper on product detail (perimeter buttons + numeric input) */
.qty-stepper {
  display: inline-flex; align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  padding: 4px;
}
.qty-stepper .qty-btn {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 0;
  font-size: 20px; font-weight: 500;
}
.qty-value {
  width: 44px;
  background: transparent; border: 0; outline: 0;
  color: var(--label-base);
  text-align: center;
  font-size: 16px; font-weight: 600;
  -moz-appearance: textfield;
}
.qty-value::-webkit-inner-spin-button,
.qty-value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.product-detail-add { display: flex; flex-direction: column; align-items: stretch; }

/* Cart-added toast — баннер сверху после "Добавить в корзину". */
.cart-toast {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--success);
  border-radius: var(--r-lg);
  padding: 10px var(--sp-3);
  margin-bottom: var(--sp-3);
  box-shadow: 0 8px 24px rgba(63, 185, 132, 0.18);
  animation: toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cart-toast.is-dismissed {
  animation: toast-out 200ms ease-in forwards;
}
.cart-toast-check {
  width: 22px; height: 22px;
  color: var(--success);
  flex-shrink: 0;
}
.cart-toast-text {
  display: flex; flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}
.cart-toast-text strong { font-size: 14px; font-weight: 600; color: var(--label-base); }
.cart-toast-text span { font-size: 12px; color: var(--label-muted); }
.cart-toast-link {
  color: var(--accent); font-size: 13px; font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-bg);
}
.cart-toast-close {
  background: transparent; border: 0;
  color: var(--label-muted);
  font-size: 22px; line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  flex-shrink: 0;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px); max-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border: 0; }
}

/* Back-link top bar on product detail */
.product-detail-topbar {
  display: flex; align-items: center;
  margin: 0 calc(-1 * var(--sp-4)) var(--sp-3);
  padding: 4px var(--sp-4) var(--sp-2);
}
.back-link {
  display: inline-flex; align-items: center;
  gap: 4px;
  color: var(--label-muted);
  font-size: 14px; font-weight: 500;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  text-decoration: none;
}
.back-link:active { background: var(--bg-elevated); }
.back-link svg { width: 18px; height: 18px; }
.qty-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  color: var(--label-base);
  font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.qty-num {
  min-width: 32px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.btn-tertiary {
  background: transparent;
  border: none;
  color: var(--label-faint);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 12px;
}

/* Order summary */
.order-summary {
  background: var(--bg-elevated); border-radius: var(--r-lg);
  padding: var(--sp-4); margin-bottom: var(--sp-5);
}
.order-summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.order-summary-row.muted { color: var(--label-muted); }
.order-summary-row.discount { color: var(--success); }
.order-summary-total {
  margin-top: var(--sp-2); padding-top: var(--sp-3);
  border-top: 1px solid var(--border-hairline);
  display: flex; justify-content: space-between;
  font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field label { font-size: 12px; font-weight: 500; color: var(--label-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  color: var(--label-base); font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }

/* Empty / errors */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 60px var(--sp-6);
  color: var(--label-muted);
}
.empty-state .emoji { font-size: 56px; margin-bottom: var(--sp-3); }
.empty-state h2 { color: var(--label-base); font-size: 18px; margin: 0 0 var(--sp-2); }
.inline-error {
  margin: var(--sp-2) 0; padding: var(--sp-2) var(--sp-3);
  background: var(--error-bg); border-radius: var(--r-md);
  color: var(--error); font-size: 13px;
}

/* Promo */
.promo-applied {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--success-bg); border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}

/* Trust footer */
.trust-footer {
  margin-top: var(--sp-6); padding: var(--sp-3) 0;
  text-align: center; font-size: 11px; color: var(--label-faint);
  line-height: 1.6;
}
.trust-footer a { color: var(--label-muted); text-decoration: underline; }
.trust-footer .bot-handle {
  color: var(--accent); font-weight: 500;
  text-decoration: none;
}
.trust-footer-sep { margin: 0 4px; color: var(--label-faint); }

.muted { color: var(--label-muted); }
.faint { color: var(--label-faint); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.center { text-align: center; }
