:root {
  --bg: #f6f7f4;
  --card: #ffffff;
  --ink: #18201b;
  --muted: #6a736d;
  --line: #e3e7e2;
  --open: #12813f;
  --soon: #c26a00;
  --closed: #8a918c;
  --chip: #eceee9;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 14px rgba(20, 30, 25, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513;
    --card: #1b201d;
    --ink: #eef2ee;
    --muted: #9aa49d;
    --line: #2b322e;
    --open: #4cc779;
    --soon: #f0a24a;
    --closed: #7d867f;
    --chip: #252b27;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

header {
  position: sticky; top: 0; z-index: 5;
  padding: 14px 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.iconbtn {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 32px; }

.hero {
  background: var(--card); border-radius: 18px; padding: 18px; margin: 6px 0 14px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hero h2 { margin: 4px 0 2px; font-size: 22px; letter-spacing: -.01em; }
.hero-meta { margin: 0 0 14px; color: var(--muted); }

.chips { display: flex; gap: 8px; margin: 0 0 10px; overflow-x: auto; scrollbar-width: none; }
.chips button {
  flex: none; border: 0; border-radius: 999px; padding: 8px 14px;
  background: var(--chip); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

#list { display: grid; gap: 12px; margin-top: 6px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 14px 12px; box-shadow: var(--shadow);
  border-left: 5px solid var(--brand);
}
.card.is-closed h3, .card.is-closed .addr span { opacity: .7; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chip {
  font-size: 12px; font-weight: 700; color: #fff; background: var(--brand);
  padding: 3px 9px; border-radius: 999px;
}
.dist { font-size: 13px; color: var(--muted); }
.card h3 { margin: 8px 0 2px; font-size: 18px; }

.status { margin: 0 0 8px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.open { color: var(--open); }
.status.soon { color: var(--soon); }
.status.closed { color: var(--closed); }

.addr {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--chip); border-radius: 10px; padding: 8px 8px 8px 12px; font-size: 14px;
  -webkit-user-select: text; user-select: text;
}
.copy {
  flex: none; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer;
  background: var(--card); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line);
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 13px; border-radius: 10px; text-decoration: none;
  border: 1px solid var(--line); color: var(--ink); background: var(--card);
  font-size: 14px; font-weight: 600;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; flex: 1 1 100%; }
.btn.big { width: 100%; padding: 13px; font-size: 16px; border-radius: 12px; }
.note { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.empty, .foot { color: var(--muted); font-size: 13px; text-align: center; }
.foot { margin-top: 22px; }

/* ---- header tabs ---- */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 10px;
  background: var(--chip); border-radius: 12px; padding: 4px;
}
.seg button {
  border: 0; border-radius: 9px; padding: 8px; background: transparent; color: var(--muted);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---- deals ---- */
.search {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; color: var(--muted);
}
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; padding: 11px 0;
}
.deals-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 2px 0 10px; font-size: 13px; color: var(--muted); }
.link { border: 0; background: none; color: var(--open); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.deal {
  position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  color: var(--ink); font: inherit; cursor: pointer; box-shadow: var(--shadow); min-height: 230px;
}
.deal .img { display: block; aspect-ratio: 4 / 3; border-radius: 10px; background: #fff; overflow: hidden; }
.deal .img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.deal .badge {
  position: absolute; top: 14px; left: 14px; z-index: 1;
  background: #e0201b; color: #fff; font-size: 13px; font-weight: 800; padding: 3px 8px; border-radius: 8px;
}
.deal .plus {
  position: absolute; top: 14px; right: 14px; z-index: 1;
  background: #ffd500; color: #0050aa; font-size: 11px; font-weight: 800; padding: 3px 7px; border-radius: 8px;
}
.deal .name { font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal .prices { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.deal .now { font-size: 19px; font-weight: 800; color: #e0201b; }
.deal .now small { font-size: 12px; font-weight: 700; margin-left: 2px; }
.deal s, .sheet-price s { color: var(--muted); font-size: 14px; }
.deal .when { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.deal .from { font-size: 11px; font-weight: 800; color: #fff; background: var(--brand); padding: 1px 6px; border-radius: 6px; }
.skeleton { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.warn { grid-column: 1 / -1; margin: 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--soon) 15%, var(--card)); font-size: 13px; }
.grid .empty { grid-column: 1 / -1; }
.picker {
  display: flex; align-items: center; gap: 10px; margin: 8px 0 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 4px 12px;
}
.picker span { font-size: 13px; font-weight: 600; color: var(--muted); }
.picker select {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 600; padding: 9px 4px;
}
.card.picked { margin-bottom: 12px; }

/* ---- item sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease;
  max-width: 640px; margin: 0 auto;
}
.sheet.open .sheet-bg { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-x {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--chip); color: var(--ink); font-size: 15px; cursor: pointer;
}
.sheet-img { display: block; width: 100%; max-height: 210px; object-fit: contain; background: #fff; border-radius: 14px; }
.sheet-panel h2 { margin: 12px 40px 4px 0; font-size: 20px; }
.sheet-price { margin: 0 0 4px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sheet-price strong { font-size: 26px; color: #e0201b; }
.sheet-price small { font-size: 14px; }
.save { font-size: 14px; font-weight: 700; color: var(--open); }
.muted { margin: 2px 0; color: var(--muted); font-size: 14px; }
.plus-note { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: #fff6c2; color: #3b3200; font-size: 13px; }
.sheet-h { margin: 18px 0 8px; font-size: 16px; }
.store-row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.store-row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.store-row .actions { margin-top: 8px; }
.btn.wide { width: 100%; margin-top: 6px; padding: 12px; }
button.btn { font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

#toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; transition: .2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
