:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* 基础与表面配色 (深空暗黑科技蓝紫) */
  --bg: #070a13;
  --bg-gradient: radial-gradient(circle at 50% -20%, rgba(99, 102, 241, 0.15), transparent 70%),
                 radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.08), transparent 50%),
                 #070a13;
  --surface: #0f172a;
  --surface-hover: #1e293b;
  --surface-active: #334155;
  --surface-card: #0d121f;

  --ink-0: #08090d;
  --ink-1: #0e1117;
  --ink-2: #151922;
  --ink-3: #1c212c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  --text-1: #f4f1ea;
  --text-2: #c3bdb1;
  --text-3: #918a7d;

  /* 品牌与状态色 */
  --gold: #d9b45b;
  --gold-fill: #d9b45b;
  --gold-on-fill: #17130a;
  --gold-text: #d9b45b;
  --gold-dim: #a8863f;
  --gold-soft: rgba(217, 180, 91, 0.13);
  --gold-ink: #17130a;

  --jade: #46c98b;
  --jade-soft: rgba(70, 201, 139, 0.13);
  --jade-ink: #06210f;

  --cinnabar: #ef6f6c;
  --cinnabar-soft: rgba(239, 111, 108, 0.13);
  --cinnabar-ink: #2a0808;

  --amber: #f5b544;
  --amber-soft: rgba(245, 158, 11, 0.10);
  --amber-line: rgba(245, 158, 11, 0.28);
  --amber-text: #f3c98b;

  --danger-text: #ffb3b1;
  --marked: #7a5c1e;

  --tabbar-bg: #0a0c11;
  --toast-bg: #232a38;
  --toast-border: rgba(255, 255, 255, 0.14);
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --qr-plate: #ffffff;
  --card-shadow: none;

  /* 边框与微发光 */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(165, 180, 252, 0.3);
  --border-glow: rgba(99, 102, 241, 0.4);

  /* 科技主题色系 */
  --accent: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-glow: rgba(99, 102, 241, 0.25);

  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.15);
  --green-border: rgba(16, 185, 129, 0.35);

  --hub-sidebar-width: 290px;
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.15);
  --red-border: rgba(239, 68, 68, 0.35);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.15);

  /* 布局与尺寸 */
  --header-h: 56px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-xl: 20px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "LXGW WenKai", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-main: var(--font);
  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* 宣纸暖白：不用纯白，长时间阅读不刺眼 */
[data-theme="light"] {
  color-scheme: light;

  --bg: #faf9f6;
  --bg-gradient: none;
  --surface: #ffffff;
  --surface-hover: #f2f0eb;
  --surface-active: #e8e5de;
  --surface-card: #ffffff;

  --ink-0: #faf9f6;
  --ink-1: #ffffff;
  --ink-2: #f2f0eb;
  --ink-3: #e8e5de;
  --line: rgba(24, 20, 12, 0.10);
  --line-strong: rgba(24, 20, 12, 0.18);

  --text-1: #1c1a16;
  --text-2: #4a463d;
  --text-3: #6b6559;

  /* 白底上的文字金按 WCAG AA 加深；填充金保持明亮，避免大面积发闷 */
  --gold: #8f6414;
  --gold-fill: #d9b45b;
  --gold-on-fill: #2a2110;
  --gold-text: #8f6414;
  --gold-dim: #7a5410;
  --gold-soft: rgba(184, 134, 42, 0.10);
  --gold-ink: #fffdf7;

  --jade: #1f6b46;
  --jade-soft: rgba(31, 107, 70, 0.10);
  --jade-ink: #ffffff;

  --cinnabar: #a3352f;
  --cinnabar-soft: rgba(163, 53, 47, 0.09);
  --cinnabar-ink: #ffffff;

  --amber: #b4741a;
  --amber-soft: rgba(180, 116, 26, 0.08);
  --amber-line: rgba(180, 116, 26, 0.25);
  --amber-text: #8a5a12;

  --danger-text: #a3352f;
  --marked: #a67c1f;

  --tabbar-bg: #ffffff;
  --toast-bg: #2a2620;
  --toast-border: rgba(0, 0, 0, 0.08);
  --overlay-bg: rgba(24, 20, 12, 0.35);
  --qr-plate: #ffffff;
  --card-shadow: 0 1px 2px rgba(24, 20, 12, 0.04);

  --border: rgba(24, 20, 12, 0.10);
  --border-hover: rgba(166, 124, 31, 0.35);
  --border-glow: rgba(166, 124, 31, 0.35);

  --accent: #4f46e5;
  --accent-purple: #7c3aed;
  --accent-cyan: #0891b2;
  --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --accent-glow: rgba(79, 70, 229, 0.18);

  --green: #0f766e;
  --green-bg: rgba(15, 118, 110, 0.10);
  --green-border: rgba(15, 118, 110, 0.30);

  --red: #b91c1c;
  --red-bg: rgba(185, 28, 28, 0.08);
  --red-border: rgba(185, 28, 28, 0.25);
  --yellow: #a16207;
  --yellow-bg: rgba(161, 98, 7, 0.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--ink-0); color: var(--text-1);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { overflow: hidden; }
#app { height: 100dvh; max-width: 430px; margin: 0 auto; position: relative; overflow: hidden; background: var(--ink-0); }
.stage { position: absolute; inset: 0; }
button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
a { color: var(--gold); text-decoration: none; }
.nums { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- shell ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--ink-0);
  animation: fade 200ms var(--ease);
}
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.screen-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px 24px; }
.screen-body.no-tab { padding-bottom: calc(24px + var(--safe-b)); }
.screen-body.with-tab { padding-bottom: calc(84px + var(--safe-b)); }

.appbar {
  position: relative; z-index: 5;
  height: 52px; flex: 0 0 52px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px; padding-top: var(--safe-t);
  background: var(--ink-0);
  border-bottom: 1px solid var(--line);
}
.appbar-title { font-size: 16px; font-weight: 600; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.iconbtn {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center; border-radius: 12px;
  color: var(--text-2); transition: background 160ms var(--ease), color 160ms var(--ease);
}
.iconbtn:active { background: var(--ink-2); color: var(--text-1); }
.iconbtn svg { width: 21px; height: 21px; }
.spacer { flex: 1; }

/* ---------- tabbar ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(58px + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; align-items: stretch;
  background: var(--tabbar-bg);
  border-top: 1px solid var(--line);
  backdrop-filter: none;
  z-index: 30;
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); font-size: 10.5px; letter-spacing: 0.02em;
  transition: color 160ms var(--ease);
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--gold); }
.tabbar button:active { opacity: 0.7; }

/* ---------- typography ---------- */
.h1 { font-size: 26px; line-height: 1.3; font-weight: 700; letter-spacing: 0.01em; margin: 0; }
.h2 { font-size: 18px; line-height: 1.4; font-weight: 600; margin: 0; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12px; line-height: 1.6; }
.tiny { font-size: 11px; line-height: 1.5; }
.gold { color: var(--gold); }
.jade { color: var(--jade); }
.cinnabar { color: var(--cinnabar); }

/* ---------- cards ---------- */
.card {
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--card-shadow);
}
.card + .card { margin-top: 12px; }
.card-flat { background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 24px 0 10px; font-size: 13px; letter-spacing: 0.06em; color: var(--text-3);
}
.section-title:first-child { margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 20px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
  transition: transform 120ms var(--ease), background 160ms var(--ease), opacity 160ms var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--gold-fill); color: var(--gold-on-fill); }
.btn-primary:disabled { opacity: 0.45; }
.btn-ghost { background: var(--ink-2); color: var(--text-1); border: 1px solid var(--line); }
.btn-outline { border: 1px solid var(--gold-dim); color: var(--gold); background: transparent; }
.btn-block { width: 100%; }
.btn-sm { height: 38px; font-size: 13px; padding: 0 14px; border-radius: 9px; }
.btn-danger { color: var(--cinnabar); border: 1px solid rgba(239, 111, 108, 0.35); }

/* ---------- inputs ---------- */
.field { margin-top: 14px; }
.label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; display: block; }
.input {
  width: 100%; height: 50px; padding: 0 14px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text-1); font-size: 16px; outline: none;
  transition: border-color 160ms var(--ease);
}
.input:focus { border-color: var(--gold-dim); }
.input::placeholder { color: var(--text-3); }
.hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.6; }
.error-text { color: var(--cinnabar); font-size: 13px; margin-top: 8px; }

/* ---------- pills / tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; letter-spacing: 0.02em;
  background: var(--ink-2); color: var(--text-1); border: 1px solid var(--line);
}
.pill.gold { background: var(--gold-soft); color: var(--gold-text); border-color: var(--border-hover); }
.pill.jade { background: var(--jade-soft); color: var(--jade); border-color: var(--green-border); }
.pill.red { background: var(--cinnabar-soft); color: var(--cinnabar); border-color: var(--red-border); }
.pill.sm { height: 20px; font-size: 10px; padding: 0 7px; }

/* ---------- progress ---------- */
.bar { height: 3px; border-radius: 3px; background: var(--ink-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 3px; transition: width 240ms var(--ease); }

/* ---------- list rows ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.chev { color: var(--text-3); width: 18px; height: 18px; flex: 0 0 18px; }

/* ---------- sheets & modals ---------- */
.overlay {
  position: absolute; inset: 0; background: var(--overlay-bg);
  opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease); z-index: 40;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 86dvh; display: flex; flex-direction: column;
  background: var(--ink-1); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--line-strong);
  transform: translateY(102%); transition: transform 240ms var(--ease);
  padding-bottom: var(--safe-b);
}
.sheet.show { transform: none; }
.sheet-grip { width: 36px; height: 4px; border-radius: 4px; background: var(--ink-3); margin: 10px auto 4px; flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 18px 12px; }
.sheet-title { font-size: 16px; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 0 18px 18px; }

/* ---------- toast ---------- */
.toast-wrap {
  position: absolute; left: 0; right: 0; bottom: calc(96px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 60; pointer-events: none;
}
.toast {
  max-width: 88%; padding: 10px 16px; border-radius: 999px;
  background: var(--toast-bg); color: #f4f1ea; font-size: 13px; /* toast stays dark on both themes */
  border: 1px solid var(--toast-border);
  animation: toastIn 200ms var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- skeleton ---------- */
.skel { background: linear-gradient(90deg, var(--ink-2) 0%, var(--ink-3) 50%, var(--ink-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.center { display: flex; align-items: center; justify-content: center; }
.stack > * + * { margin-top: 12px; }
.hstack { display: flex; align-items: center; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.empty-title { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
.fade-in { animation: fade 220ms var(--ease); }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
