/* ==========================================================================
   两站共享设计层 ds.css  v2 (2026-11-17)
   v2 变更：新增「变量组别名重映射」——实测发现两站页面的深色值全部收敛在 :root 变量里，
   但用了三套互不相同的变量名：
     组 A（blog 模板，109+359 页）: --bg/--bg-card/--bg-secondary/--border
                                --text-primary/--text-secondary/--text-hint/--accent/--accent-2
     组 B（启明 site.css / index）: --bg-primary/--bg-secondary/--bg-card/--gold
                                --text-primary/--text-secondary/--text-muted/--border
     组 C（bazi-report 等）:      --bg/--bg2/--card/--gold/--gold-l/--t1/--t2/--t3/--bd
   浅色模式下把这三套变量统一重映射到「浅底 + 高对比」，即可让 500+ 页整体转浅色，
   而不必逐页改写内联 CSS。
   另：ds.js 的浅色切换只影响本层（data-ds-theme），不动页面自有 data-theme 逻辑。
   ========================================================================== */

/* ================= 浅色主题：变量组重映射 ================= */
html[data-ds-theme="light"] {
  /* —— 组 A：blog 模板 —— */
  --bg: #faf8f3;
  --bg-card: #ffffff;
  --bg-secondary: #f4f0e6;
  --border: #e2dccd;
  --text-primary: #1f2430;
  --text-secondary: #4b5568;
  --text-hint: #5f6b80;     /* 原 #7d7a92 浅底仅 3.4:1 */
  --accent: #8a6a2a;        /* 原 #c9a86a 浅底仅 2.2:1 */
  --accent-2: #6b4fa3;      /* 原 #9b7fd4 浅底仅 3.1:1 */
  --ok: #1f6b3f;

  /* —— 组 B：启明 site.css / index —— */
  --bg-primary: #faf8f3;
  --bg-card-hover: #f5f1e8;
  --gold: #8a6a20;
  --gold-light: #6d5318;
  --gold-dim: rgba(138, 106, 32, 0.12);
  --red: #b03a3a;
  --red-dim: rgba(176, 58, 58, 0.10);
  --teal: #2e7d7d;
  --teal-dim: rgba(46, 125, 125, 0.10);
  --purple: #6b4fa3;
  --purple-dim: rgba(107, 79, 163, 0.10);
  --green: #3f7d52;
  --green-dim: rgba(63, 125, 82, 0.10);
  --blue: #3a5a8f;
  --blue-dim: rgba(58, 90, 143, 0.10);
  --gray: #5f6b80;
  --gray-dim: rgba(95, 107, 128, 0.10);
  --text-muted: #5f6b80;     /* 原 #8892a6 浅底仅 2.9:1 */
  --border-soft: rgba(0, 0, 0, 0.07);

  /* —— 组 C：bazi-report / qimen-report 等 —— */
  --bg2: #f4f0e6;
  --card: #ffffff;
  --surface: #f4f0e6;
  --surface2: #ece6d8;
  --panel: #f4f0e6;
  --text: #1f2430;
  --text2: #4b5568;
  --sub: #4b5568;
  --hint: #5f6b80;
  --t1: #1f2430;
  --t2: #4b5568;
  --t3: #5f6b80;
  --muted: #5f6b80;
  --line: #e2dccd;
  --gold-l: #6d5318;
  --gold-d: rgba(138, 106, 32, 0.12);
  --bd: rgba(138, 106, 32, 0.26);
  --accent-dark: #6d5318;

  /* —— 境明 style.css 组 —— */
  --ink: #1f2933;
  --gold-ink: #8a6a2a;
  --green-ink: #1f6b3f;
  --ac: #8a6a2a;
  --accent-soft: rgba(138, 106, 32, 0.10);
}

/* ================= 浅色主题：硬编码深色的选择器级修正 ================= */
/* 这些色值写死在内联 CSS 里，变量重映射管不到，只能按选择器覆盖。 */
html[data-ds-theme="light"] .lang-btn.active,
html[data-ds-theme="light"] .lang button.on {
  background: var(--gold) !important;
  color: #ffffff !important;
}
/* 启明首页 hero 的金色标题（内联 #e9c46a）*/
html[data-ds-theme="light"] .hero h2,
html[data-ds-theme="light"] .section-title,
html[data-ds-theme="light"] h2[style*="#e9c46a"],
html[data-ds-theme="light"] h3[style*="#e9c46a"] {
  color: #8a6a20 !important;
}
/* 内联 #aab3c5 / #94a3b8 的次级文字 */
html[data-ds-theme="light"] p[style*="#aab3c5"],
html[data-ds-theme="light"] span[style*="#aab3c5"],
html[data-ds-theme="light"] div[style*="#aab3c5"],
html[data-ds-theme="light"] p[style*="#94a3b8"],
html[data-ds-theme="light"] span[style*="#94a3b8"] {
  color: #4b5568 !important;
}
/* 内联近白文字（#f0f2f5 等）在浅底上不可见 */
html[data-ds-theme="light"] h1[style*="#f0f2f5"],
html[data-ds-theme="light"] .lede[style*="#f0f2f5"],
html[data-ds-theme="light"] p[style*="#f0f2f5"] {
  color: #1f2430 !important;
}
/* 启明 blog 语言按钮（内联 #c3ccd8）*/
html[data-ds-theme="light"] button[style*="#c3ccd8"] {
  color: #4b5568 !important;
  border-color: #b9bfc9 !important;
}
/* 境明 blog 内联 #c9a86a 金色链接 */
html[data-ds-theme="light"] a[style*="#c9a86a"],
html[data-ds-theme="light"] .content a[style*="#c9a86a"] {
  color: #8a6a2a !important;
}
/* 境明 blog 内联 #8a7a60 次级文字 */
html[data-ds-theme="light"] p[style*="#8a7a60"],
html[data-ds-theme="light"] div[style*="#8a7a60"],
html[data-ds-theme="light"] span[style*="#8a7a60"] {
  color: #5f6b80 !important;
}

/* ================= 浅色主题：容器背景修正 ================= */
html[data-ds-theme="light"] body {
  background: var(--bg, #faf8f3);
  color: var(--text-primary, #1f2430);
}
html[data-ds-theme="light"] .qm-post,
html[data-ds-theme="light"] .container,
html[data-ds-theme="light"] .post {
  background: transparent;
}

/* ================= 统一工具条（主题 + 语言） ================= */
.ds-bar {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--ds-bar-bg, rgba(15, 20, 32, 0.92));
  border: 1px solid var(--ds-bar-line, rgba(212, 168, 83, 0.28));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 13px;
  line-height: 1;
}
.ds-bar a,
.ds-bar button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ds-bar-fg, #d9dee7);
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}
.ds-bar a:hover,
.ds-bar button:hover {
  background: var(--ds-bar-hover, rgba(212, 168, 83, 0.16));
  color: var(--ds-bar-accent, #f0d48a);
}
.ds-bar .ds-lang {
  display: flex;
  align-items: center;
  gap: 2px;
}
.ds-bar .ds-lang a[aria-current="true"],
.ds-bar .ds-lang button.on {
  background: var(--ds-bar-accent-bg, rgba(212, 168, 83, 0.2));
  color: var(--ds-bar-accent, #f0d48a);
  font-weight: 600;
}
.ds-bar .ds-sep {
  width: 1px;
  height: 16px;
  background: var(--ds-bar-line, rgba(212, 168, 83, 0.28));
}

html[data-ds-theme="light"] .ds-bar {
  --ds-bar-bg: rgba(255, 255, 255, 0.94);
  --ds-bar-line: rgba(161, 124, 44, 0.28);
  --ds-bar-fg: #3b4453;
  --ds-bar-hover: rgba(161, 124, 44, 0.12);
  --ds-bar-accent: #8a6a20;
  --ds-bar-accent-bg: rgba(161, 124, 44, 0.14);
  box-shadow: 0 4px 18px rgba(31, 36, 48, 0.12);
}

@media (max-width: 640px) {
  .ds-bar {
    top: 8px;
    right: 8px;
    padding: 4px 6px;
    gap: 3px;
  }
  .ds-bar a,
  .ds-bar button {
    font-size: 12px;
    padding: 4px 7px;
  }
}
