:root {
  --bg: #0b0d0b;
  --surface: #151915;
  --surface-2: #1d231d;
  --line: #2a322a;
  --text: #f2f5f0;
  --muted: #9aa59a;
  --accent: #74f53c;
  --accent-dim: #3f8a20;
  --accent-ink: #0b0d0b;
  --danger: #ff6b6b;
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.noscript { padding: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { width: 96px; height: 96px; border-radius: 22px; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(11, 13, 11, 0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand-name { font-weight: 800; letter-spacing: -0.01em; line-height: 1.1; }
.brand-name small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.dot {
  position: absolute; top: 6px; right: 7px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--surface);
}
.search {
  margin-top: 10px; display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); cursor: pointer; text-align: left;
}
.search svg { width: 18px; height: 18px; flex: none; }

main { padding: 0 0 24px; }
.section { padding: 18px 16px 4px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
.section-head a, .link-btn { font-size: 14px; font-weight: 600; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; }
.page-title { font-size: 24px; margin: 18px 16px 4px; letter-spacing: -0.02em; }
.page-sub { margin: 0 16px 8px; color: var(--muted); }

/* categories */
.cats { display: flex; gap: 14px; overflow-x: auto; padding: 4px 16px 6px; scrollbar-width: none; }
.cats::-webkit-scrollbar, .rail::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
.cat { flex: none; width: 70px; text-align: center; background: none; border: 0; cursor: pointer; padding: 0; }
.cat-icon {
  width: 62px; height: 62px; margin: 0 auto 6px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center;
}
.cat-icon svg { width: 30px; height: 30px; color: var(--accent); }
.cat span { font-size: 12.5px; font-weight: 600; }

/* rails and cards */
.rail { display: flex; gap: 12px; overflow-x: auto; padding: 2px 16px 8px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.rail > * { scroll-snap-align: start; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: block; width: 100%;
}
.deal-card { flex: none; width: 230px; }
.deal-media { aspect-ratio: 1 / 1; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.deal-media img { width: 100%; height: 100%; object-fit: cover; }
.deal-media .ph { color: var(--accent); font-weight: 800; font-size: 26px; padding: 12px; text-align: center; }
.card-body { padding: 10px 12px 12px; }
.card-title { font-weight: 700; margin: 0 0 4px; font-size: 15px; }
.card-meta { color: var(--muted); font-size: 13px; }
.tag {
  display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: rgba(116, 245, 60, 0.14); color: var(--accent);
}
.prod-card { flex: none; width: 150px; }
.prod-media { aspect-ratio: 1; background: var(--surface-2); display: grid; place-items: center; }
.prod-media img { width: 100%; height: 100%; object-fit: cover; }
.prod-media svg { width: 44px; height: 44px; color: var(--accent-dim); }
.price { font-weight: 800; color: var(--text); margin-top: 4px; }
.list { display: grid; gap: 12px; padding: 0 16px; }
.list .deal-card { width: 100%; }

.grid-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; }
.grid-cats .card { display: flex; align-items: center; gap: 10px; padding: 14px; }
.grid-cats svg { width: 26px; height: 26px; color: var(--accent); }

/* banners */
.banner {
  margin: 16px 16px 0; padding: 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(116, 245, 60, 0.18), rgba(116, 245, 60, 0.04));
  border: 1px solid rgba(116, 245, 60, 0.35); display: flex; gap: 12px; align-items: center;
}
.banner svg { width: 28px; height: 28px; color: var(--accent); flex: none; }
.banner p { margin: 0; flex: 1; font-size: 14px; }
.banner strong { display: block; font-size: 15px; }
.empty { margin: 8px 16px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px; border: 0; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); min-height: 46px;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* deal detail */
.detail-media { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; }
.detail-media img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.detail { padding: 16px; }
.detail h1 { font-size: 22px; margin: 8px 0; letter-spacing: -0.02em; }
.detail p { color: #d6ddd3; white-space: pre-line; }
.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 14px 0; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--accent); background: rgba(116, 245, 60, 0.06);
}
.code-box code { font-size: 18px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent); }
.detail .actions { display: grid; gap: 10px; margin-top: 16px; }
.list.spaced { margin-top: 18px; }

/* shop */
.shop { display: flex; flex-direction: column; height: calc(100vh - var(--nav-h) - var(--safe-b)); }
.shop .topbar { position: static; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.menu-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.shop-note { padding: 8px 16px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

/* inbox */
.inbox-item { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.inbox-item .ic { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.inbox-item .ic svg { width: 18px; height: 18px; color: var(--accent); }
.inbox-item h3 { margin: 0 0 2px; font-size: 15px; }
.inbox-item p { margin: 0; color: var(--muted); font-size: 13.5px; white-space: pre-line; }
.inbox-item time { font-size: 12px; color: var(--muted); }
.inbox-item.unread h3::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 8px; vertical-align: middle; }

/* account */
.rows { margin: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row small { display: block; color: var(--muted); font-size: 12.5px; }
.row > svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.row > span:first-child { flex: 1; min-width: 0; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* legal footer */
.legal { margin: 24px 16px 8px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }
.legal strong { color: var(--text); font-weight: 600; }

/* bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(16, 19, 16, 0.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 600; position: relative; }
.nav a svg { width: 23px; height: 23px; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav .dot { top: 8px; right: calc(50% - 16px); }

/* sheets and overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: 20px 20px 0 0; border: 1px solid var(--line);
  padding: 20px 18px calc(20px + var(--safe-b)); max-height: 90vh; overflow: auto;
}
.sheet h2 { margin: 0 0 8px; font-size: 20px; }
.sheet ol { padding-left: 20px; }
.sheet li { margin: 8px 0; }
.sheet .actions { display: grid; gap: 10px; margin-top: 16px; }

.gate { position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow: auto; display: flex; align-items: center; justify-content: center; padding: 24px 20px calc(24px + var(--safe-b)); }
.gate-box { width: 100%; max-width: 420px; text-align: center; }
.gate-box img { width: 104px; height: 104px; border-radius: 24px; margin: 0 auto 16px; }
.gate-box h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -0.02em; }
.gate-box p { color: var(--muted); margin: 0 0 18px; }
.dob { display: grid; grid-template-columns: 1.3fr 1fr 1.2fr; gap: 8px; margin-bottom: 12px; }
.dob select, .field input, .field textarea, .field select {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
}
.gate .error { color: var(--danger); min-height: 1.4em; font-size: 14px; }
.gate .fine { font-size: 12px; color: var(--muted); margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translateX(-50%);
  z-index: 70; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center;
}

@media (min-width: 760px) {
  .shell { max-width: 760px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .nav { max-width: 760px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
