:root {
  --bg: #0e0f13;
  --card: #181a21;
  --card-2: #20232c;
  --line: #2a2e39;
  --text: #f3f4f7;
  --muted: #9aa0ae;
  --hot: #ff3d57;
  --gold: #ffd23f;
  --ok: #36d399;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: rgba(14, 15, 19, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; min-width: 0; }
.brand > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live {
  background: var(--hot); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .08em;
  padding: 3px 8px 3px 18px; border-radius: 6px; position: relative; flex: none;
}
.live::before {
  content: ""; position: absolute; left: 7px; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: #fff; animation: pulse 1.2s infinite;
}
.viewers { color: var(--muted); font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.viewers b { color: var(--text); }
.viewers i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- ticker ---------- */
.ticker {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px; min-height: 52px;
}
.ticker::-webkit-scrollbar { display: none; }
.ticker:empty { display: none; }
.ticker:empty + main { padding-top: 16px; }
.chip {
  flex: none; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px 6px 6px; font-size: 13px; white-space: nowrap;
}
.chip .code {
  background: var(--gold); color: #1a1500; font-weight: 800; border-radius: 999px;
  padding: 2px 8px; font-variant-numeric: tabular-nums;
}
.chip .ago { color: var(--muted); }
.chip.new { animation: chipIn .5s cubic-bezier(.2, 1.4, .4, 1); border-color: var(--gold); }
@keyframes chipIn { from { transform: translateX(-24px) scale(.9); opacity: 0; } }

/* ---------- grid ---------- */
main { padding: 4px 16px 16px; max-width: 1100px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .3s;
}
.card.hit { animation: hit .7s; border-color: var(--gold); }
@keyframes hit { 20% { transform: scale(.97); } 60% { transform: scale(1.01); } }
.photo { position: relative; aspect-ratio: 1; background: var(--card-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 56px; font-weight: 800; color: rgba(255, 255, 255, .16);
  background: linear-gradient(135deg, #2a2e39, #1b1d25);
}
.stamp {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(14, 15, 19, .62);
}
.stamp span {
  border: 3px solid currentColor; color: var(--gold); font-weight: 900; letter-spacing: .06em;
  padding: 6px 12px; border-radius: 8px; transform: rotate(-8deg); font-size: 15px; text-align: center;
  background: rgba(14, 15, 19, .5);
}
.card.gone .stamp span { color: var(--muted); }
.card.gone .photo img { filter: grayscale(1); }
.minus {
  position: absolute; right: 10px; top: 10px; background: var(--gold); color: #1a1500;
  font-weight: 900; border-radius: 999px; padding: 2px 10px; animation: minus 1s forwards; pointer-events: none;
}
@keyframes minus { from { transform: translateY(8px); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }

.body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.title { font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.price { font-size: 22px; font-weight: 800; color: var(--gold); letter-spacing: -.02em; }
.bar { height: 5px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width .5s; }
.left { font-size: 13px; font-weight: 600; }
.card.low .left { color: var(--hot); }
.card.low .bar i { background: var(--hot); }
.total, .drop { font-size: 12px; color: var(--muted); }
.drop b { color: var(--text); font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 12px 14px; min-height: 46px;
  font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
  background: var(--card-2); color: var(--text);
}
.btn.primary { background: var(--hot); color: #fff; }
.btn.primary:active { transform: scale(.98); }
.btn.gold { background: var(--gold); color: #1a1500; }
.btn.wa { background: #1fa855; color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { background: var(--card-2); color: var(--muted); cursor: default; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.vinted { font-size: 12px; color: var(--muted); text-align: center; }

.empty { text-align: center; color: var(--muted); padding: 64px 16px; font-size: 16px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 8px 0; }

/* ---------- cart bar ---------- */
.cartbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 6;
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--gold); color: #1a1500; border: 0; border-radius: 16px; padding: 14px 16px;
  font-weight: 700; text-align: left; cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.cartbar small { display: block; font-weight: 600; opacity: .75; font-size: 12px; }
.cartbar .go { background: #1a1500; color: var(--gold); border-radius: 10px; padding: 8px 12px; white-space: nowrap; }
.cartbar.order { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.cartbar.order .go { background: var(--gold); color: #1a1500; }

/* ---------- sheets ---------- */
dialog.sheet {
  border: 0; padding: 0; color: var(--text); background: var(--card);
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0;
  border-radius: 20px 20px 0 0; overflow-y: auto;
}
@media (min-width: 620px) { dialog.sheet { margin: auto; border-radius: 20px; } }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .65); }
#phoneForm, #cartBody { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
#checkout { display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { font-size: 20px; letter-spacing: -.01em; }
.sheet h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--hot); font-size: 13px; font-weight: 600; }
input[type=tel], input[type=text], textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px;
}
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.line {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.line .t { flex: 1; min-width: 0; }
.line .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .t small { color: var(--muted); font-variant-numeric: tabular-nums; }
.line .p { font-weight: 700; white-space: nowrap; }
.line button { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px 4px; }
.sum { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.sum b { white-space: nowrap; }
.sum small { display: block; color: var(--muted); }
.pay { display: flex; flex-direction: column; gap: 8px; }
.pay label {
  display: flex; gap: 10px; align-items: center; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.pay label:has(input:checked) { border-color: var(--gold); }
.pay input { accent-color: var(--gold); width: 18px; height: 18px; }
.bigcode {
  text-align: center; background: var(--bg); border: 1px dashed var(--gold); border-radius: 16px; padding: 14px;
}
.bigcode span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.bigcode b { font-size: 44px; font-weight: 900; color: var(--gold); letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.status { border-radius: 12px; padding: 12px 14px; background: var(--bg); font-size: 14px; border-left: 4px solid var(--gold); }
.status.paid { border-color: var(--ok); }
.status.cancelled { border-color: var(--hot); }

.toast {
  position: fixed; left: 50%; top: 112px; transform: translateX(-50%); z-index: 20;
  background: var(--ok); color: #04130c; font-weight: 700; border-radius: 12px; padding: 10px 16px;
  max-width: calc(100% - 32px); text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: chipIn .3s;
}
.toast.bad { background: var(--hot); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.ref { font-size: 12px; color: var(--muted, #8a8f9c); margin-top: -2px; }
.ref s { text-decoration-thickness: 1.5px; }
