:root {
  --page: #f7f8f7; --surface: #ffffff; --surface-2: #f0f2f0;
  --ink: #14171a; --ink-2: #4d5451; --muted: #8a908d;
  --ring: rgba(20,23,26,.10); --accent: #2a78d6; --accent-ink: #ffffff;
  --n1: #0ca30c; --n2: #7cb518; --n3: #f0a202; --n4: #d03b3b;
  --danger: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0e1110; --surface: #191d1b; --surface-2: #222724;
    --ink: #eef1ef; --ink-2: #b9c0bc; --muted: #7f8683;
    --ring: rgba(255,255,255,.10); --accent: #3987e5;
  }
}
* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; padding: 0 14px calc(24px + env(safe-area-inset-bottom)); }
.screen[hidden] { display: none; }

/* setup */
.setup-card { text-align: center; padding: 12vh 10px 0; display: flex; flex-direction: column; gap: 12px; }
.setup-card .logo { font-size: 52px; }
.setup-card h1 { margin: 0; font-size: 28px; }
.setup-card p { color: var(--ink-2); font-size: 15px; margin: 0 0 12px; }
.setup-card .or { color: var(--muted); font-size: 13px; }
.setup-card input { text-align: center; }

/* header */
header { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
header h1 { font-size: 22px; margin: 0; }

/* inputs & buttons */
input {
  width: 100%; font-size: 16px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink); outline: none;
}
input:focus { border-color: var(--accent); }
button {
  font-size: 15px; font-weight: 600; padding: 11px 16px; border-radius: 10px;
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.ghost { background: transparent; color: var(--ink-2); }
button:active { transform: scale(.98); }

.stores { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; -webkit-overflow-scrolling: touch; }
.stores::-webkit-scrollbar { display: none; }
.store-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--ring); background: var(--surface); color: var(--ink-2);
}
.store-chip img { width: 15px; height: 15px; object-fit: contain; border-radius: 3px; }
.store-chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.addbar { display: flex; gap: 8px; }
.addbar input { flex: 1; }
.addbar button { flex: 0 0 48px; font-size: 22px; font-weight: 500; padding: 0; }

/* search results */
#results {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 12px;
  margin-top: 6px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.10);
}
.res {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--ring); background: none; width: 100%; text-align: left;
  border-radius: 0; border-left: none; border-right: none; border-top: none; font-weight: 500;
}
.res:last-child { border-bottom: none; }
.res:hover { background: var(--surface-2); }
.res img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: #fff; flex: 0 0 auto; }
.res .noimg { width: 34px; height: 34px; border-radius: 6px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.res .r-name { font-size: 14px; }
.res .r-sub { font-size: 12px; color: var(--muted); }
.res .r-price { margin-left: auto; font-size: 13px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.res-note { padding: 9px 12px; font-size: 12.5px; color: var(--muted); }

.toolbar { display: flex; gap: 8px; margin: 12px 0 6px; }
.toolbar button { font-size: 13.5px; padding: 8px 12px; }

/* items */
.items { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--ring); border-radius: 12px; padding: 10px 12px;
}
.item .check {
  flex: 0 0 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted);
  background: none; padding: 0; display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 15px;
}
.item.checked .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.item .body { flex: 1; min-width: 0; }
.item .name { font-size: 15px; font-weight: 550; }
.item .sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item.checked .name { text-decoration: line-through; color: var(--muted); font-weight: 450; }
.item .del { flex: 0 0 auto; background: none; border: none; color: var(--muted); font-size: 17px; padding: 4px 6px; }
.items.done .item { opacity: .65; }
.done-head { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 16px 0 2px; }

/* nova badges */
.nova {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
}
.nova.n1 { background: var(--n1); } .nova.n2 { background: var(--n2); }
.nova.n3 { background: var(--n3); } .nova.n4 { background: var(--n4); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; }
.badge.b4 { color: var(--n4); }
.badge.b3 { color: var(--n3); }

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 32px 20px; }

footer { margin-top: 26px; display: flex; flex-direction: column; gap: 8px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.sync { font-size: 11px; color: var(--muted); }

#toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--page); font-size: 13.5px; font-weight: 550;
  padding: 9px 16px; border-radius: 999px; z-index: 20; max-width: 90vw; text-align: center;
}
@media (prefers-reduced-motion: no-preference) {
  #toast { animation: pop .18s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(6px); } }
}
