:root {
  color-scheme: light dark;
  --bg: #f5f6f3;
  --card: #ffffff;
  --text: #1c211e;
  --muted: #5f6a64;
  --line: #dde1dc;
  --accent: #14663f;
  --accent-text: #ffffff;
  --save: #b3361e;
  --coles: #c8102e;
  --woolworths: #137a3e;
  --warn-bg: #fff3d6;
  --warn-text: #6d4a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141815;
    --card: #1f2521;
    --text: #edf0ec;
    --muted: #a3ada7;
    --line: #333b36;
    --accent: #3fb57a;
    --accent-text: #08130d;
    --save: #ff8f73;
    --coles: #ff7b8c;
    --woolworths: #5fd08f;
    --warn-bg: #3b3013;
    --warn-text: #f4d58a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
.top { padding: 14px 16px 6px; }
h1 { margin: 0; font-size: 22px; font-weight: 600; }
h2 { font-size: 18px; margin: 20px 0 4px; font-weight: 600; }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); font-weight: 500; }
main { max-width: 640px; margin: 0 auto; padding: 4px 16px 16px; }
.host-link { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 8px; background: var(--card); font-size: 14px; }
body:not(.on-home) .host-link { display: none; }
.host-link span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.host-link a { color: var(--accent); font-weight: 600; }
.host-link button { min-height: 36px; padding: 0 14px; }
.notice {margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }
.muted, .footnote { color: var(--muted); font-size: 14px; }
.footnote { margin-top: 20px; }
.empty { color: var(--muted); text-align: center; padding: 40px 12px; }
button { font: inherit; min-height: 44px; border-radius: 8px; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* 搜索栏贴在屏幕顶部，往下滚动也一直在。 */
.search-bar { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 6px 16px; border-bottom: 1px solid var(--line); }
.search-form { display: flex; gap: 8px; padding: 4px 0; max-width: 640px; margin: 0 auto; }
.search-form input { flex: 1; min-width: 0; min-height: 44px; font: inherit; padding: 4px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.search-form button { padding: 0 16px; flex: none; }
.compare-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare-price { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.compare-price.cheapest { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.compare-price .price { display: block; }
.half-tag { color: var(--save); font-size: 12px; font-weight: 600; margin-left: 4px; }
.similar-tag { align-self: start; justify-self: start; padding: 1px 8px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-text); font-size: 12px; font-weight: 600; }
.offer-name { display: block; font-size: 14px; line-height: 1.3; margin-top: 2px; overflow-wrap: anywhere; }
.unit-price { display: block; color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 0 14px; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.cards { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.store { font-weight: 600; }
.store.coles { color: var(--coles); }
.store.woolworths { color: var(--woolworths); }
.save { color: var(--save); font-weight: 600; }
.name { overflow-wrap: anywhere; }
.size { color: var(--muted); font-size: 14px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.price { font-size: 20px; font-weight: 600; }
.was { color: var(--muted); font-size: 14px; text-decoration: line-through; margin-left: 6px; }
.other { color: var(--muted); font-size: 14px; }
.other.better { color: var(--save); font-weight: 500; }
.primary, .add { background: var(--accent); color: var(--accent-text); border: 0; font-weight: 500; }
.add { padding: 0 16px; white-space: nowrap; }
.add.added { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.wide { width: 100%; margin-top: 10px; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 44px; background: transparent; color: var(--text); border: 1px solid var(--line); }
.qty span { min-width: 28px; text-align: center; }
.settings { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 12px; }
.settings summary { cursor: pointer; font-weight: 500; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.settings input { width: 88px; min-height: 40px; font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }
.summary { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 8px; }
.summary:empty { display: none; }
.summary strong { display: block; font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.summary p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.stop-total { color: var(--muted); font-size: 14px; margin: 0 0 4px; }
.check-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.check-row .grow { flex: 1; min-width: 0; }
.check-row .line-price { font-weight: 600; white-space: nowrap; }
.check-row .unknown { color: var(--warn-text); font-size: 13px; font-weight: 500; white-space: nowrap; }
.check-row.done .grow, .check-row.done .line-price { text-decoration: line-through; color: var(--muted); }
.tabs { position: fixed; inset: auto 0 0 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 2; }
.tab { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); text-decoration: none; font-size: 13px; }
.tab-icon { font-size: 18px; line-height: 1; }
.tab { position: relative; }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 8px); }
.tab.active { color: var(--accent); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }
.title-row { display: flex; align-items: center; gap: 4px; }
h1 a { color: inherit; text-decoration: none; }
.icon-button { min-width: 44px; min-height: 44px; margin-left: -10px; background: transparent; border: 0; color: var(--text); font-size: 22px; }
.view-title { margin: 8px 0; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 76px; padding: 8px 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; text-align: center; }
.tile:first-child { border-color: var(--accent); }
.tile-icon { font-size: 26px; line-height: 1; }
.menu-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 0 4px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.menu-row.accent { color: var(--accent); font-weight: 600; }
.menu-count { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.chevron { font-size: 22px; line-height: 1; }
.toggle { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 0 12px; margin: 6px 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.crumb { margin: 6px 0; color: var(--muted); font-size: 14px; }
.crumb a { color: var(--accent); }
.sort-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 4px 0; }
.sort { min-height: 44px; padding: 0 8px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
a.name { color: var(--text); text-decoration: none; font-weight: 500; }
a.name:active, a.name:hover { text-decoration: underline; }
.foot-text { display: flex; flex-direction: column; gap: 2px; }
.more-link { color: var(--accent); font-size: 14px; }
.chart { width: 100%; height: auto; display: block; margin: 6px 0; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke-width: 2; }
.chart .line.coles { stroke: var(--coles); stroke-dasharray: 6 4; }
.chart .line.woolworths { stroke: var(--woolworths); }
.legend { display: flex; gap: 14px; font-size: 13px; }
.stats-list { display: grid; gap: 8px; margin-top: 8px; }
.stats { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.stats.coles { border-left: 4px solid var(--coles); border-radius: 0 8px 8px 0; }
.stats.woolworths { border-left: 4px solid var(--woolworths); border-radius: 0 8px 8px 0; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin: 4px 0; }
.stats-grid small { display: block; color: var(--muted); font-size: 12px; }
.stats-grid strong { font-size: 17px; font-weight: 600; }
.stats .muted { margin: 0; font-size: 12px; }
.hint { margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }
.feedback-card { margin-top: 16px; border-color: var(--accent); }
.feedback-form { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.field textarea, .field input { font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); resize: vertical; }
.compare-price.missing { border-style: dashed; }
.compare-price.missing .muted { display: block; margin-top: 4px; }
.link-button { display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 44px; border-radius: 8px; text-decoration: none; }
a.secondary.link-button { color: var(--text); }
.raw-line { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.import-edit { display: flex; gap: 8px; }
.import-edit input { flex: 1; min-width: 0; min-height: 44px; font: inherit; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.import-edit button { flex: none; padding: 0 12px; }
.import-options { display: grid; gap: 6px; }
.import-option { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.import-option.chosen { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.import-option input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.import-option .grow { flex: 1; min-width: 0; display: grid; gap: 2px; }
#view-import .field textarea { min-height: 180px; }
.foot-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.watch-button { min-width: 44px; padding: 0 10px; background: transparent; border: 1px solid var(--line); color: var(--text); font-size: 15px; }
.watch-button.on { border-color: var(--accent); background: var(--card); }
.card > .watch-button { width: 100%; }
.watch-banner { display: block; margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); font-weight: 500; text-decoration: none; }
.drop-line { color: var(--save); font-weight: 500; font-size: 15px; }
.watch-section .card-foot { justify-content: flex-end; gap: 8px; }
.watch-section .card-foot button { padding: 0 14px; }
.badge.alert { background: var(--save); }
.store-links { display: grid; gap: 6px; }
.store-link { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 500; }
.store-link::after { content: "↗"; margin-left: 6px; }
.store-link.coles { color: var(--coles); }
.store-link.woolworths { color: var(--woolworths); }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.card-title { flex: 1; min-width: 0; display: grid; gap: 2px; }
/* 商品图多是白底，深色模式下也保留白底，免得透明背景的图看不清。 */
.thumb { width: 64px; height: 64px; flex: none; object-fit: contain; border-radius: 8px; background: #fff; }
.thumb.small { width: 44px; height: 44px; }
.compare-price .thumb.small { display: block; margin: 4px 0; }
.check-row .thumb.small { margin-top: -2px; }
.detail-images { display: flex; justify-content: center; gap: 12px; }
.detail-image { width: min(60%, 220px); aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: #fff; }
.detail-images .detail-image + .detail-image { width: min(45%, 180px); }
.form-error { margin: 0; color: var(--save); font-size: 14px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: 12px; line-height: 20px; }

/* 语言切换按钮：标题右边。 */
.lang-switch { margin-left: auto; min-height: 36px; padding: 0 12px; background: var(--card); color: var(--text); border: 1px solid var(--line); font-size: 14px; }

/* 电脑宽屏：内容放宽，卡片多列，分类格子一行，详情页左右两栏。手机排版不变。 */
@media (min-width: 900px) {
  .top, main { max-width: 1200px; margin-left: auto; margin-right: auto; }
  .top { padding: 18px 24px 6px; }
  main { padding: 4px 24px 24px; }
  .tiles { grid-template-columns: repeat(9, minmax(0, 1fr)); }
  .cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; gap: 12px; }
  #view-menu, #view-route, #view-me, #cart-actions { max-width: 760px; margin-left: auto; margin-right: auto; }
  #view-product:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
  #view-product > .card:first-child { position: sticky; top: 12px; }
  .search-bar { padding: 8px 24px; }
  .search-form { max-width: 1152px; }
  #search-results > .half-toggle, #view-browse .half-toggle { max-width: 760px; }
  .tabs { justify-content: center; }
  .tab { flex: 0 1 200px; }
}
