/* ============================================================
 * 全站主题系统 · 浅色覆盖层
 * 深色 = 默认（style.css / 各游戏内联样式原样）
 * 浅色 = html[data-theme="light"] 时本文件生效
 * theme.js 在 <head> 早期读取 localStorage 并落 data-theme，避免闪烁
 * ============================================================ */

/* ---------- 1. 通用 CSS 变量覆盖（主站 style.css 页） ---------- */
html[data-theme="light"] {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f0f3fa;
  --panel-3: #e6eaf4;
  --line: #d9dfec;
  --text: #1e263a;
  --muted: #6b7590;
  --brand: #5a4ae0;
  --brand-2: #0891b2;
  --danger: #dc2626;
  --success: #059669;
  color-scheme: light;
}

/* 独立落地页 / 工具页自带 :root 深色变量（--card/--card2/--panel2 等）。
   这些变量名与主站不同，必须单独覆盖，否则浅色模式下会残留深色卡片。 */
html[data-theme="light"] {
  --card: #ffffff;
  --card2: #f4f6fb;
  --panel2: #f4f6fb;
  --bg1: #f4f6fb;
  --bg2: #e9edf7;
  --ink: #1e263a;
  --sub: #6b7590;
  --ok: #059669;
  --err: #dc2626;
  --warn: #b45309;
  --gold: #b45309;
}

/* ---------- 2. 主站 body / 侧栏 / 顶栏 / 应用区硬编码覆盖 ---------- */
html[data-theme="light"] { background: #eef1f8; }
html[data-theme="light"] body { background: #eef1f8; color: var(--text); }
html[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fd 100%);
  border-right: 1px solid #e2e7f2;
  box-shadow: 4px 0 24px rgba(30,40,80,.06);
}
html[data-theme="light"] .logo { color: #fff; }
html[data-theme="light"] .brand h1 { color: var(--text); }
html[data-theme="light"] .sidebar-foot { border-top: 1px solid #e2e7f2; }
html[data-theme="light"] .module-btn { color: var(--muted); }
html[data-theme="light"] .module-btn:hover { background: var(--panel-2); color: var(--text); }
html[data-theme="light"] .mod-group { color: var(--muted); }
html[data-theme="light"] .app { background: #eef1f8; }

/* 表单控件 */
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
  background: #fff; color: var(--text); border-color: #d9dfec;
}
html[data-theme="light"] input:focus,
html[data-theme="light"] textarea:focus,
html[data-theme="light"] select:focus { background: #fff; }
html[data-theme="light"] .chip,
html[data-theme="light"] .voice-chip { background: #fff; color: var(--text); border-color: #d9dfec; }
html[data-theme="light"] .chip:hover,
html[data-theme="light"] .voice-chip:hover { background: var(--panel-2); }

/* 卡片 / 弹层 / 通用面板：变量已覆盖，这里补少量硬编码 */
html[data-theme="light"] .card::before { opacity: .5; }
html[data-theme="light"] .modal-card { background: #fff; }
html[data-theme="light"] .site-bar { background: rgba(255,255,255,.92); border-bottom: 1px solid #e2e7f2; }
html[data-theme="light"] .site-bar .logo { color: var(--text); }
html[data-theme="light"] .site-bar .logo .en { color: #8b95ad; }
html[data-theme="light"] .site-foot { border-color: #e2e7f2; }

/* 深色专用浅字 → 浅色下改深色，避免白字白底 */
html[data-theme="light"] .recharge-pill,
html[data-theme="light"] .am-tag.member,
html[data-theme="light"] .mc-badge.pending,
html[data-theme="light"] .product-price { color: #9a6700; }
html[data-theme="light"] .state-badge.live,
html[data-theme="light"] .reward-done,
html[data-theme="light"] .mc-badge.paid,
html[data-theme="light"] .mc-cmp td.yes { color: #047857; }
html[data-theme="light"] .mc-tip,
html[data-theme="light"] .mc-plan .pdesc,
html[data-theme="light"] .mc-plan .pprice small,
html[data-theme="light"] .mc-cmp th,
html[data-theme="light"] .mc-order .o-time,
html[data-theme="light"] .mc-badge.other,
html[data-theme="light"] .mc-empty,
html[data-theme="light"] .ledger-balance,
html[data-theme="light"] .ledger-time { color: var(--muted); }
html[data-theme="light"] .mc-faq,
html[data-theme="light"] .reward-fake,
html[data-theme="light"] .site-foot p,
html[data-theme="light"] .legal p,
html[data-theme="light"] .legal li { color: var(--text); }

/* 骨架屏 / 预览 / 图片背景 */
html[data-theme="light"] .sk-img { background: #e6eaf4; }
html[data-theme="light"] .sk-bar { background: #d9dfec; }
html[data-theme="light"] .studio-preview { background: #fff; }
html[data-theme="light"] .lightbox-card img { background: #eceff6; }
html[data-theme="light"] .upload-zone,
html[data-theme="light"] .drop-zone { background: #f7f9fd; }

/* ---------- 3. 游戏页 / 独立页（不引 style.css）浅色覆盖 ---------- */

/* 节拍金币 coin-game.html（深色 canvas 游戏 + 深顶栏） */
html[data-theme="light"] .site-bar.coin-bar,
html[data-theme="light"] #coinGame + .site-bar,
html[data-theme="light"] body:has(#stage canvas#game) .site-bar {
  background: rgba(255,255,255,.92); border-bottom: 1px solid #e2e7f2;
}
html[data-theme="light"] body:has(#stage canvas#game) .site-bar .logo { color: #1e263a; }
html[data-theme="light"] body:has(#stage canvas#game) .site-bar .logo .en { color: #8b95ad; }
html[data-theme="light"] body:has(#stage canvas#game) .site-bar .back {
  color: #4f46e5; background: rgba(79,70,229,.1); border-color: rgba(79,70,229,.28);
}
html[data-theme="light"] body:has(#stage canvas#game) .coin-foot,
html[data-theme="light"] body:has(#stage canvas#game) .mz-foot {
  background: rgba(255,255,255,.94); border-top: 1px solid #e2e7f2; color: #64748b;
}

/* 猎人打虎 game.html（深底 + 顶栏） */
html[data-theme="light"] body:has(.tiger-board, #board) { background: #eef1f8; }
html[data-theme="light"] body:has(.tiger-board, #board) .site-bar {
  background: rgba(255,255,255,.92); border-bottom: 1px solid #e2e7f2;
}
html[data-theme="light"] body:has(.tiger-board, #board) .site-bar .logo { color: #1e263a; }
html[data-theme="light"] body:has(.tiger-board, #board) .site-bar .logo .en { color: #8b95ad; }
html[data-theme="light"] body:has(.tiger-board, #board) .site-bar .back {
  color: #4f46e5; background: rgba(79,70,229,.1); border-color: rgba(79,70,229,.28);
}
html[data-theme="light"] body:has(.tiger-board, #board) .site-foot {
  background: rgba(255,255,255,.94); border-top: 1px solid #e2e7f2; color: #64748b;
}

/* 单词迷宫 word-maze.html（本就浅色，深色模式由本文件外 theme.js 的 dark 分支处理） */
html[data-theme="light"] .mz-bar { background: rgba(255,255,255,.94); border-bottom: 1px solid #e2e8f0; }
html[data-theme="light"] .mz-foot { background: rgba(255,255,255,.94); border-top: 1px solid #e2e8f0; }

/* 独立落地页（business-card / product-video / story-video / share-card） */
html[data-theme="light"] body:has(.share-card, .sc-wrap, .pv-wrap, .sv-wrap, .bc-wrap) {
  background: #eef1f8;
}

/* ---------- 3.5 落地页 / 工具页硬编码浅色文字的浅色模式修正 ----------
 * 这批页面（product-video / story-video / audio-converter）在深色模式用
 * #c7c2f8、#a5e9f5、#fff 等固定浅色字；浅色模式下底色变浅后这些字会糊掉。
 * 统一在此改写为深色系。 */

/* 提示条（紫底浅字） */
html[data-theme="light"] .notice {
  background: rgba(109,94,252,.07);
  border-color: rgba(109,94,252,.28);
  color: #4c3fc4;
}
html[data-theme="light"] .notice b { color: #372ba8; }

/* 青色估时条 */
html[data-theme="light"] .est {
  background: rgba(8,145,178,.08);
  border-color: rgba(8,145,178,.3);
  color: #0e7490;
}
html[data-theme="light"] .est b { color: #155e75; }

/* 步骤条编号圆点 */
html[data-theme="light"] .step b {
  background: rgba(109,94,252,.14);
  color: #4c3fc4;
}
html[data-theme="light"] .step.on b { background: var(--brand); color: #fff; }

/* 商品卡选中态标题 */
html[data-theme="light"] .pcard.on .nm { color: #4c3fc4; }

/* 提示行 / 序号徽标 / 剧本条目 */
html[data-theme="light"] .pt .n {
  background: rgba(109,94,252,.13);
  color: #4c3fc4;
}
html[data-theme="light"] .cost-tip {
  background: rgba(109,94,252,.07);
  border-color: rgba(109,94,252,.26);
  color: #4c3fc4;
}
html[data-theme="light"] .cost-tip b { color: #372ba8; }
html[data-theme="light"] .chip {
  background: rgba(109,94,252,.13);
  color: #4c3fc4;
}
html[data-theme="light"] .chip.on,
html[data-theme="light"] .chip.on b { color: #372ba8; }

/* 顶栏 logo 英文后缀 */
html[data-theme="light"] .site-bar .logo .en { color: #8b95ad; }

/* 页面主标题下的副标题（部分页用 .sub） */
html[data-theme="light"] .page-head .sub { color: var(--muted); }

/* ---------- 4. 主题开关按钮（注入到各页顶栏右上角） ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 10px; cursor: pointer; user-select: none;
  border: 1px solid rgba(140,150,180,.35);
  background: rgba(140,150,180,.12);
  color: var(--text, #6b7590);
  font-size: 16px; line-height: 1;
  transition: background .15s, border-color .15s, transform .08s;
}
.theme-toggle:hover { background: rgba(140,150,180,.22); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

/* 无 .site-bar/.mz-bar 的页面：固定右上角浮层兜底 */
.theme-toggle.floating {
  position: fixed; top: 12px; right: 12px; z-index: 9999;
  background: rgba(20,24,36,.82); color: #fff; border-color: rgba(255,255,255,.25);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
html[data-theme="light"] .theme-toggle.floating {
  background: rgba(255,255,255,.94); color: #1e263a; border-color: #d9dfec;
  box-shadow: 0 4px 16px rgba(30,40,80,.1);
}

/* ---------- 5. 单词迷宫深色模式（默认浅色，需反向覆盖） ---------- */
html[data-theme="dark"] body:has(.mz-bar) {
  background: #0f1424 !important;
  color: #e8edf8;
}
html[data-theme="dark"] body:has(.mz-bar) .screen { background: transparent; }
html[data-theme="dark"] body:has(.mz-bar) :root,
html[data-theme="dark"] body:has(.mz-bar) {
  --bg1: #10162b; --bg2: #0b1020; --ink: #e8edf8; --sub: #93a4c4;
  --line: #2b3550; --brand: #7c6cff; --brand2: #22d3ee;
  --gold: #fbbf24; --danger: #f87171; --ok: #34d399; --card: #182034;
}
html[data-theme="dark"] body:has(.mz-bar) .hero { color: #fff; }
html[data-theme="dark"] body:has(.mz-bar) .coinbar,
html[data-theme="dark"] body:has(.mz-bar) .streakbar { background: #1c2740; border-color: #2b3550; }
html[data-theme="dark"] body:has(.mz-bar) .btn,
html[data-theme="dark"] body:has(.mz-bar) .stage-card,
html[data-theme="dark"] body:has(.mz-bar) .hud-item { background: #182034; color: #e8edf8; border-color: #2b3550; }
html[data-theme="dark"] body:has(.mz-bar) .btn b,
html[data-theme="dark"] body:has(.mz-bar) .stage-card b { color: #e8edf8; }
html[data-theme="dark"] body:has(.mz-bar) #stage { background: #121a2e; border-color: #2b3550; }
html[data-theme="dark"] body:has(.mz-bar) .mz-bar,
html[data-theme="dark"] body:has(.mz-bar) .mz-foot {
  background: rgba(16,22,43,.94); border-color: #2b3550; color: #a9b6d9;
}
html[data-theme="dark"] body:has(.mz-bar) .mz-logo { color: #e8edf8; }
html[data-theme="dark"] body:has(.mz-bar) .mz-back { color: #a9b6ff; background: rgba(124,108,255,.14); border-color: rgba(124,108,255,.35); }
html[data-theme="dark"] body:has(.mz-bar) .panel { background: #182034; color: #e8edf8; }
html[data-theme="dark"] body:has(.mz-bar) .panel p { color: #a9b6d9; }

/* ---------- 6. 单词迷宫「答题弹层」对比度修复 ----------
 * 游戏本体硬编码浅底（.opt #f8fafc / .say #eef2ff / .qword #1e293b），
 * 深色态下与浅字叠加 -> 白底浅字、深底深字，几乎不可读（用户 11-26 截图）。
 * 这里在弹层范围内改深底浅字；浅色态同时加深选项文字/边框提升对比。 */
html[data-theme="dark"] body:has(.mz-bar) .panel .qword { color: #f1f5ff; }
html[data-theme="dark"] body:has(.mz-bar) .panel .qph { color: #a9b6d9; }
html[data-theme="dark"] body:has(.mz-bar) .panel .qtag {
  background: rgba(124,108,255,.2); color: #c4b5fd; }
html[data-theme="dark"] body:has(.mz-bar) .panel .say {
  background: rgba(124,108,255,.16); border-color: rgba(124,108,255,.5); color: #c4b5fd; }
html[data-theme="dark"] body:has(.mz-bar) .panel .opt {
  background: #212c46; border-color: #3a486b; color: #eef2ff; }
html[data-theme="dark"] body:has(.mz-bar) .panel .opt:active { background: #2c3857; }
html[data-theme="dark"] body:has(.mz-bar) .panel .demo {
  background: #212c46; color: #b8c4e0; }
html[data-theme="dark"] body:has(.mz-bar) .panel .feedback.ok { color: #4ade80; }
html[data-theme="dark"] body:has(.mz-bar) .panel .feedback.no { color: #fb7185; }
/* 判定态：暗色语义底 + 高对比字，保留删除线 */
html[data-theme="dark"] body:has(.mz-bar) .panel .opt.right {
  background: #14532d; border-color: #34d399; color: #a7f3d0; }
html[data-theme="dark"] body:has(.mz-bar) .panel .opt.wrong {
  background: #5c1d24; border-color: #f87171; color: #fecaca; }
/* 其它弹层内的浅底控件 */
html[data-theme="dark"] body:has(.mz-bar) .overlay .key {
  background: #212c46; border-color: #3a486b; color: #c4b5fd; box-shadow: none; }
html[data-theme="dark"] body:has(.mz-bar) .overlay .tab,
html[data-theme="dark"] body:has(.mz-bar) .overlay .dexcell,
html[data-theme="dark"] body:has(.mz-bar) .overlay .dailyQ .op,
html[data-theme="dark"] body:has(.mz-bar) .overlay .shopItem,
html[data-theme="dark"] body:has(.mz-bar) .overlay .achitem .ic {
  background: #212c46; color: #eef2ff; border-color: #3a486b; }
html[data-theme="dark"] body:has(.mz-bar) .overlay .tab.on { background: #37306b; color: #c4b5fd; }

/* 浅色态对比增强：选项文字加深、未选中边框加重 */
html[data-theme="light"] body:has(.mz-bar) .panel .opt {
  color: #17213a; border-color: #a9b6d4; }
html[data-theme="light"] body:has(.mz-bar) .panel .qword { color: #17213a; }
html[data-theme="light"] body:has(.mz-bar) .panel .demo { color: #475569; }
html[data-theme="light"] body:has(.mz-bar) .panel .opt.right {
  background: #bbf7d0; border-color: #059669; color: #064e3b; }
html[data-theme="light"] body:has(.mz-bar) .panel .opt.wrong {
  background: #fecaca; border-color: #dc2626; color: #7f1d1d; }
