:root {
  --bg: #0d0d0e;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f1f1f1;
  --muted: #9a9a9e;
  --accent: #e9e9e9;
  --accent-text: #111;
  --ok: #7bd88f;
  --warn: #ffb347;
  --danger: #ff6b6b;
  --radius: 18px;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* drifting smoke behind everything */
.smoke {
  position: fixed; inset: -20%;
  z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 30% at 20% 15%, rgba(255,255,255,.09), transparent 70%),
    radial-gradient(35% 25% at 85% 35%, rgba(255,255,255,.06), transparent 70%),
    radial-gradient(45% 35% at 40% 85%, rgba(255,255,255,.05), transparent 70%);
  filter: blur(20px);
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-3%, 0, 0) scale(1); }
  to   { transform: translate3d(3%, -4%, 0) scale(1.08); }
}

#app {
  position: relative; z-index: 1;
  padding: 14px 14px calc(var(--tabbar-h) + var(--safe-b) + 90px);
  max-width: 720px; margin: 0 auto;
}
.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* hero */
.hero {
  display: flex; gap: 14px; align-items: center;
  padding: 12px; border-radius: 22px;
  background: linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  border: 1px solid var(--line);
}
.hero-logo { width: 68px; height: 68px; border-radius: 16px; object-fit: cover; flex-shrink: 0; }
.hero h1 {
  margin: 0; font-size: 24px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  text-shadow: 0 0 18px rgba(255,255,255,.35);
}
.hero p { margin: 4px 0 0; color: var(--muted); font-size: 13px; white-space: pre-line; line-height: 1.4; }

/* category chips */
.chips {
  display: flex; gap: 8px; overflow-x: auto; margin: 14px -14px 0; padding: 0 14px 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 9px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }

.search {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  padding: 0 14px; height: 46px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.search input { flex: 1; background: none; border: 0; outline: none; color: var(--text); min-width: 0; }
.search input::-webkit-search-cancel-button { filter: invert(1); }

.filters { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fbtn {
  flex-shrink: 0; height: 36px; padding: 0 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600;
  appearance: none; -webkit-appearance: none;
}
select.fbtn { padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, #999 50%), linear-gradient(135deg, #999 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 10px) 15px; background-size: 4px 4px; background-repeat: no-repeat; }
select.fbtn option { background: #1b1b1d; }
.fbtn.icon { width: 36px; padding: 0; display: grid; place-items: center; }
.fbtn.on { background: var(--accent); color: var(--accent-text); }
.fbtn.on svg { fill: currentColor; }

/* product grid */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card-p {
  position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden;
  background: #1a1a1c; border: 1px solid var(--line); cursor: pointer;
}
.card-p img.cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-p .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: #444; font-weight: 800; letter-spacing: .1em; }
.card-p .fav {
  position: absolute; top: 8px; left: 8px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(6px); display: grid; place-items: center;
}
.card-p .fav.on svg { fill: var(--danger); stroke: var(--danger); }
.card-p .tag {
  position: absolute; top: 9px; right: 8px; padding: 4px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: rgba(0,0,0,.5); backdrop-filter: blur(6px);
}
.card-p .tag.badge { top: 40px; background: var(--accent); color: var(--accent-text); }
.card-p .info {
  position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 9px 44px 9px 10px; border-radius: 13px;
  background: rgba(14,14,15,.78); backdrop-filter: blur(10px); border: 1px solid var(--line);
}
.card-p .info b { display: block; font-size: 13px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-p .info small { color: var(--muted); font-size: 12px; }
.card-p .info small strong { color: var(--text); white-space: nowrap; }
.card-p .plus {
  position: absolute; right: 8px; bottom: 50%; transform: translateY(50%);
  width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 20px; font-weight: 700; line-height: 1;
}
.card-p.out { opacity: .5; }
.empty, .empty-block { text-align: center; color: var(--muted); padding: 40px 0; }

/* generic */
.title { font-size: 26px; font-weight: 800; margin: 6px 0 14px; }
.title-row { display: flex; align-items: center; justify-content: space-between; }
.subtitle { font-size: 17px; margin: 22px 0 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.btn {
  height: 44px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 700;
}
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; }
.hint { margin-top: 10px; padding: 11px 14px; border-radius: 14px; border: 1px dashed var(--line); font-size: 13px; text-align: center; color: var(--muted); }
.hint b { color: var(--text); }

/* cart */
.cart-row {
  display: flex; gap: 12px; align-items: center; padding: 10px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.cart-row img, .cart-row .ph { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: #222; flex-shrink: 0; }
.cart-row .meta { flex: 1; min-width: 0; }
.cart-row .meta b { display: block; font-size: 14px; }
.cart-row .meta small { color: var(--muted); }
.cart-row .warn { color: var(--warn); font-size: 12px; display: block; }
.qty { display: flex; align-items: center; gap: 4px; background: rgba(0,0,0,.3); border-radius: 12px; padding: 3px; }
.qty button { width: 30px; height: 30px; border-radius: 9px; border: 0; background: var(--surface-2); font-size: 17px; font-weight: 700; }
.qty span { min-width: 22px; text-align: center; font-weight: 700; }
.qty button:disabled { opacity: .3; }

.sticky-total {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); width: min(560px, calc(100% - 28px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 18px; border-radius: 20px;
  background: rgba(24,24,26,.92); backdrop-filter: blur(14px); border: 1px solid var(--line);
}
.sticky-total small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.sticky-total b { font-size: 22px; }

/* tab bar */
.tabbar {
  position: fixed; z-index: 10; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-b)); width: min(560px, calc(100% - 20px)); height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; gap: 4px;
  background: rgba(20,20,22,.88); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 24px;
}
.tabbar button {
  position: relative; border: 0; background: none; border-radius: 18px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 700;
}
.tabbar button.active { background: var(--surface-2); color: var(--text); }
.badge {
  position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: var(--accent-text); font-size: 11px; font-style: normal;
  display: grid; place-items: center;
}

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  position: relative; width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  background: #141415; border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0;
  padding: 16px 16px calc(100px + var(--safe-b)); animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); font-size: 22px; line-height: 1; }
.sheet .pimg { width: 100%; aspect-ratio: 1; border-radius: 20px; object-fit: cover; background: #1e1e20; display: block; }
.sheet h2 { margin: 14px 0 2px; font-size: 21px; }
.sheet .brand { color: var(--muted); font-size: 13px; }
.sheet .desc { margin: 10px 0 0; line-height: 1.5; white-space: pre-line; color: #d6d6d6; font-size: 14px; }
.sheet .vlabel { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; justify-content: space-between; }
.variant {
  display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 8px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
}
.variant.picked { border-color: rgba(255,255,255,.45); }
.variant img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.variant .vmeta { flex: 1; min-width: 0; }
.variant .vmeta b { display: block; font-size: 14px; }
.variant .vmeta small { color: var(--muted); font-size: 12px; }
.variant.out { opacity: .45; }
.sheet-bar {
  position: fixed; z-index: 21; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b));
  width: min(690px, calc(100% - 24px)); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; border-radius: 20px; background: rgba(30,30,32,.95); backdrop-filter: blur(14px); border: 1px solid var(--line);
}
.sheet-bar b { font-size: 20px; }
.sheet-bar small { color: var(--muted); margin-left: 6px; }

/* checkout */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.seg button { height: 40px; border: 0; border-radius: 11px; background: none; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--accent); color: var(--accent-text); }
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); outline: none;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field textarea:focus { border-color: rgba(255,255,255,.35); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary { margin-top: 16px; }
.summary div { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); }
.summary div.total { color: var(--text); font-weight: 800; font-size: 18px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.note { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.45; }

/* profile */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.stat small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat b { font-size: 19px; display: block; margin-top: 4px; }
.order { padding: 12px 14px; margin-bottom: 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.order-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-head b { font-size: 15px; }
.order small { color: var(--muted); }
.order ul { margin: 8px 0 0; padding-left: 18px; color: #cfcfcf; font-size: 13px; line-height: 1.6; }
.status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); }
.status.new { color: var(--warn); }
.status.confirmed { color: #8ab4ff; }
.status.done { color: var(--ok); }
.status.cancelled { color: var(--danger); }

/* chat */
.chat-messages { display: flex; flex-direction: column; gap: 8px; min-height: 180px; max-height: calc(100vh - 330px); overflow-y: auto; padding: 10px 0; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 16px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 5px; }
.msg.shop { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; }
.msg time { display: block; font-size: 10px; opacity: .55; margin-top: 3px; text-align: right; }
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form input { flex: 1; height: 46px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,.25); outline: none; min-width: 0; }
.send { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; }

/* age gate */
.gate { position: fixed; inset: 0; z-index: 50; background: rgba(5,5,6,.92); backdrop-filter: blur(10px); display: grid; place-items: center; padding: 20px; }
.gate-card { width: min(380px, 100%); text-align: center; padding: 24px; border-radius: 24px; background: #151517; border: 1px solid var(--line); }
.gate-card img { width: 110px; height: 110px; border-radius: 22px; object-fit: cover; }
.gate-card h2 { margin: 16px 0 6px; }
.gate-card p { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0 0 18px; }
.gate-card .btn + .btn { margin-top: 8px; }

.toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top, 0px));
  max-width: calc(100% - 28px); padding: 11px 16px; border-radius: 14px; background: #f1f1f1; color: #111; font-weight: 700; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: fade .2s;
}
.toast.error { background: var(--danger); color: #fff; }
.success { text-align: center; padding: 30px 10px 10px; }
.success .check { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-size: 34px; font-weight: 800; }
.success p { color: var(--muted); line-height: 1.5; }
