/* 设计 token —— 亮/暗跟随系统 */
:root {
  --bg: #FFFFFF; --bg-subtle: #F5F5F7; --surface: #FFFFFF; --border: #D9D9DE;
  --text: #1D1D1F; --text-2: #6E6E73; --text-3: #A1A1A6;
  --primary: #2563EB; --primary-hover: #1D4ED8; --primary-fg: #FFFFFF;
  --success: #16A34A; --warning: #C2410C; --danger: #DC2626; --focus: #2563EB;
  --shadow-card: 0 1px 2px rgba(0,0,0,.06); --shadow-sheet: 0 -8px 32px rgba(0,0,0,.12);
  --r-input: 10px; --r-card: 14px; --r-sheet: 20px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0B0F; --bg-subtle: #16161A; --surface: #1C1C21; --border: #2E2E35;
    --text: #F2F2F5; --text-2: #9A9AA3; --text-3: #6B6B74;
    --primary: #4F8BFF; --primary-hover: #6B9DFF; --primary-fg: #0B0B0F;
    --success: #34C759; --warning: #FF9F0A; --danger: #FF453A; --focus: #4F8BFF;
    --shadow-card: none; --shadow-sheet: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100dvh;
  font: 15px/22px -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* 布局 */
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 24px; } }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--border); }
.topbar .wrap { height: 52px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; color: var(--text); }
.brand img { width: 26px; height: 26px; }
.nav-orders { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; color: var(--text); font-size: 15px; }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--primary); color: var(--primary-fg);
  font-size: 12px; line-height: 18px; text-align: center; font-weight: 600; }

/* 首屏 */
.hero { padding: 28px 0 8px; }
.hero h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.01em; }
.hero p { margin: 8px 0 0; color: var(--text-2); }
.trust { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 560px) { .trust { grid-template-columns: repeat(4, 1fr); } }
.trust li { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-subtle);
  border-radius: 12px; font-size: 13px; line-height: 18px; color: var(--text-2); }
.trust img { width: 18px; height: 18px; flex: none; }

/* 区块 */
.section { margin-top: 28px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 12px; font-size: 17px; line-height: 24px; font-weight: 600; }
.section-title small { font-weight: 400; font-size: 13px; color: var(--text-2); }

/* 卡片 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px; }
.products { display: grid; gap: 12px; }
@media (min-width: 768px) { .products { grid-template-columns: 1fr 1fr; } }
.product { display: flex; flex-direction: column; gap: 10px; }
.product-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.product h3 { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
.desc { margin: 0; color: var(--text-2); font-size: 13px; line-height: 18px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.desc.open { -webkit-line-clamp: unset; display: block; }
.more { background: none; border: 0; padding: 0; color: var(--primary); font-size: 13px; cursor: pointer; align-self: flex-start; min-height: 24px; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; }
.price { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; }
.price small { font-size: 13px; color: var(--text-2); font-weight: 400; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-2); }

/* 徽章 */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.badge.success { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }
.badge.warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent); }
.badge.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.badge.muted { color: var(--text-2); background: var(--bg-subtle); }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 20px; border-radius: var(--r-input);
  border: 1px solid transparent; font-size: 17px; font-weight: 600; cursor: pointer; transition: transform .08s, background .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent; text-align: center; }
@media (pointer: fine) { .btn { height: 44px; } }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost { background: none; color: var(--primary); padding: 0 8px; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 表单 */
.field { margin-top: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; line-height: 18px; color: var(--text-2); }
.field label .opt { color: var(--text-3); }
.input, .select { width: 100%; height: 48px; padding: 0 14px; border-radius: var(--r-input); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px; -webkit-appearance: none; appearance: none; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.input.err { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.err-msg { margin-top: 6px; font-size: 13px; line-height: 18px; color: var(--danger); }
.help { margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--text-3); }
.contact-row { display: grid; grid-template-columns: 112px 1fr; gap: 8px; }
.select { padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-input); overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--bg-subtle); font-size: 20px; cursor: pointer; }
.stepper button[disabled] { opacity: .4; cursor: default; }
.stepper input { width: 56px; height: 44px; border: 0; text-align: center; font-size: 16px; background: var(--surface); color: var(--text); }

/* 付款方式 */
.pays { display: grid; gap: 8px; }
.pay-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; min-height: 56px; }
.pay-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pay-opt img { width: 28px; height: 28px; flex: none; }
.pay-opt b { display: block; font-size: 15px; line-height: 20px; font-weight: 600; }
.pay-opt span { display: block; font-size: 12px; line-height: 16px; color: var(--text-2); }
.pay-opt .tick { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.field label.pay-opt { display: flex; margin: 0; font-size: 15px; line-height: 20px; color: var(--text); }
.pay-opt.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.pay-opt.on .tick { border-color: var(--primary); background: radial-gradient(circle, var(--primary) 45%, transparent 50%); }
.secure { display: flex; gap: 6px; align-items: center; margin-top: 10px; font-size: 12px; line-height: 16px; color: var(--text-2); }
.secure img { width: 14px; height: 14px; }

/* Bottom sheet */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .24s; }
.scrim.on { opacity: 1; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-sheet);
  transform: translateY(100%); transition: transform .24s cubic-bezier(.2,.8,.2,1); }
@media (prefers-color-scheme: dark) { .sheet { border-top: 1px solid var(--border); } }
.sheet.on { transform: none; }
@media (min-width: 768px) {
  .sheet { left: auto; top: 0; width: 440px; max-height: none; border-radius: 0; transform: translateX(100%); }
  .sheet.on { transform: none; }
}
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 0; flex: none; }
@media (min-width: 768px) { .sheet-handle { display: none; } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 16px 0; flex: none; }
.sheet-head h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.sheet-head .price { font-size: 15px; color: var(--text-2); font-weight: 400; }
.x { width: 44px; height: 44px; margin: -8px -10px 0 0; border: 0; background: none; font-size: 24px; color: var(--text-2); cursor: pointer; flex: none; }
.sheet-body { padding: 0 16px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex: none; background: var(--surface); }
.banner { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 18px;
  background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.banner.info { background: var(--bg-subtle); color: var(--text-2); }
body.lock { overflow: hidden; }

/* 最近订单横滑 */
.hscroll { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.hscroll::-webkit-scrollbar { display: none; }
.mini { flex: 0 0 200px; scroll-snap-align: start; display: block; color: var(--text); padding: 12px 14px; }
.mini b { display: block; font-size: 15px; line-height: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .meta { margin-top: 6px; }

/* FAQ */
.faq details { border-bottom: 1px solid var(--border); }
.faq summary { list-style: none; cursor: pointer; padding: 14px 28px 14px 0; position: relative; font-size: 15px; line-height: 22px; min-height: 44px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; position: absolute; right: 6px; top: 20px; width: 8px; height: 8px; border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(-135deg); top: 24px; }
.faq p { margin: 0 0 14px; color: var(--text-2); font-size: 14px; line-height: 21px; }

/* 联系方式 */
.contacts { display: grid; gap: 8px; }
.contact { display: flex; align-items: center; gap: 10px; }
.contact img { width: 20px; height: 20px; }
.contact .v { flex: 1; font-family: var(--mono); font-size: 14px; word-break: break-all; }
.footer { margin: 40px 0 0; padding: 20px 0 calc(28px + env(safe-area-inset-bottom)); color: var(--text-3); font-size: 12px; line-height: 18px; border-top: 1px solid var(--border); }

/* 空状态 / 骨架 */
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty img { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .6; }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--bg-subtle) 0%, color-mix(in srgb, var(--bg-subtle) 60%, var(--surface)) 50%, var(--bg-subtle) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 132px; border-radius: var(--r-card); }
.skel-line { height: 14px; margin-top: 10px; }

/* Toast */
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); opacity: 0;
  background: rgba(29,29,31,.92); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 86vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 订单页 */
.status-head { padding: 28px 0 4px; text-align: center; }
.status-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 12%, transparent); }
.status-icon img { width: 28px; height: 28px; }
.status-icon.success { background: color-mix(in srgb, var(--success) 14%, transparent); }
.status-icon.warning { background: color-mix(in srgb, var(--warning) 14%, transparent); }
.status-icon.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.status-icon.muted { background: var(--bg-subtle); }
.status-head h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 600; }
.status-head p { margin: 8px auto 0; max-width: 440px; color: var(--text-2); }
.fade { animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.amount { text-align: center; font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; }
.qr { width: 252px; margin: 16px auto 0; padding: 16px; background: #fff; border-radius: 16px; border: 1px solid #E5E5EA; }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; }
.steps { margin: 16px auto 0; max-width: 360px; color: var(--text-2); font-size: 14px; line-height: 21px; text-align: center; }
.center { text-align: center; }
.stack { display: grid; gap: 10px; margin-top: 16px; }
.guide { background: var(--bg-subtle); border-radius: 12px; padding: 14px; font-size: 14px; line-height: 21px; }
.guide b { display: block; margin-bottom: 4px; }
.keys-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.key { display: flex; align-items: center; gap: 8px; padding: 10px 6px 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; background: var(--bg-subtle); }
.key code { flex: 1; font-family: var(--mono); font-size: 15px; line-height: 22px; word-break: break-all; white-space: pre-wrap; user-select: all; -webkit-user-select: all; }
.icon-btn { width: 44px; height: 44px; flex: none; border: 0; background: none; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn img { width: 20px; height: 20px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; line-height: 20px; margin: 12px 0 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; word-break: break-all; }
.summary-toggle { display: flex; justify-content: space-between; width: 100%; background: none; border: 0; padding: 0; font-size: 15px; font-weight: 600; cursor: pointer; min-height: 32px; }
.arrow-hint { position: fixed; top: 6px; right: 14px; z-index: 70; color: #fff; background: rgba(0,0,0,.75); padding: 8px 12px; border-radius: 10px; font-size: 13px;
  animation: hint 3.4s forwards; }
.arrow-hint::before { content: ""; position: absolute; top: -6px; right: 14px; border: 6px solid transparent; border-top: 0; border-bottom-color: rgba(0,0,0,.75); }
@keyframes hint { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.check-anim { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .3s .1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .check-anim { stroke-dashoffset: 0; }
}
.card, .section { scroll-margin-top: 64px; }
.products > .empty { grid-column: 1 / -1; }
