:root {
  --green: #19e68c;
  --amber: #ffb340;
  --red: #ff5a5f;
  --gray: rgba(244, 245, 247, .32);
  --ink: #f4f5f7;
  --ink-2: rgba(244, 245, 247, .66);
  --ink-3: rgba(244, 245, 247, .42);
  --ink-4: rgba(244, 245, 247, .26);
  --line: rgba(255, 255, 255, .08);
  --panel: #0f0f11;
  --panel-2: #18181b;
  --track: rgba(255, 255, 255, .1);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: #000; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #000;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.sheet-open { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }
.num, .pct, .w-pct, .w-cd, .win-pct, .win-reset, .data-time, .cost, .kv .v { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

.statusbar-cover {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--sat);
  background: #000;
  z-index: 15;
  pointer-events: none;
}

/* ---------- 额度坞 ---------- */
.dock {
  position: relative;
  background: linear-gradient(180deg, #000 0%, #050506 70%, #0a0a0c 100%);
  border-radius: 0 0 28px 28px;
  padding: calc(var(--sat) + 4px) calc(10px + var(--sar)) 8px calc(10px + var(--sal));
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .07), 0 14px 30px -18px rgba(25, 230, 140, .12);
}
.dock-top {
  display: flex; align-items: center; gap: 2px;
  min-height: 48px;
  padding-left: 6px;
}
.dock-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.dock-title h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.data-time {
  font-size: 12.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: inline-flex; align-items: center; gap: 5px;
}
.data-time::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); flex: none;
}
.data-time.stale { color: var(--amber); }
.data-time.stale::before { background: var(--amber); }
.data-time.old::before, .data-time.none::before { background: var(--gray); }
.data-time.mock::before { background: #8e7dff; }

.icon-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.icon-btn:active { background: rgba(255, 255, 255, .1); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid rgba(25, 230, 140, .7); outline-offset: -2px; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  appearance: none; border: 0; width: calc(100% - 12px);
  margin: 0 6px 6px;
  display: flex; align-items: center; gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 12px;
  background: rgba(255, 179, 64, .12);
  color: var(--amber);
  font-size: 13px; line-height: 1.3; text-align: left;
  cursor: pointer;
}
.banner.err { background: rgba(255, 90, 95, .13); color: #ff8a8e; }
.banner .b-text { flex: 1; min-width: 0; }
.banner .b-act { flex: none; font-weight: 600; opacity: .9; }

.rings {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  row-gap: 0;
  padding: 0 0 2px;
}
.g-label {
  position: relative;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--ink-3);
  padding: 6px 6px 0 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.g-label.cont { color: var(--ink-4); }
.g-label .g-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }
.sep::before {
  content: ""; position: absolute; left: 0; width: 1px;
  background: var(--line);
}
.g-label.sep::before { top: 8px; bottom: 0; }
.ring-cell.sep::before { top: 0; bottom: 12px; }

.ring-cell {
  position: relative;
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  min-width: 0; min-height: 44px;
  padding: 5px 2px 9px;
  border-radius: 16px;
  transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.ring-cell:active { background: rgba(255, 255, 255, .07); transform: scale(.96); }
.ring-cell:focus-visible { outline: 2px solid rgba(25, 230, 140, .7); outline-offset: -2px; }
.ring-cell[aria-expanded="true"] { background: rgba(255, 255, 255, .08); }
.ring { position: relative; width: 42px; height: 42px; flex: none; }
.ring svg.r { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .trk { stroke: var(--track); }
.ring .arc { transition: stroke-dasharray .8s var(--ease); }
.ring .dash { stroke: var(--gray); }
.ring .glyph {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.ring .glyph svg { width: 18px; height: 18px; display: block; }
.ring-cell.bad .ring .glyph { opacity: .45; }
.pct {
  font-size: 14px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2;
  color: var(--ink);
}
.pct.low { color: var(--red); }
.pct.warn { color: var(--amber); }
.pct.bad { color: var(--ink-3); font-weight: 700; }
.nm {
  max-width: 100%;
  font-size: 10.5px; line-height: 1.2; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: inline-flex; align-items: center; gap: 3px;
}
.nm .act-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--green); flex: none; }

/* ---------- 列表 ---------- */
.notice:empty { display: none; }
.notice { padding: 12px calc(12px + var(--sar)) 0 calc(12px + var(--sal)); }
.list {
  padding: 12px calc(12px + var(--sar)) calc(28px + var(--sab)) calc(12px + var(--sal));
  display: flex; flex-direction: column; gap: 12px;
}
.card {
  background: var(--panel);
  border-radius: 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  overflow: hidden;
}
.g-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 8px;
}
.logo {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
}
.logo svg { width: 16px; height: 16px; display: block; }
.g-title { flex: 1; min-width: 0; }
.g-name { font-size: 15px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-name .avail { font-weight: 500; color: var(--ink-3); font-size: 13px; }
.g-name .avail.bad { color: var(--amber); }
.g-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-sub b { color: var(--ink-2); font-weight: 600; }
.g-note { margin: 0 14px 6px; font-size: 12px; color: var(--amber); }
.svc { font-size: 11px; color: var(--amber); }

.acct {
  appearance: none; border: 0; background: transparent; cursor: pointer; text-align: left;
  display: block; width: 100%;
  padding: 10px 14px 11px;
  border-top: 1px solid var(--line);
  min-height: 44px;
  transition: background-color .15s var(--ease);
}
.acct:active { background: rgba(255, 255, 255, .05); }
.acct:focus-visible { outline: 2px solid rgba(25, 230, 140, .7); outline-offset: -2px; }
.a-top { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 7px; }
.a-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.a-plan { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.a-chev { margin-left: auto; color: var(--ink-4); flex: none; width: 14px; height: 14px; }
.tag {
  flex: none;
  font-size: 10.5px; line-height: 1; font-weight: 600;
  padding: 3px 6px; border-radius: 5px;
  background: rgba(25, 230, 140, .14); color: var(--green);
}
.tag.red { background: rgba(255, 90, 95, .16); color: var(--red); }
.tag.gray { background: rgba(255, 255, 255, .08); color: var(--ink-2); }

.wins {
  display: grid;
  grid-template-columns: auto minmax(40px, 1fr) 2.9em auto;
  column-gap: 8px; row-gap: 6px;
  align-items: center;
}
.w-name { font-size: 12px; color: var(--ink-2); white-space: nowrap; max-width: 6.5em; overflow: hidden; text-overflow: ellipsis; }
.w-bar { height: 4px; border-radius: 99px; background: var(--track); overflow: hidden; }
.w-bar i, .bar i { display: block; height: 100%; border-radius: inherit; transform-origin: left; }
.w-pct { font-size: 12.5px; font-weight: 600; text-align: right; }
.w-cd { font-size: 11.5px; color: var(--ink-3); text-align: right; white-space: nowrap; }
.a-warn { margin-top: 7px; font-size: 12px; color: var(--red); }
.a-err { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: baseline; }
.a-err b { color: var(--amber); font-weight: 600; flex: none; }

.empty {
  padding: 28px 20px; text-align: center; color: var(--ink-3); font-size: 14px;
}
.empty .btn { margin-top: 14px; }
.empty-why { margin-top: 6px; font-size: 12.5px; line-height: 1.5; color: var(--ink-4); }

.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  background: var(--panel-2); color: var(--ink);
  font-size: 15px; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.btn:active { background: #222226; }
.btn.primary { background: var(--green); color: #00150b; box-shadow: none; }
.btn.primary:active { background: #14c97a; }
.btn.danger { color: #ff8a8e; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 14px; }
.btn:focus-visible { outline: 2px solid rgba(25, 230, 140, .7); outline-offset: 2px; }

.token-card { padding: 18px 16px 16px; }
.token-card h2 { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.token-card p { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.token-card code { font-family: var(--mono); font-size: 12px; color: var(--ink); background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.token-card .t-err { color: var(--red); margin: -4px 0 10px; }
.field {
  display: block; width: 100%;
  min-height: 46px; padding: 0 14px; margin-bottom: 12px;
  border-radius: 12px; border: 1px solid rgba(255, 255, 255, .12);
  background: #000; color: var(--ink);
  font-size: 16px;
  font-family: var(--mono);
}
.field:focus { outline: none; border-color: rgba(25, 230, 140, .7); }
.token-card .btn { width: 100%; }

/* ---------- 底部抽屉 ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, .6);
  opacity: 0; visibility: hidden;
  transition: opacity .25s var(--ease), visibility 0s linear .25s;
}
.backdrop.open { opacity: 1; visibility: visible; transition: opacity .25s var(--ease), visibility 0s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 560px; margin: 0 auto;
  max-height: calc(100vh - var(--sat) - 24px);
  max-height: calc(100dvh - var(--sat) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-radius: 24px 24px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 -20px 50px -10px rgba(0, 0, 0, .8);
  padding: 0 calc(20px + var(--sar)) calc(22px + var(--sab)) calc(20px + var(--sal));
  transform: translateY(105%);
  visibility: hidden;
  transition: transform .32s var(--ease), visibility 0s linear .32s;
}
.sheet.open { transform: none; visibility: visible; transition: transform .34s var(--ease), visibility 0s; }
.sheet.dragging { transition: none; }
.sheet:focus { outline: none; }
.sheet-grab {
  position: sticky; top: 0; z-index: 2;
  height: 30px; margin: 0 -20px 4px;
  background: var(--panel);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 8px;
  touch-action: none;
}
.sheet-grab > span { width: 38px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .22); }
.sheet-close {
  position: absolute; right: 8px; top: 2px;
  appearance: none; border: 0; background: transparent; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-3);
}
.sheet-close svg { width: 18px; height: 18px; display: block; }
.sheet-close:active { background: rgba(255, 255, 255, .08); }

.s-head { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding-right: 30px; }
.s-head .logo { width: 32px; height: 32px; border-radius: 9px; }
.s-head .logo svg { width: 18px; height: 18px; }
.s-tt { flex: 1; min-width: 0; }
.s-title { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 6px; min-width: 0; }
.s-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.s-upd { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-variant-numeric: tabular-nums; }

.win + .win { margin-top: 16px; }
.win-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.win-label { font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; min-width: 0; }
.win-tag { font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 4px; font-weight: 600; }
.win-pct { font-size: 14px; font-weight: 650; white-space: nowrap; }
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.win-reset { margin-top: 7px; font-size: 12px; color: var(--ink-3); }
.win-reset b { font-weight: 500; color: var(--ink-2); }
.win-pace { margin-top: 5px; font-size: 12px; color: var(--ink-2); }
.win-pace.bad { color: var(--red); }
.win-pace.good { color: var(--green); }

.hr { height: 1px; background: var(--line); margin: 18px -20px 14px; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; min-height: 26px; }
.kv + .kv { margin-top: 8px; }
.kv .k { color: var(--ink-3); flex: none; }
.kv .v { min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.kv .v.mono { font-family: var(--mono); font-size: 12.5px; }

.err-box {
  border-radius: 14px; padding: 12px 14px;
  background: rgba(255, 90, 95, .09);
  box-shadow: inset 0 0 0 1px rgba(255, 90, 95, .18);
}
.err-box h3 { margin: 0 0 4px; font-size: 14px; color: #ff8a8e; font-weight: 650; }
.err-box p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.err-box .raw { margin-top: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); word-break: break-word; }

.s-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.s-actions .btn { flex: 1; }
.rename { display: flex; gap: 8px; margin: -4px 0 16px; align-items: center; }
.rename .field { margin: 0; flex: 1; min-width: 0; font-family: var(--font); }
.hint { font-size: 12px; color: var(--ink-3); margin: -8px 0 14px; }

.switch {
  appearance: none; border: 0; cursor: pointer; flex: none;
  width: 51px; height: 31px; border-radius: 99px; padding: 2px;
  background: rgba(255, 255, 255, .16);
  position: relative;
  transition: background-color .2s var(--ease);
}
.switch::after {
  content: ""; display: block; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; transition: transform .2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid rgba(25, 230, 140, .7); outline-offset: 2px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-size: 15px; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row .sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.s-sec { font-size: 12.5px; color: var(--ink-3); font-weight: 600; margin: 16px 0 4px; }

@media (min-width: 600px) {
  .list { max-width: 640px; margin: 0 auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}
