:root {
  --brand: #3B2A20;
  --accent: #C8763A;
  --accent-ink: #fff;
  --bg: #F6F1EA;
  --surface: #FFFFFF;
  --surface-2: #EFE8DE;
  --ink: #23180F;
  --muted: #7D6E62;
  --line: #E4DACD;
  --danger: #B23A2E;
  --ok: #2F7D4F;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(35, 24, 15, .06), 0 6px 20px rgba(35, 24, 15, .06);
  color-scheme: light;
}

/* Тёмная тема браузера (на сайте). В Telegram цвета приходят из themeParams. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120E; --surface: #221A14; --surface-2: #2C221A; --ink: #F3EADF;
    --muted: #AD9C8D; --line: #3A2E24; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17120E; --surface: #221A14; --surface-2: #2C221A; --ink: #F3EADF;
  --muted: #AD9C8D; --line: #3A2E24; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.page { padding-bottom: 110px; }

/* загрузка */
.loading { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* шапка */
.hero { background: var(--brand); color: #fff; padding: 22px 0 26px; border-radius: 0 0 28px 28px; }
.hero .wrap { display: flex; gap: 14px; align-items: center; }
.hero-logo { width: 56px; height: 56px; border-radius: 16px; object-fit: cover; background: rgba(255,255,255,.12); flex: none; display: grid; place-items: center; font-weight: 800; font-size: 24px; }
.hero h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; line-height: 1.15; }
.hero p { margin: 2px 0 0; opacity: .78; font-size: 13.5px; }
.hero .meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; opacity: .7; }
.tg .hero { display: none; }

.banner { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); font-weight: 600; font-size: 14px; }
.active-order { margin: 14px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); width: 100%; text-align: left; }
.active-order b { color: var(--accent); }

/* категории */
.cats { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 8px; }
.cats-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.cats-row::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 15px; border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; box-shadow: inset 0 0 0 1px var(--line); transition: background .15s, color .15s; }
.chip.on { background: var(--ink); color: var(--bg); box-shadow: none; }

.section-title { margin: 22px 0 10px; font-size: 19px; font-weight: 800; letter-spacing: -.02em; scroll-margin-top: 64px; }

/* товары */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; text-align: left; transition: transform .12s; }
.card:active { transform: scale(.98); }
.card .ph { aspect-ratio: 1 / 1; background: var(--surface-2); position: relative; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.ph-letter { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 800; color: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card .name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.card .desc { color: var(--muted); font-size: 12.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; }
.price { font-weight: 800; }
.plus { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 20px; font-weight: 700; line-height: 1; }
.card.off { opacity: .5; }
.card.off .plus { display: none; }
.badge-off { font-size: 12px; color: var(--muted); font-weight: 600; }
.in-cart { position: absolute; top: 8px; right: 8px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; display: grid; place-items: center; }

/* нижняя панель корзины (на сайте; в Telegram — MainButton) */
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 60%, transparent); z-index: 10; }
.cartbar .btn { max-width: 688px; margin: 0 auto; }
.tg .cartbar { display: none; }

.btn { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 18px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 16px; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.split { justify-content: space-between; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }

/* шторка товара */
.overlay { position: fixed; inset: 0; background: rgba(15, 10, 6, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; scroll-padding-bottom: 96px; background: var(--surface); border-radius: 26px 26px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); animation: up .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 26px; } }
.overlay.static, .overlay.static .sheet { animation: none; }
.sheet .ph { aspect-ratio: 16 / 10; background: var(--surface-2); position: relative; }
.sheet .ph img { width: 100%; height: 100%; object-fit: cover; }
.sheet-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 18px; display: grid; place-items: center; z-index: 1; }
.sheet .inner { padding: 16px 18px 0; }
.sheet h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.sheet .desc { margin: 4px 0 0; color: var(--muted); }
.group { margin-top: 18px; }
.group-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 8px; }
.group-title small { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.seg { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 11px; font-weight: 600; font-size: 14px; line-height: 1.2; }
.seg button small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); }
.opt { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.opt:last-child { border-bottom: 0; }
.opt .mark { width: 22px; height: 22px; flex: none; border-radius: 7px; box-shadow: inset 0 0 0 2px var(--line); display: grid; place-items: center; transition: background .12s; }
.opt.radio .mark { border-radius: 50%; }
.opt.on .mark { background: var(--accent); box-shadow: none; }
.opt.on .mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); }
.opt .t { flex: 1; }
.opt .p { color: var(--muted); font-size: 14px; }
.opt[disabled] { opacity: .4; }
.sheet-foot { display: flex; gap: 10px; align-items: center; padding: 18px 18px 0; position: sticky; bottom: 0; background: var(--surface); }
.qty { display: flex; align-items: center; background: var(--surface-2); border-radius: 14px; height: 52px; flex: none; }
.qty button { width: 42px; height: 52px; font-size: 22px; font-weight: 600; }
.qty span { min-width: 22px; text-align: center; font-weight: 800; }
.qty.sm { height: 36px; border-radius: 11px; }
.qty.sm button { width: 32px; height: 36px; font-size: 18px; }

/* корзина и оформление */
.topbar { display: flex; align-items: center; gap: 10px; padding: 16px 0 6px; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.back { width: 38px; height: 38px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; font-size: 18px; }
.tg .back { display: none; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 14px; margin-top: 12px; }
.line { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .info { flex: 1; min-width: 0; }
.line .info .n { font-weight: 700; }
.line .info .m { color: var(--muted); font-size: 13px; }
.line .sum { font-weight: 800; white-space: nowrap; }
.total-row { display: flex; justify-content: space-between; padding: 14px 0; font-size: 17px; font-weight: 800; }
.field { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field span { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; border: 0; background: transparent; outline: none; font-size: 16px; padding: 2px 0; resize: none; }
.field select { appearance: none; }
.note { color: var(--muted); font-size: 13px; margin: 10px 2px 0; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 46px; margin-bottom: 6px; }

/* статус заказа */
.order-num { text-align: center; padding: 26px 0 8px; }
.order-num small { color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; font-size: 12px; }
.order-num div { font-size: 64px; font-weight: 800; letter-spacing: -.04em; line-height: 1; margin-top: 4px; }
.steps { display: flex; gap: 6px; margin: 18px 0 6px; }
.steps i { flex: 1; height: 6px; border-radius: 6px; background: var(--line); }
.steps i.on { background: var(--accent); }
.status-text { text-align: center; font-size: 18px; font-weight: 700; }
.status-sub { text-align: center; color: var(--muted); margin-top: 2px; }
.status-text.cancel { color: var(--danger); }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }

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