/* ==========================================================================
   缅A修炼手册 H5 · 全局设计令牌与共享组件
   --------------------------------------------------------------------------
   一比一复刻自小程序 app.wxss（1rpx = 0.5px 换算，375px 设计基准）。
   本文件只放全项目复用的令牌与组件；页面专属样式一律内联到各自 HTML 的
   <style>（对应小程序各页 *.wxss 的下沉原则）。
   【主题】默认暗色；body.theme-light 仅覆盖变量，引用 var() 处自动翻转。
   ========================================================================== */

:root {
  /* ---- 暗色令牌（默认） ---- */
  --bg: #050e1a;
  --card: rgba(10, 22, 38, .86);
  --card-2: rgba(10, 22, 38, .7);
  --seg-bg: #0a1626;
  --card-border: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .06);
  --text: #e8f3ff;
  --text-sub: #9fb3cc;
  --text-weak: #7d94b0;
  --text-faint: #5d7390;
  --accent: #00d4aa;
  --up: #ff5e3a;          /* 涨，A股红涨绿跌，全项目唯一取值 */
  --down: #2ecc71;        /* 跌 */
  --gold: #f0b429;        /* 热度/积分金 */
  --hover: rgba(255, 255, 255, .1);
  --hover-2: rgba(255, 255, 255, .06);
  --chip-bg: rgba(255, 255, 255, .06);
  --chip-text: #c7d6e8;
  --shadow: rgba(0, 0, 0, .30);
  /* H5 附加：tabBar（对齐小程序 app.json tabBar 配置） */
  --tabbar-bg: #08101c;
  --tabbar-color: #8ba3bf;
  --tabbar-h: 52px;
}

/* ---- 亮色主题：仅覆盖变量 ---- */
body.theme-light {
  --bg: #f4f6fa;
  --card: #ffffff;
  --card-2: #eef2f7;
  --seg-bg: #eef2f7;
  --card-border: rgba(0, 0, 0, .08);
  --line: rgba(0, 0, 0, .06);
  --text: #0b1a2b;
  --text-sub: #5a6b80;
  --text-weak: #8295a8;
  --text-faint: #a7b4c2;
  --accent: #008a72;
  --up: #d63c1e;
  --down: #157f4a;
  --gold: #b7791f;
  --hover: rgba(0, 0, 0, .05);
  --hover-2: rgba(0, 0, 0, .04);
  --chip-bg: rgba(0, 0, 0, .05);
  --chip-text: #3a4a5e;
  --shadow: rgba(0, 0, 0, .10);
  --tabbar-bg: #eef2f7;
}

/* 大盘情绪主题色：红盘（body.mkt-up）时全站 --accent 跟随 --up 翻红。
   必须定义在 body.theme-light 之后：亮色下红盘同样翻红（--up 亮色为深红）。 */
body.mkt-up { --accent: var(--up); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

/* ============ 1. 布局容器 ============ */
.page {
  min-height: 100vh;
  background: var(--bg);
  padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
  max-width: 480px;          /* H5 桌面限宽居中；375px 手机上等同满宽 */
  margin: 0 auto;
}
.page.has-tabbar { padding-bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; }
.grid2 > view, .grid2 > div { flex: 1 1 46%; min-width: 0; }

/* ============ 2. 文本语义 ============ */
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-weak); font-size: 11px; }
.sub { color: var(--text-sub); font-size: 12px; line-height: 1.6; }
.center { text-align: center; }
.tip { font-size: 11px; color: var(--text-weak); margin: 12px 0 0; }
.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.clamp2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* ============ 3. 卡片与区块标题 ============ */
.card {
  background: var(--card);
  border: 0.5px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 12px;
}
/* 统一卡片景深 */
.ncard, .tcard, .dcard, .zycard, .scard, .cloud-wrap, .card {
  box-shadow: 0 3px 10px var(--shadow);
  transition: transform .16s ease, box-shadow .2s ease;
}
.sec-title { position: relative; margin: 10px 0 4px; padding-left: 9px; font-size: 14px; color: var(--accent); font-weight: 600; }
.sec-title::before { content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 3px; border-radius: 1.5px; background: var(--accent); }
.sec-sub { font-size: 11px; color: var(--text-weak); font-weight: 400; margin-left: 4px; }

/* ============ 4. 分段控件（全项目统一） ============ */
.seg {
  display: flex;
  background: var(--seg-bg);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 8px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.seg-item { flex: 1; text-align: center; padding: 11px 0; color: var(--text-sub); font-size: 13px; transition: color .15s ease, background .2s ease; cursor: pointer; user-select: none; }
.seg-item.on { color: var(--accent); background: rgba(0, 212, 170, .12); font-weight: 600; }
.seg.sm .seg-item { font-size: 11.5px; padding: 10px 0; }

/* ============ 5. 标签 / 徽标 / 按钮 ============ */
.chip { display: inline-block; font-size: 11px; padding: 2px 6px; border-radius: 4px; color: var(--chip-text); background: var(--chip-bg); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; background: #2b6cff; color: #fff; }
.badge.b { background: rgba(255, 90, 70, .18); color: var(--up); border: 0.5px solid rgba(255, 90, 70, .28); }
.badge.s { background: rgba(46, 204, 113, .14); color: var(--down); border: 0.5px solid rgba(46, 204, 113, .28); }

.btn {
  display: block;
  text-align: center;
  background: linear-gradient(90deg, var(--accent), #00b894);
  color: #08101c;
  font-size: 15px;
  font-weight: 700;
  padding: 11px;
  border-radius: 10px;
  box-shadow: 0 3px 9px rgba(0, 212, 170, .28);
  transition: transform .15s ease, opacity .15s ease, box-shadow .2s ease;
  cursor: pointer;
}
.btn.hv { transform: scale(.98); opacity: .92; }
.btn.ghost { background: transparent; color: var(--accent); border: 0.5px solid var(--accent); }
.btn.ghost.hv { background: rgba(0, 212, 170, .12); transform: scale(.98); opacity: 1; }

/* ============ 6. 状态：加载 / 空 / 错误 ============ */
.state { padding: 30px 12px; text-align: center; }
.state-icon { display: block; font-size: 30px; margin-bottom: 6px; animation: statePulse 1.6s ease-in-out infinite; }
@keyframes statePulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.state-text { display: block; font-size: 13px; color: var(--text-weak); }
.state-sub { display: block; margin-top: 4px; font-size: 11px; color: var(--text-weak); }
.state-act { margin: 10px auto 0; max-width: 160px; }
.empty { padding: 24px 12px; text-align: center; font-size: 13px; color: var(--text-weak); }

/* ============ 7. 交互反馈 ============ */
.hv { opacity: .85; transition: opacity .15s; cursor: pointer; }
.hv-card { background: var(--hover); transform: scale(.985); transition: transform .16s, background .2s; }

/* ============ 8. H5 页头（小程序标题在系统导航栏，H5 自绘极简头） ============ */
.navbar {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 4px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--line);
}
.navbar .nb-title { flex: 1; text-align: center; font-size: 15px; font-weight: 600; }
.navbar .nb-back, .navbar .nb-theme {
  flex: none; width: 40px; text-align: center; font-size: 18px; color: var(--text-sub); cursor: pointer;
}
.navbar .nb-back:active, .navbar .nb-theme:active { opacity: .6; }

/* ============ 9. H5 底部 tabBar（对齐小程序 5 tab） ============ */
.footer-icp { text-align: center; color: var(--text-faint); font-size: 10px; padding: 18px 0 8px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--tabbar-bg);
  border-top: 0.5px solid var(--card-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: flex; width: 100%; max-width: 480px; margin: 0 auto; }
.tabbar a {
  flex: 1; text-align: center; padding: 6px 0 5px; font-size: 10px;
  color: var(--tabbar-color); line-height: 1.25;
}
.tabbar a .tb-ico { display: block; font-size: 21px; margin-bottom: 1px; }
.tabbar a.active { color: var(--accent); }
