:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --text: #15171a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #ff5577;
  --accent-ink: #ffffff;
  --ok: #1aa260;
  --err: #d92d20;
  --warn: #b54708;
  --radius: 14px;
  --radius-sm: 10px;
  --pad: 16px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #1f232b;
    --text: #f3f4f6;
    --muted: #9aa1ab;
    --line: #262a32;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 8px var(--pad);
  padding-top: calc(8px + env(safe-area-inset-top));
  min-height: var(--topbar-h);
}
.topbar__back {
  border: 0; background: transparent; padding: 6px 10px;
  font-size: 28px; line-height: 1; color: var(--muted);
  border-radius: 10px;
}
.topbar__back:active { background: var(--surface-2); }
.topbar__titles { flex: 1; min-width: 0; }
.topbar__title { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__cart {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
}
.topbar__cart:active { background: var(--surface-2); }
.topbar__cart-i { font-size: 20px; }
.topbar__cart-c {
  position: absolute; top: 2px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 9px; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.topbar__cart-c[hidden] { display: none; }

/* ===== Screen ===== */
.screen { padding: var(--pad); display: grid; gap: 14px; }

.loading, .empty { color: var(--muted); padding: 30px 10px; text-align: center; }
.empty__h { font-size: 16px; color: var(--text); margin-bottom: 6px; }

/* ===== Hero (букет дня) ===== */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #ff8aa3);
  color: var(--accent-ink);
  min-height: 220px;
  display: grid; grid-template-rows: 1fr auto;
}
.hero__img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  opacity: .9;
}
.hero__shade {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,.55), rgba(0,0,0,.05) 60%, rgba(0,0,0,0));
}
.hero__body {
  position: relative; align-self: end; padding: 14px 16px 16px;
}
.hero__tag {
  display: inline-block; background: rgba(255,255,255,.18); backdrop-filter: blur(6px);
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.hero__h { margin: 8px 0 4px; font-size: 19px; font-weight: 700; line-height: 1.2; text-shadow: 0 1px 8px rgba(0,0,0,.25); }
.hero__price { font-size: 16px; font-weight: 700; }
.hero__price-old { opacity: .7; text-decoration: line-through; font-weight: 500; margin-left: 6px; font-size: 13px; }
.hero__cta {
  position: absolute; right: 14px; bottom: 14px;
  background: #fff; color: #15171a;
  border: 0; padding: 10px 14px; border-radius: 999px;
  font-weight: 700; font-size: 13px;
}

/* ===== Section header ===== */
.sec__h {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 4px 2px 0;
}
.sec__h h2 { margin: 0; font-size: 17px; font-weight: 700; }
.sec__h a { font-size: 13px; color: var(--muted); }

/* ===== Cards row (горизонтальный скролл) ===== */
.row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 64%;
  gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad) 4px;
  scrollbar-width: none;
}
.row::-webkit-scrollbar { display: none; }
.row > * { scroll-snap-align: start; }

/* ===== Product card ===== */
.pc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.pc__img-wrap { position: relative; aspect-ratio: 3 / 4; background: var(--surface-2); overflow: hidden; }
.pc__img { width: 100%; height: 100%; object-fit: cover; }
.pc__badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--accent); color: var(--accent-ink);
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.pc__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pc__name { font-size: 13px; line-height: 1.3; min-height: calc(1.3em * 2);
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc__price { display: flex; align-items: baseline; gap: 6px; margin-top: auto; }
.pc__price b { font-size: 15px; font-weight: 700; }
.pc__price s { font-size: 12px; color: var(--muted); }
.pc__oos { color: var(--warn); font-size: 12px; font-weight: 600; }

/* ===== Categories grid ===== */
.cats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.cat {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  display: block;
}
.cat__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cat__shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.6), rgba(0,0,0,0) 60%); }
.cat__name {
  position: absolute; left: 12px; bottom: 10px; right: 12px;
  color: #fff; font-weight: 700; font-size: 14px;
  text-shadow: 0 1px 6px rgba(0,0,0,.3);
}
.cat__count { color: rgba(255,255,255,.85); font-weight: 500; font-size: 11px; }

/* ===== Listing grid (category page) ===== */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

/* ===== Product page ===== */
.pp__gal {
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 8px;
  display: grid; grid-auto-flow: column; grid-auto-columns: 100%;
  overflow-x: auto; scroll-snap-type: x mandatory;
  background: var(--surface-2);
}
.pp__gal__cell { aspect-ratio: 3 / 4; overflow: hidden; scroll-snap-align: start; }
.pp__gal img { width: 100%; height: 100%; object-fit: cover; }
.pp__name { font-size: 20px; font-weight: 700; margin: 4px 0; }
.pp__price { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 14px; }
.pp__price b { font-size: 22px; font-weight: 700; }
.pp__price s { color: var(--muted); }
.pp__price .pc__badge { position: static; }
.pp__attrs { display: grid; gap: 6px; margin: 8px 0; }
.pp__attr { display: flex; gap: 8px; font-size: 13px; color: var(--muted); }
.pp__attr b { color: var(--text); font-weight: 600; }
.pp__desc { font-size: 14px; line-height: 1.5; color: var(--text); }
.pp__desc p { margin: 0 0 8px; }

/* ===== Sticky CTA ===== */
.cta-bar {
  position: sticky; bottom: 0; z-index: 5;
  margin: 12px calc(-1 * var(--pad)) 0;
  padding: 10px var(--pad);
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}

.btn {
  flex: 1; border: 0; padding: 13px 18px; border-radius: 12px;
  font-weight: 700; font-size: 15px;
  background: var(--accent); color: var(--accent-ink);
}
.btn:disabled { opacity: .5; }
.btn--ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }

/* Qty stepper */
.qty {
  display: inline-flex; align-items: center; gap: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.qty__b { width: 36px; height: 40px; border: 0; background: transparent; font-size: 18px; }
.qty__v { min-width: 32px; text-align: center; font-weight: 700; font-size: 14px; }

/* ===== Cart ===== */
.cart-line {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px;
  align-items: center;
}
.cart-line__img { width: 64px; height: 64px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2); }
.cart-line__name { font-size: 14px; line-height: 1.3; }
.cart-line__meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 4px; }
.cart-line__meta b { color: var(--text); font-weight: 700; }
.cart-line__rm { background: transparent; border: 0; color: var(--err); padding: 6px; font-size: 14px; }

.cart-total {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.cart-total b { font-size: 18px; font-weight: 700; }

/* ===== Form ===== */
.form { display: grid; gap: 12px; }
.form__field { display: grid; gap: 6px; }
.form__field label { font-size: 13px; color: var(--muted); }
.form__field input, .form__field textarea, .form__field select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit;
}
.form__field textarea { min-height: 80px; resize: vertical; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.phone-btn {
  border: 1px solid var(--line); background: var(--surface-2);
  padding: 10px 12px; border-radius: 10px; font-size: 13px;
  width: 100%; text-align: left;
}

/* ===== Badge / utility ===== */
.muted { color: var(--muted); font-size: 13px; }
.ok  { color: var(--ok); }
.err { color: var(--err); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(20,22,28,.92); color: #fff;
  padding: 10px 14px; border-radius: 12px;
  font-size: 13px; z-index: 50;
  max-width: 92vw;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
