/* ═══════════════════════════════════════════════════════════
   IKEA Каталог — mobile-first · Soft Bento v3
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #f3f3f1;
  --surface: #ffffff;
  --surface-2: #f0f1f3;
  --text: #101114;
  --muted: #6a6d73;
  --faint: #9a9ca1;
  --border: #e6e6e3;
  --accent: #0058a3;
  --accent-hover: #004a8a;
  --accent-soft: #e6f0fa;
  --accent-text: #ffffff;
  --warn: #b45309;
  --danger: #d92d20;
  --ok: #12804a;
  --glass: rgba(255, 255, 255, .86);
  --shadow-sm: 0 1px 2px rgba(16, 17, 20, .05), 0 1px 3px rgba(16, 17, 20, .04);
  --shadow: 0 6px 18px rgba(16, 17, 20, .08);
  --shadow-lg: 0 14px 40px rgba(16, 17, 20, .18);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --bn: 60px;
  --bn-total: calc(var(--bn) + env(safe-area-inset-bottom, 0px));
  --bar-h: 0px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d0d0e;
  --surface: #1a1a1c;
  --surface-2: #26282c;
  --text: #f4f4f5;
  --muted: #a0a3a9;
  --faint: #6d7077;
  --border: #2b2d31;
  --accent: #4aa3ff;
  --accent-hover: #6bb4ff;
  --accent-soft: #14283f;
  --accent-text: #08111c;
  --warn: #fbbf24;
  --danger: #ff6b60;
  --ok: #4ade80;
  --glass: rgba(26, 26, 28, .86);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow: 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ── Основа ── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bn-total) + var(--bar-h) + 16px);
  transition: background .2s, color .2s;
}
body.no-scroll { overflow: hidden; }
.has-bar-sm { --bar-h: 76px; }
.has-bar-lg { --bar-h: 124px; }

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 6px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 18px; line-height: 1.3; margin: 0 0 10px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 10px; font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.ic { flex-shrink: 0; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

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

/* ── Шапка ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-in { margin: 0 auto; padding: 8px 14px; display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 0; min-height: 56px; }
.brand { display: flex; align-items: baseline; gap: 6px; font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: -.02em; flex: 1; }
.brand span { font-weight: 600; font-size: 14px; color: var(--muted); letter-spacing: 0; }
.brand:hover { text-decoration: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; padding: 0;
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.sm { width: 38px; height: 38px; border-radius: 12px; }
.icon-btn.plain { border-color: transparent; background: transparent; }

.theme-toggle .i-moon { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-moon { display: block; }

.nav-desktop { display: none; }

.header-search {
  position: relative; order: 10; flex: 0 0 100%;
  padding: 2px 0 8px; margin: 0;
  max-height: 64px; overflow: hidden;
  transition: max-height .22s ease, opacity .18s ease, padding .22s ease;
}
.topbar.compact .header-search { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; pointer-events: none; }
.header-search .search-ic { position: absolute; left: 16px; top: 16px; color: var(--muted); pointer-events: none; }
.header-search input {
  padding-left: 44px; border-radius: 999px; background: var(--surface-2);
  border-color: transparent; font-size: 16px;
}
.header-search input:focus { background: var(--surface); }

/* ── Нижняя навигация ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: flex; gap: 4px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 48px; border-radius: 14px;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .01em;
  transition: color .15s, background .15s, transform .1s;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a:active { transform: scale(.94); }
.bottom-nav a.active { color: var(--accent); background: var(--accent-soft); }

/* ── Формы ── */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; width: 100%; min-height: 48px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 90px; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=checkbox] {
  width: 22px; height: 22px; min-height: 0; padding: 0;
  flex-shrink: 0; accent-color: var(--accent); cursor: pointer;
}
select {
  -webkit-appearance: none; appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239a9ca1' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ── Кнопки ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 16px; line-height: 1;
  cursor: pointer; padding: 12px 20px; min-height: 48px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); text-decoration: none;
  transition: transform .1s, background .15s, filter .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); filter: none; }
.btn-danger { color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 40px; padding: 8px 16px; font-size: 14px; }
.btn-block { width: 100%; }

/* ── Панели ── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px;
}
.panel + .panel { margin-top: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.page-head h1 { margin-top: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; font-weight: 600; min-height: 32px; }
.back-link:hover { color: var(--accent); text-decoration: none; }

.fold { padding: 0; }
.fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 0 16px; min-height: 56px; font-weight: 700; font-size: 16px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: ""; width: 9px; height: 9px; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.fold[open] > summary::after { transform: rotate(225deg); }
.fold-body { padding: 0 16px 16px; }

.empty-state { text-align: center; padding: 36px 20px; }
.empty-state .empty-ic { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty-state h2 { margin-bottom: 6px; }
.empty-state .btn { margin-top: 14px; }

/* ── Поиск (legacy) ── */
.searchbar { display: flex; gap: 8px; margin-bottom: 16px; }
.searchbar input { flex: 1; min-width: 0; }

/* ── Сетка товаров ── */
.grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  display: flex; flex-direction: column; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow); text-decoration: none; }
.card:active { transform: scale(.98); }
.card-img { aspect-ratio: 1; background: var(--surface-2); overflow: hidden; position: relative; }
.card-img img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.card-img img.loaded { opacity: 1; }
.card-img.noimg::after, .gallery-slide.noimg::after { content: "Нет фото"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 13px; font-weight: 600; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.card-name {
  font-weight: 600; font-size: 14.5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 38px;
}
.card-sub { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.card-price { font-weight: 800; font-size: 17px; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: sk 1.4s ease-in-out infinite;
}
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ═══════════════════════════════════════════════════════════
   КАТАЛОГ
   ═══════════════════════════════════════════════════════════ */
.shop { display: block; }
.shop-main { min-width: 0; }

.chips-row {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px 10px; padding: 2px 14px 4px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
}
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.chip:hover { text-decoration: none; background: var(--surface-2); }
.chip:active { transform: scale(.96); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chips-row.sub .chip { min-height: 34px; padding: 5px 13px; font-size: 13px; font-weight: 500; }
.chips-row.sub .chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chip .x { opacity: .7; font-size: 15px; line-height: 1; }

.toolbar { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.toolbar .count { color: var(--muted); font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .count b { color: var(--text); }
.toolbar select { width: auto; min-height: 42px; padding: 8px 34px 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; max-width: 170px; }
.filter-btn { position: relative; gap: 8px; min-height: 42px; padding: 8px 16px; font-size: 14px; }
.filter-btn .badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; line-height: 1;
}
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.active-filters .chip { min-height: 34px; padding: 4px 6px 4px 12px; font-size: 13px; background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.active-filters .chip .x { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* Шторки (bottom sheet) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  max-height: 88vh; max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(105%); visibility: hidden;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
}
.sheet.open { transform: none; visibility: visible; transition-delay: 0s; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 0; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px 8px 20px; flex-shrink: 0; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 16px; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface);
}
.sheet-foot .btn { flex: 1; }
.sheet-section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 8px; }
.sheet-section-title:first-child { margin-top: 4px; }

.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filter-grid .wide { grid-column: 1 / -1; }

/* Дерево категорий */
.cat-tree-wrap { display: flex; flex-direction: column; gap: 2px; }
.cat-row { display: flex; align-items: center; gap: 2px; }
.cat-toggle {
  width: 38px; height: 42px; flex-shrink: 0; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; border-radius: 10px; cursor: pointer; padding: 0;
}
.cat-toggle .ic { transition: transform .18s; }
.cat-toggle.open .ic { transform: rotate(90deg); }
.cat-toggle.empty { visibility: hidden; pointer-events: none; }
.cat-item {
  flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; min-height: 42px; border-radius: 12px;
  color: var(--text); font-weight: 600; font-size: 15px;
}
.cat-item > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.cat-item:hover, .cat-subitem:hover { background: var(--surface-2); text-decoration: none; }
.cat-item.active { background: var(--accent-soft); color: var(--accent); }
.cat-item .count, .cat-subitem .count { color: var(--muted); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.cat-item:focus-visible, .cat-subitem:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cat-sub { display: none; margin: 2px 0 6px 19px; padding-left: 10px; border-left: 2px solid var(--border); }
.cat-sub.open { display: block; }
.cat-subitem {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 10px; min-height: 38px; border-radius: 10px; color: var(--text); font-size: 14px;
}
.cat-subitem.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* Пагинация */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 42px; height: 42px; padding: 0 12px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600;
}
.pager .cur { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pager a:hover { background: var(--surface-2); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════
   КАРТОЧКА ТОВАРА
   ═══════════════════════════════════════════════════════════ */
.product-page { padding-top: 2px; }
.product { display: block; }
.product-info { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

/* Галерея */
.gallery { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.gallery-track {
  display: flex; aspect-ratio: 1 / 1; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-slide { flex: 0 0 100%; position: relative; scroll-snap-align: center; scroll-snap-stop: always; background: var(--surface-2); }
.gallery-slide img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; opacity: 0; transition: opacity .3s; }
.gallery-slide img.loaded { opacity: 1; }
.gallery-count {
  position: absolute; right: 12px; top: 12px; padding: 4px 11px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 700;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); font-variant-numeric: tabular-nums;
}
.gallery-dots { position: absolute; left: 0; right: 0; bottom: 12px; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.gallery-dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(120, 120, 120, .45); transition: all .2s; }
.gallery-dots i.on { width: 18px; background: var(--accent); }
.g-nav { display: none; }
.gallery-thumbs { display: none; }

.product-category { margin-bottom: 10px; }
.product-head { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.product-title { font-size: 24px; font-weight: 800; margin: 0; line-height: 1.2; letter-spacing: -.02em; }
.product-article-inline {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: all;
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace; font-size: 13px; font-weight: 600;
  color: var(--muted); background: var(--surface-2); padding: 7px 12px; border-radius: 999px;
  font-variant-numeric: tabular-nums; transition: background .15s, color .15s;
}
.product-article-inline:hover, .product-article-inline:active { background: var(--accent-soft); color: var(--accent); }

.price-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm);
}
.price-big { font-size: 36px; font-weight: 800; line-height: 1; letter-spacing: -.03em; margin: 0; font-variant-numeric: tabular-nums; }
.price-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.price-chip { background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.price-chip b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

.stock-badge {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 700;
  background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok);
}
.stock-badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.stock-badge.out { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.stock-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.product-description { font-size: 15px; line-height: 1.6; color: var(--text); }
.product-description.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.read-more { background: none; border: 0; padding: 4px 0; color: var(--accent); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; align-self: flex-start; display: none; }
.read-more.show { display: inline-block; }

.packages-summary { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.packages-summary-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.packages-summary-row > span:first-child { color: var(--muted); }
.packages-summary-row > span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.packages-summary .total { padding-top: 8px; border-top: 1px solid var(--border); font-weight: 700; font-size: 15px; }
.packages-summary .total > span:first-child { color: var(--text); }

/* Панель «В корзину» */
.addbar {
  position: fixed; left: 0; right: 0; bottom: var(--bn-total); z-index: 46;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 14px 12px; background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border); border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 24px rgba(16, 17, 20, .08);
}
.addbar-row { display: flex; align-items: center; gap: 10px; }
.addbar-cart { display: flex; align-items: center; gap: 10px; }
.addbar-cart label { font-size: 13px; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.addbar-cart select { min-height: 40px; padding: 6px 36px 6px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; background-color: var(--surface-2); border-color: transparent; }
.addbar .btn-primary { flex: 1; min-height: 50px; }

.quantity-control {
  display: inline-flex; align-items: stretch; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
  background: var(--surface); height: 48px;
}
.quantity-control .qty-step { width: 46px; border: 0; background: transparent; color: var(--text); font-size: 22px; font-weight: 600; cursor: pointer; padding: 0; line-height: 1; }
.quantity-control .qty-step:hover { background: var(--surface-2); }
.quantity-control .qty-step:active { background: var(--border); }
.quantity-control .qty {
  width: 52px; border: 0; border-radius: 0; text-align: center; padding: 0; min-height: 0;
  font-weight: 700; background: transparent; box-shadow: none;
}
.quantity-control .qty:focus { background: var(--surface-2); box-shadow: none; }

/* Варианты */
.variants-group { margin-bottom: 14px; }
.variants-group:last-child { margin-bottom: 0; }
.variants-title { color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.variants-list { display: flex; flex-wrap: wrap; gap: 8px; }
.variant-chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; min-height: 42px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 14px;
}
.variant-chip:hover { background: var(--surface-2); text-decoration: none; }
.variant-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); cursor: default; }

/* Упаковка */
.package-list { display: flex; flex-direction: column; gap: 10px; }
.package-card { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.package-card-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.package-card-title .pk-qty { margin-left: auto; color: var(--accent); font-weight: 800; }
.package-card-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14px; }
.package-card-row span:first-child { color: var(--muted); }
.package-card-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ═══════════════════════════════════════════════════════════
   КОРЗИНА
   ═══════════════════════════════════════════════════════════ */
.cart-layout { display: flex; flex-direction: column; gap: 14px; }
.cart-layout .panel + .panel { margin-top: 0; }
.cart-items { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.cart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.cart-card-head { display: flex; gap: 12px; align-items: flex-start; }
.cart-card-head img { width: 76px; height: 76px; object-fit: cover; border-radius: 14px; background: var(--surface-2); flex-shrink: 0; }
.cart-card-head-info { flex: 1; min-width: 0; }
.cart-item-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 700; font-size: 16px; color: var(--text); line-height: 1.3; margin-bottom: 4px;
}
.cart-item-name:hover { color: var(--accent); text-decoration: none; }
.cart-item-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cart-card-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.check-line {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 12px; min-height: 48px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 15px; font-weight: 600; user-select: none;
}
.check-line:hover { background: var(--surface-2); }
.check-line input { margin: 0; }
.check-line.block { width: 100%; justify-content: flex-start; border-radius: var(--radius-sm); background: var(--surface-2); border-color: transparent; }
.markup-field {
  display: inline-flex; align-items: center; gap: 8px; flex: 1; min-width: 160px;
  padding: 2px 4px 2px 16px; min-height: 48px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px; color: var(--muted); font-weight: 600;
  white-space: nowrap;
}
.markup-field input { flex: 1; min-width: 60px; border: 0; min-height: 0; padding: 10px; background: transparent; text-align: right; font-weight: 700; color: var(--text); box-shadow: none; }
.cart-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px dashed var(--border); }
.cart-card-foot .lbl { color: var(--muted); font-size: 13px; font-weight: 600; }
.cart-card-total { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.add-line { display: flex; gap: 8px; margin-top: 14px; }
.add-line input[type=text], .add-line input:not([type]) { flex: 1; min-width: 0; }
.add-line #addQty { width: 76px; flex-shrink: 0; text-align: center; }
.add-line .btn { padding: 12px 20px; }

/* Прейскурант */
.price-list-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.pl-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; font-size: 15px; }
.pl-row > span:first-child { color: var(--muted); }
.pl-row b { font-weight: 700; font-variant-numeric: tabular-nums; }
.pl-total { font-size: 22px; font-weight: 800; padding-top: 4px; }
.pl-total > span:first-child { color: var(--text); }

.cart-bar {
  position: fixed; left: 0; right: 0; bottom: var(--bn-total); z-index: 46;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px 12px; background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border); border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 24px rgba(16, 17, 20, .08);
}
.cart-bar-sum { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.cart-bar-sum small { color: var(--muted); font-size: 12px; font-weight: 600; }
.cart-bar-sum b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.cart-bar .btn { min-height: 50px; padding: 12px 22px; }

/* Формы */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form-grid .wide { grid-column: 1 / -1; }

/* ═══════════════════════════════════════════════════════════
   СПИСОК КОРЗИН
   ═══════════════════════════════════════════════════════════ */
.carts-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
.cart-tile {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.cart-tile:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.cart-tile:active { transform: scale(.985); }
.cart-tile-link { display: flex; align-items: center; gap: 12px; color: inherit; padding-right: 44px; min-width: 0; }
.cart-tile-link:hover { text-decoration: none; }
.cart-tile-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.avatar {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 15px;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
  font-size: 19px; font-weight: 800;
}
.cart-tile-main { display: flex; flex-direction: column; min-width: 0; }
.cart-tile-name { font-weight: 700; font-size: 17px; line-height: 1.25; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-tile-meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cart-tile-total { font-weight: 800; font-size: 21px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.cart-tile-badge { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 700; }
.cart-tile-del {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 40px; height: 40px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 12px; cursor: pointer; color: var(--faint);
}
.cart-tile-del:hover, .cart-tile-del:active { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ═══════════════════════════════════════════════════════════
   КАЛЬКУЛЯТОР
   ═══════════════════════════════════════════════════════════ */
.calc-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.calc-form input[type=text] { font-size: 18px; font-weight: 600; min-height: 56px; border-radius: 16px; letter-spacing: .02em; }
.switch-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; user-select: none; font-weight: 600; font-size: 15px; }
.switch-line small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; }
.switch-line input[type=checkbox] {
  -webkit-appearance: none; appearance: none; width: 52px; height: 32px; border-radius: 999px;
  background: var(--border); position: relative; transition: background .2s; cursor: pointer; flex-shrink: 0; border: 0;
}
.switch-line input[type=checkbox]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s;
}
.switch-line input[type=checkbox]:checked { background: var(--accent); }
.switch-line input[type=checkbox]:checked::after { transform: translateX(20px); }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1.2em; margin: 0; }

.result-card { margin-top: 16px; display: none; }
.result-card.show { display: block; animation: rise .3s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.calc-gallery { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.calc-gallery::-webkit-scrollbar { display: none; }
.calc-gallery img { width: 92px; height: 92px; flex-shrink: 0; object-fit: cover; border-radius: 14px; cursor: zoom-in; background: var(--surface-2); }
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); font-size: 15px; }
.calc-row > span:first-child { color: var(--muted); }
.calc-row > span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.calc-total { margin-top: 14px; padding: 16px; border-radius: var(--radius-sm); background: var(--accent-soft); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.calc-total span:first-child { color: var(--accent); font-weight: 700; }
.calc-total span:last-child { font-size: 28px; font-weight: 800; color: var(--accent); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════════════════
   ЛАЙТБОКС
   ═══════════════════════════════════════════════════════════ */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lb-track { flex: 1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; display: grid; place-items: center; padding: 56px 8px 48px; }
.lb-slide img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; background: #fff; }
.lb-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 2;
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.lb-count { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; font-weight: 600; opacity: .85; pointer-events: none; }

/* ═══════════════════════════════════════════════════════════
   ТОСТ
   ═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(var(--bn-total) + var(--bar-h) + 12px);
  background: var(--text); color: var(--bg);
  padding: 12px 14px 12px 16px; border-radius: 16px;
  opacity: 0; pointer-events: none; transform: translateY(16px);
  transition: opacity .25s, transform .25s;
  z-index: 300; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 600;
}
.toast.show { opacity: 1; pointer-events: auto; transform: none; }
.toast.err { background: var(--danger); color: #fff; }
.toast-msg { flex: 1; min-width: 0; }
.toast-action {
  background: rgba(255, 255, 255, .2); color: inherit; padding: 9px 14px; border-radius: 12px;
  font-weight: 700; font-size: 14px; flex-shrink: 0; display: inline-flex; align-items: center;
}
[data-theme="dark"] .toast-action { background: rgba(0, 0, 0, .14); }
.toast-action:hover { text-decoration: none; filter: brightness(1.1); }

/* ── Legacy (catalog.html) ── */
.layout { display: block; }
.layout > section { min-width: 0; }
.sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; margin-bottom: 16px; }
.sidebar > summary { cursor: pointer; font-weight: 600; padding: 14px 16px; list-style: none; display: flex; justify-content: space-between; align-items: center; border-radius: var(--radius-sm); }
.sidebar > summary::-webkit-details-marker { display: none; }
.sidebar > summary::after { content: "▾"; color: var(--muted); font-size: 14px; transition: transform .2s; }
.sidebar[open] > summary::after { transform: rotate(180deg); }
.cat-list { display: flex; flex-direction: column; max-height: 60vh; overflow-y: auto; padding: 4px; }
.cat-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--text); font-size: 14px; font-weight: 500; min-height: 40px; }
.cat-list a:hover { background: var(--surface-2); text-decoration: none; }
.cat-list a.active { background: var(--accent); color: var(--accent-text); }
.cat-list small { color: var(--muted); }
.cat-list a.active small { color: inherit; opacity: .85; }

/* ═══════════════════════════════════════════════════════════
   ПЛАНШЕТ / ДЕСКТОП
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .carts-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .toast { left: 50%; right: auto; width: 480px; max-width: calc(100% - 28px); transform: translateX(-50%) translateY(16px); }
  .toast.show { transform: translateX(-50%); }
}

@media (min-width: 900px) {
  :root { --bn-total: 0px; }
  .has-bar-sm, .has-bar-lg { --bar-h: 0px; }
  body { padding-bottom: 32px; }
  .container { max-width: 1240px; padding: 24px; }
  h1 { font-size: 28px; }

  .topbar-in { max-width: 1240px; padding: 10px 24px; }
  .brand { flex: 0 0 auto; margin-right: 8px; }
  .nav-desktop { display: flex; gap: 4px; flex: 1; }
  .nav-desktop a { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; color: var(--text); font-weight: 600; font-size: 15px; }
  .nav-desktop a:hover { background: var(--surface-2); text-decoration: none; }
  .nav-desktop a.active { background: var(--accent); color: var(--accent-text); }
  .bottom-nav { display: none; }
  .header-search { order: 0; flex: 0 0 340px; padding: 0; max-height: none; overflow: visible; }
  .header-search .search-ic { left: 16px; top: 14px; }
  .header-search input { min-height: 44px; }
  .topbar.compact .header-search { max-height: none; opacity: 1; padding: 0; pointer-events: auto; }

  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .card { transition: transform .15s, box-shadow .2s; }
  .card:hover { transform: translateY(-3px); }

  /* каталог */
  .shop { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
  .chips-row { display: none; }
  .filter-btn, .sheet-backdrop.filter-bd { display: none; }
  .filter-sheet {
    position: sticky; top: 84px; left: auto; right: auto; bottom: auto; z-index: 1;
    transform: none; visibility: visible; max-height: calc(100vh - 108px);
    border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  }
  .filter-sheet .sheet-handle, .filter-sheet .sheet-close { display: none; }
  .filter-sheet .sheet-head { padding-top: 14px; }
  .filter-sheet .sheet-foot { border-radius: 0 0 var(--radius) var(--radius); }

  /* модальная шторка по центру */
  .sheet.modal {
    left: 50%; right: auto; bottom: auto; top: 50%; width: 440px; border-radius: var(--radius-lg);
    transform: translate(-50%, -46%); opacity: 0; transition: transform .25s, opacity .2s, visibility 0s linear .25s;
  }
  .sheet.modal.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.modal .sheet-handle { display: none; }

  /* карточка товара */
  .product { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 36px; align-items: start; }
  .product-gallery { position: sticky; top: 84px; }
  .product-info { margin-top: 0; }
  .gallery-dots { display: none; }
  .g-nav {
    display: grid; place-items: center; position: absolute; top: calc(50% - 22px); width: 44px; height: 44px; z-index: 2;
    border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
    box-shadow: var(--shadow); opacity: 0; transition: opacity .15s;
  }
  .gallery:hover .g-nav { opacity: 1; }
  .g-nav.prev { left: 12px; }
  .g-nav.next { right: 12px; }
  .gallery-thumbs { display: flex; gap: 8px; padding: 12px; overflow-x: auto; justify-content: center; border-top: 1px solid var(--border); }
  .gallery-thumbs img {
    width: 64px; height: 64px; flex-shrink: 0; border-radius: 12px; object-fit: cover; cursor: pointer;
    border: 2px solid transparent; background: var(--surface-2); transition: border-color .15s;
  }
  .gallery-thumbs img.active { border-color: var(--accent); }
  .product-head { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 16px; }
  .product-title { font-size: 28px; }
  .addbar {
    position: static; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow-sm); -webkit-backdrop-filter: none; backdrop-filter: none;
  }

  /* корзина */
  .cart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
  .cart-layout > .cart-main, .cart-layout > .cart-settings { grid-column: 1; }
  .cart-layout > .price-list { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 84px; }
  .cart-bar { display: none; }
  .copy-desktop { display: inline-flex !important; }

  .carts-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .calc-wrap { max-width: 640px; }

  .layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
  .sidebar { padding: 10px 12px; position: sticky; top: 84px; margin-bottom: 0; }
  .cat-list { max-height: 70vh; }
}
@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .shop .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.copy-desktop { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
