/* 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;
  /* A11y-2 (audit 2026-05-29): #1e88e5 на #fff = 3.67:1 — WCAG AA fail.
   * Сдвинули на #1565c0 (5.06:1). SSR-вариант parity с shared/styles.css. */
  --accent: #1565c0;
  --accent-hover: #4ba3ee;
  --accent-bg: rgba(21, 101, 192, 0.14);
  --success: #3fb984;
  --success-bg: rgba(63, 185, 132, 0.12);
  --error: #ef6f6f;
  --error-bg: rgba(239, 111, 111, 0.12);
  /* =====================================================================
   * Strength taxonomy — MIRROR с webapp/src/shared/styles.css
   * (parity gate: tools/check-css-strength-parity.sh).
   * Saarinen §B WCAG AA verified palette — НЕ ИЗМЕНЯТЬ без re-run axe.
   * mild 6.3:1 · medium 8.4:1 · strong 6.1:1 на --bg-input #1b1b1e.
   * ===================================================================== */
  --strength-mild-bg: #1f2a1f;
  --strength-mild-fg: #7dd394;
  --strength-medium-bg: #2b2718;
  --strength-medium-fg: #e6c266;
  --strength-strong-bg: #2b1d1d;
  --strength-strong-fg: #f08a8a;
  --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 {
  /* Android Chrome / TG-Android WebView: блокируем text autosizing
     (страница уже mobile-ready через viewport, но defensive reset
     против "зум поплыл" в Telegram WebView). */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
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; }
/* iOS Safari / TG-iOS WebView auto-zoom при focus на input <16px — юзер залипает
   на zoom-in и не может закончить checkout. Принудительно 16px глобально.
   Parity с webapp/src/shared/styles.css:121 (SPA equivalent, фикс 6c6ae48). */
input, textarea, select { font-size: 16px; }
.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;
  /* A11y: --label-faint (#6b727c → 3.75:1 на #151517) — axe SERIOUS.
   * Bumped до --label-muted (#9aa1ab → 5.13:1) — parity с SPA fix. */
  font-size: 11px; color: var(--label-muted);
  gap: var(--sp-1); text-decoration: none;
}
.bottom-nav a.active { color: var(--accent-hover); }
.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 {
  /* Warm sage-green focus — на-brand (parity со strength-mild chip),
   * визуально отличается от default browser blue (user feedback 2026-05-31).
   * WCAG 2.4.7 focus visibility сохраняется. */
  border-color: var(--strength-mild-fg);
  box-shadow: 0 0 0 2px rgba(125, 211, 148, 0.18);
}
/* Kill default browser focus on input — иначе iOS/Android рисует синий
 * outline ВНУТРИ bar поверх нашего focus-within indicator. */
.search-input:focus,
.search-input:focus-visible {
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.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: 16px;
  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; }
.category-chip-clearance {
  background: linear-gradient(90deg, #d8a350 0%, #ef6f6f 100%);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.category-chip-clearance.active {
  background: linear-gradient(90deg, #c89340 0%, #df5f5f 100%);
  border-color: transparent;
}

.clearance-banner {
  margin: var(--sp-3) var(--sp-3) var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: linear-gradient(135deg, rgba(216, 163, 80, 0.12) 0%, rgba(239, 111, 111, 0.10) 100%);
  border: 1px solid rgba(239, 111, 111, 0.30);
  border-radius: var(--r-md);
}
.clearance-banner-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--label-strong, #fff);
  margin-bottom: var(--sp-1);
}
.clearance-banner-text {
  margin: 0;
  font-size: 13px;
  color: var(--label-muted);
  line-height: 1.5;
}

.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: var(--sp-3);
}
/* Desktop responsive — порядок после baseline критичен (cascade).
 * Раньше эти rules отсутствовали в SSR CSS → desktop всегда 2 columns.
 * Visualqa report 30.05.2026 — P2. */
@media (min-width: 1024px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1440px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}
.product-card-wrap {
  position: relative;
  display: flex; flex-direction: column;
  height: 100%;
}
.product-card {
  background: var(--bg-elevated);
  /* P2 #28: hairline border чтобы card отделялась от page bg #0f0f10
   * (parity с SPA fix). */
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  flex: 1;
  text-decoration: none; color: inherit;
  position: relative;
  transition: border-color var(--motion-fast);
}
.product-card:hover { border-color: var(--border-strong); }

/* Strength chip — Phase 1 (parity с webapp/src/shared/styles.css).
 * Council 2026-05-30-2036 F5+F13+F14: chip в card body, без absolute
 * position над photo (camouflage risk); без animate-in; без dead backdrop. */
.strength-chip {
  display: inline-flex; align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-2);
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.2;
  pointer-events: none; user-select: none;
  align-self: flex-start;
  margin-top: var(--sp-1);
}
.strength-chip--mild { background: var(--strength-mild-bg); color: var(--strength-mild-fg); }
.strength-chip--medium { background: var(--strength-medium-bg); color: var(--strength-medium-fg); }
.strength-chip--strong { background: var(--strength-strong-bg); color: var(--strength-strong-fg); }
/* Saarinen §A — emoji 0.85em чтобы text доминировал (parity с SPA). */
.strength-chip__emoji { display: inline-block; font-size: 0.85em; }

/* Strength filter row — Task 6 (parity с SPA). */
.strength-filter-row {
  display: flex; gap: 6px;
  overflow-x: auto;
  margin: 0 calc(-1 * var(--sp-4)) var(--sp-3);
  padding: 0 var(--sp-4);
}
.product-card-image {
  aspect-ratio: 1; width: 100%; height: 100%;
  object-fit: contain; background: var(--bg-input);
  display: block;
}
/* picture wrapper (responsive WebP) — нужен block + aspect ratio */
.product-card picture { display: block; aspect-ratio: 1; width: 100%; }
.product-card picture img.product-card-image { aspect-ratio: 1; }
.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;
  display: flex; flex-direction: column;
  flex: 1;
}
.product-card-price { margin-top: auto; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.product-card-stock.out { margin-top: auto; }
.product-card-price .old {
  /* A11y: --label-faint #6b727c 3.75:1 → --label-muted #9aa1ab 5.13:1 (parity с SPA). */
  font-size: 13px; color: var(--label-muted);
  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;
}
/* A11y: --label-faint 3.75:1 → --label-muted 5.13:1 (parity с SPA). */
.product-card-stock { margin-top: 4px; font-size: 11px; color: var(--label-muted); }
.product-card-stock.in-stock { color: var(--success); font-weight: 500; }
.product-card-stock.out { color: var(--error); font-weight: 500; }
/* A11y: opacity 0.65 ломал контраст текста stock.out (--error blended →
 * 3.x:1). Grayscale на image + муто-цвет name дают визуальный cue
 * "out-of-stock" без потери текстового контраста. */
.product-card.out-of-stock .product-card-image { filter: grayscale(0.6); }
.product-card.out-of-stock .product-card-name { color: var(--label-muted); }
.product-card-price-muted {
  margin-top: 4px;
  font-size: 13px;
  /* A11y: --label-faint 3.75:1 → --label-muted 5.13:1 на --bg-elevated */
  color: var(--label-muted);
  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; }
/* <picture> wrapper (responsive WebP) — flex child вместо img напрямую */
.product-detail-carousel > picture {
  flex: 0 0 100%;
  aspect-ratio: 1;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  background: var(--bg-input);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: block;
}
.product-detail-carousel > picture img,
.product-detail-carousel > img {  /* fallback для legacy <img> без <picture> */
  width: 100%; height: 100%;
  flex: 0 0 100%;
  aspect-ratio: 1; object-fit: contain;
  background: var(--bg-input);
  border-radius: var(--r-lg);
  display: block;
}

/* 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; justify-content: space-between;
  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; }
.share-link {
  display: inline-flex; align-items: center;
  gap: 4px;
  color: var(--label-muted);
  font-size: 14px; font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.share-link:active { background: var(--bg-elevated); }
.share-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;
  /* WCAG 2.5.5 tap target ≥44px (Saarinen finding council 2026-05-29-1242). */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 12px;
  min-height: 44px;
}
.btn-tertiary:hover { color: var(--label-base); }
.btn-tertiary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-md);
}

/* =====================================================================
 * Radio cards (shipping / payment method) — ported from webapp/shared/styles.css
 * (Saarinen P1 #10 council review 2026-05-29-1242: SSR templates use these
 * classes but app.css didn't define them → browser showed raw HTML radios).
 * ===================================================================== */
.radio-cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.radio-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  min-height: 64px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-hairline);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.radio-card:hover { border-color: var(--label-faint); }
.radio-card:focus-within {
  border-color: var(--accent);
}
/* CSS-only selected state (Chrome 105+, Safari 15.4+, Firefox 121+).
   Без этого radio click меняет input.checked, но .selected класс остаётся
   на server-rendered card — визуальный mismatch выглядит как "моргание". */
.radio-card:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.radio-card:has(input[type="radio"]:checked) .radio-card-sub {
  color: var(--label-base);
  opacity: 0.85;
}

.radio-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.radio-card.selected .radio-card-sub {
  color: var(--label-base);
  opacity: 0.85;
}
.radio-card input[type="radio"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.radio-card-body { flex: 1; min-width: 0; }
.radio-card-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.radio-card-sub {
  font-size: 12px;
  color: var(--label-muted);
  margin-top: 2px;
}
.radio-card-price {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Pill — small status badge (delivery free, on-sale, etc) */
.pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Field error/helper messages (under inputs) */
.field-error {
  font-size: 12px;
  font-weight: 500;
  color: var(--error);
  margin-top: 4px;
}
.field-helper {
  font-size: 12px;
  color: var(--label-faint);
  margin-top: 4px;
}

/* =====================================================================
 * Global focus-visible (a11y P1 #6 council review 2026-05-29-1242).
 * Modern browsers apply this only for keyboard-induced focus, not mouse.
 * Mouse-clicks still see clean borders (existing :focus border-accent).
 * ===================================================================== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-md);
}
.cta-button:focus-visible,
.btn-secondary:focus-visible,
.radio-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-bg), 0 0 0 5px var(--accent);
}

/* =====================================================================
 * Reduced motion (a11y P2 #27 council review).
 * Respects iOS Settings → Accessibility → Motion / Windows reduced motion.
 * ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 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: 16px;
  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); }
.empty-state-actions {
  display: flex; gap: var(--sp-2); flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--sp-4);
}
.empty-state-actions > * { flex: 0 1 auto; }
.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;
  /* A11y: 11px + --label-faint 3.94:1 на --bg-base → fail. 12px + --label-muted
   * 5.13:1 → AA pass. Parity с SPA fix. */
  text-align: center; font-size: 12px; color: var(--label-muted);
  line-height: 1.6;
}
.trust-footer a {
  color: var(--accent-hover, #4ba3ee);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.trust-footer .bot-handle {
  /* A11y: --accent (dark blue) 3.33:1 на dark surface → fail.
   * --accent-hover (bright blue) ~9:1 → AA pass. */
  color: var(--accent-hover, #4ba3ee); 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; }

/* ====== Smooth reveal for accordion sections (checkout shipping) ======
 * JS toggles `.is-hidden` класс вместо `display: none`. CSS transitions
 * работают на opacity + max-height (не display), и юзер видит плавное
 * раскрытие/сворачивание вместо «моргания». 800px max-height — sufficient
 * для самого длинного блока (city + pvz-map + pvz-list). */
#address-fields,
#pvz-block,
#courier-fields {
  overflow: hidden;
  max-height: 1200px;
  opacity: 1;
  transition: opacity 220ms ease, max-height 280ms ease;
}
#address-fields.is-hidden,
#pvz-block.is-hidden,
#courier-fields.is-hidden {
  max-height: 0 !important;
  opacity: 0;
  pointer-events: none;
  /* Используем margin/padding clamp чтобы collapsed-state не давал доп. зазор */
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* ====== Extracted token components (council #30 Saarinen) ======
 * Раньше эти паттерны повторялись inline `style="..."` через 4-5 templates,
 * обходя token system. Каждый рefactor темы рисковал десинхронизацией.
 * Теперь — одна точка контроля. */

/* Центрированная статусная панель (order_pending success/error/canceled cards). */
.status-panel {
  text-align: center;
  padding: 40px 24px;
  background: var(--bg-modal);
  border-radius: var(--r-lg);
}

/* Круглая иконка статуса 72×72 + emoji/символ внутри. */
.status-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--label-muted);
}
.status-icon--success { background: var(--success-bg); color: var(--success); }
.status-icon--error   { background: var(--error-bg);   color: var(--error);   }

/* Order-number mono. Используется на success/pending/canceled screens. */
.order-code-mono {
  font-family: ui-monospace, monospace;
  font-size: 16px;
  color: var(--label-muted);
  margin-bottom: 16px;
}
.order-code-mono.is-copyable {
  user-select: all;
  cursor: text;
}

/* Заголовок-метка секции в форме — uppercase muted lettering. */
.section-label {
  margin: var(--sp-5) 0 var(--sp-3);
  font-size: 14px;
  color: var(--label-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Help-paragraph текст 13px фейнтым цветом. */
.help-text {
  font-size: 13px;
  color: var(--label-faint, #6b727c);
}

/* 152-ФЗ consent checkbox row. */
.consent-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
  align-items: flex-start;
}
.consent-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  accent-color: var(--accent);
  margin-top: 2px;
}
.consent-row > span {
  font-size: 14px;
  line-height: 1.5;
}
.consent-row a {
  color: var(--accent);
  text-decoration: underline;
}

/* Stuck-payment / generic info banner. */
.info-banner {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  font-size: 13px;
}
.info-banner--error {
  background: var(--error-bg);
  color: var(--error);
  border: none;
  text-align: left;
}

/* Подключаемый inline-input — для lookup-формы (order_code, email). */
.text-input {
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-hairline);
  background: var(--bg-input);
  color: var(--label-base);
  width: 100%;
  box-sizing: border-box;
}
.text-input--mono { font-family: ui-monospace, monospace; }

/* Lookup-form column. */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 0 auto;
}

/* Centered status heading (rendered with H2/H3 — controls margin/size). */
.status-heading {
  font-size: 22px;
  margin: 0 0 8px;
}
.status-subheading {
  font-size: 16px;
  margin: 0 0 8px;
}

/* Growth Loop Phase 2 — share-set components. */
.alert {
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  margin-bottom: var(--sp-3);
  border: 1px solid var(--border-hairline);
}
.alert--success { background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.3); color: #86efac; }
.alert--warning { background: rgba(234, 179, 8, 0.08); border-color: rgba(234, 179, 8, 0.3); color: #fde68a; }
/* Plan Task 11 — `.alert--danger` modifier для dropped-items banner
 * (товары сняты с продажи: «Мы убрали из корзины»). Reuses existing
 * --error palette (parity с другими error-tinted surfaces). */
.alert--danger { background: rgba(239, 111, 111, 0.08); border-color: rgba(239, 111, 111, 0.3); color: #fda4af; }
/* No-layout-shift hint — banner reserves min-height чтобы CTA position
 * не прыгала между normal-cart и changed-cart rendering. */
.alert { min-height: 42px; }
/* Tight nested list (для dropped-items имён) — overrides browser default
 * 16-32px vertical padding которое разрывает banner visually. */
.alert-list { margin: 4px 0 0 0; padding-left: 20px; }
.alert-strong { display: block; margin-bottom: 2px; }

/* Plan Task 11 — stock-state badges. `.stock-badge--out` reuses
 * --strength-strong palette (warm red WCAG AA on --bg-input).
 * `.stock-badge--low` reuses --strength-medium (warm amber) для 1-2 шт.
 * Sentence case copy («Нет в наличии» / «Осталось N шт») — friedman uniformity. */
.stock-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--r-md);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-top: 4px;
}
.stock-badge--out {
  background: var(--strength-strong-bg);
  color: var(--strength-strong-fg);
}
.stock-badge--low {
  background: var(--strength-medium-bg);
  color: var(--strength-medium-fg);
}

/* Plan Task 11 — OOS cart row demote. Не красный border / красный bg
 * — desaturate (parity с .product-card.out-of-stock) + муто-цвет text.
 * Stepper disabled через opacity + pointer-events; «Удалить» остаётся
 * enabled at full opacity (escape hatch — friedman recovery vocabulary). */
.cart-row--oos {
  filter: grayscale(0.6);
}
.cart-row--oos .cart-row-name,
.cart-row--oos .cart-row-variant {
  color: var(--label-muted);
}
.cart-row--oos .qty-form {
  opacity: 0.4;
  pointer-events: none;
}

/* Plan Task 11 — «Удалить» promoted из inline-styled 13px no-padding до
 * .btn-tertiary; tap-target ≥44pt (WCAG 2.5.5). Hover sweeps к --error
 * (юзер видит «удалю»). :focus-visible inherits от .btn-tertiary. */
.cart-remove-form { margin: 0; }
.cart-remove-btn {
  font-size: 14px;
  color: var(--label-muted);
}
.cart-remove-btn:hover { color: var(--error); }

/* Order-summary inline notice (под «Оформить заказ» когда CTA disabled). */
.order-summary-note {
  color: var(--label-muted);
  font-size: 13px;
}

/* Plan Task 11 — refactor inline styles из cart.html в class-based
 * tokens (Saarinen «0 new inline style=» audit). Каждый класс — 1:1
 * с прежним inline style чтобы visual diff был нулевой.
 *
 * Saarinen R9 (Council 2026-06-03-2345): token-reuse minimization —
 * promo input наследует .field input semantics, разница только в form
 * layout (flex row vs vertical stack); share form margin = sp-3 + 2px
 * sentinel чтобы CTA не лип вплотную. */
.qty-btn--disabled { opacity: 0.4; }
.promo-form {
  display: flex;
  gap: 8px;
  margin: var(--sp-4) 0;
}
.promo-input {
  flex: 1;
  text-transform: uppercase;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  color: var(--label-base);
  font-size: 15px;
}
.cta-button--mt { margin-top: var(--sp-4); }
.share-form--mt { margin-top: 14px; }

.share-form {
  display: flex; flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
}
.share-form-label {
  font-size: 13px; color: var(--label-muted);
}
.share-form-title {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  color: var(--label-base);
  font-size: 15px;
}
.share-form-submit { margin-top: 4px; }

.share-link-box {
  margin: 0 0 16px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
}
.share-link-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  color: var(--label-base);
  font-size: 13px;
  font-family: ui-monospace, monospace;
  box-sizing: border-box;
}
.share-link-hint {
  font-size: 12px; color: var(--label-muted);
  margin-top: 6px; text-align: center;
}

.share-preview-header {
  margin-bottom: var(--sp-3);
}
.share-preview-title {
  font-size: 20px; margin: 0 0 8px;
  color: var(--label-base);
}
.share-preview-aggregate {
  font-size: 13px; color: var(--label-muted);
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.share-preview-items { display: flex; flex-direction: column; gap: 10px; }
.share-preview-item--unavail { opacity: 0.55; }

/* Growth Loop Phase 3 — Quiz «Подбор под состояние». */
.quiz-intro {
  text-align: center;
  padding: var(--sp-6) var(--sp-4) var(--sp-4);
}
.quiz-intro-emoji { font-size: 56px; margin-bottom: var(--sp-3); }
.quiz-intro-title { font-size: 22px; margin: 0 0 var(--sp-3); color: var(--label-base); }
.quiz-intro-lead { color: var(--label-muted); font-size: 15px; line-height: 1.5; margin: 0 0 var(--sp-4); }
.quiz-intro-features {
  list-style: none;
  padding: 0; margin: 0 0 var(--sp-4);
  text-align: left;
  display: inline-block;
}
.quiz-intro-features li {
  padding: 6px 0 6px 24px;
  position: relative;
  color: var(--label-muted);
  font-size: 14px;
}
.quiz-intro-features li::before {
  content: "✓";
  position: absolute; left: 0; top: 6px;
  color: var(--strength-mild-fg);
  font-weight: 700;
}

.quiz-progress {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: var(--sp-4);
}
.quiz-progress-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-hairline);
}
.quiz-progress-dot.done { background: var(--strength-mild-fg); }
.quiz-progress-dot.current {
  background: var(--strength-mild-fg);
  box-shadow: 0 0 0 3px rgba(125, 211, 148, 0.18);
}
.quiz-progress-label {
  margin-left: auto;
  font-size: 13px;
  color: var(--label-muted);
}

.quiz-step-question {
  font-size: 19px;
  margin: 0 0 var(--sp-4);
  color: var(--label-base);
  line-height: 1.3;
}

.quiz-options {
  display: flex; flex-direction: column;
  gap: 10px;
}
.quiz-option {
  display: flex; align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast);
}
.quiz-option:hover { border-color: var(--label-muted); }
.quiz-option:has(input:checked) {
  border-color: var(--strength-mild-fg);
  background: rgba(125, 211, 148, 0.06);
}
.quiz-option input[type="radio"] { display: none; }
.quiz-option-emoji { font-size: 22px; flex-shrink: 0; }
.quiz-option-label { font-size: 15px; color: var(--label-base); }

.quiz-results-header {
  text-align: center;
  padding: var(--sp-4) 0;
}
.quiz-results-emoji { font-size: 40px; margin-bottom: 8px; }
.quiz-results-title { font-size: 22px; margin: 0 0 6px; color: var(--label-base); }
.quiz-results-subtitle { color: var(--label-muted); font-size: 14px; margin: 0 0 var(--sp-3); }

.quiz-matches { display: flex; flex-direction: column; gap: 10px; }
.quiz-match {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  padding: 12px;
}
.quiz-match-card {
  display: flex; gap: 12px;
  text-decoration: none; color: inherit;
}
.quiz-match-img {
  width: 80px; height: 80px;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--bg-input);
  flex-shrink: 0;
}
.quiz-match-info { flex: 1; min-width: 0; }
.quiz-match-name { font-size: 15px; font-weight: 500; color: var(--label-base); margin-bottom: 4px; }
.quiz-match-reason { font-size: 13px; color: var(--label-muted); margin-bottom: 6px; line-height: 1.4; }
.quiz-match-price { font-size: 16px; font-weight: 600; color: var(--label-base); }
.quiz-match-take-form { margin: 10px 0 0; }
.quiz-match-take { width: 100%; }
.quiz-results-actions { margin-top: var(--sp-4); display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.quiz-results-actions .btn-tertiary { text-align: center; }
