/*
  HAST — дизайн-система на основе реального логотипа (метал. глубокое вино +
  кремовый) вместо прежней placeholder-концепции "Светлая премиум"
  (молочный/графит/золото). Цвета сэмплированы из brand/*.png — см.
  docs/design-concepts.md, раздел "Реальный бренд".

  Эстетика: тихая роскошь / editorial beauty. Тёплый светлый фон (65–75%
  поверхности крем/беж), вино — акцент на CTA (15–20%), тёмный нейтральный
  текст (~5–10%), розово-винный акцент — редкий (<5%).
*/

:root {
  /* Поверхности — кремово-бежевая семья (сэмплировано с фона логотипа) */
  --color-cream-lightest: #FAF6F1;
  --color-cream: #F4ECE3;
  --color-beige: #DECCBE;
  --color-beige-muted: #A99A90;

  --color-bg: var(--color-cream-lightest);
  --color-surface: #FFFFFF;
  --color-surface-muted: var(--color-cream);
  --color-border: var(--color-beige);

  /* Вино/бордо — сэмплировано с металлического градиента монограммы */
  --color-wine-deepest: #300109;
  --color-wine-dark: #420511;
  --color-wine: #5B0F1E;
  --color-wine-light: #852538;
  --color-wine-soft: #A6485F;

  /* Текст */
  --color-text: #2D2021;
  --color-text-muted: #6B5B54;
  --color-text-on-wine: #FAF6F1;
  --color-accent-text: var(--color-wine);

  /* Статусы */
  --color-status-in-stock: #3F6B4B;
  --color-status-low-stock: #795A22;
  --color-status-preorder: #6B5B54;
  --color-status-out-of-stock: var(--color-beige-muted);
  --color-status-error: #7A2A2A;

  --color-focus: var(--color-wine);

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 2px 14px rgba(45, 32, 33, 0.08);

  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

/* ---------- Тёмная тема (используется в Telegram Mini App: colorScheme=dark) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #211013;
    --color-surface: #2A1519;
    --color-surface-muted: #33191E;
    --color-border: #4A2A30;
    --color-text: var(--color-text-on-wine);
    --color-text-muted: #CBB7B0;
    --color-accent-text: #E3A3B2;
    --shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --color-bg: #211013;
  --color-surface: #2A1519;
  --color-surface-muted: #33191E;
  --color-border: #4A2A30;
  --color-text: var(--color-text-on-wine);
  --color-text-muted: #CBB7B0;
  --color-accent-text: #E3A3B2;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-serif {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

a { color: var(--color-accent-text); text-decoration: none; }
a:hover { color: var(--color-wine-light); text-decoration: underline; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent-text);
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: 16px;
}

/* ---------- Header (base) ---------- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo {
  display: flex;
  align-items: center;
  color: var(--color-text);
}
/* Полная раскладка шапки (utility bar, сетка, поиск, иконки-действия,
   вторая строка навигации, мобильное меню) описана ниже, в разделе
   "Header layout (rebuilt)". */

/* ---------- Icons ---------- */
.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Forms & buttons ---------- */
input, select, textarea, button {
  font: inherit;
  color: inherit;
}
input, select, textarea {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  caret-color: var(--color-accent-text);
  width: 100%;
}
input::placeholder, textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}
select option { background: var(--color-surface); color: var(--color-text); }
input:focus, select:focus, textarea:focus {
  border-color: var(--color-wine);
}
label {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 4px;
  color: var(--color-text-muted);
  font-weight: 600;
}
.field { margin-bottom: 14px; }
.field-error { color: var(--color-status-error); font-size: 0.85rem; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--color-wine);
  color: var(--color-text-on-wine);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--color-wine-light); color: var(--color-text-on-wine); text-decoration: none; }
.btn-primary { background: var(--color-wine); color: var(--color-text-on-wine); }
.btn-outline {
  background: transparent;
  color: var(--color-accent-text);
  border-color: var(--color-wine);
}
.btn-outline:hover { background: var(--color-wine); color: var(--color-text-on-wine); }
.btn-danger { background: var(--color-status-error); color: var(--color-text-on-wine); }
.btn-danger:hover { background: #922f2f; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--color-wine); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-block: 10px; font-size: 0.94rem; }
.alert-success { background: #E7EFE8; color: var(--color-status-in-stock); }
.alert-error { background: #F3E3E3; color: var(--color-status-error); }
.alert-info { background: var(--color-surface-muted); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* ---------- Layout helpers ---------- */
.main-content { padding-block: 32px; min-height: 60vh; }
.section-title { font-size: 1.6rem; margin: 0 0 18px; color: var(--color-text); font-family: var(--font-serif); font-weight: 600; }
section + section { margin-top: 48px; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Category tiles ---------- */
.category-tile {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
}
.category-tile .card-body { align-items: center; text-align: center; padding: 22px 12px; }
.category-tile .card-title { font-family: var(--font-serif); font-size: 1.15rem; }

/* ---------- Product card ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
a.card:hover { box-shadow: 0 6px 22px rgba(45,32,33,0.12); text-decoration: none; }
.card-media {
  aspect-ratio: 4 / 5;
  background: var(--color-surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.card-media img { width: 100%; height: 100%; object-fit: contain; }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: 0.95rem; color: var(--color-text); font-weight: 600; }
.card-price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.price { font-weight: 700; color: var(--color-accent-text); }
.price-old { text-decoration: line-through; color: var(--color-text-muted); font-size: 0.85rem; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--color-wine-soft);
  color: var(--color-text-on-wine);
  align-self: flex-start;
}
.badge-muted { background: var(--color-surface-muted); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge-status-in_stock { background: var(--color-status-in-stock); color: var(--color-text-on-wine); }
.badge-status-low_stock { background: var(--color-status-low-stock); color: var(--color-text-on-wine); }
.badge-status-preorder { background: var(--color-status-preorder); color: var(--color-text-on-wine); }
.badge-status-out_of_stock,
.badge-status-discontinued,
.badge-status-temporarily_unavailable { background: var(--color-surface-muted); color: var(--color-text); border: 1px solid var(--color-border); }

/* ---------- Hero / banner ---------- */
.hero {
  background: linear-gradient(135deg, var(--color-wine-dark), var(--color-wine));
  background-image: url('/static/brand/hero-bg-silk-flower.jpg');
  background-size: cover;
  background-position: 15% 60%;
  color: var(--color-text-on-wine);
  border-radius: var(--radius);
  padding: 56px 24px;
  margin-bottom: 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(33,6,13,0.15) 0%, rgba(33,6,13,0.35) 55%, rgba(24,4,9,0.72) 100%);
  pointer-events: none;
}
.hero > * { position: relative; }
.hero-logo-card {
  background: var(--color-cream-lightest);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.25);
  padding: 18px 16px;
  width: 150px;
  max-width: 44%;
  margin: 0 auto 28px;
}
.hero-logo-img { width: 100%; height: auto; display: block; }
@media (min-width: 640px) {
  .hero-logo-card { width: 180px; padding: 22px 20px; }
  .hero { background-position: center 65%; }
}
.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  color: var(--color-text-on-wine);
}
.hero p { margin: 0 auto 22px; color: var(--color-cream); max-width: 42ch; }
.hero .btn-outline { color: var(--color-text-on-wine); border-color: var(--color-text-on-wine); }
.hero .btn-outline:hover { background: var(--color-text-on-wine); color: var(--color-wine); }

.hero-soft {
  background: var(--color-surface-muted);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
}
.hero-soft h2 { margin: 0 0 10px; }
.hero-soft p { margin: 0 0 18px; color: var(--color-text-muted); }

.brand-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-block: 8px;
  color: var(--color-beige-muted);
}
.brand-divider::before, .brand-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}
.brand-divider img { height: 28px; width: auto; opacity: 0.85; }

.advantages {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (min-width: 700px) { .advantages { grid-template-columns: repeat(4, 1fr); } }
.advantage {
  text-align: center;
  padding: 22px 16px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}
.advantage .icon { width: 28px; height: 28px; color: var(--color-accent-text); margin-bottom: 10px; }
.advantage strong { display: block; margin-bottom: 4px; font-family: var(--font-serif); font-size: 1.05rem; }

/* ---------- Product detail ---------- */
.product-detail {
  display: grid;
  gap: 32px;
  min-width: 0;
}
.product-detail > * { min-width: 0; }
@media (min-width: 800px) {
  .product-detail { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.product-gallery-main {
  aspect-ratio: 4/5;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  position: relative;
}
/* contain, не cover — на карточке товара фото не должно обрезаться по краям,
   как в сетке каталога; если пропорции не квадратные, остаются поля по
   бокам, но весь кадр виден целиком. */
.product-gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.product-gallery-main:focus-visible { outline: 3px solid var(--color-focus); outline-offset: -3px; }
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,0.85);
  color: var(--color-wine);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.gallery-nav-prev { left: 10px; }
.gallery-nav-next { right: 10px; }
.gallery-nav:hover { background: var(--color-wine); color: var(--color-text-on-wine); }
.gallery-zoom-hint {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,0.85);
  color: var(--color-wine);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.gallery-zoom-hint:hover { background: var(--color-wine); color: var(--color-text-on-wine); }
.product-thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.thumb-btn {
  width: 56px; height: 56px; padding: 0;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  overflow: hidden;
  cursor: pointer;
  background: none;
}
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-btn.is-active { border-color: var(--color-wine); }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20,10,11,0.92);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 90vh; object-fit: contain; }
.lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  border-radius: 999px;
  cursor: pointer;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  border-radius: 999px;
  cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.lightbox-nav-prev { left: 16px; }
.lightbox-nav-next { right: 16px; }

.buy-box { display: flex; flex-direction: column; gap: 4px; }
.buy-box h1 { margin: 4px 0 0; }
.qty-stepper { display: flex; align-items: stretch; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; }
.qty-stepper input { border: none; text-align: center; width: 100%; }
.qty-btn { width: 44px; min-width: 44px; min-height: 44px; border: none; background: var(--color-surface-muted); color: var(--color-text); font-size: 1.1rem; cursor: pointer; }
.qty-btn:hover { background: var(--color-border); }

.accordion { border-bottom: 1px solid var(--color-border); padding-block: 12px; }
.accordion summary {
  cursor: pointer;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.1rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: "+"; font-size: 1.3rem; color: var(--color-accent-text); }
.accordion[open] summary::after { content: "−"; }
.specs-list { padding-left: 18px; }
.specs-sku { color: var(--color-text-muted); font-size: 0.85rem; }

.delivery-estimate-box {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 8px;
}
.delivery-estimate-result { margin: 8px 0 0; font-weight: 600; min-height: 1.2em; }
.promo-box {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 14px 0;
}
.promo-box label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.85rem; }
.promo-box input[type="text"] { flex: 1; min-width: 0; }
.promo-result { margin: 8px 0 0; font-weight: 600; min-height: 1.2em; font-size: 0.85rem; }
.favorite-toggle.favorite-toggle--pdp {
  position: static;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--color-wine);
  color: var(--color-accent-text);
  gap: 8px;
  margin-top: 8px;
  font-weight: 600;
  align-self: flex-start;
  max-width: 100%;
}
.favorite-toggle.favorite-toggle--pdp.is-active { background: var(--color-wine); color: var(--color-text-on-wine); }

.sticky-add-bar {
  position: fixed;
  left: 0; right: 0; bottom: 64px;
  z-index: 25;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 14px rgba(45,32,33,0.1);
}
.sticky-add-bar[hidden] { display: none; }
.sticky-add-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.sticky-add-bar-inner > div { display: flex; flex-direction: column; min-width: 0; }
.sticky-add-bar-inner .card-brand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 800px) { .sticky-add-bar { display: none; } }

table.wholesale-table { width: 100%; border-collapse: collapse; margin-block: 12px; }
table.wholesale-table th, table.wholesale-table td {
  border: 1px solid var(--color-border);
  padding: 8px 10px;
  text-align: left;
  font-size: 0.9rem;
}
table.wholesale-table th { background: var(--color-surface-muted); color: var(--color-text); font-family: var(--font-serif); font-weight: 600; }

.variant-options { display: flex; gap: 8px; flex-wrap: wrap; margin-block: 10px; }
.variant-options label {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  margin: 0;
  font-weight: 500;
  color: var(--color-text);
}

/* ---------- Переключатель группы вариантов (отдельные карточки товара,
   объединённые в группу) — компактные плитки, текущий выделен рамкой ---------- */
.variant-group-switcher { margin: 10px 0 14px; }
.variant-group-label { font-size: 0.82rem; color: var(--color-text-muted); margin: 0 0 6px; }
.variant-group-tiles { display: flex; gap: 10px; flex-wrap: wrap; }
.variant-group-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 84px;
  text-align: center;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px;
  color: var(--color-text);
  text-decoration: none;
}
.variant-group-tile:hover { text-decoration: none; border-color: var(--color-border); }
.variant-group-tile.is-current { border-color: var(--color-wine); }
.variant-group-tile img,
.variant-group-tile-noimg {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  display: block;
}
.variant-group-tile-name {
  font-size: 0.74rem;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.variant-group-tile-price { font-size: 0.74rem; font-weight: 600; }

/* ---------- Cart / checkout ---------- */
.cart-row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
.cart-row img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); }
.cart-summary {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}
.checkout-grid { display: grid; gap: 28px; align-items: start; }
@media (min-width: 900px) { .checkout-grid { grid-template-columns: 1.4fr 1fr; } }
@media (min-width: 900px) { .cart-summary[data-cart-summary] { position: sticky; top: 84px; } }

.qty-stepper--cart { width: 120px; flex: 0 0 auto; }
.cart-row-price { font-size: 0.82rem; color: var(--color-text-muted); }
.cart-row-total { min-width: 90px; text-align: right; }
.delivery-note { font-size: 0.86rem; color: var(--color-text-muted); }
.cart-row.is-updating { opacity: 0.5; }
@media (max-width: 640px) {
  .cart-row { flex-wrap: wrap; }
  .cart-row-total { margin-left: auto; }
}

.empty-state, .error-state {
  text-align: center;
  padding: 56px 16px;
  color: var(--color-text-muted);
}
.error-state h1 { color: var(--color-text); }
.loading-state { text-align: center; padding: 24px; color: var(--color-text-muted); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 56px;
  padding-block: 32px;
  background: var(--color-surface-muted);
  font-size: 0.88rem;
  color: var(--color-text-muted);
}
.footer-inner { display: grid; gap: 16px; }
.footer-logo { height: 30px; width: auto; margin-bottom: 10px; }
.footer-tagline {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-accent-text);
  display: block;
  margin-top: 6px;
}
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.footer-inner a { color: var(--color-text-muted); }
.footer-inner a:hover { color: var(--color-accent-text); }
@media (min-width: 900px) {
  .footer-inner { grid-template-columns: 1.2fr 1.4fr 1fr; align-items: start; }
}

/* ---------- Telegram Mini App context ---------- */
body.tg-webapp {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--color-bg);
}
body.tg-webapp .site-header,
body.tg-webapp .site-footer { display: none; }
body.tg-webapp .main-content { padding-block: 16px; }
.miniapp-header {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px 0 4px;
}
body.tg-webapp .miniapp-header { display: flex; }
.miniapp-header img { height: 36px; width: auto; }
.miniapp-mark-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .miniapp-mark-light { display: none; }
  :root:not([data-theme="light"]) .miniapp-mark-dark { display: block; }
}
:root[data-theme="dark"] .miniapp-mark-light { display: none; }
:root[data-theme="dark"] .miniapp-mark-dark { display: block; }

.miniapp-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  transition: opacity 0.35s ease;
  opacity: 1;
}
body.tg-webapp .miniapp-splash { display: flex; }
.miniapp-splash.is-hidden { opacity: 0; pointer-events: none; }
.miniapp-splash img { width: 62%; max-width: 260px; height: auto; }
.miniapp-splash .splash-dark { display: none; }
@media (prefers-reduced-motion: reduce) {
  .miniapp-splash { transition: none; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .miniapp-splash .splash-light { display: none; }
  :root:not([data-theme="light"]) .miniapp-splash .splash-dark { display: inline-block; }
}
:root[data-theme="dark"] .miniapp-splash .splash-light { display: none; }
:root[data-theme="dark"] .miniapp-splash .splash-dark { display: inline-block; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  background: var(--color-wine);
  color: var(--color-text-on-wine);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 8px; text-decoration: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Utility bar ---------- */
.utility-bar { background: var(--color-wine-deepest); color: var(--color-cream); font-size: 0.78rem; }
.utility-bar-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 6px; flex-wrap: wrap; }
.utility-bar-inner a { color: var(--color-cream); font-weight: 600; }
.utility-bar-inner a:hover { color: #fff; }

/* ---------- Header layout (rebuilt) ---------- */
.header-inner {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
}
.mobile-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}
.mobile-menu-toggle .icon { width: 20px; height: 20px; }
.logo-full { height: 46px; width: auto; display: none; }
.logo-mark { height: 36px; width: auto; display: block; }
.search-form {
  display: flex;
  gap: 0;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface);
}
.search-form input { border: none; border-radius: 0; }
.search-form input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--color-wine); }
.search-form button {
  border: none;
  background: var(--color-wine);
  color: var(--color-text-on-wine);
  border-radius: 0;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.search-form button:hover { background: var(--color-wine-light); }
.search-btn-label { display: none; }

.header-actions { display: flex; align-items: center; gap: 4px; }
.header-icon-link {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.66rem;
  font-weight: 600;
}
.header-icon-link:hover { background: var(--color-surface-muted); color: var(--color-accent-text); text-decoration: none; }
.header-icon-link .icon { width: 21px; height: 21px; }
.header-icon-text { display: none; }
.cart-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--color-wine);
  color: var(--color-text-on-wine);
  border-radius: 999px;
  min-width: 16px;
  line-height: 16px;
  text-align: center;
  padding: 0 4px;
  font-size: 0.62rem;
  font-weight: 700;
}

.main-nav { border-top: 1px solid var(--color-border); background: var(--color-surface); }
.main-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  row-gap: 6px;
  column-gap: 22px;
  padding: 10px 0;
  margin: 0;
}
.main-nav a {
  color: var(--color-text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.main-nav a:hover { color: var(--color-accent-text); text-decoration: none; }

@media (max-width: 799px) {
  .main-nav { display: none; }
  .main-nav.is-open { display: block; }
}
@media (min-width: 800px) {
  .mobile-menu-toggle { display: none; }
  .logo-full { display: block; }
  .logo-mark { display: none; }
  .search-btn-label { display: inline; }
  .header-icon-text { display: block; }
  .header-icon-link { flex-direction: column; }
}

/* ---------- Mobile bottom tab bar ---------- */
.mobile-tabbar {
  display: flex;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 14px rgba(45,32,33,0.08);
}
.mobile-tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  color: var(--color-text-muted);
  font-size: 0.64rem;
  font-weight: 600;
  position: relative;
}
.mobile-tabbar a:hover, .mobile-tabbar a.is-active { color: var(--color-accent-text); text-decoration: none; }
.mobile-tabbar .icon { width: 21px; height: 21px; }
.tabbar-cart-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 20px);
  background: var(--color-wine);
  color: var(--color-text-on-wine);
  border-radius: 999px;
  min-width: 15px;
  line-height: 15px;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 700;
}
@media (min-width: 800px) {
  .mobile-tabbar { display: none; }
}
@media (max-width: 799px) {
  body { padding-bottom: 64px; }
  body.tg-webapp { padding-bottom: env(safe-area-inset-bottom, 0); }
  body.tg-webapp .mobile-tabbar { display: none; }
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { margin-bottom: 14px; font-size: 0.82rem; color: var(--color-text-muted); }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; }
.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs a:hover { color: var(--color-accent-text); }
.breadcrumbs .crumb-sep { margin-left: 4px; color: var(--color-beige-muted); }
.breadcrumbs [aria-current="page"] { color: var(--color-text); font-weight: 600; }

/* ---------- Catalog layout: filters + chips + sort ---------- */
.catalog-layout { display: grid; gap: 24px; }
@media (min-width: 900px) { .catalog-layout { grid-template-columns: 240px 1fr; align-items: start; } }
.catalog-sidebar { display: none; }
@media (min-width: 900px) { .catalog-sidebar { display: block; position: sticky; top: 84px; } }

.filters { display: flex; flex-direction: column; gap: 18px; }
.filter-group { border: none; padding: 0; margin: 0; }
.filter-group legend { font-family: var(--font-serif); font-weight: 600; font-size: 1rem; margin-bottom: 8px; padding: 0; }
.filter-check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--color-text); cursor: pointer; min-height: 44px; padding-block: 4px; }
.filter-check input { width: auto; min-width: 18px; min-height: 18px; }
.price-range { display: flex; align-items: center; gap: 8px; }
.price-range input { width: 100%; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm { padding: 8px 16px; min-height: 38px; font-size: 0.86rem; }
.btn-block { width: 100%; }

.filter-drawer-toggle { margin-bottom: 12px; }
@media (min-width: 900px) { .filter-drawer-toggle { display: none; } }

.filter-drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(45,32,33,0.45);
  display: flex;
  justify-content: flex-end;
}
.filter-drawer[hidden] { display: none; }
.filter-drawer-panel {
  background: var(--color-surface);
  width: min(92vw, 360px);
  height: 100%;
  overflow-y: auto;
  padding: 18px;
}
.filter-drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.filter-drawer-close { background: none; border: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--color-text); min-width: 44px; min-height: 44px; }

.active-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}
.chip:hover { background: var(--color-border); text-decoration: none; }
.chip-clear { color: var(--color-accent-text); border-color: var(--color-wine); background: transparent; }
.suggestion-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.sort-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.product-count { margin: 0; color: var(--color-text-muted); font-size: 0.9rem; }
.sort-control { display: flex; align-items: center; gap: 8px; }
.sort-control label { margin: 0; white-space: nowrap; }
.sort-control select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B0F1E' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 10px center;
  background-size: 14px;
  padding-right: 32px;
  border: 1px solid var(--color-border);
  font-weight: 600;
  cursor: pointer;
}
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.pagination-status { color: var(--color-text-muted); font-size: 0.86rem; }

/* ---------- Product card extras ---------- */
.product-card { position: relative; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge-sale { background: var(--color-status-error); }
.card-brand { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.card-variant-hint { font-size: 0.78rem; color: var(--color-text-muted); }
.card-add-form { margin-top: 6px; }
.favorite-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--color-wine);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.favorite-toggle .icon { width: 18px; height: 18px; fill: none; }
.favorite-toggle.is-active { color: var(--color-text-on-wine); background: var(--color-wine); }
.favorite-toggle.is-active .icon { fill: currentColor; }
.favorite-toggle:hover { background: var(--color-wine); color: var(--color-text-on-wine); }

/* ---------- Local placeholder image system (no real photography yet) ----------
   Tonal gradient compositions consistent with the wine/cream brand palette.
   Used wherever a product/category has no real uploaded image — architected so
   a real admin-uploaded image slots in without further template changes. */
.placeholder-media {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
}
/* Явный display:block выше перебивает браузерный [hidden]{display:none} —
   нужен свой явный override (как у .lightbox[hidden] ниже), иначе
   JS-скрытие заглушки при показе фото варианта не сработает. */
.placeholder-media[hidden] { display: none; }
.placeholder-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.35), transparent 55%);
}
.placeholder-media--a { background: linear-gradient(135deg, var(--color-wine-dark), var(--color-wine-soft)); }
.placeholder-media--b { background: linear-gradient(135deg, var(--color-beige), var(--color-wine-light)); }
.placeholder-media--c { background: linear-gradient(135deg, var(--color-cream), var(--color-beige-muted)); }
.placeholder-media--d { background: linear-gradient(135deg, var(--color-wine-soft), var(--color-cream)); }
.placeholder-media--e { background: linear-gradient(135deg, var(--color-wine), var(--color-beige)); }

.category-hero-media {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

/* ---------- Chat consultant ---------- */
.chat-shell { max-width: 640px; display: flex; flex-direction: column; gap: 12px; }
.chat-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.chat-msg { padding: 10px 14px; border-radius: 14px; max-width: 85%; white-space: pre-wrap; color: var(--color-text); }
.chat-msg.user { align-self: flex-end; background: var(--color-wine); color: var(--color-text-on-wine); }
.chat-msg.bot { align-self: flex-start; background: var(--color-surface-muted); color: var(--color-text); border: 1px solid var(--color-border); }
.chat-msg.error { border-color: var(--color-status-error); color: var(--color-status-error); }
.chat-loading { opacity: 0.7; font-style: italic; }
.chat-products { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.chat-product-card {
  display: block;
  background: var(--color-surface);
  color: var(--color-accent-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.88rem;
}
.chat-product-card:hover { border-color: var(--color-wine); text-decoration: none; }
.chat-starters { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }

/* Wine logo assets disappear on the dark wine interface without a light variant. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-full,
  :root:not([data-theme="light"]) .logo-mark,
  :root:not([data-theme="light"]) .footer-logo {
    filter: brightness(0) invert(1);
    opacity: 0.92;
  }
}
:root[data-theme="dark"] .logo-full,
:root[data-theme="dark"] .logo-mark,
:root[data-theme="dark"] .footer-logo {
  filter: brightness(0) invert(1);
  opacity: 0.92;
}
