:root {
  --green: #6fa81f;
  --green-dark: #3c6b0c;
  --green-soft: #eaf3d8;
  --bg: #f6f4ec;
  --card: #ffffff;
  --ink: #1d2415;
  --muted: #6b7262;
  --line: #e4e0d0;
  --accent: #e8590c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 50, 20, .06), 0 4px 14px rgba(40, 50, 20, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); padding-bottom: 96px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 12px; }
[hidden] { display: none !important; }
body:has(dialog[open]) { overflow: hidden; }

/* ---------- шапка: як вивіска магазину ---------- */
.hero { background: var(--green); color: #fff; padding: 18px 0 16px; text-align: center; }
.hero h1 { margin: 0; font-size: clamp(26px, 8vw, 40px); line-height: 1.05; letter-spacing: -.01em; font-weight: 800; }
.tagline { display: inline-block; margin: 10px 0 0; padding: 5px 16px; background: #fff; color: var(--green-dark); border-radius: 999px; font-size: 13px; font-weight: 600; }
.tagline:empty { display: none; }

/* ---------- пошук і фільтри ---------- */
.toolbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 8px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 11px 0; outline: none; }
.search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.chips { display: flex; gap: 6px; overflow-x: auto; margin: 10px -12px 0; padding: 0 12px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 13px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip small { color: var(--muted); font-weight: 500; margin-left: 3px; }
.chip[aria-pressed="true"] { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.chip[aria-pressed="true"] small { color: #d6e8b8; }

.filters { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.filters select { border: 0; background: none; padding: 6px 2px; font-size: 13px; font-weight: 600; color: var(--green-dark); max-width: 44%; }
.count { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- сітка товарів ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 12px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.card-open { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.pic { position: relative; aspect-ratio: 1 / 1; background: var(--green-soft); display: grid; place-items: center; overflow: hidden; }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic .ph { font-size: 54px; opacity: .75; }
.badge { position: absolute; left: 8px; top: 8px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge.inline { position: static; display: inline-block; margin-bottom: 8px; }
.card.promo { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.promo .price { color: var(--accent); }
.card-date { margin: 2px 10px 0; font-size: 12px; color: var(--muted); }
.card-name { margin: 9px 10px 0; font-size: 14.5px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px 10px; margin-top: auto; }
.price { font-size: 18px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.price small { font-size: 12px; font-weight: 600; color: var(--muted); }
.price.ask { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: normal; line-height: 1.2; }

.add { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--green); color: #fff; font-size: 26px; line-height: 1; display: grid; place-items: center; }
.add:active { transform: scale(.94); }
.stepper { display: flex; align-items: center; background: var(--green-soft); border-radius: 999px; }
.stepper button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--green); color: #fff; font-size: 22px; line-height: 1; }
.stepper button.minus { background: #fff; color: var(--green-dark); box-shadow: inset 0 0 0 1.5px var(--green); }
.stepper output { min-width: 44px; padding: 0 4px; text-align: center; font-size: 13px; font-weight: 700; white-space: nowrap; }
.card-foot.has-qty { flex-direction: column; align-items: stretch; }
.card-foot.has-qty .stepper { justify-content: space-between; }

.empty { text-align: center; color: var(--muted); padding: 48px 12px; }

/* ---------- контакти ---------- */
.contacts { margin-top: 36px; padding-top: 22px; padding-bottom: 12px; border-top: 1px solid var(--line); font-size: 14.5px; }
.contacts h2 { font-size: 18px; margin: 0 0 6px; }
.contacts p { margin: 0 0 12px; color: var(--muted); }
.contacts ul { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.contacts li { background: var(--card); border-radius: 12px; padding: 10px 12px; }
.contacts li b { display: block; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links a { background: var(--green-dark); color: #fff; text-decoration: none; padding: 10px 16px; border-radius: 999px; font-weight: 600; }

/* ---------- плаваюча кнопка кошика ---------- */
.cartbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 6; max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 16px; padding: 14px 18px; background: var(--green-dark); color: #fff; font-weight: 700; font-size: 16px; box-shadow: 0 8px 24px rgba(30, 50, 5, .35); }
.cartbar-count { background: #fff; color: var(--green-dark); min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center; font-size: 14px; }
.cartbar-sum { margin-left: auto; }

/* ---------- нижні панелі (товар, кошик) ---------- */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh; border-radius: 20px 20px 0 0; background: var(--card); color: var(--ink); overflow: auto; overscroll-behavior: contain; }
.sheet::backdrop { background: rgba(20, 28, 10, .55); }
@media (min-width: 620px) { .sheet { margin: auto; border-radius: 20px; } }
.sheet-close { position: sticky; top: 10px; float: right; margin: 10px 10px -46px 0; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); font-size: 20px; line-height: 1; }
.sheet-pic { background: #14180f; display: grid; place-items: center; min-height: 180px; }
.sheet-pic img { display: block; max-width: 100%; max-height: 62dvh; object-fit: contain; }
.sheet-pic .ph { font-size: 90px; padding: 30px; }
.sheet-body { padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet-body h2 { margin: 0 0 4px; font-size: 21px; line-height: 1.2; }
.meta { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.desc { white-space: pre-line; margin: 0 0 14px; font-size: 15px; }
.avail { font-size: 13.5px; color: var(--green-dark); font-weight: 600; margin: 0 0 14px; }
.buy { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.buy .price { font-size: 24px; }
.btn { border: 0; border-radius: 12px; padding: 13px 18px; background: var(--green-dark); color: #fff; font-weight: 700; }
.btn.wide { width: 100%; }
.btn.ghost { background: var(--green-soft); color: var(--green-dark); }
.btn:disabled { opacity: .6; }

.cart-title { margin: 0 0 12px; font-size: 21px; }
.cart-list { list-style: none; margin: 0; padding: 0; }
.cart-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-item .pic { width: 56px; border-radius: 10px; }
.cart-item .pic .ph { font-size: 26px; }
.cart-item b { display: block; font-size: 14.5px; line-height: 1.2; }
.cart-item span { font-size: 12.5px; color: var(--muted); }
.cart-item .sum { font-weight: 700; color: var(--ink); font-size: 14px; }
.total { display: flex; justify-content: space-between; align-items: baseline; font-size: 19px; font-weight: 800; margin: 14px 0 4px; }
.note { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.form input, .form select, .form textarea { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; font-weight: 400; font-size: 16px; width: 100%; }
.form textarea { resize: vertical; min-height: 64px; }
.err { color: #b3261e; font-size: 13.5px; margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.linkbtn { border: 0; background: none; color: var(--muted); text-decoration: underline; font-size: 13.5px; padding: 8px; justify-self: center; }
.done { text-align: center; padding-top: 28px; }
.done .big { font-size: 54px; }
.done pre { text-align: left; white-space: pre-wrap; background: var(--bg); border-radius: 12px; padding: 12px; font: 13.5px/1.45 var(--font); margin: 14px 0; }

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