:root {
  --brand: #ff5a36;
  --brand-2: #ff2d55;
  --brand-soft: #fff1ec;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #86909c;
  --line: #eceef1;
  --price: #f53f3f;
  --ok: #00b42a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --tabbar-h: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113;
    --card: #1b1c1f;
    --text: #e8e9eb;
    --muted: #8a8f98;
    --line: #2a2c30;
    --brand-soft: #3a1f18;
    --price: #ff6b6b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  max-width: 560px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button, .tabbar a, .chip { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 15px;
}
.search {
  flex: 1; display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: 18px;
  background: var(--card); color: var(--muted); box-shadow: var(--shadow);
}
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text);
  font-size: 16px; /* 防止 iOS 聚焦缩放 */
}

/* ---------- hero ---------- */
.hero {
  margin: 4px 16px 0; padding: 18px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  border-radius: 50%; background: rgba(255, 255, 255, .12);
}
.hero-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; background: rgba(255, 255, 255, .22); font-size: 12px; }
.hero h1 { margin: 8px 0 4px; font-size: 22px; line-height: 1.3; }
.hero p { margin: 0; opacity: .92; font-size: 13px; }
.countdown { display: flex; gap: 6px; margin-top: 14px; align-items: baseline; font-size: 13px; }
.countdown b {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 6px;
  border-radius: 8px; background: rgba(0, 0, 0, .18); font-size: 18px; font-variant-numeric: tabular-nums;
}

/* ---------- chips ---------- */
.chips {
  display: flex; gap: 8px; padding: 14px 16px 2px; overflow-x: auto; scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 14px; border-radius: 16px;
  background: var(--card); color: var(--text); font-size: 14px; box-shadow: var(--shadow);
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }

/* ---------- blocks ---------- */
.block { margin: 18px 16px 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.block h2 { margin: 0; font-size: 18px; }
.more { color: var(--muted); font-size: 13px; padding: 6px 0 6px 12px; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }

/* ---------- product grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left;
  padding: 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.card:active { transform: scale(.98); }
.card-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.5px;
}
.card-name { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.price { color: var(--price); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }
.price small { font-size: 13px; margin-right: 1px; }
.price-unit { color: var(--muted); font-size: 12px; }
.original { color: var(--muted); font-size: 12px; text-decoration: line-through; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; min-height: 20px; }
.badge { padding: 1px 6px; border-radius: 4px; font-size: 11px; line-height: 18px; background: var(--brand-soft); color: var(--brand); }
.badge.low { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.hot { background: var(--brand); color: #fff; }

/* ---------- deals ---------- */
.deals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.deal { padding: 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.deal-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.src { padding: 0 6px; border-radius: 4px; color: #fff; font-size: 11px; line-height: 18px; }
.src.ithome { background: #d22222; }
.src.smzdm { background: #f04848; }
.src.manual { background: var(--brand); }
.deal-title { margin: 6px 0 0; font-size: 15px; line-height: 1.45; font-weight: 500; }
.deal-note { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.deal-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.deal-actions .price { font-size: 18px; margin-right: auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 34px; padding: 0 14px; border-radius: 17px; font-size: 14px; font-weight: 600;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text); }
.btn:active { opacity: .8; }

/* ---------- calendar ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 12px 14px 12px 34px; margin-bottom: 10px;
  border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
}
.timeline li::before {
  content: ""; position: absolute; left: 14px; top: 19px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--line);
}
.timeline li.active::before { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .name { font-weight: 600; }
.timeline .live { color: var(--brand); font-size: 12px; margin-left: 6px; }
.tips { padding: 14px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.tips h2 { font-size: 16px; }
.tips ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.tips li + li { margin-top: 6px; }

/* ---------- footer / tabbar ---------- */
.disclosure { margin: 24px 16px 0; font-size: 12px; color: var(--muted); line-height: 1.6; text-align: center; }
.tabbar {
  position: fixed; left: 50%; bottom: 0; z-index: 20; transform: translateX(-50%);
  width: 100%; max-width: 560px; display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); }
.tabbar a[aria-current="page"] { color: var(--brand); }
.tabbar svg { width: 22px; height: 22px; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .45); animation: fade .2s ease; }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 31; transform: translateX(-50%);
  width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; background: var(--card);
  animation: up .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head .logo { width: 48px; height: 48px; font-size: 20px; border-radius: 12px; }
.sheet h3 { margin: 0; font-size: 18px; }
.sheet-price { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 4px; }
.sheet-price .price { font-size: 30px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { padding: 10px; border-radius: 10px; background: var(--bg); text-align: center; }
.stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.sheet h4 { margin: 16px 0 8px; font-size: 14px; }
.channels { display: flex; flex-direction: column; gap: 8px; }
.channel {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); font-weight: 600;
}
.channel.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.channel span { font-weight: 400; font-size: 12px; opacity: .8; }
.sheet ul.tip-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.sheet .fineprint { margin-top: 14px; font-size: 12px; color: var(--muted); }
.spark { width: 100%; height: 64px; display: block; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px); z-index: 40;
  transform: translateX(-50%); max-width: 86vw; padding: 10px 16px; border-radius: 10px;
  background: rgba(0, 0, 0, .82); color: #fff; font-size: 14px; text-align: center;
}

@keyframes up { from { transform: translate(-50%, 100%); } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (hover: hover) { .card:hover, .deal:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, .08); } }
@media (max-width: 340px) { .grid { grid-template-columns: 1fr; } }
