/* CartScout — Apple-style grocery price scout */
:root {
  --bg: #f2f2f7;
  --bg-solid: #ffffff;
  --bg-elevated: rgba(255,255,255,.78);
  --fill: rgba(120,120,128,.12);
  --line: rgba(60,60,67,.12);
  --label: #000;
  --muted: rgba(60,60,67,.6);
  --blue: #007aff;
  --green: #34c759;
  --mint: #00c7be;
  --orange: #ff9500;
  --red: #ff3b30;
  --purple: #af52de;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-solid: #1c1c1e;
    --bg-elevated: rgba(28,28,30,.82);
    --fill: rgba(120,120,128,.24);
    --line: rgba(84,84,88,.65);
    --label: #fff;
    --muted: rgba(235,235,245,.6);
    --shadow: 0 8px 28px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--label);
  font-family: var(--font); font-size: 17px;
  letter-spacing: -0.022em; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
#app { min-height: 100%; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  padding: calc(8px + var(--safe-top)) 16px 10px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand .logo-img {
  width: 36px; height: 36px; border-radius: 9px;
  object-fit: cover; background: linear-gradient(180deg, #7dffd4, #00c7be);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.brand strong { display: block; font-size: 17px; font-weight: 600; letter-spacing: -0.03em; }
.brand small { color: var(--muted); font-size: 12px; }
.tabs {
  display: flex; gap: 2px; padding: 2px; overflow-x: auto;
  background: var(--fill); border-radius: 9px; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; border: 0; background: transparent; color: var(--label);
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  touch-action: manipulation; min-height: 36px;
}
.tab.active {
  background: var(--bg-solid); font-weight: 600;
  box-shadow: 0 0.5px 1px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  .tab.active { background: #636366; box-shadow: none; }
}

main {
  flex: 1; padding: 18px 16px calc(28px + var(--safe-bottom));
  max-width: 720px; width: 100%; margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; animation: in .28s cubic-bezier(.22,1,.36,1); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
}

.banner-demo {
  background: rgba(255,149,0,.12); color: var(--orange);
  border: 0.5px solid rgba(255,149,0,.28);
  border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 500;
  margin-bottom: 12px; line-height: 1.35;
}

.banner-live {
  display: flex; align-items: center; gap: 8px;
  background: var(--fill); color: var(--muted);
  border: 0.5px solid var(--line);
  border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 500;
  margin-bottom: 12px; line-height: 1.35;
}
.banner-live .dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); opacity: .6;
}
.banner-live.ok {
  background: rgba(52,199,89,.1); color: #1a7f37;
  border-color: rgba(52,199,89,.28);
}
.banner-live.ok .dot { background: var(--green); opacity: 1; }
.banner-live.err {
  background: rgba(255,59,48,.1); color: var(--red);
  border-color: rgba(255,59,48,.28);
}
.banner-live.err .dot { background: var(--red); opacity: 1; }
@media (prefers-color-scheme: dark) {
  .banner-live.ok { color: #63e6a0; }
}

.loading-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
/* Author display:flex overrides UA [hidden]{display:none} — force hide */
.loading-card[hidden] {
  display: none !important;
}
.loading-card strong { display: block; font-size: 15px; font-weight: 600; }
.loading-card p { margin: 2px 0 0; }
.spinner {
  flex-shrink: 0; width: 28px; height: 28px;
  border: 2.5px solid var(--fill); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--blue); opacity: .7; }
}

.hero {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: 20px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.hero h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
.hero p { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; margin: 10px 0 12px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.35; }
.foot { margin-top: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-gap { display: flex; flex-direction: column; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 12px; box-shadow: 0 0.5px 0 rgba(0,0,0,.04);
}
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.stat strong { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.card {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.form-card { display: flex; flex-direction: column; gap: 12px; }
.card-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  touch-action: manipulation; transition: transform .1s ease;
}
.item-card.clickable { cursor: pointer; }
.item-card.clickable:active { transform: scale(0.985); }
.item-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.item-card .top strong { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.item-card .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.item-card .meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--muted); gap: 8px; flex-wrap: wrap; }
.item-card .price { font-weight: 700; color: var(--label); font-variant-numeric: tabular-nums; }
.item-card .price.best { color: #0a8f88; }
@media (prefers-color-scheme: dark) {
  .item-card .price.best { color: #63e6de; }
}
.item-row-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }

.badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap; letter-spacing: -0.01em;
}
.badge.in_stock { background: rgba(52,199,89,.15); color: var(--green); }
.badge.low { background: rgba(255,149,0,.16); color: var(--orange); }
.badge.out { background: rgba(255,59,48,.14); color: var(--red); }
.badge.unknown { background: var(--fill); color: var(--muted); }
.badge.best { background: rgba(0,199,190,.16); color: #0a8f88; }
.badge.save { background: rgba(0,122,255,.12); color: var(--blue); }
.badge.rank { background: var(--fill); color: var(--label); }
.badge.runner { background: rgba(0,122,255,.1); color: var(--blue); }
@media (prefers-color-scheme: dark) {
  .badge.best { color: #63e6de; }
}

.empty-state {
  text-align: center; padding: 22px 16px;
  background: var(--bg-solid); border: 0.5px dashed var(--line);
  border-radius: var(--radius);
}
.empty-state strong {
  display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.empty-state .mint-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--mint);
  display: inline-block; margin-bottom: 10px;
  box-shadow: 0 0 0 4px rgba(0,199,190,.18);
}

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer;
  font-size: 16px; font-weight: 600; letter-spacing: -0.02em;
  background: var(--fill); color: var(--label); touch-action: manipulation;
  transition: transform .08s ease-out, opacity .1s ease;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.secondary { background: rgba(0,199,190,.16); color: #0a8f88; }
@media (prefers-color-scheme: dark) {
  .btn.secondary { color: #63e6de; }
}
.btn.ghost { background: transparent; color: var(--blue); }
.btn.danger { background: rgba(255,59,48,.12); color: var(--red); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 14px; min-height: 36px; border-radius: 10px; }
.btn.icon {
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  border-radius: 10px; display: grid; place-items: center;
  font-size: 20px; line-height: 1;
}

.chip-row, .filter-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.chip {
  border: 0; background: var(--fill); color: var(--label);
  border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; touch-action: manipulation; min-height: 36px;
}
.chip.active { background: var(--blue); color: #fff; }
.chip.add { background: rgba(0,122,255,.12); color: var(--blue); }

.search-row { margin-bottom: 10px; }
.search-row input, .field input, .field select {
  width: 100%; border: 0.5px solid var(--line); background: var(--bg-solid);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
.search-row input:focus, .field input:focus, .field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,.18);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }

.seg {
  display: flex; gap: 2px; padding: 2px; background: var(--fill);
  border-radius: 10px; margin: 10px 0 14px;
}
.seg-btn {
  flex: 1; border: 0; background: transparent; color: var(--label);
  padding: 10px 8px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; touch-action: manipulation; min-height: 44px;
}
.seg-btn.active {
  background: var(--bg-solid);
  box-shadow: 0 0.5px 1px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  .seg-btn.active { background: #636366; box-shadow: none; }
}

.store-bar {
  height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; margin-top: 8px;
}
.store-bar > i {
  display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--green));
  border-radius: inherit;
}

.qty {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--fill); border-radius: 12px; padding: 2px;
}
.qty span { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.36); z-index: 80;
  touch-action: manipulation;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  max-height: min(88dvh, 720px);
  background: var(--bg-solid);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
  padding: 4px 16px calc(18px + var(--safe-bottom));
  overflow: auto;
  animation: sheetIn .28s cubic-bezier(.22,1,.36,1);
  transition: transform .2s ease-out;
}
.sheet.sheet-dragging { animation: none; transition: none; }
@keyframes sheetIn { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}
.sheet-handle {
  display: block; width: 100%; max-width: none; height: 28px; min-height: 28px;
  border: 0; padding: 0; margin: 0 0 8px; cursor: pointer;
  background: transparent; position: relative; touch-action: none;
}
.sheet-handle::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 36px; height: 5px; border-radius: 999px; background: var(--fill);
}
.sheet h3 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.03em; }
.sheet .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Sticky scout CTA on List when items exist */
#view-list.has-items {
  padding-bottom: calc(88px + var(--safe-bottom));
}
.sticky-cta {
  position: fixed; left: 50%; bottom: 0; z-index: 30;
  transform: translateX(-50%);
  width: 100%; max-width: 720px;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
  box-shadow: 0 -4px 20px rgba(0,199,190,.06);
}
.sticky-cta .btn.primary {
  background: linear-gradient(180deg, #1a86ff, var(--blue));
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 4px 12px rgba(0,122,255,.28);
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(28,28,30,.92); color: #fff;
  padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  z-index: 100; max-width: 90vw; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
@media (prefers-color-scheme: light) {
  .toast { background: rgba(28,28,30,.92); }
}

.price-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.price-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 10px 12px; border-radius: 12px; background: var(--fill);
}
.price-row.best-row { background: rgba(0,199,190,.12); }
.price-row .store-name { font-weight: 600; font-size: 14px; }
.price-row .stock { font-size: 11px; font-weight: 700; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.switch {
  appearance: none; width: 50px; height: 30px; border-radius: 999px;
  background: #e5e5ea; position: relative; border: 0; cursor: pointer;
  transition: background .15s ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(20px); }
@media (prefers-color-scheme: dark) {
  .switch { background: #39393d; }
}

.split-stop {
  border-left: 3px solid var(--mint);
  padding-left: 12px; margin: 8px 0;
}

.brand strong::after {
  content: ""; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--mint); margin-left: 6px;
  vertical-align: middle; opacity: .85;
}


/* Weekly ads */
.ad-card .price { font-variant-numeric: tabular-nums; }
#adsChainFilters { margin: 8px 0 12px; flex-wrap: wrap; }
.foot-note { font-size: 12px; margin: 16px 8px 32px; opacity: 0.75; }
#homeAds .btn { margin-top: 8px; }

.share-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(61,255,154,.12), rgba(245,197,24,.1));
  border: 1px solid rgba(61,255,154,.25);
  font-size: 13px;
}
.share-banner[hidden] { display: none !important; }
.share-banner .muted { font-size: 11px; margin-top: 2px; }
.tiny { font-size: 11px; }

.row-check { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted,#9ec9ad); }
.row-check input { width:18px; height:18px; }
.recipe-ing-row {
  display:flex; align-items:center; gap:8px; padding:8px 0;
  border-bottom:1px solid rgba(255,255,255,.06); font-size:13px;
}
.recipe-ing-row .grow { flex:1; min-width:0; }
.recipe-ing-row select.ing-swap {
  max-width:42%; font-size:11px; border-radius:8px; padding:4px 6px;
  background:rgba(0,0,0,.25); color:inherit; border:1px solid rgba(255,255,255,.12);
}
.recipe-ing-row .qty-step {
  display:flex; align-items:center; gap:4px;
}
.recipe-ing-row .qty-step button {
  width:28px; height:28px; border-radius:8px; border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.06); color:inherit; font-weight:700;
}
.recipe-actions { display:flex; flex-direction:column; gap:8px; margin-top:12px; }
.recipe-actions .btn { width:100%; }
.map-pill {
  display:inline-block; font-size:10px; padding:2px 6px; border-radius:999px;
  background:rgba(61,255,154,.15); color:#3dff9a; margin-left:4px;
}
.map-pill.bad { background:rgba(255,92,92,.15); color:#ff8a8a; }
.recipe-card .store-hint { font-size:11px; color:#9ec9ad; margin-top:6px; }

/* Trip mode */
.trip-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:8px 0 12px; }
.trip-actions .btn, .trip-actions a.btn { text-decoration:none; text-align:center; }
.aisle-block { margin:12px 0; }
.aisle-label {
  font-size:12px; font-weight:700; letter-spacing:0.04em; text-transform:uppercase;
  color:var(--muted); margin:0 0 8px;
}
.trip-line {
  display:flex; align-items:flex-start; gap:10px;
  padding:10px 0; border-bottom:0.5px solid var(--line);
}
.trip-line:last-child { border-bottom:none; }
.trip-line.miss { opacity:0.55; }
.trip-check { width:1.2em; color:var(--muted); font-weight:600; }
.trip-line .grow { flex:1; min-width:0; }
.trip-line .grow .sub { display:block; font-size:12px; margin-top:2px; }
.trip-hero { border:1px solid rgba(0,122,255,.25); }


/* ── Barcode scan (iPhone camera) ───────────────── */
body.scan-open { overflow: hidden; }
.scan-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: #000; color: #fff;
  display: flex; flex-direction: column;
  padding: calc(6px + var(--safe-top)) 0 calc(10px + var(--safe-bottom));
}
.scan-overlay[hidden] { display: none !important; }
.scan-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; gap: 8px;
}
.scan-top strong { font-size: 16px; font-weight: 600; }
.scan-stage {
  position: relative; flex: 1; min-height: 240px;
  margin: 0 12px; border-radius: 16px; overflow: hidden;
  background: #111;
  transition: opacity .2s ease, filter .2s ease;
}
.scan-stage.scan-looking {
  opacity: .45;
  filter: brightness(.55);
}
.scan-stage.scan-looking .scan-laser { animation-play-state: paused; opacity: .2; }
.scan-stage video, .scan-html5-box {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.scan-html5-box video { object-fit: cover !important; }
.scan-frame {
  position: absolute; left: 50%; top: 50%;
  width: min(78%, 300px); height: 140px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,.85);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35);
  pointer-events: none;
}
.scan-status {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  text-align: center; font-size: 14px; font-weight: 500;
  background: rgba(0,0,0,.55); backdrop-filter: blur(8px);
  padding: 10px 12px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  z-index: 4;
}
.scan-spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}
@media (prefers-reduced-motion: reduce) {
  .scan-spin { animation: none; opacity: .7; }
}
.scan-tools { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.scan-manual { display: flex; gap: 8px; }
.scan-manual input {
  flex: 1; border-radius: 12px; border: 0; padding: 12px 14px;
  background: rgba(255,255,255,.12); color: #fff;
}
.scan-manual input::placeholder { color: rgba(255,255,255,.5); }
.scan-hint { font-size: 12px; opacity: .7; margin: 0; }
.scan-result {
  max-height: min(52vh, 440px); overflow: auto;
  padding: 0 12px calc(8px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
.scan-result-card {
  background: var(--bg-solid); color: var(--label);
  border-radius: 18px; padding: 14px 14px 12px;
  box-shadow: 0 -8px 32px rgba(0,0,0,.35);
}
.scan-product {
  display: flex; gap: 12px; align-items: center;
}
.scan-product img,
.scan-product-ph {
  width: 72px; height: 72px; border-radius: 12px; object-fit: contain;
  background: var(--fill); flex-shrink: 0;
}
.scan-product-ph {
  background:
    linear-gradient(135deg, var(--fill), transparent),
    var(--fill);
}
.scan-product .meta { flex: 1; min-width: 0; }
.scan-product .meta strong {
  display: block; font-size: 17px; font-weight: 650; letter-spacing: -0.02em;
  line-height: 1.25;
}
.scan-upc {
  display: inline-block; margin-top: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--muted); background: var(--fill);
  padding: 3px 7px; border-radius: 6px;
}
.scan-best {
  margin-top: 12px; padding: 12px 12px 10px;
  border-radius: 14px;
  background: rgba(52,199,89,.12);
}
.scan-best-empty { background: var(--fill); }
.scan-best-label {
  font-size: 11px; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--green); margin-bottom: 4px;
}
.scan-best-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.scan-best-price {
  font-size: 28px; font-weight: 700; letter-spacing: -0.04em;
  color: var(--label);
}
.scan-best-store { font-size: 14px; font-weight: 560; text-align: right; }
.scan-best-src { font-size: 11px; margin-top: 2px; }
.scan-store-list {
  margin-top: 8px; border-radius: 12px; overflow: hidden;
  background: var(--fill);
}
.scan-store-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; font-size: 13px;
  border-bottom: 0.5px solid var(--line);
}
.scan-store-row:last-child { border-bottom: 0; }
.scan-store-row.best .price { color: var(--green); font-weight: 700; }
.scan-store-row .name { font-weight: 550; min-width: 0; }
.scan-store-row .dist { color: var(--muted); font-weight: 500; }
.scan-store-row .price { font-variant-numeric: tabular-nums; font-weight: 600; }
.scan-honesty {
  margin: 10px 0 0; font-size: 11px; line-height: 1.3; opacity: .85;
}
.scan-shelf-row {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
}
.scan-shelf-field {
  display: flex; align-items: center; gap: 2px;
  flex: 1; min-width: 0;
  background: var(--fill); border-radius: 10px; padding: 0 10px;
}
.scan-dollar {
  font-weight: 600; color: var(--muted); font-size: 15px;
}
.scan-shelf-field input {
  flex: 1; border: 0; background: transparent; padding: 10px 4px;
  min-width: 0; font-variant-numeric: tabular-nums;
  outline: none; width: 100%;
}
.scan-shelf-row select {
  border: 0; background: var(--fill); border-radius: 10px;
  padding: 10px 8px; max-width: 38%; font-size: 13px;
}
.scan-actions {
  display: flex; flex-direction: column; gap: 8px; margin-top: 12px;
}
.btn.scan-next {
  background: transparent; color: var(--blue);
  border: 0; font-weight: 650; padding: 12px;
  font-size: 16px;
}
.btn.scan-cta {
  position: sticky; bottom: 0;
}
/* List barcode chip */
.upc-chip {
  display: inline-block; margin: 6px 0 2px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 500; letter-spacing: 0.03em;
  color: var(--muted); background: var(--fill);
  padding: 2px 7px; border-radius: 6px;
}
.upc-chip::before {
  content: "▥ ";
  font-family: var(--font);
  opacity: .7;
}
/* List/home scan buttons */
.btn.scan-fab {
  display: inline-flex; align-items: center; gap: 6px;
}

.scan-engine {
  font-size: 11px; opacity: .7; font-weight: 500;
  max-width: 42%; text-align: right;
}
.scan-html5-box {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 2;
}
.scan-html5-box video {
  object-fit: cover !important;
  border-radius: 16px;
}
.scan-stage video#scanVideo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 1;
}
.scan-canvas { display: none !important; }
.scan-frame { z-index: 3; }

/* ── Apple-fast scan chrome ─────────────────────── */
.scan-overlay-apple {
  background: #000;
}
.scan-top-apple {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 6px;
  position: relative; z-index: 5;
}
.scan-top-mid { text-align: center; flex: 1; }
.scan-top-mid strong {
  display: block; font-size: 17px; font-weight: 600; letter-spacing: -0.02em;
}
.scan-icon-btn {
  width: 36px; height: 36px; border-radius: 18px; border: 0;
  background: rgba(255,255,255,.14); color: #fff;
  font-size: 16px; font-weight: 600;
  display: grid; place-items: center;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.scan-engine { font-size: 11px; opacity: .55; font-weight: 500; }
.scan-overlay-apple .scan-stage {
  margin: 4px 10px; border-radius: 20px;
  min-height: min(52vh, 480px); flex: 1.2;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}
.scan-html5-box { z-index: 1; }
.scan-video-native {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; display: none;
}
.scan-reticle {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  display: grid; place-items: center;
}
.scan-reticle-corners {
  width: min(96%, 420px); height: min(22%, 120px);
  border-radius: 12px;
  box-shadow:
    0 0 0 999px rgba(0,0,0,.28),
    inset 0 0 0 2px rgba(255,255,255,.88);
  position: relative;
  transform: translateY(var(--band-y, 0%));
  transition: transform .18s ease, height .25s ease, box-shadow .18s ease;
}
.scan-stage.scan-wide .scan-reticle-corners {
  height: min(40%, 200px);
}
.scan-reticle-corners::before,
.scan-reticle-corners::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 3px solid #0a84ff; border-radius: 4px;
}
.scan-reticle-corners::before {
  top: -2px; left: -2px; border-right: 0; border-bottom: 0;
}
.scan-reticle-corners::after {
  right: -2px; bottom: -2px; border-left: 0; border-top: 0;
}
.scan-laser {
  position: absolute; left: 50%; top: 50%;
  width: min(90%, 400px); height: 2px;
  background: linear-gradient(90deg, transparent, #0a84ff, #64d2ff, #0a84ff, transparent);
  box-shadow: 0 0 12px rgba(10,132,255,.85);
  animation: scanLaser 1.2s ease-in-out infinite;
}
.scan-stage.scan-wide .scan-laser {
  animation: scanLaserWide 1.45s ease-in-out infinite;
}
/* --band-y follows tracked barcode (Apple ROI feel) */
@keyframes scanLaser {
  0%, 100% { transform: translate(-50%, calc(-28px + var(--band-y, 0%))); opacity: .35; }
  50% { transform: translate(-50%, calc(28px + var(--band-y, 0%))); opacity: 1; }
}
@keyframes scanLaserWide {
  0%, 100% { transform: translate(-50%, calc(-52px + var(--band-y, 0%))); opacity: .35; }
  50% { transform: translate(-50%, calc(52px + var(--band-y, 0%))); opacity: 1; }
}
.scan-stage.scan-hit {
  animation: scanHitFlash .42s ease-out;
}
@keyframes scanHitFlash {
  0% { box-shadow: 0 0 0 0 rgba(52,199,89,.0); }
  30% { box-shadow: 0 0 0 6px rgba(52,199,89,.85), 0 0 40px rgba(52,199,89,.5); }
  100% { box-shadow: 0 0 0 0 rgba(52,199,89,.0); }
}
.scan-stage.scan-hit .scan-reticle-corners {
  box-shadow:
    0 0 0 999px rgba(0,0,0,.2),
    inset 0 0 0 3px #34c759;
}
/* Live "barcode in frame" lock — before commit */
.scan-stage.scan-inframe .scan-reticle-corners {
  box-shadow:
    0 0 0 999px rgba(0,0,0,.18),
    inset 0 0 0 3px #34c759,
    0 0 24px rgba(52,199,89,.45);
  transition: box-shadow .18s ease;
}
.scan-stage.scan-inframe .scan-reticle-corners::before,
.scan-stage.scan-inframe .scan-reticle-corners::after {
  border-color: #34c759;
}
.scan-stage.scan-inframe .scan-laser {
  background: linear-gradient(90deg, transparent, #34c759, #30d158, #34c759, transparent);
  box-shadow: 0 0 14px rgba(52,199,89,.9);
  animation-duration: .85s;
}
.scan-stage.scan-seeking .scan-reticle-corners {
  transition: box-shadow .2s ease;
}
.scan-track-box {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border: 2.5px solid #34c759;
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(52,199,89,.35),
    0 0 18px rgba(52,199,89,.55);
  background: rgba(52,199,89,.08);
  transition: left .08s linear, top .08s linear, width .08s linear, height .08s linear;
}
.scan-track-box::after {
  content: "In frame";
  position: absolute;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(52,199,89,.92);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.scan-stage.scan-inframe ~ .scan-status-apple,
.scan-stage.scan-inframe .scan-status-apple {
  /* status is inside stage */
}
.scan-stage.scan-inframe #scanStatus {
  background: rgba(22, 120, 55, .72);
  border-color: rgba(52,199,89,.45);
}
.scan-status-apple {
  left: 16px; right: 16px; bottom: 14px;
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.02em;
  background: rgba(0,0,0,.45);
  border: 0.5px solid rgba(255,255,255,.12);
}
.scan-tools-apple {
  padding: 10px 14px 8px;
  gap: 8px;
}
.scan-top-right {
  display: flex; align-items: center; gap: 6px;
  min-width: 36px; justify-content: flex-end;
}
.scan-multi-btn {
  width: auto !important; min-width: 52px; padding: 0 10px;
  font-size: 12px !important; letter-spacing: -0.01em;
  border-radius: 18px !important;
}
.scan-multi-btn.active {
  background: rgba(52,199,89,.28);
  color: #30d158;
  box-shadow: inset 0 0 0 1px rgba(52,199,89,.55);
}
.scan-count-badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: #34c759; color: #fff;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.scan-icon-btn.active {
  background: rgba(255,214,10,.28);
  color: #ffd60a;
}
/* Zoom controls — retail inventory adjust */
.scan-zoom-row {
  position: absolute; left: 12px; right: 12px; bottom: 58px;
  z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 14px;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 0.5px solid rgba(255,255,255,.12);
}
.scan-zoom-row[hidden] { display: none !important; }
.scan-zoom-btn {
  width: 32px; height: 32px; border-radius: 10px; border: 0;
  background: rgba(255,255,255,.14); color: #fff;
  font-size: 18px; font-weight: 600; line-height: 1;
  display: grid; place-items: center; flex-shrink: 0;
}
.scan-zoom-slider {
  flex: 1; min-width: 0; accent-color: #0a84ff;
  height: 28px;
}
.scan-zoom-label {
  font-size: 12px; font-weight: 650; min-width: 34px;
  text-align: right; font-variant-numeric: tabular-nums;
  opacity: .9;
}
.scan-tools-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.scan-hint-inline {
  font-size: 11px; opacity: .55; font-weight: 500;
}
.scan-live-toast {
  position: absolute; left: 50%; top: 14px; z-index: 6;
  transform: translateX(-50%) translateY(-8px);
  max-width: 88%; padding: 8px 14px; border-radius: 999px;
  background: rgba(52,199,89,.92); color: #fff;
  font-size: 13px; font-weight: 650; letter-spacing: -0.01em;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scan-live-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.scan-result-compact {
  max-height: min(28vh, 220px);
}
.scan-result-compact .scan-result-card {
  padding: 10px 12px;
  border-radius: 14px;
}
.scan-result-compact .scan-product img,
.scan-result-compact .scan-product-ph {
  width: 48px; height: 48px;
}
.scan-result-compact .scan-best-price { font-size: 20px; }
.scan-result-compact .scan-store-list,
.scan-result-compact .scan-honesty,
.scan-result-compact .scan-shelf-row { display: none; }
.scan-stage.scan-continuous .scan-status-apple {
  bottom: 96px;
}
.scan-stage.scan-continuous #scanZoomRow {
  bottom: 52px;
}
/* Telegram Mini App */
body.tg-webapp #telegramPromo { display: none !important; }
body.tg-webapp .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
body.tg-webapp {
  /* Telegram provides theme vars sometimes */
  min-height: 100vh;
  min-height: 100dvh;
}
.scan-pill {
  display: inline-flex; align-self: flex-start;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(255,255,255,.12); color: #fff;
  font-size: 14px; font-weight: 600;
}
.scan-overlay-apple .scan-manual input {
  background: rgba(255,255,255,.1);
}

/* Hide html5-qrcode dashboard junk — keep video only */
#scanHtml5Box > img,
#scanHtml5Box img[alt="Info icon"],
#scanHtml5Box #qr-shaded-region,
#scanHtml5Box .qr-shaded-region,
#qr-shaded-region {
  display: none !important;
}
#scanHtml5Box video {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
#scanHtml5Box button#html5-qrcode-button-camera-permission,
#scanHtml5Box button#html5-qrcode-button-camera-start,
#scanHtml5Box button#html5-qrcode-button-camera-stop,
#scanHtml5Box button#html5-qrcode-button-file-selection,
#scanHtml5Box #html5-qrcode-select-camera,
#html5-qrcode-anchor-scan-type-change {
  display: none !important;
}
/* Torch / chrome from lib: tuck away; we have our own controls */
#scanHtml5Box button {
  position: absolute !important; width: 1px !important; height: 1px !important;
  opacity: 0 !important; pointer-events: none !important; overflow: hidden !important;
}
#scanHtml5Box input[type="file"],
#scanHtml5Box select {
  display: none !important;
}

/* Telegram Bot Promotion Banner */
.telegram-promo {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  padding: 12px 16px;
  text-align: center;
  position: relative;
}
.promo-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.promo-text {
  color: white;
  font-size: 14px;
  font-weight: 500;
}
.promo-btn {
  background: white;
  color: var(--blue);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.1s;
}
.promo-btn:hover {
  transform: scale(1.05);
}
.promo-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.2);
  border: none;
  color: white;
  font-size: 20px;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
