/* API 余额查询：整页只有余额滚轮这一处醒目，其余保持安静。 */

@font-face {
  font-family: "Readout";
  src: url("/assets/barlow-condensed-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Readout";
  src: url("/assets/barlow-condensed-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #e6ebef;
  --surface: #f6f8fa;
  --ink: #16202a;
  --ink-2: #3f4c58;
  --muted: #687480;
  --line: #c6cfd7;
  --line-strong: #a9b5c0;
  --bezel: #27323d;
  --bezel-edge: #141c23;
  --drum-dark: #0f161c;
  --drum: #2f3c48;
  --numeral: #f3f5f7;
  --frac-dark: #5e110c;
  --frac: #c22d21;
  --good: #2b7a4c;
  --warn: #9c5708;
  --bad: #b42318;
  --focus: #2b6cd4;
  --bar: #8795a2;
  --bar-today: #27323d;
  --emboss: rgba(255, 255, 255, 0.7);
  --drop: rgba(22, 32, 42, 0.5);

  --text: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  --digits: "Readout", "Barlow Condensed", "DIN Condensed", "Arial Narrow", var(--text);
  --drum-size: clamp(44px, 12.5vw, 74px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10151a;
    --surface: #171e26;
    --ink: #e3e8ed;
    --ink-2: #b5c0ca;
    --muted: #8a96a2;
    --line: #2a3540;
    --line-strong: #3b4855;
    --bezel: #080c10;
    --bezel-edge: #000000;
    --drum-dark: #06090c;
    --drum: #222d37;
    --numeral: #e9edf0;
    --frac-dark: #4a0d09;
    --frac: #ad281d;
    --good: #5fb684;
    --warn: #d99a45;
    --bad: #ec6a5e;
    --focus: #6aa0f5;
    --bar: #4f5d6a;
    --bar-today: #c9d2da;
    --emboss: rgba(255, 255, 255, 0.05);
    --drop: rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --paper: #10151a;
  --surface: #171e26;
  --ink: #e3e8ed;
  --ink-2: #b5c0ca;
  --muted: #8a96a2;
  --line: #2a3540;
  --line-strong: #3b4855;
  --bezel: #080c10;
  --bezel-edge: #000000;
  --drum-dark: #06090c;
  --drum: #222d37;
  --numeral: #e9edf0;
  --frac-dark: #4a0d09;
  --frac: #ad281d;
  --good: #5fb684;
  --warn: #d99a45;
  --bad: #ec6a5e;
  --focus: #6aa0f5;
  --bar: #4f5d6a;
  --bar-today: #c9d2da;
  --emboss: rgba(255, 255, 255, 0.05);
  --drop: rgba(0, 0, 0, 0.7);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

.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;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.page {
  max-width: 36rem;
  margin: 0 auto;
  padding: 64px 16px 72px;
}

/* 标题 */
.head h1 {
  font-size: 26px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.lede {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

/* 输入 */
.ask {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.field {
  position: relative;
}

.field input {
  width: 100%;
  height: 52px;
  padding: 0 64px 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 500 16px/1 var(--text);
  letter-spacing: 0.02em;
  transition: border-color 0.15s;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.field input:hover {
  border-color: var(--muted);
}

.field input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

.peek {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: 14px/1 var(--text);
  cursor: pointer;
}

.peek:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--line) 50%, transparent);
}

.go {
  height: 52px;
  min-width: 96px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font: 600 16px/1 var(--text);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background-color 0.15s;
}

.go:hover {
  background: var(--ink-2);
}

.go:disabled {
  cursor: progress;
  background: var(--ink-2);
}

.hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

/* 出错 */
.alert {
  margin-top: 20px;
  padding: 12px 14px;
  border-left: 3px solid var(--bad);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--bad) 8%, var(--surface));
  color: var(--ink);
  font-size: 15px;
}

/* 余额读数 */
.readout {
  margin-top: 48px;
}

.readout-top {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.readout-top h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--good);
}

.state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.state.is-bad {
  color: var(--bad);
}

.meter-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--drum-size);
}

.currency {
  font-family: var(--digits);
  font-weight: 600;
  font-size: 0.62em;
  line-height: 1;
  color: var(--ink-2);
}

.meter {
  display: inline-flex;
  align-items: stretch;
  gap: 0.06em;
  padding: 0.14em 0.16em;
  border-radius: 0.18em;
  background: var(--bezel);
  box-shadow:
    inset 0 0 0 1px var(--bezel-edge),
    inset 0 0.04em 0 rgba(255, 255, 255, 0.06),
    0 1px 0 var(--emboss),
    0 0.3em 0.5em -0.32em var(--drop);
  max-width: 100%;
}

.drum {
  position: relative;
  width: 0.6em;
  height: 1.14em;
  overflow: hidden;
  border-radius: 0.06em;
  background: linear-gradient(
    180deg,
    var(--drum-dark) 0%,
    var(--drum) 24%,
    var(--drum) 76%,
    var(--drum-dark) 100%
  );
}

.drum.frac {
  background: linear-gradient(
    180deg,
    var(--frac-dark) 0%,
    var(--frac) 26%,
    var(--frac) 74%,
    var(--frac-dark) 100%
  );
}

.drum.gap {
  margin-left: 0.12em;
}

/* 滚轮上下的弧面阴影 */
.drum::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.42) 0%,
    rgba(0, 0, 0, 0) 30%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0) 70%,
    rgba(0, 0, 0, 0.42) 100%
  );
}

.strip {
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--d, 0) * -1.14em));
  transition: transform var(--dur, 1100ms) cubic-bezier(0.16, 0.84, 0.24, 1) var(--delay, 0ms);
  will-change: transform;
}

.strip span {
  display: block;
  height: 1.14em;
  line-height: 1.14em;
  text-align: center;
  color: var(--numeral);
  font-family: var(--digits);
  font-weight: 600;
  font-size: 1em;
  font-variant-numeric: tabular-nums;
}

.point {
  position: relative;
  width: 0.16em;
}

.point::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0.2em;
  width: 0.09em;
  height: 0.09em;
  margin-left: -0.045em;
  border-radius: 50%;
  background: var(--numeral);
}

.sign {
  align-self: center;
  padding: 0 0.04em;
  color: var(--numeral);
  font-family: var(--digits);
  font-weight: 600;
  line-height: 1;
}

.meter.is-idle .strip {
  visibility: hidden;
}

.meter.is-idle .drum {
  opacity: 0.6;
}

.readout-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.readout-note strong {
  color: var(--ink);
  font-weight: 600;
}

.gauge {
  margin-top: 10px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.gauge i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  border-radius: inherit;
  background: var(--ink-2);
}

.gauge.is-high i {
  background: var(--warn);
}

.gauge.is-full i {
  background: var(--bad);
}

/* 明细 */
.details {
  margin-top: 40px;
}

.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.figures dt {
  color: var(--muted);
  font-size: 14px;
}

.figures dd {
  margin-top: 2px;
}

.money {
  display: block;
  font-family: var(--digits);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.sub {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.block {
  margin-top: 40px;
}

.block h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}

/* 7 天柱状 */
.days {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  height: 168px;
}

.days li {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
}

.days .col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  border-bottom: 1px solid var(--line-strong);
}

.days .val {
  margin-bottom: 4px;
  text-align: center;
  color: var(--ink-2);
  font-family: var(--digits);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.days .bar {
  height: var(--h, 0%);
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--bar);
}

.days .is-zero .bar {
  min-height: 0;
  height: 0;
}

.days .is-today .bar {
  background: var(--bar-today);
}

.days .day {
  padding-top: 6px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.days .is-today .day {
  color: var(--ink);
  font-weight: 600;
}

/* 模型 */
.models {
  margin-top: 10px;
}

.models li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  column-gap: 16px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.models li:last-child {
  border-bottom: 0;
}

.models .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.models .count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.models .amt {
  font-family: var(--digits);
  font-weight: 600;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 5.5em;
}

.models .share {
  grid-column: 1 / -1;
  margin-top: 6px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.models .share i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: var(--bar);
}

.models .is-rest .name {
  color: var(--muted);
}

/* 限额 */
.limits {
  margin-top: 6px;
}

.limits li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.limits li:last-child {
  border-bottom: 0;
}

.limits .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 14px;
}

.limits .what {
  color: var(--ink);
}

.limits .how {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.limits .when {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.limits .gauge {
  margin-top: 8px;
  height: 4px;
}

.stamp {
  margin-top: 36px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 480px) {
  .page {
    padding-top: 40px;
  }

  .head h1 {
    font-size: 23px;
  }

  .ask {
    grid-template-columns: 1fr;
  }

  .go {
    width: 100%;
  }

  .meter-row {
    gap: 8px;
  }

  .money {
    font-size: 28px;
  }

  .days {
    gap: 5px;
  }

  .days .val {
    font-size: 12px;
  }

  .models li {
    column-gap: 10px;
  }

  .models .count {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .strip {
    transition: none;
  }
}
