:root {
  --ink: #111214;
  --panel: #1a1b1e;
  --line: #2a2b2f;
  --fog: #cfd0d0;
  --white: #ffffff;
  --steel: #808080;
  --gold: #ffd700;
  --danger: #ff6b6b;

  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --wide: "Unbounded", "Arial Black", sans-serif;

  --gutter: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body {
  background: var(--ink);
  color: var(--fog);
  font: 400 13px/1.5 var(--mono);
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--white); }
img { display: block; max-width: 100%; }
:focus-visible { outline: 1px solid var(--white); outline-offset: 2px; }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font: 700 15px/1 var(--wide);
  letter-spacing: 0.04em;
  color: var(--white);
}
.wordmark .zeros { color: var(--gold); }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.search-link { display: flex; padding: 2px; color: var(--fog); }
.search-link svg { width: 18px; height: 18px; }
.cart-link { display: flex; align-items: center; gap: 8px; color: var(--fog); }
.cart-count {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--gold); color: var(--ink);
  font-weight: 500; font-size: 11px; line-height: 20px; text-align: center;
}

/* ---------- Каталог ---------- */
.intro { padding: 28px var(--gutter) 20px; }
.intro h1 {
  font: 700 clamp(26px, 8.4vw, 40px)/1 var(--wide);
  overflow-wrap: break-word;
  color: var(--white);
  letter-spacing: -0.01em;
}
.intro p { margin-top: 12px; color: var(--steel); max-width: 34ch; }

.filters {
  display: flex; gap: 20px;
  padding: 0 var(--gutter) 14px;
  overflow-x: auto; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters + .filters { padding-top: 0; }
.chip {
  flex: none; padding: 4px 0;
  color: var(--steel); white-space: nowrap;
  border-bottom: 1px solid transparent;
}
.chip sup { font-size: 9px; margin-left: 2px; }
.chip[aria-pressed="true"] { color: var(--white); border-bottom-color: var(--white); }
.filters.collections .chip { font-family: var(--wide); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; }

.grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding-bottom: calc(96px + var(--safe-bottom));
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* flex-колонка: кнопка иначе центрирует содержимое, и в ряду с более длинными названиями фото съезжает вниз */
.tile { display: flex; flex-direction: column; min-width: 0; text-align: left; background: var(--ink); }
.tile-photo { aspect-ratio: 3 / 4; background: var(--panel); overflow: hidden; }
.tile-photo img { width: 100%; height: 100%; object-fit: cover; }
.tile-tag { padding: 8px 10px 16px; }
.tile-name {
  color: var(--fog);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-price { margin-top: 2px; color: var(--white); }
.tile.sold-out .tile-photo img { opacity: 0.4; }
.tile.sold-out .tile-price { color: var(--steel); }

.old-price { color: var(--steel); text-decoration: line-through; margin-right: 6px; }

/* ---------- Главная ---------- */
.hero { position: relative; height: min(78vh, 620px); overflow: hidden; background: var(--panel); }
.hero-media { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--ink) 0%, transparent 45%);
  pointer-events: none;
}
.hero-text { position: absolute; left: var(--gutter); right: var(--gutter); bottom: 22px; z-index: 1; }
.hero-text h1 {
  font: 700 clamp(40px, 15vw, 72px)/0.88 var(--wide);
  color: var(--white); letter-spacing: -0.02em;
}
.hero-btn {
  margin-top: 18px; padding: 12px 18px;
  border: 1px solid var(--white); color: var(--white);
  background: color-mix(in srgb, var(--ink) 35%, transparent);
}

.marquee {
  display: flex; overflow: hidden; white-space: nowrap;
  border-block: 1px solid var(--line);
  padding: 10px 0; color: var(--fog); font-size: 12px;
}
.marquee-track { flex: none; padding-right: 0; }
@media (prefers-reduced-motion: no-preference) {
  .marquee-track { animation: marquee 40s linear infinite; }
  @keyframes marquee { to { transform: translateX(-100%); } }
}

.shelf { padding-top: 32px; }
.shelf-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 0 var(--gutter) 14px;
}
.shelf-head h2 { font: 700 18px/1.1 var(--wide); color: var(--white); }
.shelf-link { text-align: left; }   /* заголовок ленты — ссылка на категорию, как «Дивитись усі» */
.shelf-all { color: var(--fog); white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; }
.shelf-all sup { font-size: 9px; margin-left: 2px; }
.shelf-row {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  scroll-snap-type: x proximity; scroll-padding-left: var(--gutter);
  padding: 0 var(--gutter);
}
.shelf-row::-webkit-scrollbar { display: none; }
.shelf-row .tile { flex: none; width: min(44vw, 220px); scroll-snap-align: start; }

.collection-card {
  position: relative; flex: none; width: min(62vw, 300px); aspect-ratio: 3 / 4;
  overflow: hidden; background: var(--panel); text-align: left; scroll-snap-align: start;
}
.collection-card img { width: 100%; height: 100%; object-fit: cover; }
.collection-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(17, 18, 20, 0.85) 0%, transparent 50%);
}
.collection-name {
  position: absolute; left: 14px; right: 14px; bottom: 34px; z-index: 1;
  font: 700 22px/1 var(--wide); color: var(--white);
}
.collection-count { position: absolute; left: 14px; bottom: 14px; z-index: 1; color: var(--fog); font-size: 12px; }

.home-foot {
  margin-top: 48px; padding: 40px var(--gutter) calc(110px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}
.home-foot .wordmark { font-size: 28px; }
.home-foot p { margin-top: 10px; color: var(--steel); max-width: 30ch; }
/* видео под надписью: во всю ширину экрана (поверх отступов футера), края растворяются в фоне */
.foot-scene {
  position: relative; margin: 28px calc(-1 * var(--gutter)) 0;
  aspect-ratio: 16 / 9; max-height: 60vh; overflow: hidden; background: var(--ink);
}
.foot-media { width: 100%; height: 100%; object-fit: cover; display: block; }
.foot-scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, var(--ink) 0%, transparent 22%, transparent 78%, var(--ink) 100%);
}

/* ---------- Каталог ---------- */
.list-head { position: relative; padding: 24px var(--gutter) 18px; }
.list-head h1 { font: 700 clamp(26px, 8vw, 36px)/1 var(--wide); color: var(--white); }
.list-head p { margin-top: 6px; color: var(--steel); }
.list-head.with-cover { padding: 0; height: min(52vh, 420px); overflow: hidden; margin-bottom: 18px; }
.list-cover { width: 100%; height: 100%; object-fit: cover; }
.list-head.with-cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--ink) 0%, transparent 55%);
}
.list-head.with-cover .list-title { position: absolute; left: var(--gutter); bottom: 16px; z-index: 1; }

/* ---------- Бейджи и размеры на карточке ---------- */
.tile-photo { position: relative; }
.badges { position: absolute; top: 8px; left: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.badge { padding: 3px 7px; font-size: 10px; line-height: 1.2; font-weight: 500; }
.badge-new { background: var(--gold); color: var(--ink); }
.badge-low { background: var(--ink); color: var(--white); border: 1px solid var(--white); }
.badge-out { background: var(--ink); color: var(--steel); }
.tile-sizes { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 6px; font-size: 10px; color: var(--steel); }
.tile-sizes .na { text-decoration: line-through; opacity: 0.45; }

/* ---------- Товар ---------- */
.gallery {
  position: relative;
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery img {
  flex: none; width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  scroll-snap-align: start; background: var(--panel);
}
.gallery-wrap { position: relative; }
.gallery.dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 65%, transparent);
  color: var(--white); font-size: 26px; line-height: 38px; text-align: center;
}
.gallery-arrow.prev { left: 10px; }
.gallery-arrow.next { right: 10px; }
.gallery-arrow[hidden] { display: none; }
@media (hover: hover) { .gallery { cursor: grab; } .gallery-arrow:hover { background: var(--ink); } }
.gallery-counter {
  position: absolute; right: var(--gutter); bottom: 12px;
  padding: 2px 8px; border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 70%, transparent);
  color: var(--white); font-size: 11px;
}

.product { padding: 20px var(--gutter) calc(110px + var(--safe-bottom)); }
.product.has-related { padding-bottom: 0; }   /* отступ под главную кнопку — у полки ниже */
.related { padding-bottom: calc(110px + var(--safe-bottom)); }
.product h1 { font: 500 18px/1.3 var(--wide); color: var(--white); }
.product .price { margin-top: 8px; font-size: 16px; color: var(--white); }
.product .sku { margin-top: 2px; color: var(--steel); font-size: 11px; }

.block { margin-top: 28px; }
.block h2 { font: 500 12px/1 var(--wide); color: var(--white); margin-bottom: 12px; letter-spacing: 0.04em; }

.sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.size {
  min-width: 52px; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 2px;
  color: var(--fog);
}
.size[aria-pressed="true"] { border-color: var(--white); color: var(--ink); background: var(--white); }
.size:disabled { color: var(--steel); text-decoration: line-through; cursor: not-allowed; opacity: 0.6; }
.size-hint { margin-top: 10px; color: var(--steel); font-size: 12px; }

.specs { display: flex; flex-wrap: wrap; gap: 6px; }
.specs li { list-style: none; padding: 3px 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--fog); font-size: 12px; }

.description { white-space: pre-line; color: var(--fog); max-width: 68ch; }
.description.clamped { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.more { margin-top: 8px; color: var(--white); text-decoration: underline; text-underline-offset: 3px; }

.gallery img { cursor: zoom-in; }

/* ---------- Повноекранний перегляд ---------- */
html.viewer-open, html.viewer-open body { overflow: hidden; }
.viewer {
  --fade: 1;
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, var(--fade));
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.viewer[hidden] { display: none; }
.viewer-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.viewer-img {
  width: 100%; height: 100%; object-fit: contain;   /* картинка вписана, рамка = весь экран */
  transform-origin: center center; will-change: transform;
  cursor: zoom-in; -webkit-user-drag: none;
}
.viewer.zoomed .viewer-img { cursor: grab; }
.viewer.zoomed .viewer-img:active { cursor: grabbing; }

.viewer-close, .viewer-nav {
  position: absolute; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(17, 18, 20, 0.6); color: var(--white);
}
.viewer-close { top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; font-size: 18px; }
.viewer-nav { top: 50%; transform: translateY(-50%); font-size: 28px; line-height: 42px; }
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
.viewer-nav[hidden], .viewer.zoomed .viewer-nav { display: none; }
@media (hover: none) { .viewer-nav { display: none; } }   /* на телефоне листаем свайпом */

.viewer-counter {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + var(--safe-bottom));
  color: var(--white); font-size: 12px;
}
.viewer-hint {
  position: absolute; left: 50%; top: calc(20px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  padding: 8px 12px; background: rgba(17, 18, 20, 0.75); color: var(--white); font-size: 12px; white-space: nowrap;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.viewer.show-hint .viewer-hint { opacity: 1; }

/* ---------- Кошик ---------- */
.page { padding: 24px var(--gutter) calc(110px + var(--safe-bottom)); }
.page-title { font: 700 22px/1.1 var(--wide); color: var(--white); margin-bottom: 20px; }

.cart-line {
  display: grid; grid-template-columns: 72px 1fr; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.cart-line:first-of-type { border-top: 1px solid var(--line); }
.cart-line img { width: 72px; aspect-ratio: 3 / 4; object-fit: cover; background: var(--panel); }
.cart-line-name { color: var(--white); }
.cart-line-meta { color: var(--steel); font-size: 12px; margin-top: 2px; }
.cart-line-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); }
.stepper button { width: 34px; height: 32px; font-size: 16px; }
.stepper span { min-width: 26px; text-align: center; color: var(--white); }
.remove { color: var(--steel); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; margin-top: 8px; }

.summary { display: flex; justify-content: space-between; padding: 18px 0; font-size: 15px; color: var(--white); }
.note { color: var(--steel); font-size: 12px; max-width: 46ch; }

.empty { padding: 60px 0 20px; }
.empty p { color: var(--steel); margin-bottom: 20px; }
.ghost-btn {
  padding: 12px 18px; border: 1px solid var(--white); color: var(--white);
}

/* ---------- Пошук ---------- */
.search { padding-top: 16px; }
.search-box { position: relative; margin: 0 var(--gutter); }
.search-input {
  width: 100%; padding: 12px 36px 12px 0;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  font-size: 15px;
  -webkit-appearance: none; appearance: none;
}
.search-input:focus { outline: none; border-bottom-color: var(--white); }
.search-input::placeholder { color: var(--steel); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  padding: 8px 0 8px 12px; color: var(--steel);
}
.search-count { padding: 14px var(--gutter); color: var(--steel); }
.search-hints { padding: 22px var(--gutter); }
.search-hints p { margin-bottom: 10px; color: var(--steel); font-size: 12px; }
.search-hint-list { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.search-hint-list .chip { color: var(--fog); }
.search-empty { padding: 48px var(--gutter); color: var(--steel); }
.search-empty button {
  margin-top: 16px; padding: 4px 0;
  color: var(--white); border-bottom: 1px solid var(--white);
}

/* ---------- Оформлення ---------- */
.form { display: grid; gap: 18px; }
.field label { display: block; margin-bottom: 6px; color: var(--steel); font-size: 12px; }
.field input, .field textarea {
  width: 100%; padding: 12px 0;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  font-size: 15px;
}
.field input:focus, .field textarea:focus { outline: none; border-bottom-color: var(--white); }
.field textarea { resize: none; min-height: 64px; }
/* автозаполнение браузера красит поле в голубой — фон у него не перебить, поэтому закрываем тенью */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--white);
  caret-color: var(--white);
  box-shadow: 0 0 0 1000px var(--ink) inset;
  transition: background-color 9999s ease-out;
}
.field.invalid input { border-bottom-color: var(--danger); }
.field .error { color: var(--danger); font-size: 12px; margin-top: 6px; }
.form-total { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--white); font-size: 15px; }

/* ---------- Готово ---------- */
.done { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; padding: 0 var(--gutter); }
.done-number { font: 700 clamp(56px, 22vw, 96px)/0.9 var(--wide); color: var(--gold); }
.done h1 { margin-top: 18px; font: 500 18px/1.3 var(--wide); color: var(--white); }
.done p { margin-top: 10px; color: var(--fog); max-width: 38ch; }
.done .ghost-btn { margin-top: 28px; align-self: flex-start; }

/* ---------- Нижня кнопка (браузер) і повідомлення ---------- */
.fallback-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 10px var(--gutter) calc(10px + var(--safe-bottom));
  background: var(--ink); border-top: 1px solid var(--line);
}
.fallback-btn {
  width: 100%; height: 50px;
  background: var(--fog); color: var(--ink); font-weight: 500;
}
.fallback-btn:disabled { opacity: 0.4; }

.toast {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(80px + var(--safe-bottom)); z-index: 30;
  padding: 12px 14px; background: var(--white); color: var(--ink);
}

.loading { padding: 80px var(--gutter); color: var(--steel); }

@media (prefers-reduced-motion: no-preference) {
  .view-enter { animation: enter 0.18s ease-out; }
  @keyframes enter { from { opacity: 0; transform: translateY(6px); } }
}

/* ---------- Наведение мышью ----------
   Только там, где есть мышь (Telegram Desktop, браузер): на телефоне после тапа подсветка «залипала» бы. */
@media (hover: hover) {
  /* карточки товаров и коллекций приподнимаются и выходят вперёд */
  .tile, .collection-card { transition: transform 0.3s ease, box-shadow 0.3s ease; }
  .tile:hover, .collection-card:hover {
    z-index: 2;
    transform: translateY(-4px) scale(1.04);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
  }
  /* запас в лентах под приподнятую карточку (ровно на отступ заголовка ленты — «Дивитись усі» не перекрывается) */
  .shelf-row { padding-top: 14px; padding-bottom: 14px; margin-top: -14px; margin-bottom: -14px; }

  /* текст и кнопки плавно увеличиваются и подсвечиваются */
  .tile-name, .chip, .shelf-link, .shelf-all, .more, .topbar .wordmark, .search-link, .cart-link, .search-clear,
  .search-empty button, .size, .hero-btn {
    transition: transform 0.2s ease, color 0.2s, border-color 0.2s, background 0.2s;
  }
  .chip:hover, .shelf-all:hover, .more:hover, .topbar .wordmark:hover, .search-link:hover, .cart-link:hover,
  .search-empty button:hover { transform: scale(1.08); }
  .shelf-link { transform-origin: left center; }   /* растёт вправо, не залезая на левый отступ */
  .shelf-link:hover { transform: scale(1.06); color: var(--gold); }   /* заголовок и так белый — подсвечиваем золотом */
  .size:not(:disabled):hover, .hero-btn:hover { transform: scale(1.05); }
  .search-clear:hover { transform: translateY(-50%) scale(1.2); }   /* translateY — его обычное положение */

  .tile:hover .tile-name,
  .shelf-all:hover, .more:hover, .search-link:hover, .cart-link:hover, .search-clear:hover { color: var(--white); }
  .chip:hover { color: var(--white); border-bottom-color: var(--white); }
  .size:not(:disabled):not([aria-pressed="true"]):hover { color: var(--white); border-color: var(--white); }
  .hero-btn:hover { background: var(--white); color: var(--ink); }

  /* запас сверху в рядах фильтров (они прокручиваются вбок и обрезали бы увеличенный фильтр) */
  .filters, .filters + .filters { padding-top: 4px; margin-top: -4px; }
}
/* С мышью ленты листает edge-scroll.js (курсор у края). Без примагничивания к карточкам —
   иначе Chrome возвращал бы ленту к ближайшей карточке после каждого шага. */
@media (hover: hover) and (pointer: fine) {
  .shelf-row { scroll-snap-type: none; }
}
@media (hover: hover) and (prefers-reduced-motion: reduce) {
  /* без движения — только тень и подсветка */
  .tile:hover, .collection-card:hover, .chip:hover, .shelf-link:hover, .shelf-all:hover, .more:hover, .topbar .wordmark:hover,
  .search-link:hover, .cart-link:hover, .search-empty button:hover, .size:hover, .hero-btn:hover { transform: none; }
  .search-clear:hover { transform: translateY(-50%); }
}
