:root {
  --bg: #f7f6f3; --surface: #ffffff; --fg: #1f1d1a; --muted: #77716a; --line: #e6e2dc;
  --accent: #e2531b; --accent-fg: #ffffff; --accent-soft: #fdeee6;
  --good: #1f8a5b; --tag-bg: #fff4ec; --tag-fg: #b5481a;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514; --surface: #201f1d; --fg: #eeebe6; --muted: #a29b92; --line: #34312d;
    --accent: #ff7a45; --accent-fg: #1b0d06; --accent-soft: #3a2117;
    --good: #4fc28b; --tag-bg: #33231a; --tag-fg: #ffad85;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161514; --surface: #201f1d; --fg: #eeebe6; --muted: #a29b92; --line: #34312d;
  --accent: #ff7a45; --accent-fg: #1b0d06; --accent-soft: #3a2117;
  --good: #4fc28b; --tag-bg: #33231a; --tag-fg: #ffad85;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); line-height: 1.55;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
.wrap {
  max-width: 960px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
}

.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { font-weight: 700; text-decoration: none; font-size: 17px; }
.brand::before { content: "¥"; display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; border-radius: 7px; background: var(--accent); color: var(--accent-fg); font-size: 14px; }
.nav { display: flex; gap: 16px; font-size: 14px; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover { color: var(--fg); }

.hero { padding: 40px 0 24px; }
.hero-compact { padding: 28px 0 12px; }
.hero h1 { font-size: clamp(24px, 6vw, 34px); line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.01em; }
.lead { color: var(--muted); margin: 0 0 20px; max-width: 36em; }
.message { text-align: center; padding-top: 64px; }
.message .lead { margin-left: auto; margin-right: auto; }

.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; min-width: 0; }
input, textarea {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
.searchbar button, .btn {
  font: inherit; font-size: 14px; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
}
.searchbar button, .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.searchbar button { padding: 0 20px; font-size: 16px; }
.btn:active, .searchbar button:active { transform: translateY(1px); }

.examples { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.examples a { padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--fg); }

.features { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 16px 0 40px; }
.feature { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.feature h2 { font-size: 16px; margin: 0 0 6px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }

.page-search { padding: 20px 0 8px; }
.filters { margin: 4px 0 16px; font-size: 14px; }
.filters summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.filter-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; align-items: end; }
.filter-form label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.filter-form .wide { grid-column: 1 / -1; }

.notice { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; color: var(--muted); }
.parsed { font-size: 14px; color: var(--muted); }
.parsed b { color: var(--fg); }

.summary { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.stat-main { background: var(--accent-soft); border-color: transparent; }
.stat-used { grid-column: 1 / -1; }
.stat-label { font-size: 12px; color: var(--muted); display: block; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-main .stat-value { color: var(--accent); }
.stat-note { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-note b { color: var(--good); font-size: 15px; }
.used-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-weight: 600; }
.used-row input { max-width: 180px; padding: 8px 10px; }
@media (min-width: 720px) {
  .summary { grid-template-columns: 1fr 1fr 1.2fr; }
  .stat-used { grid-column: auto; }
}

.section-title { font-size: 15px; margin: 8px 0 12px; color: var(--muted); font-weight: 600; }
.items { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.item { position: relative; min-width: 0; display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.item-img { width: 96px; height: 96px; flex: none; border-radius: 10px; object-fit: cover; background: var(--line); }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-title { font-size: 14px; font-weight: 500; margin: 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; background: var(--accent); color: var(--accent-fg); border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 1px; }
.item-shop { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; color: var(--tag-fg); background: var(--tag-bg); border-radius: 4px; padding: 0 5px; }
.item-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.price { display: flex; align-items: baseline; gap: 6px; }
.price-now { color: var(--accent); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-was { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 6px; }
.actions .btn { padding: 6px 11px; font-size: 13px; }
.alert-form { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 8px; align-items: end; margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--line); }
.alert-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.alert-form input { padding: 8px 10px; font-size: 14px; }
@media (max-width: 520px) {
  .item-img { width: 80px; height: 80px; }
  .alert-form { grid-template-columns: 1fr; }
}

.accessories { margin: 20px 0; font-size: 14px; }
.accessories summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }
.linkform { display: grid; gap: 10px; }
.linkform .btn { justify-self: start; padding: 10px 22px; font-size: 15px; }

.footer { color: var(--muted); font-size: 12px; padding-top: 32px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); z-index: 20; }

.hero-home { padding-bottom: 12px; }
.muted { color: var(--muted); font-weight: 400; }

/* 首页频道 Tab：横向滚动，吸在顶栏下面 */
.tabs { position: sticky; top: 52px; z-index: 5; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 8px 0 12px; padding: 8px 0; background: var(--bg); }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 5px 13px; border-radius: 999px; font-size: 14px; text-decoration: none; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.tab-on { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.pager { display: flex; justify-content: center; gap: 10px; margin: 20px 0; }

/* 搜索排序/筛选 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.chip { padding: 4px 12px; border-radius: 999px; font-size: 13px; text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line); }
.chip-on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chip-sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }

/* 商品卡片：整卡可点进详情，按钮浮在链接层上面 */
.item-link { position: absolute; inset: 0; border-radius: var(--radius); z-index: 1; }
.item .actions { position: relative; z-index: 2; }
.rank { position: absolute; left: 6px; top: 6px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--fg) 55%, transparent); color: var(--bg); }
.rank-top { background: var(--accent); color: var(--accent-fg); }
.badge-soft { background: var(--accent-soft); color: var(--accent); }
.rounding { font-size: 12px; color: var(--accent); }

/* 商品详情 */
.detail { padding: 16px 0 0; display: grid; gap: 12px; }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: var(--radius); }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: none; width: min(100%, 400px); aspect-ratio: 1; object-fit: cover; scroll-snap-align: start; border-radius: var(--radius); background: var(--line); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.detail-price { align-items: center; }
.detail-price .price-now { font-size: 28px; }
.card .rounding { margin: 4px 0 0; font-size: 13px; }
.detail-title { font-size: 16px; font-weight: 600; line-height: 1.45; margin: 8px 0 4px; }
.card .item-shop { margin: 0; }
.label { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.label .muted { font-size: 12px; margin-left: 6px; }
.promos { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; }
.promos ul { margin: 0; padding-left: 18px; color: var(--muted); }
.chart { margin: 0; color: var(--accent); }
.chart svg { display: block; width: 100%; height: 160px; }
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.card .alert-form { margin-top: 0; padding-top: 0; border-top: 0; }
.buy-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.buy-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.buy-btn { padding: 10px 28px; font-size: 15px; }
body:has(.buy-bar) .footer { padding-bottom: 84px; }
body:has(.buy-bar) .toast { bottom: 84px; }
.beian { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.beian a { color: var(--muted); text-decoration: none; }
