:root {
  --bg: #0b0b0f;
  --bg-elev: #14141a;
  --bg-card: #1a1a22;
  --bg-card-hover: #22222c;
  --border: #2a2a36;
  --text: #f4f4f7;
  --muted: #9a9aad;
  --accent: #7ee787;
  --accent-dim: rgba(126, 231, 135, 0.15);
  --danger: #ff7b72;
  --warn: #e3b341;
  --wechat: #07c160;
  --alipay: #1677ff;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2430 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

code {
  font-size: 0.85em;
  background: var(--bg-elev);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* —— Topbar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(11, 11, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(126, 231, 135, 0.35);
}

.pill.muted {
  background: var(--bg-elev);
  color: var(--muted);
  border-color: var(--border);
}

/* —— Hero —— */
.hero {
  padding: 28px 16px 8px;
  max-width: 960px;
  margin: 0 auto;
}

.hero-kicker {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h2 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* —— Product grid —— */
.products {
  padding: 16px 16px 48px;
  max-width: 960px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 520px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 860px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: #3a3a4a;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-emoji {
  font-size: 2.4rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.in {
  background: var(--accent-dim);
  color: var(--accent);
}

.badge.low {
  background: rgba(227, 179, 65, 0.18);
  color: var(--warn);
}

.badge.out {
  background: rgba(255, 123, 114, 0.15);
  color: var(--danger);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.card-desc {
  margin: 0 0 14px;
  flex: 1;
  font-size: 0.85rem;
  color: var(--muted);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.price small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 2px;
}

.btn-buy {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--text);
  color: #111;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-buy:hover {
  opacity: 0.92;
}

.btn-buy:active {
  transform: scale(0.97);
}

.btn-buy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* —— Footer —— */
.site-footer {
  text-align: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

/* —— Modals —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: min(92dvh, 720px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + var(--safe-b));
  box-shadow: var(--shadow);
  animation: slide-up 0.22s ease-out;
}

@media (min-width: 560px) {
  .modal {
    align-items: center;
    padding: 16px;
  }

  .modal-sheet {
    border-radius: 20px;
    padding-bottom: 20px;
  }
}

@keyframes slide-up {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.order-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-right: 36px;
}

.order-emoji {
  font-size: 2.5rem;
  line-height: 1;
}

.order-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.order-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.field,
.field-row {
  margin-bottom: 14px;
}

.field label,
.field-row label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.field input:focus {
  outline: 2px solid rgba(126, 231, 135, 0.45);
  outline-offset: 1px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qty-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
}

.qty-ctrl button {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}

.qty-ctrl button:hover {
  background: var(--bg-card-hover);
}

.qty-ctrl input {
  width: 48px;
  height: 40px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: center;
  font: inherit;
  font-weight: 700;
  -moz-appearance: textfield;
}

.qty-ctrl input::-webkit-outer-spin-button,
.qty-ctrl input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.order-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 8px 0 16px;
  padding: 12px 0;
  border-top: 1px dashed var(--border);
  font-size: 0.95rem;
  color: var(--muted);
}

.order-total strong {
  font-size: 1.5rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.btn-primary {
  width: 100%;
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, #8af0a0, #5ad87a);
  color: #0a1a0c;
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-ghost {
  width: 100%;
  margin-top: 12px;
  appearance: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

/* —— Pay sheet —— */
.pay-sheet h3 {
  margin: 0 0 8px;
  padding-right: 36px;
}

.pay-summary {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.pay-note {
  margin: 0 0 16px;
  font-size: 0.78rem;
  color: var(--warn);
}

.qr-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.qr-card {
  margin: 0;
  padding: 12px 10px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-align: center;
}

.qr-card figcaption {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.qr-card.wechat figcaption {
  color: var(--wechat);
}

.qr-card.alipay figcaption {
  color: var(--alipay);
}

.qr-card img {
  margin: 0 auto;
  width: 100%;
  max-width: 140px;
  height: auto;
  border-radius: 8px;
  background: #fff;
}

.pay-hint {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}


.field-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  margin-bottom: 0;
}

.field .req {
  color: var(--danger);
  font-weight: 600;
  font-size: 0.72rem;
  margin-left: 4px;
}

.form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 123, 114, 0.12);
  border: 1px solid rgba(255, 123, 114, 0.35);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

@media (max-width: 400px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}


/* —— One-tap pay —— */
.pay-amount {
  margin: 4px 0 10px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
  text-align: center;
}

.pay-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 16px;
}

.btn-pay {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 14px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
  color: #fff;
  letter-spacing: 0.02em;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-pay:active {
  transform: scale(0.99);
}

.btn-pay.alipay {
  background: linear-gradient(135deg, #3d8dff, #1677ff);
  box-shadow: 0 8px 20px rgba(22, 119, 255, 0.28);
}

.btn-pay.wechat {
  background: linear-gradient(135deg, #2ad37a, #07c160);
  box-shadow: 0 8px 20px rgba(7, 193, 96, 0.28);
}

.btn-pay.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.qr-fallback {
  margin: 0 0 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  padding: 0 12px 12px;
}

.qr-fallback summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.qr-fallback summary::-webkit-details-marker {
  display: none;
}

.qr-fallback[open] summary {
  color: var(--text);
  border-bottom: 1px dashed var(--border);
  margin-bottom: 12px;
}

.qr-fallback .qr-pair {
  margin-top: 4px;
}
