/* ============================================================
 * 镜相 · 全局补充样式（pencil 主题）
 * Tailwind Play CDN 负责 utility 类，这里只放 Tailwind 不便表达的部分：
 * 字体栈、辉光/网格装饰、滚动条、状态胶囊、激活态、ECharts 容器、Toast。
 * ============================================================ */

:root {
  --bg: #f6f7fb;
  --bg-2: #eef1f6;
  --bg-3: #ffffff;
  --card: #ffffff;
  --card-2: #f8fafc;
  --line: #e4e7ee;
  --line-2: #d5dae4;
  --purple: #6d28d9;
  --purple-soft: #f1eafe;
  --cyan: #0891b2;
  --up: #0f9f6e;
  --down: #d92d20;
  --text: #0b1220;
  --text-2: #526071;
  --muted: #7b8798;
  --on-accent: #ffffff;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --grid-line: #0b12200a;

  --font-sans: "Inter", "Noto Sans SC", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-geist: "Geist Mono", ui-monospace, SFMono-Regular, monospace;
  --font-mono: "IBM Plex Mono", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", ui-monospace, SFMono-Regular, monospace;
}

html[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-2: #0b0b12;
  --bg-3: #0d0d12;
  --card: #131318;
  --card-2: #0a0a0a;
  --line: #181820;
  --line-2: #22222a;
  --purple: #a855f7;
  --purple-soft: #2a1b3d;
  --cyan: #38bdf8;
  --up: #16c784;
  --down: #ea3943;
  --text: #ffffff;
  --text-2: #a1a1aa;
  --muted: #63636e;
  --on-accent: #ffffff;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --grid-line: #ffffff0a;
}

html:not(.i18n-ready) body {
  opacity: 0;
}
html.i18n-ready body {
  opacity: 1;
  transition: opacity 0.15s ease;
}


html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* 通用字体工具（动态渲染时使用，避免依赖 arbitrary 类被裁剪） */
.font-geist {
  font-family: var(--font-geist);
}
.font-mono-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- 装饰：辉光 / 网格 ---------- */
.glow-purple {
  background-image: radial-gradient(ellipse 50% 50% at 50% 50%, #a855f740 0%, #a855f700 100%);
}
.glow-cyan {
  background-image: radial-gradient(ellipse 50% 50% at 50% 50%, #38bdf830 0%, #38bdf800 100%);
}
.grid-bg {
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* 缓慢呼吸动画：让 banner 有生命力，而不是一张静态图 */
@keyframes glow-breathe {
  0%,
  100% {
    opacity: 0.72;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}
.glow-purple,
.glow-cyan {
  animation: glow-breathe 11s ease-in-out infinite;
  will-change: transform, opacity;
}
.glow-cyan {
  animation-delay: -5.5s;
}
@media (prefers-reduced-motion: reduce) {
  .glow-purple,
  .glow-cyan {
    animation: none;
  }
}

/* ---------- 细滚动条（信号流列表等） ---------- */
.scroll-thin {
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.scroll-thin::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.scroll-thin::-webkit-scrollbar-track {
  background: transparent;
}
.scroll-thin::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 999px;
  border: 0;
}
.scroll-thin:hover::-webkit-scrollbar-thumb {
  background: var(--muted);
}

/* 列表上下渐隐，滚动时更有层次 */
.fade-mask {
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 14px,
    #000 calc(100% - 14px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 14px,
    #000 calc(100% - 14px),
    transparent 100%
  );
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ---------- 语言胶囊激活态 ---------- */
[data-lang-opt] {
  transition: background 0.15s, color 0.15s;
}
[data-lang-opt].is-active {
  background: var(--purple);
  color: var(--on-accent);
  font-weight: 600;
}

/* ---------- 顶部导航按钮（统一样式，无激活高亮） ---------- */
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-link:hover {
  color: var(--text);
  background: var(--card-2);
  border-color: var(--line);
}

/* 品牌字标：移动端隐藏，sm 断点起显示（避开 .hidden 的 !important） */
.brand-wordmark {
  display: none;
}
@media (min-width: 640px) {
  .brand-wordmark {
    display: flex;
  }
}

/* ---------- 连接状态胶囊 ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.status-pill.connected::before,
.status-pill.live::before {
  background: var(--up);
  box-shadow: 0 0 8px rgba(22, 199, 132, 0.7);
}
.status-pill.connecting::before {
  background: #f6b64b;
}
.status-pill.error::before {
  background: var(--down);
}
.status-pill.polling::before {
  background: var(--cyan);
}

/* ---------- 时间 / 数值等宽 ---------- */
.clock,
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- 周期 / 图表 Tab 激活态 ---------- */
#period-tabs button.active {
  background: var(--purple);
  color: #fff;
  font-weight: 700;
}
.chart-tab {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chart-tab.active {
  background: var(--purple);
  color: #fff;
  font-weight: 700;
}

/* ---------- 个人中心 Tabs / 面板 ---------- */
.acct-panel {
  display: flex;
}
.acct-tab {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.acct-tab:hover {
  color: var(--text);
}
.acct-tab.active {
  background: var(--purple);
  color: #fff;
}

/* ---------- 账户 A/B 分段切换 ---------- */
.account-tab {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.account-tab.active {
  background: var(--purple);
  color: #fff;
}

/* ---------- 个人中心侧栏激活态 ---------- */
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: inherit;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.side-item:hover {
  background: var(--card-2);
  color: var(--text);
}
.side-item.active {
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 600;
}

/* ---------- 表单 ---------- */
.field-input {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input::placeholder {
  color: var(--muted);
}
.field-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}
select.field-input {
  appearance: none;
  cursor: pointer;
}

/* ---------- 表格行 hover ---------- */
.row-hover:hover {
  background: var(--card-2);
}

/* 持仓操作展开行 */
.pos-actions-row {
  display: none;
}
.pos-actions-row.open {
  display: table-row;
}

/* 日志表格：保持单行不换行，窄屏改为横向滚动 */
.api-log-table th,
.api-log-table td,
.orders-table th,
.orders-table td {
  white-space: nowrap;
}

/* 迷你操作按钮 */
.mini-btn {
  border: 1px solid var(--line-2);
  background: var(--card-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mini-btn:hover {
  color: var(--text);
  border-color: var(--purple);
}
.mini-btn.primary {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}
.mini-btn.close {
  color: var(--down);
  border-color: rgba(234, 57, 67, 0.4);
}
.mini-btn.close:hover {
  background: rgba(234, 57, 67, 0.12);
}
.mini-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- ECharts 容器 ---------- */
#candle-chart {
  width: 100%;
  height: 500px;
}
#equity-chart {
  width: 100%;
  height: 500px;
}
.echarts-empty {
  display: grid;
  place-items: center;
  height: 500px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Toast ---------- */
.ui-toast:empty {
  display: none;
}
.ui-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 999;
}

/* ---------- 访客禁用 ---------- */
.guest-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- 空态 ---------- */
.empty-state {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 24px 8px;
}

/* ============================================================
 * 移动端适配
 * ============================================================ */

/* 汉堡按钮（仅移动端显示） */
.nav-burger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
}
.nav-burger:hover {
  border-color: var(--purple);
}

/* 抽屉 */
.nav-drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav-drawer-mask.open {
  opacity: 1;
  pointer-events: auto;
}
.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(86vw, 340px);
  background: var(--bg-3);
  border-left: 1px solid var(--line);
  z-index: 81;
  transform: translateX(100%);
  transition: transform 0.26s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  overflow-y: auto;
}
.nav-drawer.open {
  transform: translateX(0);
}
.nav-drawer .dr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 12px;
}
.nav-drawer .dr-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
}
.nav-drawer a,
.nav-drawer .dr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  min-height: 46px;
  cursor: pointer;
}
.nav-drawer a:hover,
.nav-drawer .dr-item:hover {
  background: var(--card-2);
  color: var(--text);
}
.nav-drawer .dr-lang {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin: 8px 8px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}
.nav-drawer .dr-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 8px;
}
body.drawer-open {
  overflow: hidden;
}

/* 平板/手机断点（< 1024px） */
@media (max-width: 1023px) {
  /* 隐藏桌面导航中段与次要操作，仅保留汉堡 */
  [data-nav] {
    display: none !important;
  }
  [data-nav-actions] > *:not(.nav-burger) {
    display: none !important;
  }
  .nav-burger {
    display: inline-flex;
  }

  /* 图表高度下调 */
  #candle-chart,
  #equity-chart {
    height: 360px;
  }
  .backtest-chart {
    height: 300px;
  }
  .attr-chart {
    height: 180px;
  }

  /* 个人中心侧栏：移动端改为横向滚动菜单 */
  .side-menu {
    flex-direction: row !important;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .side-menu::-webkit-scrollbar {
    display: none;
  }
  .side-menu .side-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .side-menu .side-group-label {
    display: none;
  }

  /* iOS 输入缩放：移动端字号 ≥16px */
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

/* 手机断点（< 640px） */
@media (max-width: 639px) {
  .app-h1 {
    font-size: 38px !important;
  }
  .app-h2 {
    font-size: 24px !important;
  }
  .hero-card {
    width: 100% !important;
    max-width: 100% !important;
  }
  .metric-value {
    font-size: 20px !important;
  }
}

/* ============================================================
 * Theme: light overrides for existing utility classes
 * ============================================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover {
  color: var(--purple);
  border-color: var(--purple);
}

html[data-theme="light"] .bg-\[\#0A0A0A\] { background-color: var(--bg) !important; }
html[data-theme="light"] .bg-\[\#0B0B12\] { background-color: var(--bg-2) !important; }
html[data-theme="light"] .bg-\[\#0D0D12\] { background-color: var(--bg-3) !important; }
html[data-theme="light"] .bg-\[\#131318\] { background-color: var(--card) !important; }
html[data-theme="light"] .bg-\[\#181820\] { background-color: var(--line) !important; }
html[data-theme="light"] .bg-\[\#22222A\] { background-color: var(--card-2) !important; }
html[data-theme="light"] .bg-\[\#2A1B3D\] { background-color: var(--purple-soft) !important; }
html[data-theme="light"] .bg-\[\#0F0F14\] { background-color: var(--card) !important; }

html[data-theme="light"] .border-\[\#181820\] { border-color: var(--line) !important; }
html[data-theme="light"] .border-\[\#22222A\] { border-color: var(--line-2) !important; }
html[data-theme="light"] .border-\[\#A855F740\] { border-color: #ddd6fe !important; }
html[data-theme="light"] .border-\[\#A855F7\] { border-color: var(--purple) !important; }

html[data-theme="light"] .text-\[\#FFFFFF\],
html[data-theme="light"] .text-white { color: var(--text) !important; }
html[data-theme="light"] .text-\[\#A1A1AA\] { color: var(--text-2) !important; }
html[data-theme="light"] .text-\[\#63636E\] { color: var(--muted) !important; }
html[data-theme="light"] .text-\[\#E4E4E7\] { color: var(--text-2) !important; }
html[data-theme="light"] .text-\[\#E9D5FF\] { color: #4c1d95 !important; }
html[data-theme="light"] .text-\[\#A855F7\] { color: var(--purple) !important; }
html[data-theme="light"] .text-\[\#F6B64B\] { color: #b45309 !important; }
html[data-theme="light"] .hover\:text-white:hover { color: var(--text) !important; }
html[data-theme="light"] .hover\:text-\[\#A855F7\]:hover { color: var(--purple) !important; }

html[data-theme="light"] .bg-\[\#A855F7\].text-white,
html[data-theme="light"] .bg-\[\#A855F7\] .text-white,
html[data-theme="light"] .bg-\[\#A855F7\] .text-\[\#FFFFFF\],
html[data-theme="light"] .bg-\[\#16C784\].text-white,
html[data-theme="light"] .bg-\[\#16C784\] .text-white,
html[data-theme="light"] .bg-\[\#EA3943\].text-white,
html[data-theme="light"] .bg-\[\#EA3943\] .text-white {
  color: #fff !important;
}

html[data-theme="light"] [class*="shadow-["] {
  box-shadow: var(--shadow) !important;
}

html[data-theme="light"] .glow-purple {
  background-image: radial-gradient(ellipse 50% 50% at 50% 50%, #6d28d924 0%, #6d28d900 100%);
}
html[data-theme="light"] .glow-cyan {
  background-image: radial-gradient(ellipse 50% 50% at 50% 50%, #0891b214 0%, #0891b200 100%);
}
html[data-theme="light"] .grid-bg {
  opacity: 0.75;
}

html[data-theme="light"] .sub-banner {
  background: linear-gradient(120deg, #f3eeff 0%, #ffffff 72%) !important;
}

html[data-theme="light"] .nav-drawer-mask {
  background: rgba(15, 23, 42, 0.35);
}

html[data-theme="light"] .text-\[\#16C784\] { color: var(--up) !important; }
html[data-theme="light"] .text-\[\#EA3943\] { color: var(--down) !important; }
html[data-theme="light"] .text-\[\#38BDF8\] { color: var(--cyan) !important; }
html[data-theme="light"] .bg-\[\#16C7840D\] { background-color: #0f9f6e0d !important; }
html[data-theme="light"] .border-\[\#16C78433\] { border-color: #0f9f6e33 !important; }

.sub-banner {
  background: linear-gradient(120deg, var(--purple-soft) 0%, var(--card) 72%);
}

html[data-theme="light"] .bg-\[\#16C784\] .text-\[\#FFFFFF\],
html[data-theme="light"] .bg-\[\#EA3943\] .text-\[\#FFFFFF\],
html[data-theme="light"] .bg-\[\#F59E0B\] .text-\[\#FFFFFF\],
html[data-theme="light"] .bg-\[\#F59E0B\].text-white {
  color: #fff !important;
}

.font-ui {
  font-family: var(--font-sans);
}

/* Developer guide */
.docs-toc {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 18px;
  transition: color 0.15s, background 0.15s;
}
.docs-toc:hover,
.docs-toc.active {
  color: var(--purple);
  background: var(--purple-soft);
}
.docs-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: 92px;
}
.docs-section h2 {
  color: var(--text);
  font-size: 22px;
  line-height: 1.3;
  font-weight: 700;
}
.docs-section h3 {
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
}
.docs-section p,
.docs-list {
  color: var(--text-2);
  font-size: 13px;
  line-height: 22px;
}
.docs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 18px;
  list-style: disc;
}
.docs-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text-2);
  font-size: 12px;
  line-height: 20px;
}
.docs-step b {
  color: var(--purple);
  font-family: var(--font-mono);
  font-size: 11px;
}
.docs-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.docs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 900px) {
  .docs-grid { grid-template-columns: 1fr 1fr; }
}
.docs-code {
  overflow-x: auto;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-3);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.75;
  white-space: pre;
}
.docs-note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--purple);
  border-radius: 8px;
  background: var(--purple-soft);
  color: var(--text-2);
  font-size: 12px;
  line-height: 20px;
}
.docs-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.docs-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 12px;
}
.docs-table th,
.docs-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  color: var(--text-2);
}
.docs-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  background: var(--card-2);
}
.docs-table tr:last-child td { border-bottom: 0; }
.docs-table code {
  color: var(--purple);
  font-family: var(--font-mono);
  font-size: 11px;
}
.docs-copy,
.docs-inline-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.docs-copy {
  padding: 5px 10px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-2);
}
.docs-copy:hover { color: var(--purple); border-color: var(--purple); }
.docs-inline-cta {
  width: fit-content;
  padding: 9px 16px;
  background: var(--purple);
  color: var(--on-accent);
  text-decoration: none;
}

.docs-section,
.docs-card,
.docs-table-wrap,
.docs-grid {
  width: 100%;
}
