:root {
  --bg: #f5f6f4;
  --card: #ffffff;
  --text: #1c1f1e;
  --muted: #66706c;
  --line: #e2e5e3;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --best: #e7f6ef;
  --best-line: #2f9e6e;
  --promo: #b4232a;
  --member: #8a5a00;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --card: #1c201f;
    --text: #e9ecea;
    --muted: #9aa49f;
    --line: #2c3230;
    --accent: #2bb3a3;
    --accent-text: #08201d;
    --best: #15302a;
    --best-line: #3ec28a;
    --promo: #ff7b7b;
    --member: #f0b54a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
main, .top, .status { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: max(20px, env(safe-area-inset-top)); }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 28px 0 8px; }
.sub { margin: 2px 0 18px; color: var(--muted); }

.scan-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-size: 1.15rem; font-weight: 650; cursor: pointer;
}
.scan-btn svg { width: 28px; height: 28px; }

.search { display: flex; gap: 8px; margin: 12px 0 8px; }
.search input {
  flex: 1; min-width: 0; padding: 12px 14px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
}
.search button {
  padding: 0 18px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 14px; }
.product { display: flex; gap: 14px; align-items: center; }
.product img { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.product h3 { margin: 0; font-size: 1.1rem; }
.meta { color: var(--muted); font-size: 0.9rem; }
.ean { font-variant-numeric: tabular-nums; }

.offers { list-style: none; margin: 10px 0 0; padding: 0; }
.offer {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-top: 8px;
  color: inherit; text-decoration: none; background: var(--card);
}
.offer.best { background: var(--best); border-color: var(--best-line); }
.offer .store { font-weight: 650; }
.offer .price { font-weight: 700; font-size: 1.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.offer .small { color: var(--muted); font-size: 0.85rem; }
.offer .right { text-align: right; }
.offer .tag { font-size: 0.8rem; font-weight: 600; color: var(--best-line); }
.offer .promo { color: var(--promo); font-size: 0.88rem; font-weight: 600; }
.offer .promo.member { color: var(--member); }
.offer .strike { text-decoration: line-through; }
.offer.oos { opacity: 0.55; }

.empty { color: var(--muted); }
.saving { margin-top: 10px; font-weight: 600; color: var(--best-line); }

.results { list-style: none; padding: 0; margin: 0; }
.results li button, .results li a {
  text-decoration: none;
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  padding: 10px; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: inherit; font: inherit; cursor: pointer;
}
.results img { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 6px; flex: none; }
.results .grow { flex: 1; min-width: 0; }
.results .name { font-weight: 600; }
.results .from { font-weight: 700; white-space: nowrap; }

.recent { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.recent button {
  border: 1px solid var(--line); background: var(--card); color: inherit; border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: 0.9rem; cursor: pointer; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.status { color: var(--muted); font-size: 0.8rem; padding-top: 28px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.scanner { position: fixed; inset: 0; background: #000; z-index: 10; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute; left: 50%; top: 45%; width: min(80vw, 420px); height: 160px;
  transform: translate(-50%, -50%); border: 3px solid rgba(255, 255, 255, 0.9); border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
}
.scanner .hint { position: absolute; left: 0; right: 0; bottom: max(40px, env(safe-area-inset-bottom)); text-align: center; color: #fff; margin: 0; }
.scanner .close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; width: 44px; height: 44px;
  border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1.3rem; cursor: pointer;
}

.similar { margin: 18px 0 2px; font-size: 0.95rem; }
.small-note { margin: 0; color: var(--muted); font-size: 0.85rem; }

.watch { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.watch input {
  flex: 1; min-width: 0; padding: 10px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
}
.watch button {
  padding: 10px 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent);
  color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.watch.on { justify-content: space-between; padding: 10px 12px; border-radius: 10px; background: var(--best); }
.watch.on button { background: transparent; color: var(--text); border-color: var(--line); }
