/* ===== Палитра: светлая и тёмная тема (переключается по теме Telegram) ===== */
:root {
  --bg: #f6f1ee;
  --surface: #ffffff;
  --surface-2: #f4e1e6;
  --text: #2b2326;
  --muted: #8c7f84;
  --line: #ece4e0;
  --accent: #c27f91;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3e8;
  --cream: #f7ece2;
  --ok: #4f8a63;
  --ok-soft: #e3f0e6;
  --warn: #b7832f;
  --warn-soft: #f7ecd8;
  --danger: #b4534f;
  --danger-soft: #f6e1df;
  --shadow: 0 4px 16px rgba(90, 40, 55, .07);
  --radius: 18px;
  --radius-sm: 12px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171315; --surface: #221d20; --surface-2: #2e2428; --text: #f3eaed; --muted: #a8979d;
    --line: #382e32; --accent: #e0a3b3; --accent-ink: #24181c; --accent-soft: #3d2930; --cream: #2c2522;
    --ok: #7cbf8f; --ok-soft: #22332a; --warn: #e0b065; --warn-soft: #3a3020;
    --danger: #e38a85; --danger-soft: #3b2423; --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171315; --surface: #221d20; --surface-2: #2e2428; --text: #f3eaed; --muted: #a8979d;
  --line: #382e32; --accent: #e0a3b3; --accent-ink: #24181c; --accent-soft: #3d2930; --cream: #2c2522;
  --ok: #7cbf8f; --ok-soft: #22332a; --warn: #e0b065; --warn-soft: #3a3020;
  --danger: #e38a85; --danger-soft: #3b2423; --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ===== Верхняя панель ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name {
  font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow);
}
.icon-btn svg, .tabbar svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linejoin: round; stroke-linecap: round;
}
.badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ===== Контент ===== */
.view {
  max-width: 600px; margin: 0 auto;
  padding: 8px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  min-height: 70vh;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view, .card, .toast { animation: none !important; transition: none !important; } }

h1, h2, h3 { margin: 0; font-weight: 600; }
.page-title { font-family: var(--serif); font-size: 30px; line-height: 1.1; margin: 8px 0 14px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  font-family: var(--serif); font-size: 24px; margin: 26px 0 12px;
}
.section-title button { font: 600 13px var(--sans); color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ===== Баннер ===== */
.hero {
  position: relative; overflow: hidden;
  border-radius: 24px; padding: 28px 22px 24px;
  background: linear-gradient(135deg, var(--surface-2), var(--cream));
  box-shadow: var(--shadow);
}
.hero::after {
  content: "✨"; position: absolute; right: 2px; top: -4px; font-size: 76px; opacity: .4;
}
.hero-kicker { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.hero h1 { font-family: var(--serif); font-size: 38px; line-height: 1.02; margin: 0 0 10px; max-width: 85%; }
.hero p { margin: 0 0 18px; color: var(--muted); max-width: 90%; }
.hero p.hero-kicker { color: var(--accent); }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  transition: transform .12s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-block { display: flex; width: 100%; }
.btn-ghost { background: var(--accent-soft); color: var(--accent); }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn .spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: grid; gap: 10px; margin-top: 16px; }

/* ===== Категории ===== */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 14px; white-space: nowrap;
  transition: background .2s, color .2s;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cat-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 14px 6px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow);
  font-size: 13px; text-align: center; min-height: 86px;
}
.cat-tile .emoji { font-size: 24px; }

/* ===== Быстрые действия ===== */
.quick { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
.quick button {
  text-align: left; padding: 14px; border-radius: var(--radius-sm); background: var(--surface);
  box-shadow: var(--shadow); min-height: 84px;
}
.quick b { display: block; margin: 4px 0 2px; font-size: 14px; }
.quick span { font-size: 12px; color: var(--muted); }

/* ===== Карточки товаров ===== */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card {
  position: relative; text-align: left; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow);
  animation: fadeIn .3s ease both;
}
.card:active { transform: scale(.985); }
.card .ph { aspect-ratio: 4 / 5; background: var(--surface-2); }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card { cursor: pointer; display: flex; flex-direction: column; }
.card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.card-add {
  display: block; margin-top: auto; padding: 8px; border-radius: 10px; text-align: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px;
}
.card .price + .card-add { margin-top: 8px; }
.card-add.done { background: var(--accent); color: var(--accent-ink); }
.card-add.busy { opacity: .6; }
.card .title { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 36px; }
.card .price { margin-top: 4px; font-weight: 700; }
.card.sold .ph img { filter: grayscale(.7); opacity: .65; }
.status {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--ok-soft); color: var(--ok);
}
.status.preorder { background: var(--warn-soft); color: var(--warn); }
.status.sold, .status.cancelled { background: var(--danger-soft); color: var(--danger); }
.card .status { position: absolute; top: 10px; left: 10px; backdrop-filter: blur(6px); }

/* ===== Скелетоны ===== */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-card { aspect-ratio: 4 / 6; }

/* ===== Поиск ===== */
.search { position: relative; margin-bottom: 12px; }
.search input {
  width: 100%; height: 46px; padding: 0 14px 0 42px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.search input:focus { border-color: var(--accent); }
.search svg { position: absolute; left: 14px; top: 13px; width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2; }

/* ===== Страница товара ===== */
.gallery { position: relative; margin: 0 -16px; }
.gallery-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-track .slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 1 / 1; background: var(--surface-2); }
.gallery-track img { width: 100%; height: 100%; object-fit: cover; }
.dots { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.6); transition: width .2s, background .2s; }
.dots i.on { width: 18px; background: #fff; }
.product-head { margin-top: 16px; }
.product-head h1 { font-family: var(--serif); font-size: 30px; line-height: 1.1; }
.product-price { font-size: 24px; font-weight: 700; margin: 8px 0; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.notice { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: 14px; }
.notice.info { background: var(--accent-soft); }
.notice.danger { background: var(--danger-soft); }
.block { margin-top: 18px; }
.block-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.option { min-width: 48px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); }
.option.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.description { white-space: pre-line; }
.sticky-buy {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 10px); margin-top: 22px;
  display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.sticky-buy .btn { flex: 1; }

/* ===== Счётчик ===== */
.stepper { display: inline-flex; align-items: center; border-radius: 12px; background: var(--surface-2); }
.stepper button { width: 38px; height: 40px; font-size: 20px; color: var(--accent); }
.stepper button[disabled] { opacity: .3; }
.stepper span { min-width: 26px; text-align: center; font-weight: 600; }

/* ===== Корзина ===== */
.cart-item { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 10px; }
.cart-item .ph { width: 76px; height: 92px; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.cart-item img { width: 100%; height: 100%; object-fit: cover; }
.cart-item .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.cart-item .t { font-weight: 600; font-size: 14px; }
.remove { color: var(--muted); font-size: 13px; padding: 6px 0; }
.problem { color: var(--danger); font-size: 13px; margin-top: 4px; }
.summary { padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-top: 14px; }
.summary .line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.summary .total { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }

/* ===== Формы ===== */
.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none; font-size: 16px; /* 16px — чтобы iOS не зумил */
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field.error input, .field.error textarea, .field.error select { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: 12px; margin: 5px 0 0 2px; }
.field .hint { color: var(--muted); font-size: 12px; margin: 5px 0 0 2px; }
.methods { display: grid; gap: 10px; }
.method {
  display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1.5px solid var(--line); text-align: left; width: 100%;
}
.method.active { border-color: var(--accent); background: var(--accent-soft); }
.method .ico { font-size: 22px; }
.method b { display: block; font-size: 15px; }
.method span { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }
.check.error { color: var(--danger); }

.uploads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.upload-thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb button { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; line-height: 24px; }
.upload-add { aspect-ratio: 1; border-radius: 12px; border: 1.5px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 26px; background: var(--surface); }

/* ===== Заказы ===== */
.order-card { display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 10px; }
.order-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-card b { font-size: 16px; }
.order-items { display: grid; gap: 6px; }
.order-items div { display: flex; justify-content: space-between; gap: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ===== Пустые состояния и успех ===== */
.empty { text-align: center; padding: 48px 16px 24px; }
.empty .big { font-size: 46px; }
.empty h2 { font-family: var(--serif); font-size: 26px; margin: 10px 0 6px; }
.empty p { color: var(--muted); margin: 0 auto 18px; max-width: 320px; }
.success-mark {
  width: 84px; height: 84px; margin: 20px auto 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); font-size: 40px;
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Нижнее меню ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; }
.tabbar button.active { color: var(--accent); }
.tabbar button.active svg { stroke-width: 2.1; }
.tab-badge { top: 6px; right: calc(50% - 22px); }

/* ===== Тост ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 50;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg);
  font-size: 14px; box-shadow: var(--shadow); animation: fadeIn .2s ease;
}

.footer-note { margin: 28px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
