/* ============================================================
   币价预警 — 单文件样式表
   深色为默认主题，浅色通过 html[data-theme="light"] 覆盖
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --bg: #0b0f14;
  --surface: #121a22;
  --surface-2: #18222c;
  --border: #22303d;
  --text: #e7eef6;
  --muted: #8a9aa9;
  --up: #16c784;
  --down: #ea3943;
  --brand: #4f7cff;
  --warn: #f0b90b;

  --brand-weak: rgba(79, 124, 255, .14);
  --up-weak: rgba(22, 199, 132, .14);
  --down-weak: rgba(234, 57, 67, .14);
  --warn-weak: rgba(240, 185, 11, .15);
  --overlay: rgba(3, 6, 10, .62);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 26px rgba(0, 0, 0, .28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);

  --header-h: 54px;
  --nav-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --maxw: 1080px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --border: #dde5ee;
  --text: #0f1a24;
  --muted: #5e7285;
  --up: #0a9d67;
  --down: #d52b35;
  --brand: #3563e9;
  --warn: #b07800;

  --brand-weak: rgba(53, 99, 233, .12);
  --up-weak: rgba(10, 157, 103, .12);
  --down-weak: rgba(213, 43, 53, .12);
  --warn-weak: rgba(176, 120, 0, .14);
  --overlay: rgba(18, 28, 40, .42);

  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 10px 24px rgba(16, 32, 48, .1);
  --shadow-sm: 0 1px 2px rgba(16, 32, 48, .07);
  color-scheme: light;
}

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

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
}

/*
 * 关键：overflow-x / overscroll-behavior 只写在根元素上。
 * 如果给 body 也加 overflow-x: hidden，body 会变成独立滚动容器，
 * 再叠加 overscroll-behavior-y: none（禁止滚动链），触摸手势就既滚不动
 * body 也无法上抛给视口 —— 页面内容再长也滑不动。
 */
html {
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .18s ease, color .18s ease;
}

h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration: none; }
img, canvas, svg { max-width: 100%; }
::selection { background: var(--brand-weak); }

.num, .price, .pct, .abs, time, .mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.spacer { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 布局骨架 ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-t);
}

@supports not (backdrop-filter: blur(1px)) {
  .app-header { background: var(--bg); }
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 10px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; flex: none; }
.brand-name {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 4px; flex: none; }

.app-main {
  flex: 1 1 auto;
  width: 100%;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
}

.view { width: 100%; }
.view-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}

@supports not (backdrop-filter: blur(1px)) {
  .tabbar { background: var(--surface); }
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .3px;
  transition: color .15s ease;
}
.tab svg { display: block; }
.tab[aria-current="page"] { color: var(--brand); }
.tab:active { opacity: .7; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: transform .08s ease, opacity .15s ease, background-color .15s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .42; pointer-events: none; }
.btn-primary { background: var(--brand); border-color: transparent; color: #fff; }
.btn-danger { background: var(--down-weak); border-color: color-mix(in srgb, var(--down) 40%, transparent); color: var(--down); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon-only { padding: 0; width: 44px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  color: var(--muted);
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { background: var(--surface-2); transform: scale(.96); }
.icon-btn-sm { width: 44px; height: 44px; border-radius: 10px; }
.icon-btn.danger { color: var(--down); }

html[data-theme="dark"] .i-sun { display: none; }
html[data-theme="light"] .i-moon { display: none; }

/* 连接状态指示 */
.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  max-width: 108px;
}
.conn-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.conn[data-state="live"] { color: var(--up); border-color: color-mix(in srgb, var(--up) 34%, transparent); }
.conn[data-state="live"] .conn-led { background: var(--up); box-shadow: 0 0 0 3px var(--up-weak); animation: pulse 2.4s ease-in-out infinite; }
.conn[data-state="poll"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 34%, transparent); }
.conn[data-state="poll"] .conn-led { background: var(--warn); }
.conn[data-state="down"] { color: var(--down); border-color: color-mix(in srgb, var(--down) 34%, transparent); }
.conn[data-state="down"] .conn-led { background: var(--down); }
.conn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.card-tight { padding: 12px; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-title { font-size: 14.5px; font-weight: 650; letter-spacing: .2px; }
.card-sub { font-size: 12px; color: var(--muted); }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .4px;
  padding: 2px 2px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

/* ---------- 徽标 / 标签 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-brand { background: var(--brand-weak); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.badge-up { background: var(--up-weak); color: var(--up); border-color: color-mix(in srgb, var(--up) 30%, transparent); }
.badge-down { background: var(--down-weak); color: var(--down); border-color: color-mix(in srgb, var(--down) 30%, transparent); }
.badge-warn { background: var(--warn-weak); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.badge-plain { background: transparent; }

.state-idle { color: var(--muted); }
.state-armed { background: var(--brand-weak); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.state-triggered { background: var(--up-weak); color: var(--up); border-color: color-mix(in srgb, var(--up) 30%, transparent); }
.state-cooldown { background: var(--warn-weak); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.state-stopped { background: var(--surface-2); color: var(--muted); }

/* ---------- 过滤 chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 12px 2px;
  margin: 0 -12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-padding-inline: 12px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  transition: background-color .15s ease, color .15s ease;
}
.chip[aria-pressed="true"] {
  background: var(--brand-weak);
  border-color: color-mix(in srgb, var(--brand) 42%, transparent);
  color: var(--brand);
}

/* ---------- 行情网格 ---------- */
.sym-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
}

.sym-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform .1s ease, border-color .15s ease;
  min-height: 128px;
}
.sym-card:active { transform: scale(.985); }
.sym-card.is-stale { opacity: .68; }

.sym-top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.sym-name { font-size: 14px; font-weight: 650; letter-spacing: .2px; min-width: 0; }
.sym-price {
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -.3px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.sym-chg { font-size: 13px; font-weight: 600; margin-top: 2px; }
.sym-foot {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.sym-foot-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sym-foot-line b { font-weight: 550; color: var(--text); }

.reorder-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.reorder-row .btn { flex: 1 1 0; background: var(--surface-2); border-color: var(--border); color: var(--text); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* 统计小格 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  min-width: 0;
}
.stat-k { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.stat-v { font-size: 15px; font-weight: 620; overflow-wrap: anywhere; }

/* ---------- 列表行 ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 12px;
  min-width: 0;
}
.list-row-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; }
.list-row-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list-row-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* 预警卡片 */
.rule-card { display: flex; flex-direction: column; gap: 10px; }
.rule-head { display: flex; align-items: flex-start; gap: 8px; }
.rule-name { font-size: 15px; font-weight: 640; min-width: 0; overflow-wrap: anywhere; }
.rule-cond {
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.rule-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.rule-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rule-actions .btn { flex: 1 1 auto; }

/* 记录行 */
.ev-row { display: flex; flex-direction: column; gap: 8px; }
.ev-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ev-time { font-size: 12px; color: var(--muted); flex: none; }
.ev-title { font-size: 14px; font-weight: 620; min-width: 0; overflow-wrap: anywhere; }
.ev-reason {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.ev-price { font-size: 16px; font-weight: 650; }
.ev-chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- 开关 ---------- */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 44px;
  flex: none;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch-track {
  width: 46px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background-color .18s ease, border-color .18s ease;
  position: relative;
  pointer-events: none;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .18s ease, background-color .18s ease;
}
.switch input:checked + .switch-track { background: var(--brand-weak); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--brand); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.field-hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.field-error { font-size: 12px; color: var(--down); }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  min-width: 0;
}
.textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .75; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-weak);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--down); }
.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.select-sm { min-height: 44px; padding: 8px 30px 8px 10px; font-size: 13.5px; }

.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg > button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 0 6px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.seg > button[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
html[data-theme="light"] .seg > button[aria-pressed="true"] { background: #fff; }

.seg-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-opt {
  min-height: 44px;
  padding: 0 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
}
.pill-opt[aria-pressed="true"] {
  background: var(--brand-weak);
  border-color: color-mix(in srgb, var(--brand) 45%, transparent);
  color: var(--brand);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 20px; height: 20px; flex: none; accent-color: var(--brand); margin: 0;
}
.check-row-main { min-width: 0; flex: 1 1 auto; }
.check-row-title { font-size: 13.5px; font-weight: 600; }
.check-row-sub { font-size: 11.5px; color: var(--muted); }
.check-row[aria-checked="true"] { border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--brand-weak); }

.inline-form { display: flex; gap: 8px; align-items: stretch; }
.inline-form .input { flex: 1 1 auto; }
.inline-form .btn { flex: none; }

.form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.form-section > h3 {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: .4px;
}

/* ---------- 底部抽屉 / 弹层 ---------- */
.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  animation: fadeIn .16s ease;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: sheetUp .2s cubic-bezier(.22, .68, .34, 1);
  padding-bottom: var(--safe-b);
  overflow: hidden;
}
.sheet-full { height: 94vh; height: 94dvh; }
.sheet-sm { max-width: 420px; }

@keyframes sheetUp { from { transform: translateY(14px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 8px auto 0; flex: none; }
.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet-head h2 { font-size: 16px; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet-foot {
  flex: none;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--surface);
}
.sheet-foot .btn { flex: 1 1 0; }

.sheet-body::-webkit-scrollbar { width: 6px; }
.sheet-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------- Toast ---------- */
.toast-action {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-weak);
}
.toast-action:active { transform: scale(.97); }

.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  line-height: 1.45;
  animation: toastIn .18s ease;
  overflow-wrap: anywhere;
}
.toast-bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--brand); flex: none; }
.toast-ok .toast-bar { background: var(--up); }
.toast-err .toast-bar { background: var(--down); }
.toast-warn .toast-bar { background: var(--warn); }
.toast-msg { flex: 1 1 auto; min-width: 0; }
.toast-icon { flex: none; margin-top: 1px; color: var(--brand); }
.toast-ok .toast-icon { color: var(--up); }
.toast-err .toast-icon { color: var(--down); }
.toast-warn .toast-icon { color: var(--warn); }
.toast-close { flex: none; color: var(--muted); width: 44px; height: 44px; margin: -11px -12px -11px 0; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }

@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- 空状态 / 骨架 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 18px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-icon { color: var(--muted); opacity: .7; }
.empty-title { font-size: 15px; font-weight: 620; color: var(--text); }
.empty-text { font-size: 13px; max-width: 30ch; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 8px;
  height: 14px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.loading-line { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; color: var(--muted); font-size: 13px; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 图表 ---------- */
.chart-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.chart-canvas { display: block; width: 100%; height: 180px; }
.chart-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.chart-legend b { font-weight: 600; color: var(--text); }

/* ---------- 设置 ---------- */
.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.set-row:last-child { border-bottom: 0; }
.set-row-main { flex: 1 1 auto; min-width: 0; }
.set-row-k { font-size: 13.5px; font-weight: 550; }
.set-row-v { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

textarea.input {
  min-height: 66px;
  padding: 9px 12px;
  line-height: 1.5;
  resize: vertical;
}

/* 规则的补充信息（规则卡 / 预警记录） */
.rule-note {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--brand);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
}
.rule-note-icon { flex: none; opacity: .75; }

/* 行情降级提示（首页） */
.degraded-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent);
  background: var(--warn-weak);
}
.degraded-row { display: flex; gap: 8px; align-items: flex-start; }
.degraded-icon { flex: none; line-height: 1.4; }
.degraded-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.degraded-text strong { font-size: 13.5px; font-weight: 620; color: var(--warn); }
.degraded-text span { font-size: 12.5px; color: var(--muted); }

/* 输入框与按钮同行时，输入框占满剩余宽度 */
.field .row > .input { flex: 1 1 auto; min-width: 0; }

.src-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12.5px; padding: 5px 0; min-width: 0; }

.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 4px 0; min-width: 0; }
.kv-k { color: var(--muted); flex: none; }
.kv-v { text-align: right; overflow-wrap: anywhere; }

/* ---------- 安装横幅 ---------- */
.install-banner {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: toastIn .2s ease;
}
.install-icon { border-radius: 9px; flex: none; }
.install-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.install-text strong { font-size: 13.5px; font-weight: 640; }
.install-text span { font-size: 11.5px; color: var(--muted); }

/* ---------- 其它 ---------- */
.noscript {
  margin: 40px 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  z-index: 60;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(79, 124, 255, .42);
  transition: transform .1s ease;
}
.fab:active { transform: scale(.94); }

.divider { height: 1px; background: var(--border); margin: 2px 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  min-height: 52px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.search-result:active { border-color: var(--brand); }
.search-result-main { flex: 1 1 auto; min-width: 0; }
.search-result .sym { font-size: 14px; font-weight: 620; }
.search-result .sub { font-size: 11.5px; color: var(--muted); }

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

/* ---------- 宽屏适配 ---------- */
@media (min-width: 560px) {
  .sym-grid { grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); }
  .sheet { border-radius: 18px; border-bottom: 1px solid var(--border); }
  .sheet-layer { align-items: center; padding: 16px; }
  .sheet-full { height: min(760px, 92dvh); }
  .toast-root { bottom: calc(var(--safe-b) + 20px); }
  .fab { right: calc(50% - var(--maxw) / 2 + 16px); }
  .install-banner { left: auto; right: 16px; width: 380px; }
  .rule-actions .btn { flex: 0 0 auto; }
}

@media (min-width: 880px) {
  .sym-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .view-inner { padding: 16px 16px 8px; }
  .chips { padding-inline: 16px; margin-inline: -16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 行情源错误信息（设置 → 系统状态） */
.src-error {
  flex-basis: 100%;
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--warn);
  word-break: break-word;
}
