/* Warna mengikuti tema Telegram pembeli (terang/gelap), dengan cadangan untuk browser biasa. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #14151a);
  --hint: var(--tg-theme-hint-color, #8a8d96);
  --accent: var(--tg-theme-button-color, #2f7cf6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2f7cf6);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --ok: #1fa45a;
  --warn: #e08a00;
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --radius: 16px;
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #0f1013; --card: #1b1c21; --text: #f2f3f5; --hint: #8c8f99;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#view { padding: 16px 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
#app.no-tabs #view { padding-bottom: 110px; }

/* ---------- header ---------- */
.store-head { display: flex; align-items: center; gap: 12px; margin: 4px 2px 16px; }
.store-logo {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #8b5cf6));
}
.store-head h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.store-head p { margin: 1px 0 0; color: var(--hint); font-size: 13px; }

.search {
  display: flex; align-items: center; gap: 8px; background: var(--card);
  border-radius: 12px; padding: 0 12px; height: 42px; margin-bottom: 14px;
}
.search svg { width: 18px; height: 18px; color: var(--hint); flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: inherit; min-width: 0; }
.search input::placeholder { color: var(--hint); }

.trust { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.trust span {
  flex: none; font-size: 12px; color: var(--hint); background: var(--card);
  padding: 6px 10px; border-radius: 99px; display: inline-flex; gap: 5px; align-items: center;
}
.trust svg { width: 14px; height: 14px; color: var(--accent); }

.section-title { font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; margin: 0 4px 10px; }

/* ---------- produk ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; text-align: left;
  display: flex; flex-direction: column; transition: transform .12s;
}
.card:active { transform: scale(.97); }
.card.soldout { opacity: .55; }
.thumb { aspect-ratio: 4 / 3; position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .art {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 34px; font-weight: 800; color: rgba(255,255,255,.95); letter-spacing: -.02em;
}
.thumb .tag {
  position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 99px; background: rgba(0,0,0,.45); color: #fff; backdrop-filter: blur(6px);
}
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .name { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .price { font-weight: 700; color: var(--accent); margin-top: auto; }
.card .meta { font-size: 12px; color: var(--hint); }

.empty { text-align: center; padding: 56px 24px; color: var(--hint); }
.empty .icon { font-size: 44px; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 0 0 4px; font-size: 17px; }

/* ---------- detail ---------- */
.hero { border-radius: 20px; overflow: hidden; margin: -4px 0 16px; }
.hero .thumb { aspect-ratio: 16 / 10; }
.hero .art { font-size: 56px; }
.detail h2 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.01em; }
.detail .price-lg { font-size: 26px; font-weight: 800; color: var(--accent); margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { font-size: 12px; padding: 5px 10px; border-radius: 99px; background: var(--card); color: var(--hint); display: inline-flex; gap: 5px; align-items: center; }
.chip svg { width: 14px; height: 14px; }
.chip.ok { color: var(--ok); } .chip.bad { color: var(--danger); }
.panel { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.panel h4 { margin: 0 0 6px; font-size: 13px; color: var(--hint); font-weight: 600; }
.panel p { margin: 0; white-space: pre-wrap; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.steps b { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--soft); color: var(--accent); font-size: 12px; display: grid; place-items: center; }

/* ---------- checkout ---------- */
.status {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 99px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn);
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
.checkout { text-align: center; }
.checkout .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--hint); font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.timer svg { width: 16px; height: 16px; }
.timer.low { color: var(--danger); }
.qr-card { background: #fff; border-radius: 20px; padding: 18px 18px 14px; margin: 0 auto 14px; max-width: 320px; box-shadow: 0 10px 30px -18px rgba(0,0,0,.4); }
.qr-card .brand { display: flex; justify-content: space-between; align-items: center; color: #111; font-weight: 800; font-size: 13px; letter-spacing: .08em; margin-bottom: 8px; }
.qr-card .brand small { font-weight: 600; color: #888; letter-spacing: 0; font-size: 11px; }
.qr-card img { width: 100%; aspect-ratio: 1; display: block; image-rendering: pixelated; }
.qr-card .merchant { color: #666; font-size: 12px; margin-top: 6px; }
.amount-label { color: var(--hint); font-size: 13px; }
.amount { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 4px; }
.amount .uniq { color: var(--accent); }
.copy { color: var(--link); font-size: 13px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.copy svg { width: 16px; height: 16px; }
.note {
  font-size: 13px; text-align: left; background: color-mix(in srgb, var(--warn) 12%, transparent);
  color: var(--text); border-radius: 12px; padding: 10px 12px; margin: 12px 0; display: flex; gap: 8px;
}
.note svg { width: 18px; height: 18px; color: var(--warn); flex: none; margin-top: 1px; }
.rows { text-align: left; }
.rows div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.rows div + div { border-top: 1px solid var(--line); }
.rows span:first-child { color: var(--hint); }
.btn {
  width: 100%; height: 48px; border-radius: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-text);
}
.btn.secondary { background: var(--card); color: var(--link); }
.btn.ghost { background: none; color: var(--danger); height: 40px; }
.btn svg { width: 18px; height: 18px; }
.stack { display: grid; gap: 8px; margin-top: 12px; }

/* ---------- sukses ---------- */
.success { text-align: center; padding-top: 12px; }
.check {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 50%; background: var(--ok); color: #fff;
  display: grid; place-items: center; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
.check svg { width: 44px; height: 44px; stroke-width: 2.6; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .4s .25s forwards; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.success h2 { margin: 0 0 4px; font-size: 22px; }
.success > p { color: var(--hint); margin: 0 0 20px; }
.deliver { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: left; margin-bottom: 12px; }
.deliver h4 { margin: 0 0 10px; font-size: 13px; color: var(--hint); }
.code {
  font: 600 15px/1.4 ui-monospace, "SF Mono", Menlo, monospace; background: var(--bg); border: 1px dashed var(--line);
  border-radius: 10px; padding: 12px; word-break: break-all; margin-bottom: 10px; user-select: all;
}

/* ---------- daftar pesanan ---------- */
.olist { display: grid; gap: 10px; }
.orow { background: var(--card); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; }
.orow .ico { width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center; }
.orow .ico svg { width: 20px; height: 20px; }
.orow .ico.paid { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.orow .ico.pending { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.orow .ico.expired { background: var(--line); color: var(--hint); }
.orow .mid { flex: 1; min-width: 0; }
.orow .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orow .s { font-size: 12px; color: var(--hint); }
.orow .r { text-align: right; font-weight: 600; font-size: 14px; }
.orow .r small { display: block; font-weight: 500; font-size: 11px; }
.r .paid { color: var(--ok); } .r .pending { color: var(--warn); } .r .expired { color: var(--hint); }

/* ---------- navigasi bawah ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--card);
  border-top: 1px solid var(--line); z-index: 10;
}
#app.no-tabs .tabs { display: none; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--hint); position: relative; }
.tab.active { color: var(--accent); }
.tab .badge { position: absolute; top: 9px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--danger); color: #fff; font: 700 10px/16px sans-serif; font-style: normal; text-align: center; padding: 0 4px; }

.fallback-cta { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); z-index: 11; }
.fallback-cta button { width: 100%; max-width: 528px; margin: 0 auto; display: block; height: 50px; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 16px; }
.fallback-cta button:disabled { opacity: .6; }

.back { display: inline-flex; align-items: center; gap: 2px; color: var(--link); font-weight: 600; margin: 0 0 12px -4px; }
.back svg { width: 20px; height: 20px; }
.tg .back { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 20; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.skeleton { background: linear-gradient(90deg, var(--card) 25%, color-mix(in srgb, var(--hint) 12%, var(--card)) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.fade { animation: fade .22s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .check svg { stroke-dashoffset: 0; } }

/* ---------- jumlah beli ---------- */
.card .price .unit { font-size: 11px; font-weight: 600; color: var(--hint); margin-left: 6px; }
.detail .price-lg small { font-size: 14px; font-weight: 600; color: var(--hint); }
.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qty-row h4 { margin: 0 0 2px; }
.qty-row small { color: var(--hint); font-size: 12px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex: none; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--soft); color: var(--accent); font-size: 20px; font-weight: 600; cursor: pointer; }
.stepper button:active { opacity: .6; }
.stepper input { width: 56px; height: 40px; border: 0; outline: 0; text-align: center; font: inherit; font-weight: 700; font-size: 16px; background: none; color: var(--text); }
.qty-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.qty-quick button { border: 1px solid var(--line); background: none; color: var(--text); border-radius: 99px; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.qty-quick button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.qty-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.qty-total span { color: var(--hint); font-size: 14px; }
.qty-total span.bad { color: var(--danger); }
.qty-total b { font-size: 18px; color: var(--accent); }
.code.multi { white-space: pre-wrap; max-height: 260px; overflow: auto; }

/* ---------- item email + link ---------- */
.items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 420px; overflow: auto; }
.item { background: var(--bg); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.item-text { all: unset; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; font: 600 14px/1.35 ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); word-break: break-all; }
.item-text svg { width: 15px; height: 15px; color: var(--hint); flex: none; }
.item-link { all: unset; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; color: var(--link); font-size: 14px; font-weight: 600; }
.item-link svg { width: 15px; height: 15px; }
.note-box { text-align: left; font-size: 14px; }
