/* ============ 国学文化研究 · 双主题系统 ============
   暗黑（默认） / 高亮（浅色时尚版）
   通过 <html data-theme="light"> 切换
*/

/* ---------- 暗黑主题（默认，保持原有深色基调） ---------- */
:root,
html[data-theme="dark"] {
  --bg: #080b14;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #101827 0%, #080b14 60%);
  --bg2: #0d1320;
  --card: #111726;
  --card2: #0d1320;
  --card-grad: linear-gradient(180deg, #161a1e, #111726);
  --line: #1e2839;
  --line2: #26313f;
  --fg: #333333;
  --fg2: #9aa4b8;
  --fg3: #6b7590;
  --fg4: #4d566d;
  --gold: #4F6F55;
  --gold2: #6B8F71;
  --gold3: #ffd97a;
  --jade: #8fd3a8;
  --red: #e07070;
  --blue: #6fa8dc;
  --purple: #c9a0e0;
  --shadow: none;
  --cell-bg: linear-gradient(180deg, #0f1524, #0b1120);
  --cell-grad: linear-gradient(180deg, #141d2e, #0e1522);
  --cell-mid: linear-gradient(180deg, #151a22, #0f141c);
  --input-bg: #080d16;
  --input-fg: #dde3ec;
  --table-hd: #0e1420;
  --hover-bg: rgba(107,143,113, .035);
  --chip-bg: #141b28;
  --lock-bg: linear-gradient(180deg, #1a1710, #12100a);
  --toast-bg: #1a2333;
  --scroll-thumb: #2a3446;
  --scroll-track: #0b1120;
  /* 五格/紫微专用 */
  --zw-board: linear-gradient(180deg, #0d1421, #080d16);
  --zw-cell: linear-gradient(180deg, #0f1524, #0b1120);
  --zw-center: linear-gradient(180deg, #131a2c, #0c1220);
  --pal-bg: linear-gradient(180deg, #0f1524, #0b1120);
  --pal-mid: linear-gradient(180deg, #151a22, #0f141c);
  --dcell: #0d1320;
}

/* ---------- 高亮主题（浅色时尚） ---------- */
html[data-theme="light"] {
  --bg: #f7f5f0;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, #f4f1ea 55%, #efece4 100%);
  --bg2: #ffffff;
  --card: #ffffff;
  --card2: #fbfaf7;
  --card-grad: linear-gradient(180deg, #ffffff, #fdfcfa);
  --line: #e2ddd2;
  --line2: #d4cec1;
  --fg: #2b2a26;
  --fg2: #5d5a52;
  --fg3: #8a857a;
  --fg4: #b0aa9d;
  --gold: #9c7a1f;
  --gold2: #b8912f;
  --gold3: #8a6a10;
  --jade: #2f7d54;
  --red: #c0453f;
  --blue: #2c6291;
  --purple: #7b4f9e;
  --shadow: 0 1px 2px rgba(90, 80, 60, .05), 0 4px 14px rgba(90, 80, 60, .06);
  --cell-bg: linear-gradient(180deg, #ffffff, #faf8f4);
  --cell-grad: linear-gradient(180deg, #fffdf8, #f8f5ee);
  --cell-mid: linear-gradient(180deg, #f5f2ea, #efece2);
  --input-bg: #ffffff;
  --input-fg: #2b2a26;
  --table-hd: #f4f1ea;
  --hover-bg: rgba(184, 145, 47, .06);
  --chip-bg: #f4f1ea;
  --lock-bg: linear-gradient(180deg, #fdf8ec, #faf3e2);
  --toast-bg: #2b2a26;
  --scroll-thumb: #cfc9bb;
  --scroll-track: #f0ede6;
  --zw-board: linear-gradient(180deg, #ffffff, #f7f4ec);
  --zw-cell: linear-gradient(180deg, #ffffff, #faf8f3);
  --zw-center: linear-gradient(180deg, #fdfbf5, #f6f3ea);
  --pal-bg: linear-gradient(180deg, #ffffff, #faf8f3);
  --pal-mid: linear-gradient(180deg, #f7f4ec, #f2efe6);
  --dcell: #fbfaf7;
}

/* ============ 主题切换按钮 ============ */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 999;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(255,253,246,.12);
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
  backdrop-filter: blur(8px);
}

.theme-toggle:hover {
  transform: rotate(18deg) scale(1.08);
  border-color: var(--gold);
  box-shadow: 0 4px 16px rgba(107,143,113, .25);
}

.theme-toggle:active { transform: scale(.94); }

.theme-toggle svg { width: 20px; height: 20px; }

/* 切换动画 */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color .32s ease,
              border-color .32s ease,
              color .32s ease,
              box-shadow .32s ease !important;
}

@media (max-width: 640px) {
  .theme-toggle { top: 12px; right: 12px; width: 38px; height: 38px; font-size: 16px; }
}

@media print {
  .theme-toggle { display: none !important; }
}