/* 主题变量：经典（亮/暗）+ 星夜（暗色）
 * 切换方式：<html data-theme="classic|starry" 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;
}

/* 星夜：星空点缀（多层 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%;
}

/* 星夜：右下角月牙（两个错位圆叠出月牙形，纯 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);
}

/* 星夜下内容层要压在星空之上 */
html[data-theme="starry"] .topbar,
html[data-theme="starry"] .resourcebar,
html[data-theme="starry"] .shell {
  position: relative;
  z-index: 1;
}
