:root {
  --bg: #f6f3f1;
  --card: #ffffff;
  --ink: #1d1a1c;
  --muted: #6f666b;
  --line: #e9e2df;
  --accent: #b84a74;
  --accent-ink: #a8436a;
  --accent-soft: #f7e3ea;
  --chip: #ece6e3;
  --danger: #c4314b;
  --shadow: 0 1px 2px rgba(29, 26, 28, .06), 0 4px 14px rgba(29, 26, 28, .05);
  --r: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
:root.dark {
  --bg: #161315;
  --card: #221e20;
  --ink: #f3eef0;
  --muted: #a99fa4;
  --line: #342e31;
  --accent: #e58aac;
  --accent-ink: #f0a3c0;
  --accent-soft: #3a2630;
  --chip: #2c2629;
  --danger: #ff7a8c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
html.locked, html.locked body { overflow: hidden; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  caret-color: var(--accent);
}
::selection { background: var(--accent-soft); color: var(--ink); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { opacity: .55; cursor: default; }
input, textarea { font: inherit; color: inherit; }
img { display: block; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
[hidden] { display: none !important; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.big { width: 44px; height: 44px; stroke-width: 1.4; }

/* ---------- шапка */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.brand-name { font-weight: 800; letter-spacing: .01em; font-size: 20px; }
.cart-btn {
  position: relative; width: 42px; height: 42px; border-radius: 21px; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .2s var(--ease);
}
.cart-btn .ic { width: 22px; height: 22px; }
.cart-btn:active { transform: scale(.94); }
.cart-btn.bump { animation: bump .45s var(--ease); }
@keyframes bump { 30% { transform: scale(1.14); } 60% { transform: scale(.96); } }
.cart-count {
  position: absolute; top: -4px; right: -5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.search {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; height: 42px;
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { border: 0; outline: 0; background: none; width: 100%; height: 100%; min-width: 0; }
.search input::placeholder { color: var(--muted); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 10px 16px; scrollbar-width: none; scroll-padding: 0 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--chip);
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, color .15s;
}
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }

main { padding: 4px 16px 24px; max-width: 1100px; margin: 0 auto; }
@media (min-width: 760px) { .top { padding-left: max(16px, calc(50% - 534px)); padding-right: max(16px, calc(50% - 534px)); } }

/* ---------- группа и линейки */
.group-desc {
  color: var(--muted); font-size: 13.5px; margin: 10px 0 0; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.group-desc.open { -webkit-line-clamp: unset; }
.line { margin-top: 30px; }
.line-head { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.line-title { font-size: 21px; font-weight: 800; letter-spacing: -.01em; margin: 0; line-height: 1.15; }
.badge-new {
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft); padding: 3px 7px; border-radius: 6px;
}
.line-desc { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; max-width: 65ch; }
.line-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.prices { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.price-pill { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 4px 8px; font-size: 12.5px; white-space: nowrap; }
.price-pill b { font-weight: 700; }
.palette-link {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 9px;
  color: var(--accent-ink); background: var(--accent-soft); font-weight: 700; font-size: 12.5px; align-self: flex-start;
}
.palette-link .ic { width: 16px; height: 16px; }

.shades { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; margin-top: 12px; align-items: start; }
@media (min-width: 520px) { .shades { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 760px) { .shades { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.shade { display: block; text-align: left; position: relative; touch-action: manipulation; }
.shade-img {
  display: block; aspect-ratio: 3 / 4; border-radius: var(--r); overflow: hidden; background: var(--chip);
  box-shadow: var(--shadow); transition: transform .18s var(--ease);
}
.shade:active .shade-img { transform: scale(.97); }
.shade-img img, .pick-img img, .cart-thumb img, .item-img img { width: 100%; height: 100%; opacity: 0; transition: opacity .25s ease; }
.shade-img img, .cart-thumb.shade img { object-fit: cover; }
img.ok { opacity: 1; }
.shade-img.no-photo { display: grid; place-items: center; background: linear-gradient(160deg, var(--card), var(--chip)); border: 1px solid var(--line); box-shadow: none; }
.shade-img.no-photo span { font-size: 22px; font-weight: 800; color: var(--muted); }
.shade-code { display: block; font-weight: 700; font-size: 14px; margin-top: 6px; line-height: 1.2; }
.shade-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--muted); font-size: 12px; line-height: 1.25; margin-top: 2px; min-height: 2.5em;
}
.in-cart {
  position: absolute; top: 6px; right: 6px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}
.in-cart.pop { animation: pop .35s var(--ease); }
@keyframes pop { from { transform: scale(.6); } }
.shades.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.shades.compact .shade-img { aspect-ratio: 1; border-radius: 12px; }
.shades.compact .shade-code { display: none; }
.shades.compact .in-cart { top: -6px; right: -6px; min-width: 22px; height: 22px; font-size: 11.5px; }

/* ---------- расходники */
.cat { margin-top: 28px; }
.cat-title { font-size: 19px; font-weight: 800; margin: 0 0 10px; }
.items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 620px) { .items { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .items { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.item { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--line); }
.item-img { aspect-ratio: 1; background: #fff; }
.item-img img { object-fit: contain; }
.item-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item-name {
  font-size: 13px; line-height: 1.3; min-height: 3.9em; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.item-price { font-weight: 800; font-size: 15px; }
.item-ctrl { height: 38px; }

/* ---------- кнопки и степпер */
.add {
  height: 38px; border-radius: 11px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 13.5px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .15s var(--ease);
}
.add .ic { width: 18px; height: 18px; }
.add:active { transform: scale(.97); }
.stepper { display: flex; align-items: center; height: 38px; border-radius: 11px; background: var(--chip); }
.stepper button { width: 40px; height: 38px; display: grid; place-items: center; border-radius: 11px; flex: none; }
.stepper button:active { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.stepper .ic { width: 18px; height: 18px; stroke-width: 2.2; }
.stepper input {
  flex: 1; min-width: 0; text-align: center; border: 0; background: none; font-weight: 800; font-size: 16px; outline: 0;
  -moz-appearance: textfield; appearance: textfield; padding: 0;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- нижняя панель (вне Telegram) */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); pointer-events: none; }
.bar-btn {
  pointer-events: auto; width: 100%; max-width: 560px; margin: 0 auto; height: 52px; border-radius: 15px; background: var(--accent); color: #fff;
  font-weight: 800; font-size: 15.5px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  box-shadow: 0 8px 20px rgba(184, 74, 116, .32); transition: transform .15s var(--ease);
}
.bar-btn:active { transform: scale(.98); }
.bar-left { display: inline-flex; align-items: center; gap: 8px; }
.bar-center { flex: 1; text-align: center; }

/* ---------- шторка */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 12, 14, .45); animation: fade .2s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  animation: up .28s var(--ease);
}
.sheet:not([data-mode="shade"]) .sheet-panel { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .sheet-panel { max-width: 560px; margin: 0 auto; } }
.sheet-grip { height: 22px; display: grid; place-items: center; position: sticky; top: 0; background: var(--bg); z-index: 1; }
.sheet-grip::after { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-x {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 34px; height: 34px; border-radius: 17px;
  display: grid; place-items: center; background: var(--chip); color: var(--muted);
}
.sheet-x .ic { width: 18px; height: 18px; }
@keyframes up { from { transform: translateY(48px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

.pick { display: grid; grid-template-columns: 116px 1fr; gap: 16px; align-items: start; padding-top: 4px; }
.pick-img { aspect-ratio: 3 / 5; border-radius: var(--r); overflow: hidden; background: var(--chip); }
.pick-img img { object-fit: cover; }
.pick-img.no-photo { display: grid; place-items: center; aspect-ratio: 1; }
.pick-img.no-photo span { font-size: 28px; font-weight: 800; color: var(--muted); }
.pick-line { color: var(--muted); font-size: 13px; font-weight: 600; padding-right: 36px; }
.pick-title { font-size: 26px; font-weight: 800; margin: 2px 0 8px; line-height: 1.1; }
.pick-title span { display: block; font-size: 16px; font-weight: 700; margin-top: 3px; }
.pick-desc { font-size: 14px; color: var(--muted); margin: 0; }
.vols { margin-top: 18px; display: grid; gap: 8px; }
.vol { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 8px 8px 8px 14px; }
.vol-name { font-weight: 700; }
.vol-price { color: var(--muted); font-size: 13px; }
.sheet-done { margin-top: 14px; width: 100%; height: 50px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 800; font-size: 15px; }
.sheet-h { font-size: 23px; font-weight: 800; margin: 2px 44px 8px 0; }
.form-h { font-size: 18px; margin-top: 24px; }

/* ---------- корзина и оформление */
.cart-line { display: grid; grid-template-columns: 44px minmax(0, 1fr) 118px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-thumb { width: 44px; height: 58px; border-radius: 10px; overflow: hidden; background: var(--chip); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--muted); }
.cart-thumb.item { background: #fff; border: 1px solid var(--line); }
.cart-thumb.item img { object-fit: contain; }
.cart-name { font-size: 13.5px; line-height: 1.3; overflow-wrap: anywhere; }
.cart-sum { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.cart-sum b { color: var(--ink); }
.cart-line .stepper { height: 34px; }
.cart-line .stepper button { width: 34px; height: 34px; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 0 4px; font-weight: 800; font-size: 19px; }
.total small { color: var(--muted); font-weight: 600; font-size: 13px; }
.clear-cart { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-top: 6px; padding: 6px 0; }
.clear-cart .ic { width: 16px; height: 16px; }
.form { display: grid; gap: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 0 0 5px 2px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; outline: 0; font-size: 16px;
  transition: border-color .15s;
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .8; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field.bad input { border-color: var(--danger); }
.field textarea { min-height: 76px; resize: vertical; }
.phone-row { display: flex; gap: 8px; }
.phone-row input { min-width: 0; }
.phone-row button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 13px; }
.phone-row .ic { width: 16px; height: 16px; }
.err { color: var(--danger); font-size: 13.5px; min-height: 18px; }

.done, .empty-cart { text-align: center; padding: 28px 8px 8px; }
.done-mark { width: 68px; height: 68px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; margin: 0 auto 14px; animation: pop .45s var(--ease); }
.done-mark .ic { width: 34px; height: 34px; stroke-width: 2.4; }
.done h2, .empty-cart h3 { margin: 0 0 6px; font-size: 22px; }
.done p, .empty-cart p { color: var(--muted); margin: 0 0 4px; }
.empty-cart .ic.big { color: var(--muted); margin-bottom: 8px; }
.empty-cart .sheet-done { margin-top: 20px; }

.empty { display: grid; gap: 4px; text-align: center; color: var(--muted); padding: 48px 12px; }
.empty b { color: var(--ink); font-size: 16px; }

/* ---------- палитра целиком */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #0d0b0c; animation: fade .2s ease; }
.lightbox-scroll { position: absolute; inset: 0; overflow: auto; display: grid; place-items: center; }
.lightbox img { max-width: 100%; max-height: 100vh; opacity: 0; transition: opacity .25s ease; cursor: zoom-in; }
.lightbox img.ok { opacity: 1; }
.lightbox.zoom img { max-width: none; max-height: none; width: 200%; cursor: zoom-out; }
.lightbox-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 1; width: 40px; height: 40px; border-radius: 20px;
  display: grid; place-items: center; background: rgba(255, 255, 255, .16); color: #fff;
}

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; z-index: 60; white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.toast .ic { width: 18px; height: 18px; color: var(--accent); stroke-width: 2.4; }
.toast.show { animation: toast .3s var(--ease); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

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