:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --text: #111318;
  --muted: #6b7079;
  --faint: #a1a5ad;
  --line: rgba(17, 19, 24, 0.07);
  --primary: #111318;
  --on-primary: #ffffff;
  --save: #10915a;
  --save-bg: rgba(16, 145, 90, 0.1);
  --plain: #9f1239;
  --warn: #c2410c;
  --warn-bg: rgba(194, 65, 12, 0.08);
  --shadow: 0 1px 1px rgba(17, 19, 24, 0.03), 0 6px 20px -6px rgba(17, 19, 24, 0.08);
  --radius: 22px;
  --radius-sm: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0f;
    --surface: #16181d;
    --surface-2: #20232a;
    --text: #f2f3f5;
    --muted: #9298a3;
    --faint: #5f6570;
    --line: rgba(255, 255, 255, 0.06);
    --primary: #f2f3f5;
    --on-primary: #0b0c0f;
    --save: #3ddc97;
    --save-bg: rgba(61, 220, 151, 0.12);
    --plain: #fb7185;
    --warn: #fb923c;
    --warn-bg: rgba(251, 146, 60, 0.12);
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; line-height: 1.35; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding: 0 16px calc(112px + var(--safe-bottom)); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 14px 0 12px; background: var(--bg); }
.topbar h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 760; letter-spacing: -0.025em; }
.topbar h1.sm { font-size: 22px; }
.title-input { flex: 1; min-width: 0; border: 0; background: none; font-size: 22px; font-weight: 760; letter-spacing: -0.02em; outline: none; padding: 6px 0; border-bottom: 1.5px solid transparent; }
.title-input:focus { border-bottom-color: var(--line); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.text { width: auto; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.lead { color: var(--muted); font-size: 16px; margin: -6px 2px 18px; }
.section-title { margin: 24px 4px 10px; font-size: 14px; font-weight: 650; color: var(--muted); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; text-align: left; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 72px; right: 0; height: 1px; background: var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 580; font-size: 16.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .meta { color: var(--muted); font-size: 14px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.thumb { width: 46px; height: 46px; border-radius: 12px; background: #fff; object-fit: contain; flex: none; border: 1px solid var(--line); padding: 2px; }
.thumb.ph { display: grid; place-items: center; background: var(--surface-2); border: 0; color: var(--muted); padding: 0; }
.thumb.ph svg { width: 22px; height: 22px; }

.empty { text-align: center; padding: 64px 28px 24px; color: var(--muted); font-size: 15px; }
.empty .art { width: 72px; height: 72px; border-radius: 24px; margin: 0 auto 16px; display: grid; place-items: center; font-size: 34px; background: var(--surface); box-shadow: var(--shadow); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 19px; letter-spacing: -0.01em; }

/* ---------- basket icon ---------- */
.bicon { --c: #8b8f97; width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; flex: none; background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.bicon.lg { width: 44px; height: 44px; border-radius: 14px; font-size: 23px; }
.bicon.xl { width: 76px; height: 76px; border-radius: 24px; font-size: 40px; margin: 4px auto 0; }

/* ---------- home ---------- */
.basket-card { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 14px; width: 100%; text-align: left; margin-bottom: 10px; cursor: pointer; transition: transform .12s ease; }
.basket-card:active { transform: scale(0.985); }
.basket-card .grow { flex: 1; min-width: 0; }
.basket-card .name { font-weight: 680; font-size: 18.5px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.basket-card .preview { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; height: 38px; padding: 0 15px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: 15px; font-weight: 650; }
.pill:disabled { opacity: .25; }

/* ---------- search field ---------- */
.search-field { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--radius-sm); padding: 0 14px; height: 52px; box-shadow: var(--shadow); width: 100%; color: var(--muted); font-size: 17px; }
.search-field svg { width: 20px; height: 20px; flex: none; }
.search-field input { flex: 1; border: 0; outline: none; background: none; height: 100%; font-size: 17px; color: var(--text); min-width: 0; }

/* ---------- basket items ---------- */
.qty { display: flex; align-items: center; background: var(--surface-2); border-radius: 999px; padding: 3px; flex: none; }
.qty button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; font-weight: 600; color: var(--muted); }
.qty button:active { background: var(--line); }
.qty .val { min-width: 50px; text-align: center; font-size: 15px; font-weight: 650; cursor: pointer; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.save { background: var(--save-bg); color: var(--save); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- store logo ---------- */
.logo { width: 46px; height: 46px; border-radius: 14px; flex: none; overflow: hidden; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.logo img { width: 100%; height: 100%; object-fit: cover; }
.logo.contain img { object-fit: contain; padding: 5px; }
.logo.sm { width: 20px; height: 20px; border-radius: 6px; }
.logo.sm.contain img { padding: 1px; }
.store-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- results ---------- */
.tile { display: flex; align-items: center; gap: 12px; padding: 16px 14px; width: 100%; text-align: left; margin-bottom: 10px; position: relative; transition: transform .12s ease; }
.tile:active { transform: scale(0.985); }
.tile.best { box-shadow: 0 0 0 2px var(--save), var(--shadow); }
.tile .grow { flex: 1; min-width: 0; }
.tile .sname { font-weight: 720; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.tile .sub.warn { color: var(--warn); font-weight: 600; }
.tile .prices { display: flex; flex-direction: column; gap: 3px; flex: none; }
.tile .price-col { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.tile .price-col .lbl { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tile .price-col .val { min-width: 84px; text-align: right; font-size: 18px; font-weight: 740; letter-spacing: -0.01em; white-space: nowrap; }
.tile .price-col.card .val { color: var(--save); }
.tile .price-col.plain .val { color: var(--plain); }
.tile .price-col .val.na { color: var(--faint); font-weight: 600; }
.badge-best { display: inline-block; white-space: nowrap; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--save); background: var(--save-bg); padding: 2px 8px; border-radius: 999px; letter-spacing: .01em; }


/* ---------- store detail ---------- */
.store-head { padding: 16px; margin-bottom: 14px; }
.store-head .top { display: flex; gap: 12px; align-items: center; }
.store-head .totals { display: flex; gap: 10px; margin-top: 14px; }
.store-head .total-box { flex: 1; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.store-head .total-box .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.store-head .total-box .val { font-size: 23px; font-weight: 760; letter-spacing: -0.01em; }
.store-head .total-box.card .val { color: var(--save); }
.store-head .total-box.plain .val { color: var(--plain); }
.line .right, .offer .right { text-align: right; flex: none; }
.line .right .p, .offer .right .p { font-weight: 720; white-space: nowrap; font-size: 16.5px; }
.line .right .p.plain, .line .right .s.plain { color: var(--plain); }
.line .right .p.card, .offer .right .p.card { color: var(--save); }
.offer .right .p.card { font-size: 14px; }
.line .right .s, .offer .right .s { font-size: 13px; color: var(--muted); white-space: nowrap; margin-top: 1px; }
.line .right .was { color: var(--faint); text-decoration: line-through; font-size: 12px; }
.promo { color: var(--save); font-weight: 650; }
.line.missing .name { color: var(--muted); font-weight: 500; }

/* ---------- bottom action bar ---------- */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 14px 16px calc(14px + var(--safe-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
.bottom-bar .inner { max-width: 488px; margin: 0 auto; display: flex; gap: 10px; }
.btn { height: 56px; border-radius: 18px; font-weight: 680; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; }
.btn.primary { background: var(--primary); color: var(--on-primary); flex: 1; }
.btn.primary:disabled { opacity: .3; }
.btn.danger { color: var(--warn); background: var(--warn-bg); }
.btn.full { width: 100%; }
.btn svg { width: 20px; height: 20px; }

/* ---------- sheets ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.32); animation: fade .18s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 520px; margin: 0 auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 8px 16px calc(22px + var(--safe-bottom)); animation: up .26s cubic-bezier(.2, .8, .2, 1); max-height: 92vh; display: flex; flex-direction: column; }
.sheet.full { top: 0; max-height: none; border-radius: 0; padding-top: 12px; }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--faint); opacity: .45; margin: 0 auto 14px; flex: none; }
.sheet .scroll { overflow-y: auto; flex: 1; margin: 0 -16px; padding: 4px 16px 32px; -webkit-overflow-scrolling: touch; }
.sheet h2 { margin: 2px 0 14px; font-size: 20px; letter-spacing: -0.015em; text-align: center; }
.sheet .head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex: none; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 13px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-size: 15px; font-weight: 620; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--primary); color: var(--on-primary); }
.chip .cnt { opacity: .55; font-weight: 500; }

.any-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 6px; width: 100%; text-align: left; }
.any-row .ico { width: 46px; height: 46px; border-radius: 12px; background: var(--save-bg); color: var(--save); display: grid; place-items: center; flex: none; }
.any-row .ico svg { width: 22px; height: 22px; }
.any-row .t { font-weight: 650; }
.any-row .s { font-size: 14px; color: var(--muted); margin-top: 2px; }
.any-row .add { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; flex: none; }
.any-row .add svg { width: 18px; height: 18px; }

/* qty sheet */
.qty-big { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 16px 0 20px; }
.qty-big button { width: 52px; height: 52px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); font-size: 26px; font-weight: 500; }
.qty-big .field { display: flex; align-items: baseline; gap: 6px; }
.qty-big input { width: 110px; text-align: right; font-size: 42px; font-weight: 760; border: 0; background: none; outline: none; letter-spacing: -0.02em; }
.qty-big .u { font-size: 20px; font-weight: 650; color: var(--muted); min-width: 32px; }
.product-head { display: flex; gap: 14px; align-items: center; padding: 4px 2px; }
.product-head .thumb { width: 64px; height: 64px; border-radius: 16px; }
.product-head .t { font-weight: 650; }
.product-head .s { color: var(--muted); font-size: 14px; margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.toggle { display: flex; background: var(--surface-2); border-radius: 14px; padding: 3px; gap: 2px; }
.toggle button { flex: 1; height: 38px; border-radius: 11px; font-size: 14px; font-weight: 650; color: var(--muted); }
.toggle button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.hint-text { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

/* icon picker */
.field-input { width: 100%; height: 50px; border-radius: var(--radius-sm); border: 0; background: var(--surface); box-shadow: var(--shadow); padding: 0 16px; font-size: 17px; font-weight: 600; outline: none; text-align: center; margin: 14px 0 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 14px; font-size: 24px; background: var(--surface); display: grid; place-items: center; }
.emoji-grid button.on { box-shadow: inset 0 0 0 2px var(--primary); background: var(--surface-2); }
.color-row { display: flex; gap: 10px; justify-content: center; margin: 4px 0 4px; }
.color-row button { width: 32px; height: 32px; border-radius: 50%; background: var(--c); }
.color-row button.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c); }

/* skeleton */
.sk { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite linear; border-radius: 12px; }
@keyframes sh { to { background-position: -200% 0; } }
.sk-tile { height: 78px; border-radius: var(--radius); margin-bottom: 10px; }
.loading-line { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; margin: 0 4px 14px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--muted); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: calc(98px + var(--safe-bottom)); transform: translateX(-50%); background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 40; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: fade .2s ease; white-space: nowrap; }
.footer-note { color: var(--faint); font-size: 13px; text-align: center; margin: 22px 12px 0; line-height: 1.5; }

/* settings switches */
.switch-row .logo { width: 36px; height: 36px; border-radius: 11px; }
.switch-row + .switch-row::before { left: 62px; }
.switch { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-2); position: relative; flex: none; transition: background .15s ease; box-shadow: inset 0 0 0 1px var(--line); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s ease; }
.switch.on { background: var(--save); }
.switch.on::after { transform: translateX(18px); }

/* results summary */
.summary { display: flex; gap: 12px; align-items: center; padding: 14px 16px; margin-bottom: 16px; background: var(--save-bg); box-shadow: none; }
.summary.warn { background: var(--warn-bg); }
.summary .t { font-weight: 720; font-size: 17px; }
.summary .s { font-size: 14px; color: var(--muted); margin-top: 2px; }

.meta.deal { font-size: 13px; color: var(--muted); }
.meta.deal::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--save); margin-right: 2px; }

.promo-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* onboarding guide */
.guide { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; align-items: center; padding: 10px 20px calc(18px + var(--safe-bottom)); }
.guide > * { width: 100%; max-width: 440px; }
.guide-top { display: flex; justify-content: flex-end; height: 36px; flex: none; }
.guide-skip { color: var(--muted); font-weight: 600; font-size: 15px; padding: 6px 4px; }
.guide-shot { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 0 14px; }
.guide-shot img { max-height: 100%; max-width: 78%; border-radius: 28px; border: 6px solid var(--surface-2); box-shadow: 0 20px 50px -20px rgba(0,0,0,.45); object-fit: contain; }
.guide .enter { animation: rise .28s ease; }
@keyframes rise { from { transform: translateY(8px); opacity: .35; } }
.guide-text { text-align: center; flex: none; }
.guide-text h2 { margin: 0 0 8px; font-size: 25px; letter-spacing: -0.02em; }
.guide-text p { margin: 0 auto; color: var(--muted); font-size: 16.5px; line-height: 1.45; max-width: 360px; min-height: 72px; }
.guide-dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0 16px; flex: none; }
.guide-dots span { width: 7px; height: 7px; border-radius: 4px; background: var(--faint); opacity: .45; transition: all .2s ease; }
.guide-dots span.on { width: 22px; background: var(--primary); opacity: 1; }
.guide-actions { display: flex; gap: 10px; align-items: center; flex: none; }
.guide-actions .icon-btn { width: 54px; height: 54px; }

.sheet > .btn, .sheet > .toggle, .sheet > .qty-big, .sheet > .product-head, .sheet > h2, .sheet > .section-title, .sheet > #preview, .sheet > .field-input, .sheet > .color-row { flex: none; }

/* item delete + sheet actions */
.row-del { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--faint); flex: none; margin-left: -4px; }
.row-del svg { width: 18px; height: 18px; }
.row-del:active { background: var(--warn-bg); color: var(--warn); }
.sheet-actions { display: flex; gap: 10px; flex: none; }
.sheet-actions .btn.primary { flex: 1; }
.btn.icon { width: 56px; padding: 0; flex: none; }
.btn.icon svg { width: 22px; height: 22px; }
.btn.primary { box-shadow: 0 6px 18px -8px rgba(0,0,0,.35); transition: transform .1s ease; }
.btn:active { transform: scale(0.98); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-btn { font-weight: 700; color: var(--save); padding: 2px 4px; }
.toast[hidden] { display: none; }

/* sharing */
.shared-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--save); font-weight: 600; }
.shared-tag svg { width: 14px; height: 14px; }
.action-row .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.action-row .ico svg { width: 20px; height: 20px; }
.action-row + .action-row::before { left: 68px; }
.nick-row { display: flex; gap: 8px; align-items: center; }
.nick-row .field-input { margin: 0; text-align: left; flex: 1; min-width: 0; font-weight: 500; }
.nick-row .btn { height: 50px; padding: 0 18px; flex: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--save-bg); color: var(--save); display: grid; place-items: center; font-weight: 700; flex: none; }
.member + .member::before { left: 64px; }
.tag.wrap { white-space: normal; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; border-radius: 10px; }
.row .meta > span { max-width: 100%; }

/* store format / branch */
.sub-row { padding-left: 62px; }
.sub-row .name { font-size: 15px; font-weight: 600; }
.chev-r { color: var(--faint); font-size: 22px; line-height: 1; padding: 0 4px; }
.row.branch .tag { flex: none; }
.tick { color: var(--save); flex: none; display: grid; place-items: center; }
.tick svg { width: 20px; height: 20px; }
.sheet .head .logo { width: 38px; height: 38px; border-radius: 12px; }

/* invitations */
.invite-card { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 10px; box-shadow: 0 0 0 1.5px var(--save), var(--shadow); }
.invite-card .grow { flex: 1; min-width: 0; }
.invite-card .name { font-weight: 680; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-card .preview { color: var(--muted); font-size: 13.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill.ghost { background: var(--surface-2); color: var(--text); }
.invite-hero { text-align: center; padding: 8px 4px 16px; flex: none; }
.invite-hero h2 { margin: 14px 0 4px; }
.text-btn { display: block; margin: 10px auto 0; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 10px; }
.invite-card .icon-btn.decline { width: 38px; height: 38px; background: var(--surface-2); box-shadow: none; color: var(--muted); }
.invite-card .icon-btn.decline svg { width: 18px; height: 18px; }

/* change product */
.row.line { align-items: flex-start; }
.row.line .thumb-link { cursor: pointer; flex: none; }
.row.line .grow { cursor: pointer; }
.line-actions { margin-top: 6px; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 650; color: var(--text); background: var(--surface-2); border-radius: 999px; padding: 4px 10px; }
.link-btn svg, .text-btn svg { width: 15px; height: 15px; }
.text-btn { display: inline-flex; align-items: center; gap: 6px; }
.swap-btn { flex: none; align-self: center; font-size: 13px; font-weight: 650; background: var(--primary); color: var(--on-primary); border-radius: 999px; padding: 6px 12px; }
.sheet > .text-btn { flex: none; display: flex; }

.group-toggle { display: flex; width: calc(100% - 8px); align-items: center; justify-content: space-between; text-align: left; }
.switch.sm { width: 38px; height: 23px; }
.switch.sm::after { width: 17px; height: 17px; }
.switch.sm.on::after { transform: translateX(15px); }

/* tabs on the home screen */
.toggle.tabs { margin: 0 0 16px; }
.toggle.tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.toggle.tabs svg { width: 16px; height: 16px; }
.toggle.tabs .count { font-size: 12px; background: var(--surface-2); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.toggle.tabs button.on .count { background: var(--primary); color: var(--on-primary); }
.topbar h1 { flex: 1; }

/* watched */
.watch-row .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.watch-row .right { text-align: right; flex: none; }
.sheet-links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.text-btn.on { color: var(--save); }
.ico-left { width: 28px; flex: none; display: grid; place-items: center; font-size: 18px; color: var(--muted); }
.ico-left svg { width: 20px; height: 20px; }

/* search field: scan */
.search-field .field-btn { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.search-field .field-btn svg { width: 20px; height: 20px; }

/* route */
.card.route { padding: 14px; margin-bottom: 14px; }
.route-title { font-weight: 700; font-size: 15px; margin: 0 2px 10px; }
.toggle.plans button { height: auto; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.2; }
.toggle.plans small { font-size: 12px; font-weight: 600; color: var(--muted); }
.toggle.plans small.save { color: var(--save); }
.route-store { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 2px 4px; border-top: 1px solid var(--line, rgba(127,127,127,.15)); margin-top: 10px; }
.route-store .name { font-weight: 650; }
.route-store .sum { font-weight: 700; flex: none; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--muted); }

/* shop mode */
.btn.secondary { background: var(--surface-2); color: var(--text); flex: none; padding: 0 16px; }
.btn.secondary svg { width: 20px; height: 20px; }
.shop-progress { margin: 0 4px 6px; }
.shop-progress .bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 8px; }
.shop-progress .bar i { display: block; height: 100%; background: var(--save); border-radius: 999px; transition: width .25s; }
.shop-store { display: flex; align-items: center; gap: 8px; }
.shop-row { min-height: 60px; text-align: left; width: 100%; }
.shop-row .check { width: 28px; height: 28px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--muted); display: grid; place-items: center; transition: background .15s; }
.shop-row .check svg { width: 16px; height: 16px; }
.shop-row.done .check { background: var(--save); color: #fff; box-shadow: none; }
.shop-row.done .name { text-decoration: line-through; color: var(--muted); }

/* nutrition: one quiet line in lists, a card when opened */
.nutri { font-size: 12px; color: var(--muted); margin-top: 3px; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.nutri:empty { display: none; }
.nutri b { color: var(--text); font-weight: 650; }
.nutri .per { opacity: .7; }
.nutri-panel { background: var(--surface-2); border-radius: 16px; padding: 12px; margin: 4px 0 6px; }
.nutri-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 650; margin: 0 2px 8px; }
.nutri-panel .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.nutri-panel .cell { background: var(--surface); border-radius: 12px; padding: 8px 4px; text-align: center; }
.nutri-panel .cell .v { font-size: 17px; font-weight: 750; }
.nutri-panel .cell.kcal .v { color: var(--save); }
.nutri-panel .cell .l { font-size: 11px; color: var(--muted); margin-top: 1px; }
.nutri-panel .pack { font-size: 13px; color: var(--muted); margin: 9px 2px 0; }
.nutri-panel .pack b { color: var(--text); }
.nutri-panel .src { font-size: 11px; color: var(--muted); opacity: .8; margin: 6px 2px 0; }
.nutri-loading, .nutri-none { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 2px; }
.product-card { text-align: center; padding: 4px 4px 12px; }
.product-card .pc-img { width: 132px; height: 132px; margin: 0 auto 12px; border-radius: 20px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.product-card .pc-img img { max-width: 88%; max-height: 88%; object-fit: contain; }
.product-card .t { font-size: 18px; font-weight: 700; line-height: 1.25; }
.product-card .s { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 6px; }
.product-card .meta { justify-content: center; margin-top: 6px; }

/* buttons under a product: clearly two separate buttons */
.sheet-links .text-btn { margin: 0; background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 9px 14px; font-size: 14px; }
.sheet-links .text-btn.on { color: var(--save); }

/* route: price always on the right, actions */
.route-store .grow { flex: 1; min-width: 0; }
.route-store .logo, .route-store img { flex: none; }
.route-store .sum { margin-left: auto; text-align: right; white-space: nowrap; }
.route-actions { display: flex; gap: 8px; margin-top: 14px; }
.route-actions .btn { height: 46px; font-size: 15px; }
.route-actions .btn.primary { flex: 1; }
.route-actions .btn svg { width: 19px; height: 19px; }

/* results: "with card / without card" said once, above the tiles */
.tiles-legend { display: flex; justify-content: flex-end; gap: 14px; margin: 2px 6px 8px; font-size: 12px; font-weight: 650; }
.tiles-legend .lg-card { color: var(--save); }
.tiles-legend .lg-plain { color: var(--plain); }
.tile .price-col .lbl { display: none; }

/* home: a bit more air between baskets; drag to reorder */
.basket-card { margin-bottom: 14px; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.basket-card.dragging { position: relative; z-index: 5; transition: none; box-shadow: 0 12px 32px rgba(0,0,0,.35); opacity: .97; }
body.reordering { overscroll-behavior: none; }

/* text size from settings: everything scales together */
body { zoom: var(--zoom, 1); }

/* basket rows: the name gets the whole width, quantity sits under it */
.row.item { align-items: flex-start; }
.row.item .thumb { margin-top: 2px; }
.row.item .grow { flex: 1; min-width: 0; }
.row.item .name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; cursor: pointer; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.item-foot .meta { min-width: 0; flex: 1; overflow: hidden; cursor: pointer; }
.item-foot .meta .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.item-foot .qty { flex: none; }
.row.item .row-del { align-self: center; }

/* header of a basket: the name keeps room */
.topbar .title-input { font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }

/* narrow phones (iPhone 13 mini / SE …) */
@media (max-width: 380px) {
  .topbar h1 { font-size: 26px; }
  .topbar .title-input { font-size: 18px; }
  .basket-card .name { font-size: 17px; }
  .qty button { width: 28px; height: 28px; }
  .qty .val { min-width: 44px; font-size: 14px; }
  .toggle.plans small { font-size: 11px; }
  .tile .val { font-size: 17px; }
}

/* keyboard open (iPhone): sheets sit above it and never run under it */
/* lengths inside the zoomed body are multiplied by the zoom: divide screen sizes back */
.sheet { bottom: calc(var(--kb, 0px) / var(--zoom, 1)); max-height: calc(min(92vh, var(--vvh, 100vh) - 12px) / var(--zoom, 1)); }
.sheet.full { top: auto; height: calc(var(--vvh, 100vh) / var(--zoom, 1)); max-height: none; }
body.kb-open .sheet:not(.full) { border-radius: 26px 26px 0 0; }
body.kb-open .bottom-bar { display: none; }
.toggle.text-size { margin-bottom: 0; }

/* tight space (small phone + big text): the quantity moves to its own line, the tag stays whole */
.item-foot { flex-wrap: wrap; row-gap: 6px; }
.item-foot .meta { flex: 0 1 auto; width: auto; min-width: 0; max-width: 100%; }
.item-foot .qty { margin-left: auto; }
.bottom-bar .btn { white-space: nowrap; }
.bottom-bar .btn.secondary { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.item-foot { column-gap: 6px; }
.item-foot .qty .val { min-width: 42px; }

/* "В магазине" shows only its icon when the bar is narrow, so "Сравнить цены" always fits */
.bottom-bar .inner { container-type: inline-size; }
@container (max-width: 400px) { .btn.secondary .lbl { display: none; } .btn.secondary { padding: 0 14px; } }
.pill { white-space: nowrap; }
/* prices being recalculated after a swap */
body.recalc .store-head .val, body.recalc .line .right { opacity: .35; transition: opacity .15s; }
body.recalc .topbar::after { content: ""; width: 18px; height: 18px; margin-left: auto; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--text); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
