/* Theme variables: classic (light/dark) + starry (dark) + forest (dark) + ocean (dark) + obsidian (dark) + sunset (light) + sakura (light) + mint (light) + ice (light) + desert (light). Switch with <html data-theme="classic|starry|forest|ocean|obsidian|sunset|sakura|mint|ice|desert" data-mode="light|dark">. Only classic follows the light/dark switch; the other themes are fixed (starry/forest/ocean/obsidian dark, sunset/sakura/mint/ice/desert light). The starfield, the moon and the ambient glows are pure CSS gradients, no images. 主题变量：经典（亮/暗）+ 星夜（暗色）+ 森林（暗色）+ 海洋（暗色）+ 曜石（暗色）+ 落日（亮色）+ 樱花（亮色）+ 薄荷（亮色）+ 冰蓝（亮色）+ 沙漠（亮色）。切换方式：<html data-theme="classic|starry|forest|ocean|obsidian|sunset|sakura|mint|ice|desert" data-mode="light|dark">。只有经典主题跟随明暗切换，其余主题固定明暗（星夜/森林/海洋/曜石为暗色，落日/樱花/薄荷/冰蓝/沙漠为亮色）。星空、月亮与环境光晕全部用 CSS 渐变实现，不引用任何图片。 */

/* ---------- 经典主题 · 亮色（默认） ---------- */
:root,
html[data-theme="classic"][data-mode="light"] {
  --bg: #f3f5fa;
  --bg-soft: #eef1f7;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-soft-text: #1e40af;
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --topbar-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-active-bg: #dbeafe;
  --sidebar-active-text: #1e40af;
  --input-bg: #ffffff;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.14);
  --login-bg: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #7c3aed 100%);
  color-scheme: light;
}

/* ---------- 经典主题 · 暗色 ---------- */
html[data-theme="classic"][data-mode="dark"] {
  --bg: #0f172a;
  --bg-soft: #131c2e;
  --surface: #1e293b;
  --surface-hover: #26334a;
  --surface-muted: #182234;
  --border: #334155;
  --border-strong: #475569;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: #1e3a8a;
  --accent-soft-text: #bfdbfe;
  --on-accent: #ffffff;
  --success: #22c55e;
  --success-soft: #14532d;
  --warning: #f59e0b;
  --warning-soft: #451a03;
  --danger: #ef4444;
  --danger-soft: #450a0a;
  --info: #22d3ee;
  --topbar-bg: #1e293b;
  --sidebar-bg: #1e293b;
  --sidebar-active-bg: #1e3a8a;
  --sidebar-active-text: #bfdbfe;
  --input-bg: #0f172a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --login-bg: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #312e81 100%);
  color-scheme: dark;
}

/* ---------- 星夜主题（深紫星空，固定暗色） ---------- */
html[data-theme="starry"],
html[data-theme="starry"][data-mode="light"],
html[data-theme="starry"][data-mode="dark"] {
  --bg: #1a1033;
  --bg-soft: #201540;
  --surface: rgba(38, 24, 68, 0.82);
  --surface-hover: rgba(56, 36, 96, 0.9);
  --surface-muted: rgba(30, 19, 54, 0.85);
  --border: #4c3a78;
  --border-strong: #6d54a3;
  --text: #ede9fe;
  --text-muted: #b8a8e0;
  --text-faint: #8b7ab8;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-soft: #2e1f56;
  --accent-soft-text: #ddd6fe;
  --on-accent: #1e1338;
  --success: #34d399;
  --success-soft: #064e3b;
  --warning: #fbbf24;
  --warning-soft: #451a03;
  --danger: #f87171;
  --danger-soft: #450a0a;
  --info: #67e8f9;
  --topbar-bg: rgba(26, 16, 51, 0.92);
  --sidebar-bg: rgba(30, 19, 54, 0.9);
  --sidebar-active-bg: #2e1f56;
  --sidebar-active-text: #ddd6fe;
  --input-bg: rgba(22, 13, 42, 0.9);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.55);
  --login-bg: linear-gradient(160deg, #120a26 0%, #1a1033 55%, #2b1a52 100%);
  color-scheme: dark;
}

/* ---------- 森林主题（深绿，固定暗色） ---------- */
html[data-theme="forest"],
html[data-theme="forest"][data-mode="light"],
html[data-theme="forest"][data-mode="dark"] {
  --bg: #0d1f16;
  --bg-soft: #10241b;
  --surface: #16281d;
  --surface-hover: #1d3325;
  --surface-muted: #12241a;
  --border: #2a4a35;
  --border-strong: #3d6350;
  --text: #e6f2e9;
  --text-muted: #9db8a4;
  --text-faint: #6b8a74;
  --accent: #4ade80;
  --accent-hover: #86efac;
  --accent-soft: #14532d;
  --accent-soft-text: #bbf7d0;
  --on-accent: #052e16;
  --success: #22c55e;
  --success-soft: #14532d;
  --warning: #fbbf24;
  --warning-soft: #451a03;
  --danger: #f87171;
  --danger-soft: #450a0a;
  --info: #67e8f9;
  --topbar-bg: #16281d;
  --sidebar-bg: #16281d;
  --sidebar-active-bg: #14532d;
  --sidebar-active-text: #bbf7d0;
  --input-bg: #0d1f16;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.55);
  --login-bg: linear-gradient(160deg, #07130d 0%, #0d1f16 55%, #14532d 100%);
  color-scheme: dark;
}

/* ---------- 海洋主题（深蓝，固定暗色） ---------- */
html[data-theme="ocean"],
html[data-theme="ocean"][data-mode="light"],
html[data-theme="ocean"][data-mode="dark"] {
  --bg: #0a1a2e;
  --bg-soft: #0d2138;
  --surface: #122c47;
  --surface-hover: #1a3a5c;
  --surface-muted: #0e2438;
  --border: #1e4a73;
  --border-strong: #2e6da3;
  --text: #e0f2fe;
  --text-muted: #93c5fd;
  --text-faint: #60a5fa;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-soft: #0c4a6e;
  --accent-soft-text: #bae6fd;
  --on-accent: #082f49;
  --success: #34d399;
  --success-soft: #064e3b;
  --warning: #fbbf24;
  --warning-soft: #451a03;
  --danger: #f87171;
  --danger-soft: #450a0a;
  --info: #22d3ee;
  --topbar-bg: #122c47;
  --sidebar-bg: #122c47;
  --sidebar-active-bg: #0c4a6e;
  --sidebar-active-text: #bae6fd;
  --input-bg: #0a1a2e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.55);
  --login-bg: linear-gradient(160deg, #050d18 0%, #0a1a2e 55%, #0c4a6e 100%);
  color-scheme: dark;
}

/* ---------- 落日主题（暖阳，固定亮色） ---------- */
html[data-theme="sunset"],
html[data-theme="sunset"][data-mode="light"],
html[data-theme="sunset"][data-mode="dark"] {
  --bg: #fdf6ec;
  --bg-soft: #faf0dd;
  --surface: #fffaf0;
  --surface-hover: #f5e9d3;
  --surface-muted: #fdf8ef;
  --border: #ecd9b8;
  --border-strong: #d9bd8a;
  --text: #3d2c1e;
  --text-muted: #8a6d4b;
  --text-faint: #b49b78;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-soft: #ffedd5;
  --accent-soft-text: #9a3412;
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --topbar-bg: #fffaf0;
  --sidebar-bg: #fffaf0;
  --sidebar-active-bg: #ffedd5;
  --sidebar-active-text: #9a3412;
  --input-bg: #ffffff;
  --shadow: 0 1px 3px rgba(61, 44, 30, 0.08), 0 4px 12px rgba(61, 44, 30, 0.05);
  --shadow-lg: 0 10px 30px rgba(61, 44, 30, 0.14);
  --login-bg: linear-gradient(135deg, #7c2d12 0%, #ea580c 55%, #f59e0b 100%);
  color-scheme: light;
}

/* ---------- 樱花主题（淡粉，固定亮色） ---------- */
html[data-theme="sakura"],
html[data-theme="sakura"][data-mode="light"],
html[data-theme="sakura"][data-mode="dark"] {
  --bg: #fdf2f5;
  --bg-soft: #fbe9ee;
  --surface: #fffafa;
  --surface-hover: #f9e2e8;
  --surface-muted: #fdf5f7;
  --border: #f3cdd8;
  --border-strong: #e5a8b8;
  --text: #3f2a30;
  --text-muted: #8a6a72;
  --text-faint: #b08e97;
  --accent: #db2777;
  --accent-hover: #be185d;
  --accent-soft: #fce7f3;
  --accent-soft-text: #9d174d;
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --topbar-bg: #fffafa;
  --sidebar-bg: #fffafa;
  --sidebar-active-bg: #fce7f3;
  --sidebar-active-text: #9d174d;
  --input-bg: #ffffff;
  --shadow: 0 1px 3px rgba(63, 42, 48, 0.08), 0 4px 12px rgba(63, 42, 48, 0.05);
  --shadow-lg: 0 10px 30px rgba(63, 42, 48, 0.14);
  --login-bg: linear-gradient(135deg, #831843 0%, #db2777 55%, #f472b6 100%);
  color-scheme: light;
}

/* ---------- 曜石主题（近黑，固定暗色） ---------- */
html[data-theme="obsidian"],
html[data-theme="obsidian"][data-mode="light"],
html[data-theme="obsidian"][data-mode="dark"] {
  --bg: #0a0a0b;
  --bg-soft: #101012;
  --surface: #18181b;
  --surface-hover: #232326;
  --surface-muted: #131316;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: #451a03;
  --accent-soft-text: #fde68a;
  --on-accent: #1c1005;
  --success: #22c55e;
  --success-soft: #14532d;
  --warning: #fbbf24;
  --warning-soft: #451a03;
  --danger: #f87171;
  --danger-soft: #450a0a;
  --info: #67e8f9;
  --topbar-bg: #18181b;
  --sidebar-bg: #18181b;
  --sidebar-active-bg: #451a03;
  --sidebar-active-text: #fde68a;
  --input-bg: #0a0a0b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.65);
  --login-bg: linear-gradient(160deg, #000000 0%, #0a0a0b 55%, #451a03 100%);
  color-scheme: dark;
}

/* ---------- 薄荷主题（清绿，固定亮色） ---------- */
html[data-theme="mint"],
html[data-theme="mint"][data-mode="light"],
html[data-theme="mint"][data-mode="dark"] {
  --bg: #f0fdf6;
  --bg-soft: #e6f9ef;
  --surface: #ffffff;
  --surface-hover: #e0f5e9;
  --surface-muted: #f4fdf8;
  --border: #c8eeda;
  --border-strong: #9adbb6;
  --text: #1a2e22;
  --text-muted: #5a7a68;
  --text-faint: #8aa896;
  --accent: #059669;
  --accent-hover: #047857;
  --accent-soft: #d1fae5;
  --accent-soft-text: #065f46;
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --topbar-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-active-bg: #d1fae5;
  --sidebar-active-text: #065f46;
  --input-bg: #ffffff;
  --shadow: 0 1px 3px rgba(26, 46, 34, 0.08), 0 4px 12px rgba(26, 46, 34, 0.05);
  --shadow-lg: 0 10px 30px rgba(26, 46, 34, 0.14);
  --login-bg: linear-gradient(135deg, #065f46 0%, #059669 55%, #34d399 100%);
  color-scheme: light;
}

/* ---------- 冰蓝主题（冷蓝，固定亮色） ---------- */
html[data-theme="ice"],
html[data-theme="ice"][data-mode="light"],
html[data-theme="ice"][data-mode="dark"] {
  --bg: #f0f9ff;
  --bg-soft: #e6f4fd;
  --surface: #ffffff;
  --surface-hover: #e0f0fa;
  --surface-muted: #f4fafd;
  --border: #c8e2f2;
  --border-strong: #9ac8e2;
  --text: #1a2a38;
  --text-muted: #5a7a90;
  --text-faint: #8aa8b8;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-soft: #e0f2fe;
  --accent-soft-text: #075985;
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --topbar-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-active-bg: #e0f2fe;
  --sidebar-active-text: #075985;
  --input-bg: #ffffff;
  --shadow: 0 1px 3px rgba(26, 42, 56, 0.08), 0 4px 12px rgba(26, 42, 56, 0.05);
  --shadow-lg: 0 10px 30px rgba(26, 42, 56, 0.14);
  --login-bg: linear-gradient(135deg, #0c4a6e 0%, #0284c7 55%, #38bdf8 100%);
  color-scheme: light;
}

/* ---------- 沙漠主题（暖沙，固定亮色） ---------- */
html[data-theme="desert"],
html[data-theme="desert"][data-mode="light"],
html[data-theme="desert"][data-mode="dark"] {
  --bg: #faf5eb;
  --bg-soft: #f5ecd9;
  --surface: #fffdf7;
  --surface-hover: #f0e6cf;
  --surface-muted: #fbf8f0;
  --border: #e5d5b3;
  --border-strong: #cbb27f;
  --text: #3a2e1c;
  --text-muted: #8a7a5c;
  --text-faint: #b3a284;
  --accent: #b45309;
  --accent-hover: #92400e;
  --accent-soft: #fef3c7;
  --accent-soft-text: #78350f;
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --topbar-bg: #fffdf7;
  --sidebar-bg: #fffdf7;
  --sidebar-active-bg: #fef3c7;
  --sidebar-active-text: #78350f;
  --input-bg: #ffffff;
  --shadow: 0 1px 3px rgba(58, 46, 28, 0.08), 0 4px 12px rgba(58, 46, 28, 0.05);
  --shadow-lg: 0 10px 30px rgba(58, 46, 28, 0.14);
  --login-bg: linear-gradient(135deg, #78350f 0%, #b45309 55%, #d97706 100%);
  color-scheme: light;
}

/* Starry: starfield accents (multiple tiled radial-gradients, no images). 星夜：星空点缀（多层 radial-gradient 平铺，不用图片）。 */
html[data-theme="starry"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 22px 34px, rgba(255, 255, 255, 0.9), transparent 60%),
    radial-gradient(1px 1px at 130px 90px, rgba(255, 255, 255, 0.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 240px 160px, rgba(221, 214, 254, 0.9), transparent 60%),
    radial-gradient(1px 1px at 320px 60px, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 70px 210px, rgba(196, 181, 253, 0.8), transparent 60%),
    radial-gradient(1.5px 1.5px at 180px 260px, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 290px 300px, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1px 1px at 360px 200px, rgba(221, 214, 254, 0.7), transparent 60%),
    radial-gradient(ellipse 60% 45% at 85% 95%, rgba(139, 92, 246, 0.22), transparent 70%),
    radial-gradient(ellipse 45% 35% at 8% 6%, rgba(59, 130, 246, 0.14), transparent 70%);
  background-size: 420px 380px, 420px 380px, 420px 380px, 420px 380px,
    420px 380px, 420px 380px, 420px 380px, 420px 380px, 100% 100%, 100% 100%;
}

/* Starry: crescent moon in the bottom-right corner (two offset circles overlapped into a crescent, pure CSS). 星夜：右下角月牙（两个错位圆叠出月牙形，纯 CSS）。 */
html[data-theme="starry"] body::after {
  content: "";
  position: fixed;
  right: 4vw;
  bottom: 3vh;
  width: 180px;
  height: 180px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background:
    radial-gradient(circle at 62% 38%, var(--bg) 0 52%, transparent 54%),
    radial-gradient(circle at 50% 50%, #fde68a 0 58%, rgba(253, 230, 138, 0.35) 62%, transparent 70%);
  filter: blur(0.4px);
}

/* 各新主题的环境光晕（单层柔光，纯 CSS，不引用图片）。 */
html[data-theme="forest"] body::before,
html[data-theme="ocean"] body::before,
html[data-theme="sunset"] body::before,
html[data-theme="sakura"] body::before,
html[data-theme="obsidian"] body::before,
html[data-theme="mint"] body::before,
html[data-theme="ice"] body::before,
html[data-theme="desert"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
html[data-theme="forest"] body::before {
  background: radial-gradient(ellipse 55% 42% at 12% 0%, rgba(74, 222, 128, 0.13), transparent 70%);
}
html[data-theme="ocean"] body::before {
  background: radial-gradient(ellipse 65% 48% at 50% 108%, rgba(56, 189, 248, 0.18), transparent 70%);
}
html[data-theme="sunset"] body::before {
  background: radial-gradient(ellipse 48% 42% at 88% 0%, rgba(234, 88, 12, 0.13), transparent 70%);
}
html[data-theme="sakura"] body::before {
  background: radial-gradient(ellipse 52% 42% at 85% 100%, rgba(219, 39, 119, 0.10), transparent 70%);
}
html[data-theme="obsidian"] body::before {
  background: radial-gradient(ellipse 50% 40% at 50% 0%, rgba(245, 158, 11, 0.10), transparent 70%);
}
html[data-theme="mint"] body::before {
  background: radial-gradient(ellipse 50% 40% at 10% 100%, rgba(5, 150, 105, 0.12), transparent 70%);
}
html[data-theme="ice"] body::before {
  background: radial-gradient(ellipse 48% 40% at 90% 0%, rgba(2, 132, 199, 0.12), transparent 70%);
}
html[data-theme="desert"] body::before {
  background: radial-gradient(ellipse 55% 42% at 50% 105%, rgba(180, 83, 9, 0.12), transparent 70%);
}

/* In themes with a backdrop glow, the content layer must sit above it. 带环境光晕的主题下，内容层要压在光晕之上。 */
html[data-theme="starry"] .topbar,
html[data-theme="starry"] .resourcebar,
html[data-theme="starry"] .shell,
html[data-theme="forest"] .topbar,
html[data-theme="forest"] .resourcebar,
html[data-theme="forest"] .shell,
html[data-theme="ocean"] .topbar,
html[data-theme="ocean"] .resourcebar,
html[data-theme="ocean"] .shell,
html[data-theme="sunset"] .topbar,
html[data-theme="sunset"] .resourcebar,
html[data-theme="sunset"] .shell,
html[data-theme="sakura"] .topbar,
html[data-theme="sakura"] .resourcebar,
html[data-theme="sakura"] .shell,
html[data-theme="obsidian"] .topbar,
html[data-theme="obsidian"] .resourcebar,
html[data-theme="obsidian"] .shell,
html[data-theme="mint"] .topbar,
html[data-theme="mint"] .resourcebar,
html[data-theme="mint"] .shell,
html[data-theme="ice"] .topbar,
html[data-theme="ice"] .resourcebar,
html[data-theme="ice"] .shell,
html[data-theme="desert"] .topbar,
html[data-theme="desert"] .resourcebar,
html[data-theme="desert"] .shell {
  position: relative;
  z-index: 1;
}
