/* ============================================================
   护航 · Design Tokens & Base
   Dark first, light mode via html[data-theme="light"]
   ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "Bahnschrift", "DIN Alternate", "SF Pro Display", "Roboto Mono", ui-monospace, monospace;

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  --ease: cubic-bezier(.22,.8,.24,1);
  --fast: .18s var(--ease);
  --normal: .28s var(--ease);

  --max-mobile: 430px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #05091a;
  --bg-2: #070d20;
  --surface: #0c142b;
  --surface-2: #101b36;
  --surface-3: #162344;
  --surface-glass: rgba(14, 24, 48, .72);

  --line: rgba(255, 255, 255, .075);
  --line-strong: rgba(255, 255, 255, .14);

  --text: #f4f7ff;
  --text-2: #9aa8c7;
  --text-3: #647392;
  --text-inverse: #08101f;

  --primary: #2f6bff;
  --primary-2: #5b8cff;
  --primary-3: #1b4fd8;
  --primary-soft: rgba(47, 107, 255, .16);
  --primary-glow: rgba(47, 107, 255, .38);

  --price: #ff5c63;
  --gold: #f7b955;
  --green: #34d399;
  --red: #ff5c63;
  --orange: #ff9f43;

  --shadow: 0 20px 48px rgba(0, 0, 0, .48);
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, .28);
  --shadow-glow: 0 10px 30px rgba(47, 107, 255, .35);

  --sheet: #0a1226;
  --tabbar: rgba(7, 13, 32, .9);
  --input: rgba(255, 255, 255, .05);
  --skeleton-a: #101a34;
  --skeleton-b: #172444;
  --scrim: rgba(2, 6, 18, .72);

  --hero-overlay: linear-gradient(180deg, rgba(5,9,26,0) 0%, rgba(5,9,26,.55) 58%, #05091a 100%);
}

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f2f5fb;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f6fc;
  --surface-3: #e9eef9;
  --surface-glass: rgba(255, 255, 255, .82);

  --line: #e6ebf5;
  --line-strong: #d6deee;

  --text: #0a1224;
  --text-2: #5d6b87;
  --text-3: #8e9bb3;
  --text-inverse: #ffffff;

  --primary: #0b5cff;
  --primary-2: #3d82ff;
  --primary-3: #0a4bd6;
  --primary-soft: #e9f0ff;
  --primary-glow: rgba(11, 92, 255, .22);

  --price: #f04438;
  --gold: #c98a12;
  --green: #0e9f6e;
  --red: #e5484d;
  --orange: #e8862e;

  --shadow: 0 20px 44px rgba(15, 23, 42, .12);
  --shadow-sm: 0 8px 22px rgba(15, 23, 42, .07);
  --shadow-glow: 0 10px 26px rgba(11, 92, 255, .22);

  --sheet: #ffffff;
  --tabbar: rgba(255, 255, 255, .92);
  --input: #f3f6fc;
  --skeleton-a: #eef2f9;
  --skeleton-b: #dfe6f3;
  --scrim: rgba(12, 20, 38, .42);

  --hero-overlay: linear-gradient(180deg, rgba(5,9,26,0) 0%, rgba(5,9,26,.35) 60%, rgba(5,9,26,.75) 100%);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; width: 100%; height: 100%; object-fit: cover; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--primary); color: #fff; }

/* ---------- utilities ---------- */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.between { display: flex; align-items: center; justify-content: space-between; }
.center { display: flex; align-items: center; justify-content: center; }
.grow { flex: 1; min-width: 0; }
.gap4 { gap: 4px; } .gap6 { gap: 6px; } .gap8 { gap: 8px; }
.gap10 { gap: 10px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt4 { margin-top: 4px; } .mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; }
.mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.dim { color: var(--text-2); }
.dim3 { color: var(--text-3); }
.tiny { font-size: 11px; line-height: 1.5; }
.small { font-size: 12px; line-height: 1.55; }
.muted { color: var(--text-2); }
.strong { font-weight: 600; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hide { display: none !important; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- icon ---------- */
.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------- theme switch ---------- */
.theme-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); background: var(--input);
  border: 1px solid var(--line);
  transition: var(--fast);
}
.theme-btn:hover { color: var(--text); border-color: var(--line-strong); }
.theme-btn .ico { width: 17px; height: 17px; }

/* ---------- shared controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 48px; padding: 0 20px; border-radius: var(--r-md);
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
  transition: transform var(--fast), box-shadow var(--fast), opacity var(--fast);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .38; pointer-events: none; }
.btn.block { width: 100%; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 12px; }
.btn.xs { height: 30px; padding: 0 12px; font-size: 12px; border-radius: 9px; }
.btn.grad {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  box-shadow: var(--shadow-glow);
}
.btn.ghost { background: var(--input); color: var(--text); border: 1px solid var(--line); }
.btn.line { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: var(--red); box-shadow: 0 10px 26px rgba(229,72,77,.28); }
.btn.white { background: #fff; color: #0b1220; }
.btn.grow { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 13px; border-radius: var(--r-pill);
  background: var(--input); border: 1px solid transparent;
  color: var(--text-2); font-size: 12.5px; white-space: nowrap;
  transition: var(--fast);
}
.chip.on {
  color: var(--primary); background: var(--primary-soft);
  border-color: rgba(47, 107, 255, .35); font-weight: 600;
}
html[data-theme="light"] .chip.on { border-color: rgba(11,92,255,.24); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 7px; border-radius: 6px;
  font-size: 10.5px; font-weight: 600; line-height: 1;
  background: var(--input); color: var(--text-2); white-space: nowrap;
}
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.tag.gold { background: rgba(247,185,85,.14); color: var(--gold); }
.tag.green { background: rgba(52,211,153,.14); color: var(--green); }
.tag.red { background: rgba(255,92,99,.14); color: var(--red); }
.tag.gray { background: var(--input); color: var(--text-2); }

.price { color: var(--price); font-weight: 700; font-variant-numeric: tabular-nums; }
.price small { font-size: 10px; font-weight: 500; margin-left: 1px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px;
  box-shadow: var(--shadow-sm);
}
.card.flat { box-shadow: none; }
.card.pad0 { padding: 0; overflow: hidden; }

.avatar {
  display: inline-block; vertical-align: middle;
  border-radius: 50%; overflow: hidden; background: var(--surface-2);
  flex: none; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .dot {
  position: absolute; right: 1px; bottom: 1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--green); border: 2px solid var(--surface);
}

.field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 50px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: 0; }
.field .k { font-size: 13px; color: var(--text-2); flex: none; }
.field .v { font-size: 13.5px; color: var(--text); text-align: right; }
.field input, .field select {
  border: 0; background: transparent; text-align: right; outline: none;
  font-size: 13.5px; color: var(--text); max-width: 60%;
}

.input {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--input); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text); outline: none;
  transition: var(--fast); font-size: 14px;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.input::placeholder { color: var(--text-3); }
textarea.input { height: 92px; padding: 12px 14px; resize: none; line-height: 1.6; }
.label { font-size: 12px; color: var(--text-2); margin-bottom: 7px; display: block; }

.seg {
  display: flex; padding: 3px; gap: 2px;
  background: var(--input); border-radius: 12px;
}
.seg button {
  flex: 1; height: 32px; border-radius: 9px; font-size: 12.5px;
  color: var(--text-2); transition: var(--fast);
}
.seg button.on {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.progress { height: 6px; border-radius: 99px; background: var(--input); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary-2), var(--primary)); }

.empty {
  padding: 46px 16px; text-align: center; color: var(--text-3);
}
.empty .eic {
  width: 74px; height: 74px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--input); display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.empty .eic .ico { width: 30px; height: 30px; }
.empty b { display: block; font-size: 13.5px; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }

.skeleton {
  background: linear-gradient(90deg, var(--skeleton-a), var(--skeleton-b), var(--skeleton-a));
  background-size: 200% 100%; animation: sk 1.2s infinite;
  border-radius: 8px;
}
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- toast ---------- */
.toast-wrap {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 9000; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(10, 16, 32, .92); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 12.5px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  animation: tin .22s var(--ease);
  max-width: 300px; text-align: center;
}
html[data-theme="light"] .toast {
  background: rgba(10, 22, 40, .92); color: #fff;
}
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */
.scrim {
  position: fixed; inset: 0; background: var(--scrim);
  backdrop-filter: blur(3px); z-index: 8000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 330px; background: var(--sheet);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 20px 18px; box-shadow: var(--shadow);
  animation: pop .24s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }
.modal h3 { font-size: 17px; font-weight: 700; text-align: center; }
.modal p { font-size: 13px; color: var(--text-2); text-align: center; margin-top: 8px; line-height: 1.6; }
.modal .acts { display: flex; gap: 10px; margin-top: 18px; }
.modal .acts .btn { flex: 1; height: 44px; font-size: 14px; }

/* ---------- bottom sheet ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: var(--scrim); z-index: 8100;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  width: 100%; max-width: var(--max-mobile); max-height: 88%;
  background: var(--sheet); border-radius: 26px 26px 0 0;
  box-shadow: 0 -20px 50px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  animation: up .3s var(--ease); overflow: hidden;
}
@keyframes up { from { transform: translateY(100%); } }
.sheet-hd {
  padding: 18px 20px 12px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); flex: none;
}
.sheet-hd b { font-size: 16px; }
.sheet-hd .sub { font-size: 11px; color: var(--text-2); margin-top: 3px; }
.sheet-bd { padding: 16px 20px 20px; overflow-y: auto; }
.sheet-ft { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: none; }
.grabber { width: 36px; height: 4px; border-radius: 99px; background: var(--line-strong); margin: 8px auto 0; }

/* ---------- switch ---------- */
.switch {
  width: 46px; height: 27px; border-radius: 99px; background: var(--input);
  border: 1px solid var(--line); position: relative; transition: var(--fast); flex: none;
}
.switch::after {
  content: ""; position: absolute; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: var(--fast);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.switch.on { background: var(--primary); border-color: var(--primary); }
.switch.on::after { left: 21px; }

/* ---------- misc ---------- */
.copy-line {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--input); border-radius: 10px; font-family: var(--mono);
  font-size: 12px; color: var(--text-2); border: 1px dashed var(--line-strong);
}
.hr { height: 1px; background: var(--line); }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); display: inline-block; }
.notice {
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px;
  border-radius: 12px; background: var(--primary-soft); color: var(--primary);
  font-size: 11.5px; line-height: 1.6;
}
.notice.warn { background: rgba(247,185,85,.12); color: var(--gold); }
.notice.danger { background: rgba(255,92,99,.12); color: var(--red); }
.notice .ico { width: 14px; height: 14px; margin-top: 2px; }
