:root {
  --bg: #ffffff; --bg2: #f5f4f2; --card: #ffffff; --text: #21201f; --muted: #8b8885; --line: #ece9e5;
  --accent: #fce000; --accent-text: #21201f; --green: #2db84d; --error: #e53935;
  --radius: 20px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) { --bg: #141414; --bg2: #1f1f1f; --card: #232323; --text: #f2f2f2; --muted: #9a9a9a; --line: #2e2e2e; }
}
/* Внутри Telegram берём цвета темы пользователя */
:root[data-tg] {
  --bg: var(--tg-theme-bg-color, #fff); --bg2: var(--tg-theme-secondary-bg-color, #f5f4f2);
  --card: var(--tg-theme-bg-color, #fff); --text: var(--tg-theme-text-color, #21201f);
  --muted: var(--tg-theme-hint-color, #8b8885); --line: color-mix(in srgb, var(--muted) 25%, transparent);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body { margin: 0; font: 16px/1.35 -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { font: inherit; color: var(--text); width: 100%; padding: 14px 16px; border: 0; border-radius: 14px; background: var(--bg2); outline: none; }
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 2px var(--accent) inset; }
textarea { resize: vertical; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); }
[hidden] { display: none !important; }

/* --- шапка заведения --- */
.hero { position: relative; height: 200px; background: linear-gradient(135deg, #ffcf3d, #ff8a3d); background-size: cover; background-position: center; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(0,0,0,.45)); }
.hero-bar { position: absolute; z-index: 2; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; }
.round { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.92); color: #21201f; display: grid; place-items: center; font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.pill-btn { height: 40px; padding: 0 16px; border-radius: 20px; background: rgba(255,255,255,.92); color: #21201f; font-weight: 600; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.venue-card { position: relative; margin: -40px 16px 0; z-index: 3; background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 4px 24px rgba(0,0,0,.08); max-width: 1068px; }
@media (min-width: 1100px) { .venue-card { margin: -40px auto 0; } }
.venue-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.3px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip { font-size: 13px; padding: 6px 12px; border-radius: 12px; background: var(--bg2); }
.chip.demo { background: #fff3c4; color: #6b5300; }

/* --- поиск и категории --- */
.search { margin: 16px 0 0; position: relative; }
.search input { padding-left: 44px; }
.search::before { content: "⌕"; position: absolute; left: 16px; top: 50%; transform: translateY(-52%); font-size: 20px; color: var(--muted); }
.cats { position: sticky; top: 0; z-index: 10; background: var(--bg); display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats.shadow { box-shadow: 0 6px 12px -8px rgba(0,0,0,.15); }
.cats button { white-space: nowrap; padding: 9px 16px; border-radius: 14px; font-size: 15px; font-weight: 500; }
.cats button.on { background: var(--text); color: var(--bg); }

/* --- меню --- */
.section-title { font-size: 24px; font-weight: 700; margin: 22px 0 12px; scroll-margin-top: 70px; letter-spacing: -.3px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.card { background: var(--bg2); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; cursor: pointer; transition: transform .1s; }
.card:active { transform: scale(.98); }
.card .ph { aspect-ratio: 1; border-radius: 14px; background: var(--card) center/cover no-repeat; display: grid; place-items: center; font-size: 44px; }
.card .price { font-weight: 700; font-size: 18px; margin: 10px 4px 2px; }
.card .name { margin: 0 4px; font-size: 14px; flex: 1; }
.card .desc { margin: 2px 4px 0; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .act { margin-top: 10px; }
.card.off { opacity: .45; pointer-events: none; }
.add-btn { width: 100%; height: 40px; border-radius: 12px; background: var(--card); font-weight: 600; font-size: 15px; }
.stepper { display: flex; align-items: center; justify-content: space-between; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.stepper button { width: 40px; height: 40px; font-size: 20px; color: inherit; }
.stepper.small { height: 34px; width: 104px; background: var(--bg2); color: var(--text); }
.stepper.small button { width: 34px; height: 34px; }
.empty { text-align: center; padding: 40px 0; color: var(--muted); }

/* --- нижняя кнопка --- */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.bottom .inner { max-width: 600px; margin: 0 auto; }
.main-btn { width: 100%; min-height: 56px; border-radius: 18px; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 12px; }
.main-btn.center { justify-content: center; }
.main-btn:disabled { opacity: .6; }
.main-btn .sub { font-weight: 500; font-size: 14px; opacity: .75; }
.spacer { height: 100px; }

/* --- шторки --- */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 600px; max-height: 92vh; border-radius: 24px 24px 0 0; background: var(--bg); color: var(--text); overflow: auto; }
@media (min-width: 640px) { .sheet { margin: auto; border-radius: 24px; } }
.sheet::backdrop { background: rgba(0,0,0,.5); }
.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet-pad { padding: 20px 20px 0; }
.sheet .close { position: absolute; right: 14px; top: 14px; z-index: 2; }
.sheet .big-ph { aspect-ratio: 4/3; background: var(--bg2) center/cover no-repeat; display: grid; place-items: center; font-size: 80px; }
.sheet h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.3px; }
.sheet-foot { position: sticky; bottom: 0; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); }
.opt-group { margin: 20px 0; }
.opt-group h3 { margin: 0 0 4px; font-size: 18px; display: flex; justify-content: space-between; align-items: baseline; }
.opt-group h3 small { font-weight: 500; font-size: 12px; color: var(--muted); }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.opt span { flex: 1; }
.opt input { width: 22px; height: 22px; accent-color: var(--text); margin: 0; }
.seg { display: flex; background: var(--bg2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 10px; border-radius: 11px; font-weight: 600; font-size: 15px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* --- корзина --- */
.cart-head { display: flex; justify-content: space-between; align-items: center; }
.cart-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: center; }
.cart-item .thumb { width: 64px; height: 64px; border-radius: 14px; background: var(--bg2) center/cover no-repeat; display: grid; place-items: center; font-size: 28px; flex-shrink: 0; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .info small { display: block; color: var(--muted); font-size: 13px; }
.link { color: var(--muted); font-size: 14px; }

/* --- оформление --- */
.page-head { display: flex; align-items: center; gap: 12px; padding: 12px 0; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.page-head h1 { font-size: 22px; margin: 0; }
.back { width: 40px; height: 40px; border-radius: 50%; background: var(--bg2); font-size: 18px; }
.block { background: var(--bg2); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.block h2 { font-size: 18px; margin: 0 0 12px; }
.block input, .block textarea, .block select { background: var(--card); margin: 4px 0; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (max-width: 420px) { .row4 { grid-template-columns: repeat(2, 1fr); } }
.sum-row { display: flex; justify-content: space-between; padding: 4px 0; }
.sum-row.total { font-weight: 700; font-size: 18px; padding-top: 10px; }
.tg-phone { margin-top: 6px; font-size: 14px; color: #2481cc; font-weight: 600; }

/* --- статус заказа --- */
.status-hero { text-align: center; padding: 24px 0 8px; }
.status-hero .emoji { font-size: 64px; }
.status-hero h1 { margin: 8px 0 4px; font-size: 26px; letter-spacing: -.3px; }
.steps { display: flex; gap: 6px; margin: 20px 0; }
.steps div { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps div.on { background: var(--green); }
.steps div.now { background: linear-gradient(90deg, var(--green) 50%, var(--line) 50%); background-size: 200% 100%; animation: pulse 1.4s linear infinite; }
@keyframes pulse { from { background-position: 100% 0; } to { background-position: 0 0; } }
.order-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 15px; }
.history-item { display: block; width: 100%; text-align: left; background: var(--bg2); border-radius: var(--radius); padding: 16px; margin: 10px 0; }
.history-item .top { display: flex; justify-content: space-between; font-weight: 600; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 10px; background: var(--card); margin-top: 6px; }
.badge.live { background: #dff5e3; color: #1d7a35; }

/* --- каталог заведений --- */
.venues { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.venue-tile { text-align: left; border-radius: var(--radius); overflow: hidden; background: var(--bg2); }
.venue-tile .cover { height: 150px; background: linear-gradient(135deg, #ffcf3d, #ff8a3d) center/cover; }
.venue-tile .t { padding: 12px 14px 16px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 50; background: #21201f; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
