:root {
  --bg: #0b0e14;
  --bg2: #10151d;
  --surface: #151b25;
  --surface2: #1b2230;
  --line: rgba(255, 255, 255, 0.075);
  --text: #e9eef7;
  --muted: #7c8798;
  --up: #ff5a61;
  --down: #23c07a;
  --gold: #f0c14b;
  --accent: #4f8cff;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(96px + var(--safe-b));
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    var(--bg);
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 10px) 18px 10px;
  background: linear-gradient(180deg, rgba(11, 14, 20, 0.96), rgba(11, 14, 20, 0.82));
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .3px;
}

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3b4354;
  flex: 0 0 auto;
  transition: background .3s, box-shadow .3s;
}
.dot.live { background: var(--down); box-shadow: 0 0 0 4px rgba(35, 192, 122, .12); }
.dot.err  { background: var(--up);   box-shadow: 0 0 0 4px rgba(255, 90, 97, .12); }

.actions { display: flex; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  transition: transform .12s, background .2s;
}
.icon-btn:active { transform: scale(.93); background: var(--surface2); }
.icon-btn.spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 提示条 ---------------- */

.banner {
  margin: 10px 14px 0;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(240, 193, 75, .10);
  border: 1px solid rgba(240, 193, 75, .22);
  color: #e9c877;
  font-size: 13px;
  line-height: 1.5;
}
.banner button {
  margin-left: 8px;
  background: none; border: 0; padding: 0;
  color: var(--gold); font-size: 13px; font-weight: 600;
  text-decoration: underline;
  font-family: inherit;
}

/* ---------------- 列表 ---------------- */

.list { padding: 12px 14px 0; display: flex; flex-direction: column; gap: 10px; }

.card {
  position: relative;
  background: linear-gradient(180deg, var(--surface), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px 12px;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
  transition: background .25s;
}
.card[data-state="high"]::before { background: var(--up); }
.card[data-state="low"]::before  { background: var(--down); }
.card.off { opacity: .45; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }

.ident { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.ident .nm {
  font-size: 15px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ident .unit { font-size: 11px; color: var(--muted); white-space: nowrap; }

.del {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 16px; line-height: 1;
  display: none;
  padding: 0;
}
body.editing .del { display: block; }
.del:active { background: rgba(255, 90, 97, .16); color: var(--up); }

.price-line {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.pcol { display: flex; align-items: baseline; gap: 9px; min-width: 0; }

.spark { width: 92px; height: 34px; flex: 0 0 auto; margin-bottom: 4px; }
.sline { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.sline.up { stroke: var(--up); }
.sline.down { stroke: var(--down); }
.sfill.up { fill: rgba(255, 90, 97, .13); }
.sfill.down { fill: rgba(35, 192, 122, .13); }
.price {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.chg {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .05);
  color: var(--muted);
}
.chg.up   { color: var(--up);   background: rgba(255, 90, 97, .12); }
.chg.down { color: var(--down); background: rgba(35, 192, 122, .12); }

.meta {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  min-height: 15px;
}
.meta .flag { color: var(--gold); }
.meta .flag.hot { color: var(--up); }

.thresholds {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}

.mode {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  color: var(--muted);
  font-size: 11.5px;
  font-family: inherit;
  white-space: nowrap;
  transition: color .18s, border-color .18s, background .18s;
}
.mode.pct {
  color: var(--gold);
  border-color: rgba(240, 193, 75, .35);
  background: rgba(240, 193, 75, .10);
}

.thresholds label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 8px;
  min-width: 0;
}
.thresholds label span.lb {
  font-size: 10.5px;
  color: var(--muted);
  flex: 0 0 auto;
}
.thresholds .psign {
  display: none;
  font-size: 10.5px;
  font-style: normal;
  color: var(--muted);
  flex: 0 0 auto;
}
.thresholds label.pct .psign { display: inline; }
.thresholds input {
  width: 100%;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 16px;          /* 16px 防止 iOS 自动放大 */
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  padding: 0;
  text-align: right;
}
.thresholds input::placeholder { color: #4a5364; }
.thresholds input:placeholder-shown { text-align: center; }

.sw {
  flex: 0 0 auto;
  width: 46px; height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #232b3a;
  position: relative;
  padding: 0;
  transition: background .2s;
}
.sw i {
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #6b7688;
  transition: transform .2s, background .2s;
}
.sw[aria-pressed="true"] { background: rgba(79, 140, 255, .30); border-color: rgba(79, 140, 255, .5); }
.sw[aria-pressed="true"] i { transform: translateX(18px); background: var(--accent); }

/* ---------------- 空态 ---------------- */

.empty {
  padding: 70px 30px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty p { margin: 0 0 6px; }
.empty .sub { font-size: 12.5px; color: #5d6675; line-height: 1.6; }

/* ---------------- 底部按钮 ---------------- */

.fab-wrap {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(14px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(11, 14, 20, .92) 34%);
  z-index: 15;
  pointer-events: none;
}
.fab {
  pointer-events: auto;
  width: 100%;
  height: 50px;
  border-radius: 14px;
  border: 1px solid rgba(79, 140, 255, .35);
  background: linear-gradient(180deg, rgba(79, 140, 255, .22), rgba(79, 140, 255, .12));
  color: #cfe0ff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .5px;
  transition: transform .12s;
}
.fab:active { transform: scale(.985); }

/* ---------------- 弹层 ---------------- */

.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }

.sheet .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #121821;
  border-radius: 22px 22px 0 0;
  border-top: 1px solid rgba(255, 255, 255, .09);
  padding: 8px 18px calc(24px + var(--safe-b));
  animation: slide .24s cubic-bezier(.22, 1, .36, 1);
}
@keyframes slide { from { transform: translateY(40px); opacity: .4; } }

.sheet-grip {
  width: 38px; height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  margin: 6px auto 12px;
}

.sheet h2 { margin: 0 0 14px; font-size: 18px; font-weight: 650; }
.sheet h3.sec-title {
  margin: 18px 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .6px;
}

.searchrow { display: flex; gap: 8px; }
.searchrow input {
  flex: 1;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 0 14px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.searchrow input:focus { border-color: rgba(79, 140, 255, .5); }
.searchrow button {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
}

.results { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
}
.result .r-name { font-weight: 600; }
.result .r-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.result .r-add { color: var(--accent); font-weight: 600; font-size: 13px; }
.result:disabled { opacity: .4; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .035);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
.chip .g { color: var(--muted); font-size: 11px; margin-left: 5px; }
.chip:disabled { opacity: .35; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .3px;
}
.field input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 0 14px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.field input:focus { border-color: rgba(79, 140, 255, .5); }

.row2 { display: flex; align-items: flex-end; gap: 10px; }
.row2 .field { flex: 1; margin-bottom: 14px; }
.ghost {
  height: 46px;
  padding: 0 16px;
  margin-bottom: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  white-space: nowrap;
}

.adv { margin-bottom: 14px; }
.adv summary {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0;
  cursor: pointer;
}
.adv .field { margin-top: 10px; }

.primary {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(180deg, #5b95ff, #3d78ef);
  color: #fff;
  font-size: 16px;
  font-weight: 650;
  font-family: inherit;
  margin-top: 4px;
}
.primary:active { filter: brightness(.92); }

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 14px;
}
.hint.tiny { font-size: 11px; color: #4e5766; margin-top: 14px; }

/* ---------------- 通知渠道 ---------------- */

.ch {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .022);
  overflow: hidden;
  transition: border-color .2s, background .2s;
}
.ch.on { border-color: rgba(79, 140, 255, .34); background: rgba(79, 140, 255, .07); }

.ch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
}
.ch-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ch-name { font-size: 14.5px; font-weight: 600; }
.ch-sub { font-size: 11.5px; color: var(--muted); }

.ch-body { display: none; padding: 2px 14px 2px; }
.ch.open .ch-body { display: block; }

.tips {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: #5d6675;
  line-height: 1.75;
}
.tips p { margin: 0 0 5px; }
.tips b { color: var(--muted); }

.ghost.wide { width: 100%; margin-bottom: 10px; }

/* ---------------- 走势详情 ---------------- */

.sheet-panel.tall { min-height: 72dvh; }

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-name { font-size: 17px; font-weight: 650; }
.chart-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.chart-right { text-align: right; }
.chart-price {
  font-size: 27px;
  font-weight: 680;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.chart-chg { font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.chart-chg.up, .chart-stats .up { color: var(--up); }
.chart-chg.down, .chart-stats .down { color: var(--down); }

.ranges { display: flex; gap: 5px; margin-bottom: 14px; }
.ranges button {
  flex: 1;
  height: 34px;
  padding: 0 2px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background .18s, color .18s, border-color .18s;
}
.ranges button.on {
  background: rgba(79, 140, 255, .16);
  border-color: rgba(79, 140, 255, .45);
  color: #cfe0ff;
}

.bigchart { position: relative; }
.bc-plot { position: relative; height: 190px; touch-action: pan-y; }
.bigsvg { width: 100%; height: 190px; display: block; }
.bigsvg.up { color: var(--up); }
.bigsvg.down { color: var(--down); }
.grid { stroke: rgba(255, 255, 255, .055); stroke-width: 1; vector-effect: non-scaling-stroke; }

.bc-y { position: absolute; inset: 0; pointer-events: none; }
.bc-y span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-size: 9.5px;
  color: #4b5464;
  background: rgba(18, 24, 33, .78);
  padding: 1px 4px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.bc-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, .22);
  pointer-events: none;
}
.bc-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .16);
  pointer-events: none;
}
.bc-tip {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  font-size: 10.5px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(26, 34, 47, .96);
  border: 1px solid var(--line);
  color: #dbe4f0;
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.bc-x {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  padding: 4px 2px 0;
  font-variant-numeric: tabular-nums;
}
.chart-empty {
  display: grid;
  place-items: center;
  height: 190px;
  color: var(--muted);
  font-size: 13px;
}

.chart-stats { display: flex; gap: 9px; margin-top: 14px; }.chart-stats > div {
  flex: 1;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 11px;
}
.chart-stats span { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
.chart-stats b { font-size: 14px; font-variant-numeric: tabular-nums; }

.chart-note {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: #6b7688;
  line-height: 1.6;
}
.chart-note:empty { display: none; }

/* ---------------- 口令页 ---------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.gate[hidden] { display: none; }
.gate-box { width: 100%; max-width: 360px; }
.gate-box h2 { margin: 0 0 8px; font-size: 20px; }
.gate-box input {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 0 14px;
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 100;
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(32, 40, 54, .96);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13.5px;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  animation: toastIn .2s ease;
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
