/**
 * 全局导航主题变量 — 与 service.html .nav-header / .nav-title 对齐
 * 缺省配色与后台预设「深海极蓝 deep_blue」一致，避免首屏先绿后蓝的闪烁；
 * site-theme-loader 仍可按 Admin 其它预设覆盖。
 */
:root {
  --nav-bg: #0c1220;
  --nav-text: #f0f4f8;
  /* Mine / 卡片页（与 mine.html :root 对齐，可由 site-theme-loader 覆盖） */
  --mine-bg: #0f1419;
  --mine-bg2: #151d2a;
  --mine-card: #1b2636;
  --mine-text: #f2f4f7;
  --mine-muted: #8b95a5;
  --mine-accent: #2b7fff;
  --mine-accent-dim: rgba(43, 127, 255, 0.15);
  /* 与 mineAccent 同步；合约/行情等页 var(--theme-green) 同源，site-theme-loader 会覆盖 */
  --theme-green: #2b7fff;
  --theme-green-rgb: 43, 127, 255;
  /* 底栏顶部分割线（由 site-theme-loader 按主题色写入） */
  --mine-accent-border: rgba(43, 127, 255, 0.22);
  /* 二级页 body 渐变背景 */
  --page-gradient-start: #0f172a;
  --page-gradient-end: #1e293b;
  /* 随明暗主题由 site-theme-loader 覆盖；缺省按深色 */
  --mine-hairline: rgba(255, 255, 255, 0.08);
  --mine-icon-chip-bg: rgba(255, 255, 255, 0.06);
  --mine-icon-chip-fg: rgba(255, 255, 255, 0.88);
  /* H5 底部 Tab：实测 icon+文案+padding 高于 60px，略放大避免一级页最后一行被挡住 */
  --bottom-nav-height: 72px;
  --bottom-safe-padding: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
  /* iOS 刘海 / 横屏安全区（需 viewport-fit=cover） */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

@media (max-width: 480px) {
  :root {
    --bottom-nav-height: 68px;
  }
}

@media (min-width: 768px) {
  :root {
    --bottom-nav-height: 76px;
  }
}

@supports not (padding-bottom: env(safe-area-inset-bottom)) {
  :root {
    --bottom-safe-padding: calc(var(--bottom-nav-height) + 22px);
  }
}

/**
 * 底部五栏导航：各 H5 页共用，避免切换页时高度/位置跳动。
 * 背景用 --mine-bg2，与后台「样式」里二级页/Mine 色系一致。
 */
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  background: var(--mine-bg2);
  border-top: 1px solid var(--mine-accent-border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  flex-shrink: 0;
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  color: var(--mine-muted);
  font-size: 11px;
  border-radius: 6px;
  margin: 0 4px;
}

.bottom-nav .nav-item:active {
  background: var(--mine-accent-dim);
}

.bottom-nav .nav-item.active {
  color: var(--mine-accent);
}

.bottom-nav .nav-item .nav-icon,
.bottom-nav .nav-item .nav-label {
  color: inherit;
}

.bottom-nav .nav-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  flex-shrink: 0;
}

/* 仅约束内置直连 SVG；自定义上传经 .nav-custom-theme-icon 内联，避免 fill:none 掏空实心图标 */
.bottom-nav .nav-icon > svg {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px;
  min-height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav .nav-label {
  font-size: 11px;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .bottom-nav {
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }

  .bottom-nav .nav-item {
    padding: 6px 2px;
    gap: 4px;
  }
}

/* 顶栏：黑底白字；返回与 i/svg 使用 var(--nav-text) */
.global-black-header,
.header.global-black-header {
  display: flex;
  align-items: center;
  padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) 12px max(12px, var(--safe-left));
  background: var(--nav-bg) !important;
  color: var(--nav-text);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  box-sizing: border-box;
  border-bottom: none;
}

.global-black-header .back-btn,
.header.global-black-header .back-btn {
  cursor: pointer;
  padding: 5px;
  color: var(--nav-text) !important;
  background: transparent !important;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: static !important;
  top: auto !important;
  left: auto !important;
  width: auto;
  height: auto;
  z-index: 1;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.global-black-header .back-btn svg,
.header.global-black-header .back-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
}

.global-black-header i,
.header.global-black-header i {
  color: var(--nav-text);
}

.global-black-header > h1,
.header.global-black-header > h1 {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--nav-text) !important;
  margin: 0 30px 0 0;
  line-height: 1.2;
}

/**
 * 浅色站点主题（如纯白 / 跟随时间白天）：纠正仍写死 #fff/#888 的页面主色区。
 * 不含 K 线全屏、暗色弹层等已自带深色底的区块（那些继续用局部 #fff）。
 */
html[data-theme-brightness='light'] {
  color-scheme: light;
}

html[data-theme-brightness='dark'] {
  color-scheme: dark;
}

html[data-theme-brightness='light'] .delivery-metrics-right,
html[data-theme-brightness='light'] .delivery-metrics-right .val,
html[data-theme-brightness='light'] .delivery-balance-row,
html[data-theme-brightness='light'] .delivery-balance-row .label,
html[data-theme-brightness='light'] .delivery-pair-row .pair-text,
html[data-theme-brightness='light'] .header-price-row .pair-text,
html[data-theme-brightness='light'] .perpetual-order-type,
html[data-theme-brightness='light'] .perpetual-order-type .label,
html[data-theme-brightness='light'] .perpetual-qty-input-wrap input,
html[data-theme-brightness='light'] .perpetual-lots-row input,
html[data-theme-brightness='light'] .action-icon-wrap,
html[data-theme-brightness='light'] .mine-coin-icon,
html[data-theme-brightness='light'] .detail-name,
html[data-theme-brightness='light'] .crypto-cards .crypto-pair,
html[data-theme-brightness='light'] .card-price,
html[data-theme-brightness='light'] .detail-price,
html[data-theme-brightness='light'] .detail-card-derivatives .derivatives-price,
html[data-theme-brightness='light'] .derivatives-section .detail-card-derivatives .detail-name,
html[data-theme-brightness='light'] .derivatives-section .detail-card-derivatives .derivatives-price,
html[data-theme-brightness='light'] .pair-dropdown-row .pair-name,
html[data-theme-brightness='light'] .pair-menu-row .pair-name {
  color: var(--mine-text) !important;
}

html[data-theme-brightness='light'] .delivery-tab:not(.active),
html[data-theme-brightness='light'] .perpetual-buy-sell-toggle .btn:not(.active),
html[data-theme-brightness='light'] .perpetual-balance-row,
html[data-theme-brightness='light'] .perpetual-balance-box,
html[data-theme-brightness='light'] .perpetual-orderbook-title,
html[data-theme-brightness='light'] .perpetual-hint,
html[data-theme-brightness='light'] .perpetual-lots-row .label,
html[data-theme-brightness='light'] .perpetual-leverage-label,
html[data-theme-brightness='light'] .header-tab:not(.active),
html[data-theme-brightness='light'] .detail-pair,
html[data-theme-brightness='light'] .coin-price,
html[data-theme-brightness='light'] .about-text,
html[data-theme-brightness='light'] .lang-modal-title,
html[data-theme-brightness='light'] .lang-item-label,
html[data-theme-brightness='light'] .spot-amount-base,
html[data-theme-brightness='light'] .form-group label {
  color: var(--mine-muted) !important;
}

html[data-theme-brightness='light'] .action-icon-wrap,
html[data-theme-brightness='light'] .mine-coin-icon {
  background: var(--mine-icon-chip-bg) !important;
  color: var(--mine-icon-chip-fg) !important;
}

html[data-theme-brightness='light'] .bottom-nav .nav-item {
  color: var(--mine-muted) !important;
}

html[data-theme-brightness='light'] .bottom-nav .nav-item.active,
html[data-theme-brightness='light'] .bottom-nav .nav-item.active .nav-icon,
html[data-theme-brightness='light'] .bottom-nav .nav-item.active .nav-label {
  color: var(--mine-accent) !important;
}

html[data-theme-brightness='light'] .delivery-tabs-row,
html[data-theme-brightness='light'] .mine-coin-row,
html[data-theme-brightness='light'] .menu-item {
  border-color: var(--mine-hairline) !important;
}

html[data-theme-brightness='light'] .crypto-card,
html[data-theme-brightness='light'] .detail-card,
html[data-theme-brightness='light'] .detail-card-derivatives,
html[data-theme-brightness='light'] .about-card,
html[data-theme-brightness='light'] .mine-coin-list-wrap,
html[data-theme-brightness='light'] .menu-group-wrap {
  background: var(--mine-card) !important;
  border-color: var(--mine-hairline) !important;
}

html[data-theme-brightness='light'] .perpetual-order-type,
html[data-theme-brightness='light'] .perpetual-qty-input-wrap,
html[data-theme-brightness='light'] .perpetual-lots-row input,
html[data-theme-brightness='light'] .perpetual-stepper-btn,
html[data-theme-brightness='light'] .perpetual-buy-sell-toggle {
  background: var(--mine-card) !important;
  border-color: var(--mine-hairline) !important;
  color: var(--mine-text) !important;
}

html[data-theme-brightness='light'] .perpetual-balance-box .balance-value {
  color: var(--mine-text) !important;
}

html[data-theme-brightness='light'] .trading-header,
html[data-theme-brightness='light'] .contract-header {
  background: var(--mine-bg2) !important;
  color: var(--mine-text) !important;
  border-bottom-color: var(--mine-hairline) !important;
}
