:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #101828;
  --sub: #475467;
  --muted: #98a2b3;
  --line: #eceef2;
  --brand: #3b5bdb;
  --brand-deep: #2f49b0;
  --brand-soft: #eef2ff;
  --ok: #0e9f6e;
  --ok-soft: #e7f7f0;
  --warn: #dc6803;
  --warn-soft: #fff4e5;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px -12px rgba(16, 24, 40, .18);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  background: var(--bg);
  position: relative;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* ---------- 通用 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
  color: #fff;
  border-radius: 0 0 20px 20px;
}

.topbar.slim { padding: 12px 16px; }

.brandline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.brand small { display: block; font-size: 11px; font-weight: 400; opacity: .78; letter-spacing: .5px; margin-top: 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff; font-size: 12px; font-weight: 500;
  backdrop-filter: blur(6px);
}
.pill.solid { background: #fff; color: var(--brand); }

.search {
  margin-top: 12px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px;
  padding: 0 12px;
  height: 42px;
}
.search svg { width: 17px; height: 17px; fill: rgba(255,255,255,.8); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: #fff; font-size: 14px;
}
.search input::placeholder { color: rgba(255, 255, 255, .68); }

.chips { display: flex; gap: 8px; padding: 12px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px;
  background: #fff; color: var(--sub); font-size: 13px;
  border: 1px solid var(--line);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.list { padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 15px;
  border: 1px solid rgba(16, 24, 40, .03);
}

.mcard { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mcard:active { transform: scale(.995); }
.mcode { font-size: 16px; font-weight: 700; letter-spacing: .2px; word-break: break-all; }
.mmeta { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dotsep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); display: inline-block; }
.price { text-align: right; flex: none; }
.price b { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.price b i { font-size: 12px; font-style: normal; font-weight: 600; margin-right: 2px; }
.price span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; line-height: 18px;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.grey { background: #f2f4f7; color: var(--sub); }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14px; }
.more { margin: 12px; padding: 12px; border-radius: 12px; background: #fff; color: var(--brand); font-weight: 600; text-align: center; font-size: 14px; border: 1px solid var(--line); }
.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 详情 ---------- */
.detail-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
  color: #fff;
}
.back { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.back svg { width: 18px; height: 18px; fill: #fff; }
.detail-head h1 { font-size: 17px; margin: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hero { padding: 16px 12px 4px; }
.hero-card {
  background: linear-gradient(160deg, #ffffff 0%, #f7f9ff 100%);
  border-radius: 18px; padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(59, 91, 219, .08);
}
.hero-label { font-size: 12px; color: var(--muted); }
.hero-price { margin-top: 6px; font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.hero-price i { font-size: 16px; font-style: normal; font-weight: 700; margin-right: 3px; }
.hero-sub { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-dl { color: var(--ok); font-weight: 700; }
.hero-muted { color: var(--muted); font-size: 12px; }
.freshness.fresh { color: #19734b; }
.freshness.stale { color: #9a6500; }
.freshness.historical, .freshness.unknown { color: #a33b35; }
.price .alt { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.seg-head { margin: 12px 0 4px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.seg-head:first-child { margin-top: 4px; }

.section { margin: 14px 12px 0; }
.section-title { font-size: 14px; font-weight: 700; margin: 0 4px 8px; display: flex; align-items: center; justify-content: space-between; }
.section-title span { font-weight: 400; color: var(--muted); font-size: 12px; }

.offer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.offer:last-child { border-bottom: 0; }
.offer-name { font-size: 14px; font-weight: 600; }
.offer-meta { margin-top: 3px; font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.offer-price { text-align: right; white-space: nowrap; }
.offer-price b { font-size: 17px; font-weight: 800; }
.offer-price span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.trend { width: 100%; height: 128px; display: block; }

.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 480px; margin: 0 auto;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; gap: 10px;
}

.btn {
  flex: 1; height: 46px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 15px; font-weight: 700;
  background: var(--brand); color: #fff;
  box-shadow: 0 6px 16px -8px rgba(59, 91, 219, .7);
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid #d6ddf8; box-shadow: none; }
.btn:disabled { opacity: .55; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px 40px; background: linear-gradient(160deg, #4f46e5 0%, #2563eb 55%, #1e40af 100%); }
.login-hero { color: #fff; text-align: center; margin-bottom: 26px; }
.login-hero h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: .5px; }
.login-hero p { margin: 0; font-size: 13px; opacity: .82; line-height: 1.6; }
.login-card { background: #fff; border-radius: 20px; padding: 22px 18px; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5); }
.login-card h2 { margin: 0 0 4px; font-size: 18px; }
.login-card .sub { margin: 0 0 18px; font-size: 12px; color: var(--muted); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; font-weight: 600; }
.input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #f9fafb; padding: 0 14px; font-size: 15px; outline: none; }
.input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(59, 91, 219, .1); }
.code-row { display: flex; gap: 10px; }
.code-row .input { flex: 1; }
.send { flex: none; width: 116px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 700; border: 1px solid #dbe3ff; }
.send:disabled { color: var(--muted); background: #f2f4f7; border-color: var(--line); }
.invite-note { margin: 4px 0 14px; padding: 9px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 12px; line-height: 1.6; }
.login-btn { width: 100%; height: 48px; border-radius: 13px; margin-top: 6px; }
.login-foot { text-align: center; font-size: 11px; color: var(--muted); margin-top: 14px; line-height: 1.7; }

/* ---------- 我的 ---------- */
.me-head { padding: 22px 16px 30px; background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%); color: #fff; border-radius: 0 0 22px 22px; }
.me-name { font-size: 20px; font-weight: 700; }
.me-sub { margin-top: 4px; font-size: 12px; opacity: .8; }
.me-body { margin-top: -16px; padding: 0 12px; }

.quota { padding: 18px; }
.quota-top { display: flex; align-items: baseline; justify-content: space-between; }
.quota-num { font-size: 34px; font-weight: 800; color: var(--brand); letter-spacing: -1px; }
.quota-num small { font-size: 14px; font-weight: 600; margin-left: 3px; }
.quota-label { font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: #eef0f4; margin-top: 14px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #4f46e5, #2563eb); }

.invite-row { margin-top: 12px; padding: 16px; display: flex; align-items: center; gap: 12px; }
.invite-code { flex: 1; }
.invite-code em { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.invite-code b { font-size: 20px; letter-spacing: 2px; font-weight: 800; color: var(--brand); }

.rules { padding: 16px; font-size: 12.5px; color: var(--sub); line-height: 1.9; }
.rules h3 { margin: 0 0 6px; font-size: 13px; color: var(--ink); }
.rules ol { margin: 0; padding-left: 18px; }

.share-hero { padding: 18px; text-align: center; background: linear-gradient(160deg, #fff7ed, #fff); border: 1px solid #ffe6cc; }
.share-hero h3 { margin: 0 0 6px; font-size: 15px; }
.share-hero p { margin: 0 0 14px; font-size: 12px; color: var(--sub); line-height: 1.6; }
.share-btn { width: 100%; height: 46px; }

.logout { width: 100%; margin: 16px 0 8px; height: 44px; border-radius: 12px; background: #fff; color: var(--sub); border: 1px solid var(--line); font-size: 14px; }

/* ---------- 付费墙 ---------- */
.paywall { padding: 40px 20px; text-align: center; }
.paywall .lock { font-size: 44px; }
.paywall h2 { margin: 14px 0 8px; font-size: 20px; }
.paywall p { color: var(--sub); font-size: 13px; line-height: 1.8; margin: 0 0 20px; }
.paywall .code { font-size: 13px; color: var(--muted); margin-top: 14px; }
.paywall .code b { color: var(--brand); letter-spacing: 2px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 480px; margin: 0 auto;
  display: flex;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar[hidden] { display: none; }
.tab { flex: 1; padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; text-decoration: none; }
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab.on { color: var(--brand); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 10px);
  background: rgba(16, 24, 40, .92); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .22s ease; z-index: 90;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.skeleton { background: linear-gradient(90deg, #eef0f4 25%, #f6f7f9 37%, #eef0f4 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
