/* ==========================================================================
   FX 沙盘 — 视觉规范：Apple Style
   浅色 #f5f5f7 底 / 白色卡片 / Apple 蓝 #0071e3 强调
   系统字体、大留白、精致微阴影、胶囊按钮、无渐变
   ========================================================================== */

:root {
  color-scheme: light;

  /* 品牌与语义色 */
  --apple-black: #000000;
  --apple-white: #ffffff;
  --apple-gray: #f5f5f7;
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-green: #34c759;
  --apple-red: #ff3b30;
  --apple-purple: #a13ff6;

  --bg: var(--apple-gray);
  --surface: var(--apple-white);
  --surface-sunken: var(--apple-gray);
  --surface-veil: rgba(255, 255, 255, 0.78);
  --surface-hover: #fafafa;

  /* 文字：全部满足 WCAG AA */
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-icon: #8e8e93;
  --on-accent: #ffffff;

  --line: rgba(0, 0, 0, 0.08);
  --line-soft: rgba(0, 0, 0, 0.05);

  /* 交互填充与状态色 */
  --fill-1: rgba(0, 0, 0, 0.05);
  --fill-2: rgba(0, 0, 0, 0.08);
  --fill-3: rgba(0, 0, 0, 0.09);
  --accent-soft: rgba(0, 113, 227, 0.1);
  --accent-soft-strong: rgba(0, 113, 227, 0.16);
  --long-soft: rgba(52, 199, 89, 0.14);
  --long-ink: #24893f;
  --short-soft: rgba(255, 59, 48, 0.12);
  --short-soft-strong: rgba(255, 59, 48, 0.18);
  --short-ink: #c92b22;
  --green-hover: #2fb851;
  --red-hover: #f0322a;
  --veil: rgba(0, 0, 0, 0.28);
  --toast-bg: rgba(29, 29, 31, 0.92);
  --chevron: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 2L6 6.2 10.5 2' fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* 滑杆滑块：iOS 两个主题下都是白色圆形滑块，所以不做主题反转 */
  --slider-knob: #ffffff;
  --slider-knob-ring: rgba(0, 0, 0, 0.04);
  --slider-knob-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.16);
  --slider-track: rgba(120, 120, 128, 0.2);

  /* 分段控件里滑动胶囊的颜色 */
  --seg-pill: #ffffff;

  /* 圆角 */
  --r-2xl: 20px;
  --r-xl: 14px;
  --r-md: 10px;
  --r-pill: 980px;

  /* 阴影：克制、精致 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --focus-ring: 0 0 0 4px rgba(0, 113, 227, 0.28);

  /* 动效：iOS 曲线体系
     --ease-ios    通用过渡，Apple 表单呈现曲线，起步快、收尾慢
     --ease-inout  对称缓动，用于颜色 / 透明度这类不宜过冲的属性
     --ease-enter  入场减速
     --ease-spring 弹性回弹，带轻微过冲（只用于位移与缩放）
     --ease-exit   离场加速 */
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-inout: cubic-bezier(0.42, 0, 0.58, 1);
  --ease-enter: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.22, 1.4, 0.36, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);

  /* iOS 时长节奏：点按 110ms / 快 240ms / 常规 360ms / 呈现 520ms */
  --t-tap: 110ms;
  --t-fast: 240ms;
  --t-base: 360ms;
  --t-slow: 520ms;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Helvetica Neue", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* 涨跌配色由 body[data-scheme] 决定，默认红涨绿跌 */
body[data-scheme="cn"] { --up: var(--apple-red); --down: var(--apple-green); }
body[data-scheme="us"] { --up: var(--apple-green); --down: var(--apple-red); }

/* ==========================================================================
   暗色模式
   沿用同一套设计语言：纯黑底、抬升面、用面与面的明度差代替阴影
   ========================================================================== */

[data-theme="dark"] {
  color-scheme: dark;

  --apple-blue: #0a84ff;
  --apple-blue-hover: #1f8fff;
  --apple-green: #30d158;
  --apple-red: #ff453a;
  --apple-purple: #bf5af2;

  --bg: #000000;
  --surface: #1c1c1e;
  --surface-sunken: #2c2c2e;
  --surface-veil: rgba(28, 28, 30, 0.76);
  --surface-hover: #232326;

  --ink: #f5f5f7;
  --ink-2: #a1a1a6;
  --ink-icon: #8e8e93;
  --on-accent: #ffffff;

  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.06);

  --fill-1: rgba(255, 255, 255, 0.1);
  --fill-2: rgba(255, 255, 255, 0.16);
  --fill-3: rgba(255, 255, 255, 0.2);
  --accent-soft: rgba(10, 132, 255, 0.18);
  --accent-soft-strong: rgba(10, 132, 255, 0.3);
  --long-soft: rgba(48, 209, 88, 0.18);
  --long-ink: #30d158;
  --short-soft: rgba(255, 69, 58, 0.18);
  --short-soft-strong: rgba(255, 69, 58, 0.3);
  --short-ink: #ff453a;
  --green-hover: #3ad967;
  --red-hover: #ff5c52;
  --veil: rgba(0, 0, 0, 0.6);
  --toast-bg: rgba(58, 58, 60, 0.96);
  --chevron: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 2L6 6.2 10.5 2' fill='none' stroke='%23a1a1a6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* 暗色下阴影几乎不可见，靠面与面的明度差分层 */
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --focus-ring: 0 0 0 4px rgba(10, 132, 255, 0.32);
}

/* 暗色下分段控件的滑动胶囊要更亮，而不是更暗 */
[data-theme="dark"] { --seg-pill: #48484a; }

/* 暗色下输入框聚焦时保持底色，靠焦点环表达状态 */
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus { background: var(--surface-sunken); }

*, *::before, *::after { box-sizing: border-box; }

/* hidden 属性优先于组件自身的 display，避免 flex/grid 覆盖 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.47;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }

.num, .metric strong, .equity, .chart-quote strong, dd, .data-table .num,
.time-info strong, .return-badge { font-variant-numeric: tabular-nums; }

/* 可见焦点，键盘可达 */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-md);
}

/* ==========================================================================
   布局骨架
   ========================================================================== */

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* 顶栏：磨砂玻璃 */
.topbar {
  position: relative;
  z-index: 40;
  flex: none;
  background: var(--surface-veil);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: flex; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.brand-text small {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  font-weight: 500;
}

.top-nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; margin-left: auto; }

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-inout),
              color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.nav-btn:hover { background: var(--fill-1); color: var(--ink); }
.nav-btn.danger:hover { color: var(--apple-red); background: var(--short-soft); }
.nav-btn .ico { width: 15px; height: 15px; flex: none; color: var(--ink-icon); }
.nav-btn:hover .ico { color: currentColor; }

/* ==========================================================================
   账户概览
   ========================================================================== */

.overview {
  flex: none;
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-md);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 1.5fr);
  gap: 32px;
  align-items: center;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--apple-blue);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chip.quiet { background: var(--fill-1); color: var(--ink-2); }

/* 涨跌气泡与大号权益数字居中对齐（baseline 会让小气泡明显偏低） */
.equity-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.equity {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.return-badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  background: var(--fill-1);
  color: var(--ink-2);
  transition: color var(--t-fast) var(--ease-inout), background-color var(--t-fast) var(--ease-inout);
}
.return-badge.pos { color: var(--up); background: color-mix(in srgb, var(--up) 10%, transparent); }
.return-badge.neg { color: var(--down); background: color-mix(in srgb, var(--down) 10%, transparent); }

.overview-sub { margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.overview-sub.warn { color: var(--apple-red); font-weight: 500; }

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--r-xl);
  background: var(--surface-sunken);
}
.metric span { font-size: 11px; color: var(--ink-2); }
.metric strong { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

/* ==========================================================================
   工作区
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 306px;
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}

.card {
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}
.card-head h2 { font-size: 15px; }
.card-hint { font-size: 12px; color: var(--ink-2); }

/* 货币对列表 */
.market-panel { display: flex; flex-direction: column; padding-bottom: 8px; overflow: hidden; }
.pair-list { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.pair-row {
  appearance: none;
  border: 0;
  width: 100%;
  flex: 1 1 auto;
  min-height: 42px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  text-align: left;
  padding: 6px 10px;
  border-radius: var(--r-md);
  background: transparent;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.pair-row:hover { background: var(--surface-sunken); }
.pair-row.active { background: var(--accent-soft); }
.pair-row .pr-id { font-size: 13px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.pair-row.active .pr-id { color: var(--apple-blue); }
.pair-row .pr-name { font-size: 10px; line-height: 1.2; color: var(--ink-2); grid-column: 1; }
.pair-row .pr-price { font-size: 13px; line-height: 1.25; font-weight: 500; font-family: var(--font-mono); text-align: right; }
.pair-row .pr-chg { font-size: 10px; line-height: 1.2; font-family: var(--font-mono); text-align: right; }
.pair-row .pr-pos { font-size: 10px; color: var(--apple-blue); font-weight: 600; }

.card-foot {
  margin: 10px 20px 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--ink-2);
}

/* ==========================================================================
   图表
   ========================================================================== */

.chart-panel { display: flex; flex-direction: column; overflow: hidden; min-height: 300px; }

.chart-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 12px 18px 8px;
  flex-wrap: nowrap;
  flex: none;
}
.chart-title { min-width: 0; flex: 0 1 auto; }
.chart-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chart-title h1 { font-size: 20px; letter-spacing: -0.02em; white-space: nowrap; }
.tag {
  flex: none;
  white-space: nowrap;
  height: 20px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
}
.chart-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

.chart-quote {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
  margin-left: auto;
  text-align: right;
}
.chart-quote strong { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.quote-change { font-size: 12px; font-weight: 600; font-family: var(--font-mono); }
.quote-ba { font-size: 11px; color: var(--ink-2); font-family: var(--font-mono); }

.chart-tools { display: flex; align-items: center; gap: 8px; flex: none; }

/* 窄一些的桌面窗口里藏掉中文名，保证图表头部始终一行 */
@media (max-width: 1440px) {
  .chart-sub { display: none; }
}

/* 分段控件：iOS 风格，选中项是一颗会滑动的小胶囊 */
.segmented {
  --seg-pad: 3px;
  --seg-gap: 2px;
  position: relative;
  display: inline-flex;
  gap: var(--seg-gap);
  padding: var(--seg-pad);
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
}
.segmented::before {
  content: "";
  position: absolute;
  top: var(--seg-pad);
  bottom: var(--seg-pad);
  left: var(--seg-pad);
  width: calc((100% - 2 * var(--seg-pad) - var(--seg-gap)) / 2);
  border-radius: var(--r-pill);
  background: var(--seg-pill);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base) var(--ease-ios);
  pointer-events: none;
}
.segmented[data-active="line"]::before { transform: translateX(calc(100% + var(--seg-gap))); }

.seg {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.seg:hover { color: var(--ink); }
.seg.active { background: transparent; box-shadow: none; color: var(--ink); }

.chart-stage { position: relative; flex: 1 1 0; min-height: 140px; padding: 0 6px; }
/* pan-y：横向拖动平移图表，纵向滑动照常滚动页面
   绝对定位，避免 canvas 的像素尺寸反过来撑大容器 */
.chart-stage { position: relative; min-width: 0; }
.chart-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: pan-y;
}
.chart-stage canvas.dragging { cursor: grabbing; }

/* 行情快讯 */
.news-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 18px 8px;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  overflow: hidden;
}
.news-tag {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--fill-2);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.news-tag.up { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.news-tag.down { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
.news-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.news-time { flex: none; font-size: 10px; font-family: var(--font-mono); color: var(--ink-2); }

.toast.news { background: rgba(0, 113, 227, 0.95); }

.time-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 18px 12px;
  border-top: 1px solid var(--line-soft);
  margin-top: 6px;
}
.time-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.time-label { font-size: 11px; color: var(--ink-2); }
.time-info strong { font-size: 14px; font-weight: 600; }
.time-progress { font-size: 11px; color: var(--ink-2); }

/* 实时状态指示灯 */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--apple-green);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--apple-green);
  animation: live-pulse 1.6s var(--ease-inout) infinite;
}
.live-indicator.off { color: var(--apple-red); }
.live-indicator.off .live-dot { background: var(--apple-red); animation: none; }

.time-controls { display: flex; align-items: center; gap: 8px; flex: none; }
.time-controls > * { flex: none; }
.time-controls select { width: auto; min-width: 92px; }

/* ==========================================================================
   按钮 / 表单
   ========================================================================== */

.solid-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--r-pill);
  background: var(--apple-blue);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.28);
  transition: background-color var(--t-fast) var(--ease-inout),
              box-shadow var(--t-base) var(--ease-ios),
              transform var(--t-base) var(--ease-spring);
}
.solid-btn:hover { background: var(--apple-blue-hover); box-shadow: 0 6px 20px rgba(0, 113, 227, 0.34); transform: translateY(-1px); }
.solid-btn.small { padding: 8px 16px; font-size: 13px; }
.solid-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.quiet-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: var(--fill-1);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: background-color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.quiet-btn:hover { background: var(--fill-2); }
.quiet-btn.small { padding: 7px 14px; font-size: 12px; }
.quiet-btn.danger { color: var(--apple-red); background: var(--short-soft); }
.quiet-btn.danger:hover { background: var(--short-soft-strong); }
.quiet-btn.wide { width: 100%; }
.quiet-btn.active { background: var(--apple-blue); color: var(--on-accent); }

.icon-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--fill-1);
  color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease-inout),
              color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.icon-btn:hover { background: var(--fill-2); color: var(--ink); }

input[type="number"],
input[type="date"],
input[type="text"],
select {
  appearance: none;
  width: 100%;
  border: 0;
  padding: 11px 14px;
  border-radius: var(--r-xl);
  background: var(--surface-sunken);
  color: var(--ink);
  font-size: 14px;
  transition: box-shadow var(--t-base) var(--ease-ios),
              background-color var(--t-fast) var(--ease-inout);
}
input::placeholder { color: var(--ink-icon); }
input:focus, select:focus {
  outline: none;
  background: var(--surface);
  box-shadow: var(--focus-ring);
}
select {
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  padding-right: 34px;
  cursor: pointer;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-2);
}
.field-label em {
  font-style: normal;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--apple-blue);
}

/* 按钮与下拉框不参与拉伸，文字不换行 */
.solid-btn, .quiet-btn, .trade-btn, .nav-btn,
.seg, .tab, .row-btn, .icon-btn { white-space: nowrap; flex: none; }

/* ==========================================================================
   下单面板
   ========================================================================== */

/* 桌面端：右栏是一张卡片，自上而下是「参数」与「开仓按钮」 */
.order-column { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.order-panel { display: flex; flex-direction: column; overflow: hidden; flex: 1 1 auto; min-height: 0; }
/* 面板标题只在移动端 Sheet 里出现，桌面保持原有的无标题样式 */
.order-panel .card-head { display: none; }
.order-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* 表单可以滚动，但开仓按钮吸底，永远看得到 */
.order-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 20px 18px;
  margin-top: auto;
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   以下组件只在移动端/平板出现，桌面默认隐藏（保持桌面视觉不变）
   -------------------------------------------------------------------------- */
.pair-select,
.account-brief,
.dock-summary,
.menu-btn,
.sheet-only { display: none; }

/* 当前交易对选择器 */
.pair-select {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 100%;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 14px;
  background: transparent;
  text-align: left;
  transition: background-color var(--t-fast) var(--ease-inout);
}
.pair-select:active { background: var(--fill-1); }
.ps-left { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ps-left strong { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.ps-left small { font-size: 11px; color: var(--ink-2); }
.ps-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.ps-right strong { font-size: 20px; font-weight: 600; font-family: var(--font-mono); }
.ps-right small { font-size: 11px; font-family: var(--font-mono); }
.ps-arrow { width: 16px; height: 16px; flex: none; color: var(--ink-2); }

/* 账户摘要里的两项 + 详情入口 */
.account-brief {
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.brief-cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brief-cell span { font-size: 10px; color: var(--ink-2); }
.brief-cell strong { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.brief-more {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease-inout);
}
.brief-more:active { background: var(--fill-2); }
.brief-more .ico { width: 12px; height: 12px; }

/* Trading Dock 参数摘要（保证金 / 杠杆）：走主题变量，不用浏览器原生按钮外观 */
.dock-param {
  appearance: none;
  border: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 6px 12px;
  border-radius: var(--r-xl);
  background: var(--surface-sunken);
  color: var(--ink);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease-inout);
}
.dock-param span { font-size: 10px; color: var(--ink-2); }
.dock-param strong { font-variant-numeric: tabular-nums; }
.dock-param:active { background: var(--fill-2); }

/* 挑战未开始：下单区换成「开始挑战」（主操作，蓝色实心） */
.dock-start {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 100%;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--r-xl);
  background: var(--apple-blue);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 600;
  transition: background-color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.dock-start em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.85;
}
.dock-start:hover { background: var(--apple-blue-hover); }
.dock-start:active { transform: scale(0.97); }
.dock-start:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* 挑战进行中：持仓卡片下面的「金盆洗手」 */
.retire-btn { min-height: 48px; font-size: 15px; }

/* 底部 Sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--veil);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: veil-in var(--t-fast) var(--ease-inout);
}
.sheet-backdrop.standalone {
  position: fixed;
  z-index: 94;
  display: none;
}
@media (max-width: 767px) {
  .sheet-backdrop.standalone:not([hidden]) { display: block; }
}
.sheet-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 0 16px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh;
  overflow-y: auto;
  animation: sheet-in var(--t-base) var(--ease-ios);
}
.sheet-grip-line {
  width: 38px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--fill-3);
  margin: 10px auto 4px;
}
.sheet-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  padding: 6px 0 10px;
}
.menu-list { display: flex; flex-direction: column; }
.menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  transition: background-color var(--t-fast) var(--ease-inout);
}
.menu-item:last-child { border-bottom: 0; }
.menu-item:active { background: var(--fill-1); }
.menu-item.danger { color: var(--apple-red); }

.pair-sheet-list { display: flex; flex-direction: column; padding-bottom: 4px; }
.pair-option {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
  min-height: 58px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease-inout);
}
.pair-option:active { background: var(--fill-1); }
.pair-option.active { background: var(--accent-soft); }
.pair-option .po-id { font-size: 15px; font-weight: 600; }
.pair-option.active .po-id { color: var(--apple-blue); }
.pair-option .po-name { font-size: 11px; color: var(--ink-2); }
.pair-option .po-price { font-size: 15px; font-family: var(--font-mono); text-align: right; }
.pair-option .po-chg { font-size: 11px; font-family: var(--font-mono); text-align: right; }

.sheet-calc { display: grid; grid-template-columns: 1fr 1fr; }

/* 保证金输入 + 最大按钮 */
.input-row { display: flex; align-items: center; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.input-row .quiet-btn { flex: none; }

/* 杠杆滑杆：iOS 风格（4px 圆角轨道 + 蓝色已选段 + 白色圆形滑块带投影）
   已选比例由 JS 写进 --range-pct（原生 range 没法用纯 CSS 表达进度） */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: linear-gradient(
    to right,
    var(--apple-blue) 0 var(--range-pct, 0%),
    var(--slider-track) var(--range-pct, 0%) 100%
  );
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -11px;
  border: 0;
  border-radius: 50%;
  background: var(--slider-knob);
  box-shadow: 0 0 0 0.5px var(--slider-knob-ring), var(--slider-knob-shadow);
  transition: transform var(--t-tap) var(--ease-ios);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.06); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring), var(--slider-knob-shadow); }

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--slider-track);
}
input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--apple-blue);
}
input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--slider-knob);
  box-shadow: 0 0 0 0.5px var(--slider-knob-ring), var(--slider-knob-shadow);
}

.calc {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line-soft);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.calc > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 12px;
  background: var(--surface-sunken);
}
.calc dt { font-size: 12px; color: var(--ink-2); }
.calc dd { margin: 0; font-size: 13px; font-weight: 500; font-family: var(--font-mono); }

/* 一键开仓 */
.trade-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trade-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 13px 10px;
  border-radius: var(--r-xl);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 600;
  transition: background-color var(--t-fast) var(--ease-inout),
              box-shadow var(--t-base) var(--ease-ios),
              transform var(--t-base) var(--ease-spring);
}
.trade-btn em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  opacity: 0.85;
}
.trade-btn.long { background: var(--apple-green); box-shadow: 0 4px 16px rgba(52, 199, 89, 0.3); }
.trade-btn.long:hover { background: var(--green-hover); transform: translateY(-1px); }
.trade-btn.short { background: var(--apple-red); box-shadow: 0 4px 16px rgba(255, 59, 48, 0.3); }
.trade-btn.short:hover { background: var(--red-hover); transform: translateY(-1px); }
.trade-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.order-hint { font-size: 11px; color: var(--ink-2); text-align: center; }
.order-hint.warn { color: var(--apple-red); }

/* 持仓风险标 */
.risk-tag {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 7px;
  margin-left: 6px;
  border-radius: var(--r-pill);
  background: var(--short-soft);
  color: var(--short-ink);
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
}

/* ==========================================================================
   底部面板：持仓 / 记录 / 统计
   ========================================================================== */

.bottom-panel {
  flex: none;
  height: clamp(132px, 17vh, 190px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.tabs-spacer { flex: 1; }
.tab {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: background-color var(--t-fast) var(--ease-inout),
              color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.tab:hover { background: var(--fill-1); color: var(--ink); }
.tab.active { background: var(--accent-soft); color: var(--apple-blue); }
.count {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--fill-2);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tab.active .count { background: var(--accent-soft-strong); color: var(--apple-blue); }

.tab-panel { display: none; }
.tab-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  animation: panel-in var(--t-fast) var(--ease-ios);
}
.tab-panel.active .table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
.tab-panel.active .stats-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.tab-panel.active .empty:not([hidden]) {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; }
.data-table td.num { font-family: var(--font-mono); }
.data-table .pair-cell { font-weight: 600; letter-spacing: -0.01em; }

.dir-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
}
.dir-pill.long { background: var(--long-soft); color: var(--long-ink); }
.dir-pill.short { background: var(--short-soft); color: var(--short-ink); }

.row-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--fill-1);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  transition: background-color var(--t-fast) var(--ease-inout),
              transform var(--t-base) var(--ease-spring);
}
.row-btn:hover { background: var(--fill-3); }

.empty { padding: 44px 20px; text-align: center; font-size: 13px; color: var(--ink-2); }

.pos { color: var(--up); }
.neg { color: var(--down); }
.muted { color: var(--ink-2); }

/* 统计 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  padding: 20px;
}
.stat-cell { padding: 14px 16px; border-radius: var(--r-xl); background: var(--surface-sunken); }
.stat-cell span { display: block; font-size: 11px; color: var(--ink-2); margin-bottom: 5px; }
.stat-cell strong { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }

/* ==========================================================================
   页脚
   ========================================================================== */

.foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 4px;
  font-size: 11px;
  color: var(--ink-2);
}
/* ==========================================================================
   弹窗
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  /* 必须高于移动端固定 Trading Dock(90) 与底部 Sheet(95)，否则弹窗底部会被 Dock 盖住 */
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--veil);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: veil-in var(--t-fast) var(--ease-inout);
}
.modal[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  animation: card-in var(--t-slow) var(--ease-ios);
}
.modal-card.wide { max-width: 720px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
}
.modal-head h3 { font-size: 17px; }

.modal-body {
  padding: 0 22px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-note { font-size: 12px; color: var(--ink-2); }

/* 玩法 */
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.glossary { margin: 4px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 13px; }
.glossary dt { color: var(--ink); font-weight: 600; white-space: nowrap; }
.glossary dd { margin: 0; color: var(--ink-2); }

/* 战绩卡 */
.share-body { align-items: center; }
.share-body img {
  width: auto;
  max-width: 100%;
  max-height: 54vh;
  object-fit: contain;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.share-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* 结算 */
.result-head { text-align: center; padding: 6px 0 2px; }
.result-score {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.result-score.pos { color: var(--up); }
.result-score.neg { color: var(--down); }
.result-sub { margin-top: 6px; font-size: 13px; color: var(--ink-2); }

/* ==========================================================================
   提示条
   ========================================================================== */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  padding: 11px 20px;
  border-radius: var(--r-pill);
  background: var(--toast-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--t-base) var(--ease-ios);
}
.toast.error { background: rgba(201, 43, 34, 0.95); }
.toast.good { background: rgba(36, 137, 63, 0.95); }
.toast.out { animation: toast-out var(--t-fast) var(--ease-exit) forwards; }

/* ==========================================================================
   动画
   ========================================================================== */

@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }

/* iOS 式呈现：上浮到位后轻微回落，模拟弹簧阻尼 */
@keyframes card-in {
  0%   { opacity: 0; transform: translateY(16px) scale(0.96); }
  62%  { opacity: 1; transform: translateY(-2px) scale(1.004); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-in {
  0%   { opacity: 0; transform: translateY(18px) scale(0.96); }
  66%  { opacity: 1; transform: translateY(-3px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}
@keyframes sheet-in {
  from { transform: translateY(14%); opacity: 0.7; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   响应式：桌面端（≥1200px）保持现状，另有平板（768~1199）与移动端（<768）两套排布
   ========================================================================== */

/* ---------- 窄桌面：收窄三栏，不改变结构 ---------- */
@media (max-width: 1199px) {
  .workspace { grid-template-columns: 200px minmax(0, 1fr) 268px; gap: 12px; }
  .overview { grid-template-columns: minmax(200px, 1fr) minmax(0, 1.6fr); gap: 20px; }
  .order-body { padding: 0 16px; gap: 12px; }
  .order-actions { padding: 12px 16px 16px; }
  .chart-head { gap: 12px; padding: 14px 16px 10px; }
  .quote-ba { display: none; }
  .chart-title .tag { display: none; }
}

/* ==========================================================================
   平板（768 ~ 1023px）
   货币对列表让位给「当前交易对选择器」，保证图表与下单有足够宽度
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; }
  .market-panel { display: none; }

  .pair-select { display: grid; }
  .chart-title, .chart-quote { display: none; }
  .chart-head { justify-content: flex-end; }

  /* 五项指标挤一行会被截断，改三列两行 */
  .overview-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* 表格在平板宽度下不再横向滚动 */
  .data-table { min-width: 0; }
}

/* ==========================================================================
   移动端（<768px）—— 不是桌面的缩小版，而是重新组织的信息架构
     顶栏 → 账户摘要 → 当前交易对 → 图表 → 实时状态 → 挑战 → 持仓
     底部固定 Trading Dock（保证金 / 杠杆 / 做多 / 做空）
   ========================================================================== */

@media (max-width: 767px) {
  :root { --dock-h: 124px; }

  .app { height: 100vh; height: 100dvh; }

  /* 页面滚动；底部为固定 Dock 预留空间，内容不会被盖住 */
  .page {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 16px calc(var(--dock-h) + env(safe-area-inset-bottom, 0px) + 14px);
    overflow-x: hidden;
    overflow-y: auto;
  }
  .foot { display: none; }

  /* ---------- 顶栏：品牌 + 一个菜单入口 ---------- */
  .topbar-inner {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 6px 16px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 16px; }
  .brand-mark svg { width: 26px; height: 26px; }
  .top-nav { display: none; }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .menu-btn .ico { width: 18px; height: 18px; }

  /* 关闭按钮放大到 40px，贴近 44px 触控目标 */
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn svg { width: 16px; height: 16px; }

  /* ---------- 账户摘要 ---------- */
  .market-panel { display: none; }

  .overview {
    display: block;
    padding: 10px 14px;
    border-radius: var(--r-2xl);
    flex: none;
  }
  /* 「尚未开始 / 风险」一行贴到权益行右侧，压缩卡片高度 */
  .overview-lead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 10px;
  }
  .eyebrow { grid-column: 1; grid-row: 1; font-size: 10px; margin-bottom: 0; }
  .eyebrow .chip { height: 16px; padding: 0 8px; font-size: 10px; }
  .equity-row { grid-column: 1 / -1; grid-row: 2; margin-top: 2px; }
  .equity { font-size: 23px; }
  .return-badge { height: 20px; padding: 0 8px; font-size: 11px; }
  .overview-sub {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    font-size: 11px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .overview-metrics { display: none; }
  .account-brief {
    display: grid;
    margin-top: 5px;
    padding-top: 5px;
    gap: 8px;
  }
  .brief-cell strong { font-size: 13px; }
  .brief-cell span { line-height: 1.2; }
  .brief-cell strong { line-height: 1.25; }
  .brief-more { min-height: 30px; }

  /* ---------- 当前交易对选择器 ---------- */
  .pair-select { display: grid; padding: 10px 14px; }
  .chart-title, .chart-quote { display: none; }

  /* ---------- 图表 ---------- */
  .workspace {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
    flex: none;
  }
  .chart-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--r-2xl);
    flex: none;
  }
  .chart-head {
    order: 2;
    justify-content: space-between;
    gap: 10px;
    padding: 0 14px 8px;
    align-items: center;
  }
  .chart-tools { width: 100%; justify-content: space-between; }
  .seg { padding: 5px 13px; font-size: 12px; }
  #btnFitChart { min-height: 32px; }

  .news-bar { order: 3; margin: 0 14px 5px; padding: 5px 10px; gap: 6px; min-height: 26px; }
  .news-title { font-size: 11px; }
  .news-time { display: none; }

  /* 高度由 JS 按「可视高度 − Dock − 图表上方内容」算出，保证 K 线完整露出且不被 Dock 压住 */
  .chart-stage {
    order: 4;
    flex: none;
    height: var(--chart-h, clamp(190px, 42vh, 360px));
    min-height: 0;
    padding: 0 4px;
  }

  .time-bar {
    order: 5;
    flex-wrap: nowrap;
    padding: 6px 14px 7px;
    margin-top: 0;
    gap: 8px;
    border-top: 0;
  }
  .time-info { gap: 8px; }
  .time-info strong { font-size: 12px; }
  .time-progress { font-size: 10px; }
  .live-indicator { font-size: 10px; }

  /* ---------- 底部面板：持仓 / 成交记录 / 统计 ---------- */
  .bottom-panel {
    position: static;
    flex: none;
    height: auto;
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  .sheet-grip { display: none; }
  .tabs { flex-wrap: nowrap; gap: 2px; padding: 8px 10px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .tab-panel.active { display: block; }
  .tab-panel.active .table-wrap { overflow: visible; }
  .tab-panel.active .empty:not([hidden]) {
    display: block;
    padding: 28px 16px;
    text-align: center;
  }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; }
  .stat-cell { padding: 12px; }

  /* 持仓 / 成交记录 → 卡片 */
  .positions-table, .history-table { min-width: 0; }
  .positions-table thead, .history-table thead { display: none; }
  .positions-table tbody, .history-table tbody { display: block; padding: 12px; }
  .positions-table tr, .history-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    margin-bottom: 10px;
    padding: 14px;
    border-radius: var(--r-xl);
    background: var(--surface-sunken);
  }
  .positions-table tr:last-child, .history-table tr:last-child { margin-bottom: 0; }
  .positions-table td, .history-table td {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    padding: 0;
    border: 0;
    white-space: normal;
    text-align: left;
  }
  .positions-table td::before, .history-table td::before {
    content: attr(data-label);
    flex: none;
    font-size: 11px;
    color: var(--ink-2);
  }
  .positions-table td:nth-child(1)::before,
  .positions-table td:nth-child(9)::before,
  .history-table td:nth-child(2)::before,
  .history-table td:nth-child(10)::before { display: none; }
  .positions-table td.num, .history-table td.num { text-align: left; }
  .positions-table tbody tr:hover, .history-table tbody tr:hover { background: var(--surface-sunken); }
  .positions-table td:nth-child(1),
  .positions-table td:nth-child(8),
  .positions-table td:nth-child(9),
  .history-table td:nth-child(1),
  .history-table td:nth-child(10) { grid-column: span 2; }
  .positions-table td:nth-child(1), .history-table td:nth-child(2) { font-size: 16px; }
  .positions-table td:nth-child(8), .history-table td:nth-child(9) { font-size: 18px; }
  .positions-table .row-btn { width: 100%; min-height: 44px; font-size: 14px; }

  /* ---------- 下单设置：底部 Sheet ---------- */
  .order-column { display: contents; }
  .order-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    display: none;
    flex-direction: column;
    max-height: 86vh;
    overflow: hidden;
    background: var(--surface);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: sheet-in var(--t-base) var(--ease-ios);
  }
  .order-panel.open { display: flex; }
  .order-panel .card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 10px;
  }
  .order-panel .card-head h2 { font-size: 17px; }
  .order-panel .card-hint { margin-left: auto; }
  .sheet-only { display: inline-flex; }
  .order-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 16px 16px;
    overflow-y: auto;
    min-height: 0;
  }
  .order-panel .calc { display: grid; }
  .field-label { font-size: 12px; }
  #marginInput { padding: 12px 14px; font-size: 16px; }
  .input-row .quiet-btn { min-height: 44px; padding: 0 16px; font-size: 14px; }
  input[type="range"] { height: 34px; }

  /* ---------- 固定 Trading Dock ---------- */
  .order-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 5px 16px calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    box-shadow: var(--shadow-lg);
    background: var(--surface);
    transition: transform var(--t-base) var(--ease-ios);
  }
  /* 非必要就收起来：弹窗 / 底部 Sheet 打开时，以及向下翻阅内容时，
     避免固定 Dock 压住战绩卡预览、持仓卡片等内容 */
  body.overlay-open .order-actions,
  body.dock-hidden .order-actions {
    transform: translateY(calc(100% + 16px));
    pointer-events: none;
  }
  .dock-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .dock-param { min-height: 36px; }
  .dock-param strong { font-size: 15px; }
  .trade-actions { gap: 10px; }
  .trade-btn { min-height: 56px; padding: 8px; font-size: 16px; gap: 2px; }
  .trade-btn em { font-size: 11px; }
  .dock-start { min-height: 56px; }
  /* Dock 里的原因提示：只在被拦截时出现（未开始 / 机会用完由「开始挑战」按钮表达） */
  .order-hint { display: none; }
  .order-hint.warn {
    display: block;
    font-size: 10px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .order-hint[hidden] { display: none; }

  /* 提示条要浮在 Trading Dock 之上，否则被按钮盖住 */
  .toasts { bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px) + 14px); }
}

/* 横屏手机：快速交易固定到右栏，纵向空间尽量留给 K 线 */
@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
  .order-actions {
    left: auto;
    right: 0;
    top: var(--topbar-h, 57px);
    bottom: 0;
    width: 196px;
    justify-content: flex-end;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-radius: var(--r-2xl) 0 0 var(--r-2xl);
  }
  .dock-summary { grid-template-columns: 1fr; }
  .trade-btn { min-height: 56px; }

  .page {
    padding-right: calc(208px + env(safe-area-inset-right, 0px));
    padding-bottom: 10px;
    gap: 8px;
  }

  /* 横屏把 K 线提到最前，账户与挑战、持仓留在下方滚动区 */
  .workspace { order: -1; }

  /* 账户卡与工具行压紧，尽量少占纵向 */
  .overview { padding: 8px 14px; }
  .overview-lead { grid-template-columns: minmax(0, 1fr) auto; }
  .pair-select { padding: 8px 14px; }
  .chart-head { padding: 0 14px 6px; }
  .chart-stage { min-height: 120px; }
}


/* ==========================================================================
   iOS 触感反馈
   按下立即收缩（110ms，线性收尾），松开按弹性曲线回弹
   弹性曲线只作用于位移与缩放，颜色始终走对称缓动
   ========================================================================== */

.solid-btn:active, .quiet-btn:active, .trade-btn:active,
.nav-btn:active, .seg:active, .tab:active,
.pair-row:active, .row-btn:active,
.icon-btn:active {
  transform: scale(0.97);
  transition: transform var(--t-tap) var(--ease-ios),
              background-color var(--t-tap) var(--ease-inout),
              color var(--t-tap) var(--ease-inout);
}

/* 无障碍：尊重系统的减弱动效设置 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 视口过矮（例如笔记本矮窗口）时退回可滚动，避免内容被裁掉 */
@media (min-width: 768px) and (max-height: 640px) {
  .app { overflow: auto; }
  .page { overflow: visible; }
  .chart-stage { min-height: 200px; }
}

/* 矮窗口下桌面三栏放不下明细，先保证表单与按钮完整 */
@media (min-width: 768px) and (max-height: 760px) {
  .calc { display: none; }
}
