:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --text: #1c1917;
  --muted: #6b645c;
  --line: #ddd6cc;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --official: #1d4ed8;
  --official-bg: #dbe6ff;
  --seller: #57534e;
  --seller-bg: #ebe7e1;
  --pending: #9a3412;
  --pending-bg: #ffe4c7;
  --ok: #15803d;
  --ok-bg: #d3f5df;
  --danger: #b91c1c;
  --radius: 14px;
  --tap: 56px;
  --bar-h: 76px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --card: #221f1c;
    --text: #f5f2ee;
    --muted: #a8a097;
    --line: #3a3530;
    --accent: #ff7a2e;
    --accent-ink: #1a0d04;
    --official: #93b4ff;
    --official-bg: #1c2a4d;
    --seller: #cfc8bf;
    --seller-bg: #34302b;
    --pending: #ffb27a;
    --pending-bg: #4a2a12;
    --ok: #6ee39a;
    --ok-bg: #133a22;
    --danger: #ff8a8a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 18px;
  line-height: 1.45;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 16px);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--official); word-break: break-all; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
  border-bottom: 1px solid var(--line);
}
.search-wrap { position: relative; }
#q {
  width: 100%;
  height: 60px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
  padding: 0 56px 0 18px;
  font-size: 21px;
  outline: none;
  -webkit-appearance: none; appearance: none;
}
#q:focus { border-color: var(--accent); }
#q::-webkit-search-cancel-button { display: none; }
.clear-btn {
  position: absolute; right: 6px; top: 6px;
  width: 48px; height: 48px;
  border: 0; border-radius: 12px; background: transparent;
  font-size: 22px; color: var(--muted);
}
.chips { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 2px solid var(--line);
  background: var(--card); font-size: 17px; font-weight: 600;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .7; font-weight: 500; margin-left: 4px; }
.page-title { font-size: 22px; font-weight: 800; padding: 6px 0 4px; }

/* ---------- list ---------- */
main { padding: 12px 16px 0; max-width: 760px; margin: 0 auto; }
.count { color: var(--muted); font-size: 16px; margin: 2px 2px 10px; }
.card-btn {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
}
.card-btn:active { transform: scale(.99); background: var(--seller-bg); }
.v-name { font-size: 21px; font-weight: 800; line-height: 1.3; }
.v-sub { color: var(--muted); font-size: 16px; margin-top: 2px; }
.v-quick { display: grid; grid-template-columns: 4.2em 1fr; gap: 2px 8px; margin-top: 8px; font-size: 17px; }
.v-quick dt { color: var(--muted); }
.v-quick dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; }
.empty .big-btn { margin-top: 16px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.b-official { color: var(--official); background: var(--official-bg); }
.b-seller { color: var(--seller); background: var(--seller-bg); }
.b-pending { color: var(--pending); background: var(--pending-bg); }
.b-ok { color: var(--ok); background: var(--ok-bg); }
.b-none { color: var(--muted); background: transparent; border: 1px dashed var(--line); }

/* ---------- detail ---------- */
.d-head { margin: 4px 2px 12px; }
.d-head h1 { font-size: 25px; line-height: 1.3; margin: 0; }
.d-meta { color: var(--muted); font-size: 17px; margin-top: 4px; }
.part {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.part.is-pending { border-color: var(--pending); border-width: 2px; }
.part.is-ok { border-color: var(--ok); border-width: 2px; }
.part-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.part-label { font-size: 17px; color: var(--muted); font-weight: 700; }
.part-value { font-size: 24px; font-weight: 800; margin: 6px 0 2px; overflow-wrap: anywhere; line-height: 1.3; }
.part-note { font-size: 16px; color: var(--muted); overflow-wrap: anywhere; }
.part-empty { font-size: 19px; color: var(--muted); margin: 6px 0 2px; }
.opts { margin-top: 8px; display: grid; gap: 8px; }
.opt {
  border: 2px solid var(--pending); background: var(--pending-bg); color: var(--text);
  border-radius: 12px; padding: 10px 12px; text-align: left; min-height: var(--tap);
}
.opt b { display: block; font-size: 20px; }
.opt span { font-size: 15px; color: var(--muted); }
.opt .pick { font-size: 15px; font-weight: 800; color: var(--pending); }
.share { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.share-h { font-size: 15px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.share-list { display: flex; gap: 8px; flex-wrap: wrap; }
.share-chip {
  min-height: 44px; padding: 6px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); font-size: 16px; text-align: left;
}
.row-btns { display: flex; gap: 8px; margin-top: 10px; }
.small-btn {
  flex: 1; min-height: 48px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg); font-weight: 700; font-size: 17px;
}
.small-btn.ok-on { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.section h2 { font-size: 18px; margin: 0 0 8px; color: var(--muted); }
.shared-line { font-size: 17px; padding: 6px 0; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; }
.shared-line:last-child { border-bottom: 0; }
.src-line { font-size: 15px; margin: 6px 0; }
.src-line b { color: var(--muted); }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 800; font-size: 17px; margin-bottom: 6px; }
.field .hint { font-size: 14px; color: var(--muted); font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; min-height: var(--tap);
  border-radius: 12px; border: 2px solid var(--line);
  background: var(--card); padding: 12px 14px; font-size: 19px; outline: none;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.check {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  min-height: 44px; font-size: 17px; font-weight: 600;
}
.check input { width: 26px; height: 26px; accent-color: var(--ok); }

/* ---------- buttons ---------- */
.big-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 60px;
  border-radius: var(--radius); border: 0;
  background: var(--accent); color: var(--accent-ink);
  font-size: 20px; font-weight: 800;
}
.big-btn.secondary { background: var(--card); color: var(--text); border: 2px solid var(--line); }
.big-btn.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
.stack { display: grid; gap: 12px; }
.set-group { margin-bottom: 22px; }
.set-group h2 { font-size: 18px; color: var(--muted); margin: 0 0 8px; }
.set-group p { margin: 0 0 10px; font-size: 16px; color: var(--muted); }
.stat { font-size: 17px; margin: 4px 0; }

/* ---------- bottom bar ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.bottombar button {
  flex: 1; min-height: var(--tap);
  border-radius: var(--radius); border: 2px solid var(--line);
  background: var(--card); font-size: 19px; font-weight: 800;
}
.bottombar button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bottombar button.cur { border-color: var(--text); }

/* ---------- banner / toast ---------- */
.banner {
  position: fixed; left: 16px; right: 16px; z-index: 25;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 10px);
  background: var(--official-bg); color: var(--text);
  border: 2px solid var(--official); border-radius: var(--radius);
  padding: 12px 14px; font-size: 16px;
}
.banner .row-btns { margin-top: 8px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 999px; font-size: 17px; font-weight: 700;
  max-width: calc(100% - 32px); text-align: center;
}
