/* ============================================================
   51help便利店 · 背景色方案（2026-11-20 第 1 版）
   5 套：dark 黑色调(默认) / light 浅色亮调 / sepia 护眼暖黄 /
        blue 冷蓝灰 / auto 跟随系统(脚本自动映射成 dark 或 light)
   脚本在 <html> 上写 data-theme(实际方案) 与 data-tone(dark|light)。
   本文件必须排在各页原样式之后加载；dark 时几乎不生效，视觉零回归。
   ============================================================ */

/* ---------- 1. 附加变量：默认沿用黑色调的硬编码值 ---------- */
html {
  --th-input-bg: #11161f;  --th-input-border: #333c4d;  --th-input-ink: #e7ebf3;
  --th-placeholder: #7d879b; --th-focus: #6c7ea3;
  --th-btn-bg: #202735; --th-btn-border: #3a4458; --th-btn-hover: #2b3344; --th-btn-ink: #e7ebf3;
  --th-img-bg: #12161f; --th-card-hover: #232b39; --th-card-hover-border: #4a556c;
  --th-soft-bg: #1d2330;
  --th-panel-bg: #1b212d; --th-panel-border: #3a4458; --th-panel-ink: #e7ebf3;
  --th-panel-muted: #98a3b8; --th-panel-hover: #2b3344;
  --th-topbar-btn-bg: #202735; --th-topbar-btn-border: #3a4458; --th-topbar-btn-ink: #e7ebf3;
  --th-shadow: 0 12px 36px rgba(0,0,0,.45);
}

/* ---------- 2. 三套亮色方案：只换变量，不动结构 ---------- */
html[data-theme="light"] {
  --bg:#f4f7fb !important;      --card:#ffffff !important;  --soft:#edf1f7 !important;
  --ink:#1b2431 !important;     --muted:#667085 !important;
  --primary:#39445c !important; --primary-d:#4a5875 !important;
  --border:#d7dfea !important;  --link:#2f57d4 !important;
  --shadow:0 8px 24px rgba(24,38,60,.10) !important;
  --th-input-bg:#ffffff; --th-input-border:#c9d3e0; --th-input-ink:#1b2431;
  --th-placeholder:#8a94a6; --th-focus:#6c8ad0;
  --th-btn-bg:#eef2f8; --th-btn-border:#c9d3e0; --th-btn-hover:#e2e9f3; --th-btn-ink:#1b2431;
  --th-img-bg:#ffffff; --th-card-hover:#f0f4fa; --th-card-hover-border:#b9c6d8;
  --th-soft-bg:#eef2f7;
  --th-panel-bg:#ffffff; --th-panel-border:#d7dfea; --th-panel-ink:#1b2431;
  --th-panel-muted:#667085; --th-panel-hover:#f0f4fa;
  --th-topbar-btn-bg:#2b3344; --th-topbar-btn-border:#3a4458; --th-topbar-btn-ink:#e7ebf3;
  --th-shadow:0 12px 36px rgba(24,38,60,.18);
}

html[data-theme="sepia"] {
  --bg:#f5efe0 !important;      --card:#fffaf0 !important;  --soft:#efe6d2 !important;
  --ink:#3a3226 !important;     --muted:#8a7c66 !important;
  --primary:#6b5b45 !important; --primary-d:#574936 !important;
  --border:#ded2b8 !important;  --link:#8a5a2b !important;
  --shadow:0 8px 24px rgba(80,64,36,.12) !important;
  --th-input-bg:#fffdf7; --th-input-border:#d8cbb0; --th-input-ink:#3a3226;
  --th-placeholder:#a3947c; --th-focus:#b09256;
  --th-btn-bg:#f0e7d3; --th-btn-border:#d8cbb0; --th-btn-hover:#e7dcc3; --th-btn-ink:#3a3226;
  --th-img-bg:#fffaf0; --th-card-hover:#f6eedb; --th-card-hover-border:#cab997;
  --th-soft-bg:#efe6d2;
  --th-panel-bg:#fffaf0; --th-panel-border:#ded2b8; --th-panel-ink:#3a3226;
  --th-panel-muted:#8a7c66; --th-panel-hover:#f3ead6;
  --th-topbar-btn-bg:#2f281c; --th-topbar-btn-border:#55492c; --th-topbar-btn-ink:#f2ead6;
  --th-shadow:0 12px 36px rgba(80,64,36,.22);
}

html[data-theme="blue"] {
  --bg:#eaf1f8 !important;      --card:#ffffff !important;  --soft:#dce7f2 !important;
  --ink:#1b2b3c !important;     --muted:#5f7186 !important;
  --primary:#2f4f7a !important; --primary-d:#3b6299 !important;
  --border:#c6d6e6 !important;  --link:#2b5fa8 !important;
  --shadow:0 8px 24px rgba(30,60,95,.12) !important;
  --th-input-bg:#ffffff; --th-input-border:#b9cde0; --th-input-ink:#1b2b3c;
  --th-placeholder:#8296ab; --th-focus:#5b8ec4;
  --th-btn-bg:#e4eef8; --th-btn-border:#b9cde0; --th-btn-hover:#d6e5f4; --th-btn-ink:#1b2b3c;
  --th-img-bg:#ffffff; --th-card-hover:#e8f1fa; --th-card-hover-border:#a8c2db;
  --th-soft-bg:#dce7f2;
  --th-panel-bg:#ffffff; --th-panel-border:#c6d6e6; --th-panel-ink:#1b2b3c;
  --th-panel-muted:#5f7186; --th-panel-hover:#eef5fc;
  --th-topbar-btn-bg:#22344a; --th-topbar-btn-border:#3a5270; --th-topbar-btn-ink:#eaf1f8;
  --th-shadow:0 12px 36px rgba(30,60,95,.22);
}

/* 顶栏/页脚色调跟着方案微调，但始终保持深色（白字清晰） */
html[data-theme="sepia"] .topbar, html[data-theme="sepia"] .tool-bar,
html[data-theme="sepia"] .tabbar, html[data-theme="sepia"] .site-footer { background:#241f16 !important; }
html[data-theme="blue"] .topbar, html[data-theme="blue"] .tool-bar,
html[data-theme="blue"] .tabbar, html[data-theme="blue"] .site-footer { background:#16212f !important; }

/* ---------- 3. 亮色模式：把各页写死的深色控件改成变量驱动 ---------- */
html[data-tone="light"], html[data-tone="light"] body {
  background: var(--bg) !important; color: var(--ink) !important;
}

/* 表单输入框（排除滑块、取色器、勾选框，避免控件变形） */
html[data-tone="light"] input:not([type=range]):not([type=color]):not([type=checkbox]):not([type=radio]):not([type=file]),
html[data-tone="light"] textarea,
html[data-tone="light"] select,
html[data-tone="light"] .field input,
html[data-tone="light"] .field select,
html[data-tone="light"] .field textarea,
html[data-tone="light"] .opt,
html[data-tone="light"] .analysis .body,
html[data-tone="light"] .custom-color input[type=color] {
  background: var(--th-input-bg) !important;
  color: var(--th-input-ink) !important;
  border-color: var(--th-input-border) !important;
}
html[data-tone="light"] input::placeholder,
html[data-tone="light"] textarea::placeholder { color: var(--th-placeholder) !important; }
html[data-tone="light"] input:focus, html[data-tone="light"] textarea:focus,
html[data-tone="light"] select:focus { border-color: var(--th-focus) !important; }
html[data-tone="light"] select option { background: var(--th-input-bg) !important; color: var(--th-input-ink) !important; }

/* 次要按钮 / 标签页 / 分段控件（各页共用类名） */
html[data-tone="light"] .btn, html[data-tone="light"] .btn-ghost,
html[data-tone="light"] .btn-light, html[data-tone="light"] .sort-link,
html[data-tone="light"] .filter-tab, html[data-tone="light"] .pager-btn.disabled,
html[data-tone="light"] .seg button, html[data-tone="light"] .tab,
html[data-tone="light"] .lang button, html[data-tone="light"] .btn.ghost,
html[data-tone="light"] .tool, html[data-tone="light"] .spec {
  background-color: var(--th-btn-bg) !important;
  color: var(--th-btn-ink) !important;
  border-color: var(--th-btn-border) !important;
}
html[data-tone="light"] .btn:hover, html[data-tone="light"] .btn-ghost:hover,
html[data-tone="light"] .sort-link:hover, html[data-tone="light"] .filter-tab:hover {
  background-color: var(--th-btn-hover) !important;
}
/* 主按钮 / 选中态：跟随各方案主色 */
html[data-tone="light"] .btn-primary, html[data-tone="light"] .pager-btn:not(.disabled),
html[data-tone="light"] .tab.active, html[data-tone="light"] .seg button.active,
html[data-tone="light"] .lang button.active, html[data-tone="light"] .sort-link.active,
html[data-tone="light"] .filter-tab.active, html[data-tone="light"] .btn.primary,
html[data-tone="light"] .btn-main, html[data-tone="light"] button.primary {
  background-color: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}
html[data-tone="light"] .btn-primary:hover, html[data-tone="light"] .pager-btn:hover {
  background-color: var(--primary-d) !important; color: #fff !important;
}

/* 卡片 / 面板 / 列表（主站 + 四个子页通用类名） */
html[data-tone="light"] .card, html[data-tone="light"] .panel,
html[data-tone="light"] .box, html[data-tone="light"] .drop,
html[data-tone="light"] .uploader, html[data-tone="light"] .step,
html[data-tone="light"] .bank-item, html[data-tone="light"] .q-card,
html[data-tone="light"] .stat, html[data-tone="light"] .list-item,
html[data-tone="light"] .paper, html[data-tone="light"] .yao,
html[data-tone="light"] .gua-card, html[data-tone="light"] .item {
  background-color: var(--card) !important;
  color: var(--ink) !important;
  border-color: var(--border) !important;
}
html[data-tone="light"] .software-card:hover,
html[data-tone="light"] .drop:hover, html[data-tone="light"] .tool:hover {
  background-color: var(--th-card-hover) !important;
  border-color: var(--th-card-hover-border) !important;
}
html[data-tone="light"] .tabs, html[data-tone="light"] .seg,
html[data-tone="light"] .lang, html[data-tone="light"] .logo,
html[data-tone="light"] .drop-hint kbd, html[data-tone="light"] .drop-icon,
html[data-tone="light"] .stat b, html[data-tone="light"] .usage-item h4 span {
  background: var(--th-soft-bg) !important;
  color: var(--ink) !important;
  border-color: var(--border) !important;
}
html[data-tone="light"] .hint, html[data-tone="light"] .problem-text,
html[data-tone="light"] .table th, html[data-tone="light"] .coin-stage {
  background-color: var(--soft) !important; color: var(--ink) !important;
  border-color: var(--border) !important;
}

/* 图片容器（二维码白框 / 详情页画廊跟随方案，功能画布另保留原色） */
html[data-tone="light"] .qr-placeholder, html[data-tone="light"] .img-gallery a,
html[data-tone="light"] .carousel-slide { background: var(--th-img-bg) !important; }
html[data-tone="light"] .stage-canvas {
  background: repeating-linear-gradient(45deg,#e9edf3 0 12px,#dfe5ee 12px 24px) !important;
}

/* 链接：亮色底上改成方案链接色；顶栏/页脚/底导航保持浅字 */
html[data-tone="light"] a { color: var(--link) !important; }
html[data-tone="light"] .topbar a, html[data-tone="light"] .tool-bar a,
html[data-tone="light"] .site-footer a, html[data-tone="light"] .tabbar a,
html[data-tone="light"] .tool-home, html[data-tone="light"] .home-link,
html[data-tone="light"] .footer-links a, html[data-tone="light"] .footer-beian a {
  color: #eef2f8 !important;
}
html[data-tone="light"] .nav-link.active { color:#11151d !important; }
html[data-tone="light"] .nav-link:hover { color:#fff !important; }
html[data-tone="light"] .topbar .btn-light, html[data-tone="light"] .topbar-actions .btn {
  background-color: var(--th-topbar-btn-bg) !important;
  color: var(--th-topbar-btn-ink) !important;
  border-color: var(--th-topbar-btn-border) !important;
}
html[data-tone="light"] .muted, html[data-tone="light"] .gallery-hint,
html[data-tone="light"] .pager-info, html[data-tone="light"] .site-foot .disclaimer {
  color: var(--muted) !important;
}
html[data-tone="light"] a.muted[href*="51help.top"] {
  background: var(--th-btn-bg) !important; color: var(--th-btn-ink) !important;
  border-color: var(--th-btn-border) !important;
}

/* yijing 黑金：亮色方案下改「米白纸 + 深棕金」，保留铜钱金色 */
html[data-tone="light"] .ink-bg {
  background: radial-gradient(circle at 12% 18%,rgba(180,140,40,.09) 0%,transparent 42%) !important;
}
html[data-tone="light"] .site-head {
  background: linear-gradient(180deg,#fffaf0,#f3ead6) !important;
  border-bottom-color: var(--border) !important;
}
html[data-tone="light"] .site-head h1, html[data-tone="light"] .site-head .subtitle,
html[data-tone="light"] .site-head .motto, html[data-tone="light"] .title-block h1,
html[data-tone="light"] .motto, html[data-tone="light"] h1, html[data-tone="light"] h2,
html[data-tone="light"] h3, html[data-tone="light"] h4,
html[data-tone="light"] .panel-title, html[data-tone="light"] .gua-name,
html[data-tone="light"] .card-title { color:#8a6d1f !important; }
html[data-tone="light"] .site-foot { background: var(--soft) !important; border-top-color: var(--border) !important; }
html[data-tone="light"] .face .hole { background: var(--card) !important; }
html[data-tone="light"] hr, html[data-tone="light"] .divider { border-color: var(--border) !important; }

/* ---------- 4. 顶栏右侧「背景」按钮 + 色板面板 ---------- */
.theme-switch { position:relative; display:inline-flex; align-items:center; flex:0 0 auto; }
.theme-btn {
  display:inline-flex; align-items:center; gap:6px; height:32px; padding:0 12px;
  border:1px solid var(--th-topbar-btn-border); border-radius:999px;
  background:var(--th-topbar-btn-bg); color:var(--th-topbar-btn-ink);
  font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap;
  font-family:inherit; line-height:1; transition:.15s;
}
.theme-btn:hover { border-color:#6c7ea3; }
.theme-btn svg { width:15px; height:15px; flex:0 0 auto; }
.theme-btn[aria-expanded="true"] { border-color:#6c7ea3; }
.theme-panel {
  position:absolute; right:0; top:calc(100% + 10px); z-index:200;
  width:232px; max-width:calc(100vw - 24px); padding:10px;
  background:var(--th-panel-bg); color:var(--th-panel-ink);
  border:1px solid var(--th-panel-border); border-radius:14px;
  box-shadow:var(--th-shadow); text-align:left;
}
.theme-panel[hidden] { display:none; }
.theme-panel-hd { font-size:13px; font-weight:700; padding:4px 8px 8px; }
.theme-opt {
  display:flex; align-items:center; gap:10px; width:100%; box-sizing:border-box;
  padding:9px 8px; margin:0; border:0; border-radius:9px; cursor:pointer;
  background:transparent; color:var(--th-panel-ink); font:inherit; font-size:13px;
  text-align:left; font-family:inherit;
}
.theme-opt:hover { background:var(--th-panel-hover); }
.theme-opt.on { background:var(--th-panel-hover); font-weight:700; }
.theme-dot {
  width:20px; height:20px; flex:0 0 auto; border-radius:6px;
  border:1px solid rgba(128,140,160,.55);
}
.theme-opt-name { flex:1; }
.theme-opt-note { font-size:11px; color:var(--th-panel-muted); font-weight:400; }
.theme-check { width:14px; flex:0 0 auto; font-size:13px; color:var(--link); }
.theme-panel-ft {
  margin-top:6px; padding:8px 8px 2px; border-top:1px solid var(--th-panel-border);
  font-size:11px; color:var(--th-panel-muted); line-height:1.5;
}
.theme-switch.theme-floating { position:fixed; right:16px; top:16px; z-index:9999; }
@media (max-width:600px) {
  .theme-btn { padding:0 10px; font-size:12px; }
  .theme-panel { right:-6px; width:216px; }
}
