:root {
  --green: #1f7a3d;
  --green-d: #155c2c;
  --bg: #f5f6f4;
  --card: #ffffff;
  --ink: #16241a;
  --muted: #6b7a6f;
  --line: #e3e7e2;
  --red: #c23b3b;
  --amber: #c98a1a;
  --gift: #8a4bb0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea, button { font-size: 16px; font-family: inherit; }

.topbar { background: var(--green); color: #fff; padding: 16px 16px; padding-top: max(16px, env(safe-area-inset-top));
  max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: auto 1fr; grid-auto-rows: auto; align-items: center; column-gap: 12px; }
.brand-logo { grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: rgba(255,255,255,.2); }
.brand-logo.hidden { display: none; }
.brand { font-size: 22px; font-weight: 800; grid-column: 2; }
.brand-sub { color: rgba(255,255,255,.85); font-size: 13px; margin-top: 2px; grid-column: 2; }
.foot { max-width: 640px; margin: 0 auto; padding: 20px 16px calc(90px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; text-align: center; }

.tabbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; background: var(--bg); padding: 10px 14px 6px;
  max-width: 640px; margin: 0 auto; }
.tab { flex: 1; background: #fff; border: 1px solid var(--line); color: var(--muted); border-radius: 10px; padding: 10px 0; font-weight: 700; }
.tab.active { background: var(--green); color: #fff; border-color: var(--green); }

.view { max-width: 640px; margin: 0 auto; padding: 8px 14px 96px; display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.loading, .empty { color: var(--muted); text-align: center; padding: 30px; }

.topbar.has-hero { min-height: 160px; background-size: cover; background-position: center; align-content: end; }

/* ---- Фото: обложки, превью, галерея, плейсхолдеры ---- */
.cover { width: 100%; height: 170px; object-fit: cover; border-radius: 12px; margin-bottom: 10px; display: block; }
.cover.ph, .thumb.ph { display: flex; align-items: center; justify-content: center; background: #eef3ee; color: #9db3a3; }
.cover.ph { font-size: 46px; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; font-size: 24px; }
.gallery { display: flex; gap: 6px; overflow-x: auto; margin: 2px 0 10px; -webkit-overflow-scrolling: touch; }
.gallery .thumb { width: 60px; height: 60px; }

/* ---- Карточка набора ---- */
.basket { background: var(--card); border-radius: 14px; padding: 15px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.basket .head { display: flex; align-items: baseline; gap: 8px; }
.basket .bname { font-weight: 800; font-size: 17px; flex: 1; }
.basket .price { font-weight: 800; font-size: 18px; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef3ee; color: var(--green-d); }
.badge.gift { background: #f0e6f6; color: var(--gift); }
.basket .comp { color: var(--muted); font-size: 13px; margin: 8px 0 12px; }
.basket details summary { color: var(--green-d); font-size: 13px; cursor: pointer; margin-bottom: 8px; list-style: none; }
.basket details summary::-webkit-details-marker { display: none; }
.basket .recipe { display: flex; flex-direction: column; gap: 5px; margin: 4px 0 12px; }
.basket .recipe .rl { display: flex; justify-content: space-between; font-size: 13px; }
.basket .recipe .rl span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Свой набор ---- */
.prod { background: var(--card); border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  display: flex; align-items: center; gap: 10px; }
.prod .grow { flex: 1; min-width: 0; }
.prod .pn { font-weight: 700; }
.prod .pp { color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 700; color: var(--green-d); }
.stepper .q { min-width: 60px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn { padding: 15px; background: var(--green); color: #fff; border: 0; border-radius: 12px; font-weight: 800; width: 100%; font-size: 17px; }
.btn:disabled { opacity: .5; }
.btn.sec { background: #eef3ee; color: var(--green-d); }
.btn.small { width: auto; padding: 10px 16px; font-size: 15px; }
.btn.add { width: auto; padding: 10px 16px; }

/* ---- Нижняя панель корзины ---- */
.cartbar { position: fixed; bottom: 0; left: 0; right: 0; max-width: 640px; margin: 0 auto; z-index: 6;
  background: #fff; border-top: 1px solid var(--line); padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; }
.cartbar-info { flex: 1; display: flex; flex-direction: column; }
.cartbar-info #cart-count { color: var(--muted); font-size: 13px; }
.cartbar-info #cart-sum { font-weight: 800; font-size: 18px; }
.cartbar .btn { width: auto; padding: 14px 22px; }

/* ---- Оформление (модалка) ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; overflow-y: auto; }
.modal { background: var(--bg); max-width: 640px; margin: 0 auto; min-height: 100%; padding: 16px 14px calc(20px + env(safe-area-inset-bottom)); }
.modal .mhead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal .mhead .mtitle { font-weight: 800; font-size: 19px; flex: 1; }
.close { background: #fff; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 20px; }
.card { background: var(--card); border-radius: 14px; padding: 15px; box-shadow: 0 1px 4px rgba(0,0,0,.05); margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.sumline { display: flex; justify-content: space-between; padding: 6px 0; }
.sumline.total { font-weight: 800; font-size: 19px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.freehint { background: #eef7f0; color: var(--green-d); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 8px; }
.freehint.done { background: #e4f2e8; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 11px; }
label.field input, label.field textarea { padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; }
label.field textarea { resize: vertical; min-height: 60px; }
.paynote { color: var(--muted); font-size: 13px; margin: 4px 2px 12px; }
.itemrow { display: flex; justify-content: space-between; font-size: 14px; padding: 5px 0; }
.itemrow span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Успех ---- */
.done-screen { text-align: center; padding: 30px 16px; }
.done-screen .ok { font-size: 54px; }
.done-screen h2 { margin: 8px 0 4px; }
.done-screen .oid { font-family: ui-monospace, monospace; color: var(--muted); font-size: 13px; }
.status-pill { display: inline-block; margin-top: 10px; background: #fbf0d8; color: var(--amber); border-radius: 999px; padding: 5px 14px; font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 11px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90%; text-align: center; }
.toast.err { background: var(--red); }
