:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #18181b; --muted: #6b7280; --line: #e5e7eb;
  --brand: #2563eb; --brand-ink: #ffffff; --price: #dc2626; --ok: #16a34a; --warn: #b45309;
  --alert-bg: #fef2f2; --alert-ink: #991b1b; --notice-bg: #eff6ff; --notice-ink: #1e40af; --code-bg: #f4f4f5;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #181b21; --text: #e5e7eb; --muted: #9ca3af; --line: #2a2f38;
    --brand: #3b82f6; --price: #f87171; --alert-bg: #3b1515; --alert-ink: #fecaca;
    --notice-bg: #172554; --notice-ink: #bfdbfe; --code-bg: #23272f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.topbar nav a { margin-left: 18px; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }
main.wrap { padding-top: 24px; padding-bottom: 40px; }
.footer { color: var(--muted); font-size: 12px; padding-bottom: 32px; text-align: center; }
.page-title { font-size: 20px; margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.narrow { max-width: 460px; margin: 0 auto; padding: 24px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.product-card { display: flex; flex-direction: column; overflow: hidden; color: inherit; transition: transform .15s, box-shadow .15s; }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.cover { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: var(--code-bg); }
.cover-empty { display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; color: var(--muted); }
.cover-lg { border-radius: var(--radius); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-title { font-weight: 600; }
.card-foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; }
.price { color: var(--price); font-weight: 700; }
.price-lg { font-size: 26px; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.tag-off { color: var(--alert-ink); border-color: currentColor; }

.product { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.product-buy { padding: 20px; }
.product-title { font-size: 22px; margin: 0 0 6px; }
.price-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 16px; }
.description { margin-top: 20px; padding: 20px; }
.description h2 { font-size: 17px; margin: 0 0 8px; }
.markdown img { border-radius: 8px; }
.markdown pre, .markdown code { background: var(--code-bg); border-radius: 6px; }
.markdown pre { padding: 10px; overflow-x: auto; }

.buy-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 6px; }
input[type=email], input[type=text], input[type=number] {
  width: 100%; height: 42px; padding: 0 12px; font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; outline: none;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.qty { display: flex; width: 150px; }
.qty input { text-align: center; border-radius: 0; border-left: 0; border-right: 0; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.qty-btn { width: 42px; height: 42px; border: 1px solid var(--line); background: var(--code-bg); color: inherit; font-size: 18px; cursor: pointer; }
.qty-btn:first-child { border-radius: 8px 0 0 8px; }
.qty-btn:last-child { border-radius: 0 8px 8px 0; }
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.method input { position: absolute; opacity: 0; }
.method-box { display: block; text-align: center; padding: 10px 6px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 500; }
.method input:checked + .method-box { border-color: var(--brand); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.method input:focus-visible + .method-box { outline: 2px solid var(--brand); outline-offset: 2px; }
.total { font-size: 15px; }
.total .price { font-size: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; height: 42px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.alert { background: var(--alert-bg); color: var(--alert-ink); padding: 10px 12px; border-radius: 8px; margin: 12px 0; }
.notice { background: var(--notice-bg); color: var(--notice-ink); padding: 10px 12px; border-radius: 8px; margin: 12px 0; }

.order { max-width: 560px; margin: 0 auto; padding: 24px; }
.order-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.order-head .page-title { margin: 0; }
.status { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--code-bg); }
.status-pending { color: var(--warn); }
.status-delivered { color: var(--ok); }
.status-awaiting { color: var(--brand); }
.status-closed, .status-refunded { color: var(--muted); }
.summary { display: grid; grid-template-columns: 80px 1fr; gap: 6px 12px; margin: 18px 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }
.pay-box { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; border-top: 1px solid var(--line); padding-top: 18px; }
.qr { background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.qr svg { width: 220px; height: 220px; }
.delivery { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.delivery h2 { font-size: 16px; margin: 0 0 10px; }
.codes { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.codes li { display: flex; align-items: center; gap: 10px; background: var(--code-bg); padding: 8px 10px; border-radius: 8px; }
.codes code { flex: 1; font-size: 15px; }
.note { white-space: pre-wrap; word-break: break-all; background: var(--code-bg); padding: 10px; border-radius: 8px; margin: 0; font: inherit; }

@media (max-width: 720px) {
  .product { grid-template-columns: 1fr; }
  main.wrap { padding-top: 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .order, .narrow { padding: 18px; }
}
