:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #15181d;
  --muted: #69707d;
  --line: #e3e6eb;
  --accent: #2f6fde;
  --accent-soft: #e6eefc;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --warn: #b26a00;
  --warn-soft: #fdf1dc;
  --danger: #c93a32;
  --danger-soft: #fbe6e4;
  --radius: 14px;
  --btn: #2f6fde;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
/* 深色：跟随系统，或手动选择（data-theme） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #20242c;
    --text: #e9ecf1;
    --muted: #8d95a3;
    --line: #2a2f38;
    --accent: #6b9cff;
    --accent-soft: #1d2a45;
    --ok: #4cc27f;
    --ok-soft: #16301f;
    --warn: #f0a83a;
    --warn-soft: #33270f;
    --danger: #ff7a70;
    --danger-soft: #3a1c1a;
    --btn: #2f5fc4;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #181b21;
  --surface-2: #20242c;
  --text: #e9ecf1;
  --muted: #8d95a3;
  --line: #2a2f38;
  --accent: #6b9cff;
  --accent-soft: #1d2a45;
  --ok: #4cc27f;
  --ok-soft: #16301f;
  --warn: #f0a83a;
  --warn-soft: #33270f;
  --danger: #ff7a70;
  --danger-soft: #3a1c1a;
  --btn: #2f5fc4;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS 输入框小于 16px 会在聚焦时放大页面 */
input, select, textarea { font-size: 16px !important; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: .2px; }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px 24px; }
.topbar #topAction { display: flex; gap: 8px; }
.topbar .right { display: flex; gap: 8px; align-items: center; }
.iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--muted); padding: 0; }
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 2px 0; }
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.tabbar a.on svg { stroke-width: 2.1; }

.section-title { font-size: 13px; color: var(--muted); margin: 18px 4px 8px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.list { overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:active { background: var(--surface-2); }
.row .main { flex: 1; min-width: 0; }
a.row { color: inherit; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; flex-shrink: 0; }
.row .big { font-weight: 700; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--text) 22%, transparent); }

.bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar > i.pend { background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 4px, color-mix(in srgb, var(--accent) 55%, transparent) 4px, color-mix(in srgb, var(--accent) 55%, transparent) 8px); }
.bar.done > i { background: var(--ok); }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.stat { padding: 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--muted); display: block; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--btn); border-color: var(--btn); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 8px 12px; min-height: 38px; font-size: 13.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--btn); border-color: var(--btn); color: #fff; }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; white-space: nowrap; border: 0; background: transparent; padding: 7px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { font-size: 18px; margin: 0 0 2px; }
.sheet .sub { color: var(--muted); font-size: 13px; }

.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 10px 0; white-space: pre-line; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.howto { font-size: 14px; margin: 10px 0 0; }

.cardhead { padding: 16px; color: #fff; border-radius: var(--radius); position: relative; overflow: hidden; }
.cardhead .nm { font-size: 20px; font-weight: 700; }
.cardhead .pd { opacity: .85; font-size: 13px; }
.cardhead .meta { display: flex; gap: 18px; margin-top: 14px; font-size: 13px; }
.cardhead .meta b { display: block; font-size: 16px; }
.guide-link { display: inline-block; margin-top: 12px; padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, .18); color: #fff; font-size: 13px; font-weight: 600; }

.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.kv tr:first-child td { border-top: 0; }
.kv td:first-child { color: var(--muted); width: 34%; font-weight: 600; }

.hist { font-size: 13px; }
.hist .row { cursor: default; padding: 8px 0; }
.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; z-index: 30; font-size: 14px; max-width: 90vw; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 12px; }
details summary { cursor: pointer; }
.login { max-width: 360px; margin: 18vh auto 0; padding: 24px; }
pre.preview { white-space: pre-wrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 12px; margin: 0; }
.tmarks { position: relative; height: 18px; font-size: 11px; color: var(--muted); }
.tmarks span { position: absolute; transform: translateX(-100%); white-space: nowrap; }

/* ---------- 通用补充 ---------- */
.pad { padding: 14px; }
.pad0 { padding: 12px 14px 0; }
.center { text-align: center; }
.wrap { white-space: normal !important; }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.danger { color: var(--danger); }
.accent { color: var(--accent); }
.neg { color: var(--danger); }
.red { color: var(--danger); }
.amber { color: var(--warn); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 12px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font: 12px ui-monospace, Menlo, monospace; }
.section-title a { font-weight: 600; }
summary.section-title { display: list-item; }
.statline { margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.statline b { font-size: 17px; }
.linkrow { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; margin: 10px 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; }
.chiplink { display: inline-block; margin: 6px 6px 0 0; padding: 7px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip.sm { padding: 5px 11px; font-size: 13px; white-space: nowrap; }
.search input { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none; margin: 4px 0 10px; font-size: 15px; }
.search input:focus { border-color: var(--accent); }
.warnbtn { border-color: var(--warn); color: var(--warn); }

/* 卡面缩略图 */
.thumb { width: 40px; height: 25px; border-radius: 4px; object-fit: cover; flex-shrink: 0; display: inline-block; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent); }
.row .amt { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.row .amt b { font-weight: 700; }
.row .amt small { font-size: 12px; color: var(--muted); }

/* 待办 */
.hero { padding: 16px; margin-top: 4px; }
.hero .k { font-size: 13px; color: var(--muted); }
.hero .big { font-size: 30px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; line-height: 1.2; margin: 2px 0 4px; }
.hero .s { font-size: 13px; color: var(--muted); }
.bucket { display: flex; justify-content: space-between; padding: 7px 14px; background: var(--surface-2); font-size: 12.5px; font-weight: 700; color: var(--muted); border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.bucket:first-child { border-top: 0; }
.list .bucket + .row { border-top: 0; }
.task .box { width: 18px; height: 18px; border: 1.8px solid var(--muted); border-radius: 5px; flex-shrink: 0; }
.task .box.ghost { border-style: dashed; }
details.inner > summary { list-style: none; border-top: 1px solid var(--line); }
details.inner > summary::-webkit-details-marker { display: none; }
.bar.thick { height: 7px; border-radius: 4px; position: relative; overflow: visible; }
.bar.thick > i { border-radius: 4px; }
.bar em { position: absolute; top: -2px; width: 2px; height: 11px; background: var(--muted); opacity: .5; }

/* 钱包 */
.wallet { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .wallet { grid-template-columns: 1fr 1fr; } }
.wcard { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; box-shadow: var(--shadow); }
.wcard .art { display: block; width: 34%; max-width: 150px; flex-shrink: 0; aspect-ratio: 1.586; object-fit: cover; border-radius: 7px; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.wstrip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.wstrip .main { flex: 1; min-width: 0; }
.wstrip .t { font-weight: 700; font-size: 15.5px; }
.wstrip .s { font-size: 12.5px; color: var(--muted); }
.ring { --a: 0; --b: 0; width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: conic-gradient(var(--ok) calc(var(--a) * 1%), color-mix(in srgb, var(--ok) 35%, var(--surface-2)) 0 calc(var(--b) * 1%), var(--surface-2) 0); }
.ring.full > span { color: var(--ok); }
.ring > span { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* 卡片详情 */
.cardtop { display: grid; grid-template-columns: minmax(0, 46%) 1fr; gap: 14px; align-items: center; margin-top: 4px; }
.cardtop .art { width: 100%; aspect-ratio: 1.586; object-fit: cover; border-radius: 12px; display: block; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.cardtop .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.cardtop .stats span { display: block; font-size: 12px; color: var(--muted); }
.cardtop .stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
.valuebar { margin-top: 14px; }
.bar.two > i { position: absolute; left: 0; top: 0; }
.bar.two > i.hand { background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.decision { margin-top: 12px; border-color: var(--warn); }
.decision .t { font-weight: 700; margin-bottom: 4px; }
.decision .s { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.valuebar .s { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* 刷哪张 */
.scenes { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.scenes::-webkit-scrollbar { display: none; }
.scene { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; padding: 8px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.scene span { font-size: 19px; line-height: 1.1; }
.scene.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.seg.small { margin: 0 0 10px; }
.seg.small button { padding: 8px 5px; font-size: 13.5px; }
.seg.sticky { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 4; margin: 12px 0 4px; }
.pickrow { display: flex; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: flex-start; }
.pickrow:first-child { border-top: 0; }
.pickrow .thumb { margin-top: 2px; }
.pickrow .main { flex: 1; min-width: 0; }
.pickrow .t { font-weight: 700; }
.pickrow .s { font-size: 13px; color: var(--muted); margin-top: 1px; }
.pickrow .s b { color: var(--text); }
.pickrow.best { background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.pickrow[data-act] { cursor: pointer; }
.perk { font-size: 12.5px; color: var(--muted); margin-top: 3px; padding-left: 10px; position: relative; }
.perk::before { content: ""; position: absolute; left: 0; top: 8px; width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.empty.small { padding: 24px 0; font-size: 14px; }

/* 权益库 */
.libgrid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .libgrid { grid-template-columns: 1fr 1fr; } }
.libcard { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; }
.libcard .art { width: 84px; aspect-ratio: 1.586; object-fit: cover; border-radius: 6px; flex-shrink: 0; display: block; }
.libcard .t { font-weight: 700; }
.libcard .s { font-size: 13px; color: var(--muted); }
.libhead { display: flex; gap: 14px; align-items: center; margin-top: 4px; }
.libhead .art { width: 42%; max-width: 220px; aspect-ratio: 1.586; object-fit: cover; border-radius: 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.libhead .t { font-weight: 700; font-size: 17px; }
.libhead .s { font-size: 13px; color: var(--muted); }
.row.lib .small { margin-top: 4px; }
.map { height: 62vh; min-height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); } }
:root[data-theme="dark"] .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
.txn { display: grid; gap: 8px; }
.txn .seg.small { margin: 0; }
.amount { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; background: var(--surface-2); }
.amount span { font-size: 20px; font-weight: 700; color: var(--muted); }
.amount input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 22px !important; font-weight: 700; padding: 6px 0; font-variant-numeric: tabular-nums; }
.pickrow .val { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.pickrow .val b { font-size: 16px; }
.pickrow .val small { font-size: 11.5px; color: var(--muted); }
.tablewrap { overflow-x: auto; }
table.matrix { border-collapse: collapse; font-size: 12.5px; min-width: 620px; width: 100%; }
table.matrix th, table.matrix td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
table.matrix thead th { border-top: 0; color: var(--muted); font-weight: 700; font-size: 12px; white-space: nowrap; }
table.matrix tbody th { white-space: nowrap; font-weight: 700; position: sticky; left: 0; background: var(--surface); }
table.matrix tbody th .thumb { width: 30px; height: 19px; vertical-align: middle; margin-right: 6px; }
.offline { max-width: 720px; margin: 0 auto 6px; padding: 8px 12px; font-size: 13px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; }
@media (min-width: 900px) { .offline { max-width: 980px; } }
.kindchip { display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); }
.wrapchips { flex-wrap: wrap; overflow: visible; }
.spendrow em { font-style: normal; color: var(--muted); font-weight: 400; }
.trig { align-items: end; }

@media (min-width: 900px) {
  main { max-width: 980px; }
  .sheet { max-width: 620px; border-radius: 18px; bottom: 24px; }
}
