/* ===== Токены дизайна ===== */
:root {
  --red: #D71F26; --red-dark: #B3141B;
  --red-soft: #FDECEC; --red-ink: #8F1217;
  --white: #FFFFFF; --grey: #F4F3F1; --line: #EEEDEA;
  --text: #1B1B1B; --muted: #6B6B6B;
  --r-card: 22px; --r-btn: 14px; --r-pill: 999px;
  --h: 44px; /* минимальная высота кнопок и полей */
  --f-head: 'Unbounded', 'Manrope', sans-serif;
  --f-body: 'Manrope', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 130px; }
body { margin: 0; font: 500 15px/1.4 var(--f-body); color: var(--text); background: var(--white); -webkit-text-size-adjust: 100%; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* ===== Кнопки ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h);
  padding: 0 18px; border-radius: var(--r-btn); font-weight: 700; transition: background .15s; }
.btn--red { background: var(--red); color: #fff; }
.btn--red:hover { background: var(--red-dark); }
.btn--grey { background: var(--grey); }
.btn--grey:hover { background: var(--line); }
.btn--block { width: 100%; min-height: 52px; font-size: 16px; }
.grow { flex: 1; }
.icon-btn { width: var(--h); height: var(--h); border-radius: 50%; background: var(--grey); display: grid; place-items: center; }

/* ===== Шапка ===== */
.header { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); }
.header__in { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.logo { text-decoration: none; font: 800 20px/1 var(--f-head); letter-spacing: -.02em; }
.logo b { color: var(--red); }
.logo--w { color: #fff; }
.halal { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1.5px solid var(--red);
  border-radius: var(--r-pill); color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.halal--sm { margin-bottom: 8px; }


/* ===== Переключатель, поиск ===== */
.seg { display: flex; gap: 4px; padding: 4px; margin: 14px 0 12px; background: var(--grey); border-radius: var(--r-btn); }
.seg button { flex: 1; min-height: 40px; border-radius: 11px; font-weight: 700; color: var(--muted); }
.seg .is-on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.search { display: flex; align-items: center; gap: 10px; min-height: var(--h); padding: 0 14px; background: var(--grey);
  border-radius: var(--r-btn); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: var(--h); color: var(--text); }
.search:focus-within { box-shadow: 0 0 0 2px var(--red); }
.header .cart-btn, .header .search--head { display: none; }

/* ===== Баннер ===== */
.banner { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 14px 0 18px; padding: 20px; background: var(--red); color: #fff; border-radius: 24px; overflow: hidden; }
.banner__kicker { display: inline-block; margin-bottom: 8px; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.banner h1 { font: 800 24px/1.1 var(--f-head); letter-spacing: -.02em; }
.banner p { margin-top: 8px; font-size: 14px; opacity: .92; max-width: 30ch; }
.seal { flex: none; width: 104px; height: 104px; transform: rotate(-8deg); filter: drop-shadow(0 4px 10px rgba(0,0,0,.18)); }

/* ===== Категории и меню ===== */
.cats { position: sticky; top: 60px; z-index: 10; display: flex; gap: 8px; margin: 0 -16px; padding: 10px 16px;
  overflow-x: auto; background: #fff; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: var(--h); padding: 0 18px; border-radius: var(--r-pill);
  background: var(--grey); text-decoration: none; font-weight: 700; white-space: nowrap; }
.chip.is-on { background: var(--text); color: #fff; }
.cat { padding-top: 6px; }
.cat h2 { margin: 14px 0 12px; font: 800 20px/1.2 var(--f-head); letter-spacing: -.02em; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.card { display: flex; flex-direction: column; padding: 8px 8px 10px; background: var(--grey); border-radius: var(--r-card); }
.card__photo { position: relative; display: block; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: #E9E7E3; }
.ph { width: 100%; height: 100%; display: grid; place-items: center; color: #B9B6B0; }
.badge { position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: var(--r-pill); background: var(--red); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .05em; }
.card__price { margin: 10px 4px 0; font: 800 20px/1.1 var(--f-head); letter-spacing: -.02em; }
.card__name { margin: 4px 4px 10px; font-size: 14px; font-weight: 600; line-height: 1.25; flex: 1; }
.card__add { background: #fff; width: 100%; }
.card__add:hover { background: var(--red-soft); color: var(--red-ink); }

/* ===== Филиалы, подвал ===== */
.branches { margin: 36px 0 28px; padding: 20px; background: var(--grey); border-radius: 24px; }
.branches h2 { margin-bottom: 14px; font: 800 20px/1.2 var(--f-head); }
.branches ul { display: grid; gap: 8px 24px; font-size: 14px; max-height: 340px; overflow: auto; }
.branches li span { display: block; color: var(--muted); font-size: 13px; }
.map { display: grid; place-items: center; min-height: 200px; margin-top: 16px; border-radius: 16px; background: #E9E7E3; color: var(--muted); font-weight: 700; }
.footer { padding: 28px 0 110px; background: #1B1B1B; color: #cfcdc8; }
.footer__in { display: grid; gap: 10px; }
.footer a { color: #fff; font-weight: 700; }
.footer li { margin-top: 4px; }

/* ===== Плавающая корзина ===== */
.fab { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 30; min-height: 54px; justify-content: space-between;
  font-size: 16px; box-shadow: 0 8px 24px rgba(215,31,38,.35); }
.fab__n { display: grid; place-items: center; min-width: 26px; height: 26px; border-radius: 13px; background: #fff; color: var(--red); font-size: 14px; }

/* ===== Шторки (dialog) ===== */
.sheet { width: 100%; max-width: 560px; max-height: 90vh; max-height: 90dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 26px 26px 0 0;
  background: #fff; color: var(--text); overflow: hidden; flex-direction: column; }
.sheet[open] { display: flex; }
.sheet::backdrop { background: rgba(0,0,0,.5); }
.sheet__bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet__bar h2 { font: 800 20px var(--f-head); }
/* Причина бага в Safari: было flex:1 (basis 0%) в контейнере с auto-высотой — блок схлопывался до нуля.
   Теперь basis auto + min-height:0, а у панели корзины высота задана явно. */
.sheet__form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin: 0; }
.sheet__body { padding: 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.sheet__body h3 { margin: 22px 0 10px; font-size: 16px; font-weight: 800; }
.sheet__body > h2 { font: 800 22px/1.15 var(--f-head); margin-bottom: 6px; }
.sheet__photo { position: relative; flex: none; height: 240px; background: #E9E7E3; }
.icon-btn--float { position: absolute; top: 12px; right: 12px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.sheet__foot { flex: none; display: flex; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fff; }
.sheet__foot--col { flex-direction: column; gap: 8px; }
.sheet__foot .total { margin: 0; padding: 0; border: 0; }

.opts { border: 0; padding: 0; margin: 18px 0 0; }
.opts legend { padding: 0; margin-bottom: 6px; font-weight: 800; }
.opt { display: flex; align-items: center; gap: 10px; min-height: var(--h); border-bottom: 1px solid var(--line); }
.opt input { width: 20px; height: 20px; accent-color: var(--red); }

.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--red); color: #fff; border-radius: var(--r-btn); }
.stepper button { width: var(--h); height: var(--h); display: grid; place-items: center; color: #fff; border-radius: var(--r-btn); }
.stepper button:hover { background: var(--red-dark); }
.stepper b { min-width: 22px; text-align: center; }

.rows .row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row__ph { flex: none; width: 56px; height: 56px; border-radius: 14px; overflow: hidden; background: var(--grey); }
.row__t { flex: 1; min-width: 0; display: grid; }
.row__t span { color: var(--muted); font-size: 14px; }
.addons { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.addon { flex: none; width: 128px; display: grid; gap: 2px; padding: 8px; background: var(--red-soft); color: var(--red-ink); border-radius: 18px; font-size: 13px; }
.addon__ph { height: 64px; border-radius: 12px; overflow: hidden; background: #fff; margin-bottom: 4px; }
.addon .btn { margin-top: 6px; background: #fff; color: var(--red); }

.field { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field input { min-height: var(--h); padding: 0 14px; border: 1.5px solid transparent; border-radius: var(--r-btn); background: var(--grey); font-size: 16px; color: var(--text); outline: none; }
.field input:focus { border-color: var(--red); background: #fff; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill input { position: absolute; opacity: 0; }
.pill span { display: inline-flex; align-items: center; min-height: var(--h); padding: 0 18px; border-radius: var(--r-pill); background: var(--grey); font-weight: 700; }
.pill input:checked + span { background: var(--red); color: #fff; }
.pill input:focus-visible + span { outline: 3px solid var(--red); outline-offset: 2px; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 14px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 700; }
.total b { font: 800 22px var(--f-head); }

/* ===== Планшет ===== */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .banner { padding: 28px; } .banner h1 { font-size: 32px; } .seal { width: 140px; height: 140px; }
  .branches ul { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Компьютер ===== */
@media (min-width: 960px) {
  .wrap { padding: 0 24px; }
  .header__in { min-height: 72px; gap: 20px; }
  .header .cart-btn { display: inline-flex; }
  .header .search--head { display: flex; flex: 1; max-width: 460px; margin-left: auto; }
  .search--main, .fab { display: none; }
  .halal { margin-left: 0; }
  #mode { max-width: 320px; margin: 18px 0 0; }
  .banner { margin: 18px 0 24px; padding: 40px 48px; border-radius: 28px; }
  .banner h1 { font-size: 44px; } .banner p { font-size: 17px; max-width: 36ch; }
  .seal { width: 190px; height: 190px; }
  .layout { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
  .cats { position: sticky; top: 96px; flex-direction: column; margin: 0; padding: 0; overflow: visible; }
  .chip { border-radius: var(--r-btn); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
  .cat h2 { font-size: 24px; }
  .branches { padding: 32px; }
  .branches__in { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .map { margin: 0; min-height: 100%; }
  .footer { padding-bottom: 36px; }
  .footer__in { grid-template-columns: auto 1fr auto; align-items: center; gap: 32px; }
  html { scroll-padding-top: 100px; }
}

/* ===== Этап 2 ===== */
[hidden] { display: none !important; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.card__ctl .stepper { width: 100%; justify-content: space-between; }
.card__ctl .stepper b { flex: 1; }
.empty { padding: 24px 0; text-align: center; color: var(--muted); }
.opt em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 14px; }
.row__t small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.field small, .err { color: var(--red); font-weight: 600; font-size: 13px; }
.field small:empty, .err:empty { display: none; }
.err { display: block; margin-bottom: 10px; }
.field input[aria-invalid="true"] { border-color: var(--red); background: var(--red-soft); }
.sheet--mini { transition: transform .2s; }
.sheet--mini .sheet__body { padding-top: 4px; }
.grab { width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--line); }
.rows .row .btn { flex: none; width: var(--h); padding: 0; }

/* ===== Шторки на широких экранах (от 768px) ===== */
@media (min-width: 768px) {
  .sheet { margin: auto; border-radius: 26px; }
  .sheet--panel { margin: 0 0 0 auto; width: 440px; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
}

/* Фото из базы, скелетоны, уведомление, «нет в наличии» */
.ph img, .card__photo img, .row__ph img, .sheet__photo > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card--out .card__photo, .card--out .card__price, .card--out .card__name { opacity: .5; filter: grayscale(1); }
.card__out { display: grid; place-items: center; min-height: 44px; border-radius: var(--r-btn); background: #E9E7E3; color: var(--muted); font-size: 13px; font-weight: 700; }
.skel { min-height: 250px; border-radius: var(--r-card); background: linear-gradient(90deg, var(--grey) 25%, #EAE8E4 50%, var(--grey) 75%); background-size: 200% 100%; animation: skel 1.2s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
.err-box { grid-column: 1 / -1; padding: 40px 16px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 0; padding: 10px 14px; border-radius: var(--r-btn); background: var(--red-soft); color: var(--red-ink); font-size: 14px; font-weight: 600; }
.notice button { flex: none; font-size: 22px; line-height: 1; }
