:root {
  --bg: #FAF5EF;
  --card: #FFFFFF;
  --brand: #7B1426;
  --brand-2: #9E1C33;
  --brand-soft: #F6E7E4;
  --gold: #C8A04F;
  --gold-soft: #F4EAD3;
  --text: #2A1A1C;
  --muted: #8C7B7D;
  --line: #EEE3DA;
  --radius: 20px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 6px 20px rgba(91, 30, 38, .08);
  --glass: rgba(255, 255, 255, .92);
  --tabbar-bg: rgba(255, 255, 255, .94);
  --ok: #2E7D4F;
  --ok-soft: #E5F3EA;
  --gold-text: #8A6A22;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #161012;
  --card: #221A1C;
  --brand: #B8324C;
  --brand-2: #CC4560;
  --brand-soft: #3B2128;
  --gold: #D1AA5C;
  --gold-soft: #3A301E;
  --text: #F4EAE7;
  --muted: #A6969A;
  --line: #352A2D;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --glass: rgba(34, 26, 28, .88);
  --tabbar-bg: rgba(28, 21, 23, .94);
  --ok: #6FCF97;
  --ok-soft: #1F3328;
  --gold-text: #E2C27E;
  color-scheme: dark;
}
html, body, .card, .panel, .list, .stat, .tabbar, .sheet, .search, .chip, .cart-item { transition: background-color .25s, color .25s, border-color .25s; }
[data-theme="dark"] .top h1, [data-theme="dark"] .page-title, [data-theme="dark"] .sheet-body h2, [data-theme="dark"] .success h2 { color: #F0C9D0; }
[data-theme="dark"] .stepper span, [data-theme="dark"] .stepper button,
[data-theme="dark"] .size.active span, [data-theme="dark"] .seg button.active,
[data-theme="dark"] .list-item .ic, [data-theme="dark"] .tab.active, [data-theme="dark"] .stat b { color: #F29BAD; }
[data-theme="dark"] .tab.active::before { background: #F29BAD; }
[data-theme="dark"] .heart, [data-theme="dark"] .sheet .close { color: #F29BAD; }
[data-theme="dark"] .heart.on svg { fill: #F29BAD; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
#view { padding: 0 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 16px 0 12px; }
.logo {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #A3263B, var(--brand) 70%);
  display: grid; place-items: center;
  color: var(--gold); font-family: "Playfair Display", serif; font-style: italic; font-weight: 600;
  font-size: 11px; line-height: 1; text-align: center; letter-spacing: .3px;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--gold);
}
.top h1 { margin: 0; font-family: "Playfair Display", serif; font-size: 21px; font-weight: 700; color: var(--brand); }
.top p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.top .grow { flex: 1; min-width: 0; }
.open-pill { font-size: 11.5px; font-weight: 700; color: var(--ok); background: var(--ok-soft); padding: 5px 9px; border-radius: 99px; white-space: nowrap; }
.open-pill.closed { color: var(--brand); background: var(--brand-soft); }

.page-title { font-family: "Playfair Display", serif; font-size: 26px; color: var(--brand); margin: 20px 0 14px; }

/* ---------- search & chips ---------- */
.search {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border-radius: 14px; padding: 0 14px; height: 46px; box-shadow: var(--shadow);
}
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; font-size: 15px; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 4px; padding: 2px 16px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 15px; border-radius: 99px; background: var(--card);
  font-weight: 600; font-size: 13.5px; color: var(--text); border: 1px solid var(--line); white-space: nowrap;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- promo banner ---------- */
.promo {
  margin-top: 14px; border-radius: var(--radius); padding: 18px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #8E1A2E 0%, #5E0E1C 100%);
}
.promo::after {
  content: "🍓"; position: absolute; right: -6px; bottom: -14px; font-size: 92px; opacity: .9; transform: rotate(-12deg);
}
.promo b { display: block; font-family: "Playfair Display", serif; font-size: 19px; margin-bottom: 4px; color: #F4EAD3; max-width: 75%; }
.promo span { font-size: 13px; opacity: .85; display: block; max-width: 70%; }

/* ---------- grid / cards ---------- */
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 12px; }
.section-h h2 { margin: 0; font-size: 18px; font-weight: 800; }
.section-h small { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; text-align: left; }
.art { position: relative; aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; }
.art .emoji { font-size: 64px; filter: drop-shadow(0 8px 10px rgba(0,0,0,.18)); transition: transform .25s; }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card:active .art .emoji { transform: scale(.94); }
.tag { position: absolute; left: 10px; top: 10px; font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 8px; background: var(--gold); color: #fff; letter-spacing: .3px; text-transform: uppercase; }
.tag.new { background: #2E7D4F; }
.heart {
  position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--glass); display: grid; place-items: center; color: var(--brand);
}
.heart svg { width: 19px; height: 19px; }
.heart.on svg { fill: var(--brand); }
.heart.pop { animation: pop .35s; }
@keyframes pop { 50% { transform: scale(1.25); } }

.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.card-body .name { font-weight: 700; font-size: 14.5px; line-height: 1.25; margin-bottom: 2px; }
.card-body .meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.price { font-weight: 800; font-size: 14.5px; white-space: nowrap; }
.price small { font-weight: 600; color: var(--muted); font-size: 11px; }
.add { width: 34px; height: 34px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.add svg { width: 18px; height: 18px; stroke-width: 2.4; }

.stepper { display: inline-flex; align-items: center; background: var(--brand-soft); border-radius: 12px; height: 34px; }
.stepper button { width: 32px; height: 34px; color: var(--brand); font-size: 18px; font-weight: 700; }
.stepper span { min-width: 18px; text-align: center; font-weight: 800; font-size: 14px; color: var(--brand); }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 60px 20px 20px; color: var(--muted); }
.empty .big { font-size: 64px; margin-bottom: 12px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; }
.empty p { margin: 0 0 20px; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: 52px; border-radius: 16px; background: var(--brand); color: #fff; font-weight: 800; font-size: 16px;
}
.btn:active { background: var(--brand-2); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.inline { width: auto; display: inline-flex; padding: 0 24px; }

/* ---------- cart ---------- */
.cart-item { display: flex; gap: 12px; background: var(--card); border-radius: 18px; padding: 10px; margin-bottom: 10px; box-shadow: var(--shadow); align-items: center; }
.cart-item .art { width: 72px; height: 72px; border-radius: 14px; flex: none; aspect-ratio: auto; }
.cart-item .art .emoji { font-size: 36px; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .name { font-weight: 700; font-size: 14.5px; }
.cart-item .meta { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; }
.cart-item .row { display: flex; justify-content: space-between; align-items: center; }

.panel { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 14px; padding: 4px; }
.seg button { height: 40px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button.active { background: var(--card); color: var(--brand); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; outline: 0; font-size: 15px; resize: none;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); }
.sum-row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); }
.sum-row.total { color: var(--text); font-weight: 800; font-size: 18px; border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 12px; }
.checkout-bar { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); margin-top: 16px; z-index: 5; }
.checkout-bar .btn { box-shadow: 0 10px 24px rgba(123, 20, 38, .3); }
.checkout-bar .btn small { font-weight: 600; opacity: .85; }

/* ---------- profile ---------- */
.profile-card { display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, #8E1A2E, #5E0E1C); color: #fff; border-radius: var(--radius); padding: 18px; margin-top: 18px; }
.avatar { width: 60px; height: 60px; border-radius: 50%; background: var(--gold); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 24px; overflow: hidden; flex: none; border: 2px solid #F4EAD3; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-card h2 { margin: 0; font-size: 19px; }
.profile-card p { margin: 3px 0 0; opacity: .8; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 18px; color: var(--brand); }
.stat span { font-size: 11.5px; color: var(--muted); }

.list { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); margin-top: 14px; overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%; text-align: left; text-decoration: none; color: inherit; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-item .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.list-item .ic svg { width: 20px; height: 20px; }
.list-item .tx { flex: 1; min-width: 0; }
.list-item .tx b { display: block; font-size: 14.5px; font-weight: 700; }
.list-item .tx small { color: var(--muted); font-size: 12.5px; }
.list-item .chev { color: var(--muted); width: 18px; height: 18px; }
.lang { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 10px; }
.lang button { padding: 6px 10px; border-radius: 8px; font-weight: 700; font-size: 12.5px; color: var(--muted); }
.lang button.active { background: var(--brand); color: #fff; }

.order { padding: 14px 16px; }
.order + .order { border-top: 1px solid var(--line); }
.order .row { display: flex; justify-content: space-between; align-items: center; }
.order .id { font-weight: 800; }
.order .st { font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: var(--gold-soft); color: var(--gold-text); }
.order small { color: var(--muted); display: block; margin-top: 4px; font-size: 12.5px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--tabbar-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 700; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--brand); }
.tab.active svg { fill: var(--brand-soft); }
.tab.active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.badge {
  position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--gold); color: #fff; font-size: 10.5px; font-style: normal; font-weight: 800;
  display: none; align-items: center; justify-content: center; border: 2px solid var(--card);
}
.badge.show { display: flex; }
.badge.bump { animation: pop .35s; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(30, 10, 14, .45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30; }
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: 100%; max-width: 560px; z-index: 31;
  transform: translate(-50%, 105%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  background: var(--card); border-radius: 26px 26px 0 0; max-height: 92vh; overflow-y: auto;
  padding-bottom: calc(16px + var(--safe-b));
}
.sheet.show { transform: translate(-50%, 0); }
.sheet .art { aspect-ratio: 4 / 3; border-radius: 26px 26px 0 0; }
.sheet .art .emoji { font-size: 120px; }
.sheet .grabber { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.7); z-index: 2; }
.sheet .close { position: absolute; right: 12px; top: 14px; width: 34px; height: 34px; border-radius: 50%; background: var(--glass); display: grid; place-items: center; z-index: 2; }
.sheet .close svg { width: 18px; height: 18px; }
.sheet .heart { right: 54px; top: 14px; }
.sheet-body { padding: 18px 18px 0; }
.sheet-body h2 { margin: 0 0 6px; font-family: "Playfair Display", serif; font-size: 24px; color: var(--brand); }
.sheet-body .desc { color: var(--muted); margin: 0 0 16px; line-height: 1.5; }
.sheet-body .label { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.sizes { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.size { flex: 1; min-width: 120px; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; text-align: left; }
.size b { display: block; font-size: 14px; }
.size span { font-size: 13px; color: var(--muted); }
.size.active { border-color: var(--brand); background: var(--brand-soft); }
.size.active span { color: var(--brand); }
.sheet-actions { display: flex; gap: 12px; align-items: center; }
.sheet-actions .stepper { height: 52px; border-radius: 16px; }
.sheet-actions .stepper button { width: 44px; height: 52px; font-size: 22px; }
.sheet-actions .stepper span { min-width: 24px; font-size: 16px; }

.success { text-align: center; padding: 34px 22px 10px; }
.success .big { width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 50%; background: var(--ok-soft); display: grid; place-items: center; font-size: 42px; }
.success h2 { font-family: "Playfair Display", serif; color: var(--brand); margin: 0 0 8px; }
.success p { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px); transform: translate(-50%, -20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 40; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fade-in { animation: fade .25s ease; }
/* только opacity: transform на #view ломает position:fixed у .cart-footer во время анимации */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- checkout page ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin: 16px 0 14px; }
.page-head .page-title { margin: 0; }
.back { width: 40px; height: 40px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--text); flex: none; }
.back svg { width: 20px; height: 20px; stroke-width: 2.2; }

.pay-card {
  border-radius: 18px; padding: 16px 18px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #9E1C33 0%, #5E0E1C 100%);
  box-shadow: 0 10px 24px rgba(94, 14, 28, .28);
}
.pay-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, rgba(200,160,79,.35), transparent 70%); }
.pay-top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 14px; color: #F4EAD3; letter-spacing: .5px; }
.chip-ic { width: 34px; height: 24px; border-radius: 6px; background: linear-gradient(135deg, #E8CF8F, #B8913F); }
.pay-num { font-size: 21px; font-weight: 800; letter-spacing: 2px; margin: 18px 0 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pay-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; position: relative; z-index: 1; }
.pay-bottom small { display: block; font-size: 11px; opacity: .7; }
.pay-bottom b { font-size: 14px; letter-spacing: .5px; }
.copy { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 10px; background: rgba(255,255,255,.18); color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.copy svg { width: 16px; height: 16px; }
.copy.ghost { background: var(--brand-soft); color: var(--brand); width: 38px; padding: 0; justify-content: center; }
[data-theme="dark"] .copy.ghost { color: #F29BAD; }
.pay-amount { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg); }
.pay-amount small { display: block; color: var(--muted); font-size: 12px; }
.pay-amount b { font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 12px 0 0; }

.upload {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 16px; padding: 22px 16px; background: var(--bg);
}
.upload:active { border-color: var(--gold); }
.upload-ic { width: 52px; height: 52px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 4px; }
[data-theme="dark"] .upload-ic { color: #F29BAD; }
.upload b { font-size: 15px; }
.upload small { color: var(--muted); font-size: 12.5px; }
.upload.shake { animation: shake .4s; border-color: var(--brand); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.receipt { display: flex; gap: 12px; align-items: center; }
.receipt img { width: 72px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); flex: none; }
.receipt-info { min-width: 0; flex: 1; }
.receipt-info b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-info small { color: var(--muted); font-size: 12.5px; }
.receipt-actions { display: flex; gap: 16px; margin-top: 8px; }
.link { color: var(--brand); font-weight: 700; font-size: 13.5px; cursor: pointer; }
[data-theme="dark"] .link { color: #F29BAD; }
.link.danger { color: var(--muted); }
.btn.disabled, .checkout-bar .btn.disabled { background: #C9B3B7; color: #fff; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
[data-theme="dark"] .btn.disabled, [data-theme="dark"] .checkout-bar .btn.disabled { background: #4A3A3E; color: #BFAFB2; }

/* ---------- cart footer (pinned above tab bar) ---------- */
.cart-footer {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 10;
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  width: 100%; max-width: 560px; padding: 18px 16px 12px;
  background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}
.cart-footer .panel { margin: 0 0 12px; padding: 12px 16px; }
.cart-footer .sum-row { padding: 4px 0; font-size: 14px; }
.cart-footer .sum-row.total { font-size: 17px; padding-top: 10px; }
.cart-footer .btn { box-shadow: 0 10px 24px rgba(123, 20, 38, .3); }
.cart-footer .btn small { font-weight: 600; opacity: .85; }
.cart-footer-space { height: 200px; }
