/* ═══════════════════════════════════════════════
   主题层：CSS 变量 + 预设主题 + 背景层
   （设置面板修改的变量全部在这里定义）
   ═══════════════════════════════════════════════ */

:root {
  /* 默认 = sky 主题（settings.py DEFAULTS 与此一致） */
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, .14);
  --glass-bg: rgba(255, 255, 255, .52);
  --glass-border: rgba(255, 255, 255, .75);
  --text-main: #1e3a5f;
  --text-sub: #5b7594;
  /* 兜底栈：mac / Win / HarmonyOS / Linux 各写一个，最后才是通用族 */
  --font-main: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
               "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei",
               system-ui, sans-serif;
  --font-size: 15px;
  --radius: 22px;
  --shadow: 0 18px 40px rgba(30, 45, 75, .14);

  /* ── 阴影层：颜色跟着主题强调色走 ──
     切换主题 / 在设置里改强调色时，app.js 会把新的 --accent 写到 <html>，
     下面这几个变量用 color-mix() 现算，无需为每个主题重复写一遍 rgba。
     --shadow-ink 是「墨底」（强调色压进深色），strength 控制浓淡；
     不支持 color-mix 的浏览器继续使用上面这几条静态回退值。 */
  --shadow-ink: #1a2440;
  --shadow-strength: 12%;
  --shadow-glow-strength: 16%;
  --shadow-float: 0 10px 26px rgba(20, 40, 80, .12);
  --shadow-soft: 0 5px 14px rgba(20, 40, 80, .10);
  --shadow-side: -18px 0 42px rgba(20, 40, 80, .14);
  --shadow-glow: 0 4px 10px rgba(79, 124, 255, .16);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --shadow-ink: color-mix(in srgb, var(--accent) 35%, #1a2440);
    --shadow: 0 18px 40px color-mix(in srgb, var(--shadow-ink) var(--shadow-strength), transparent);
    --shadow-float: 0 10px 26px color-mix(in srgb, var(--shadow-ink) var(--shadow-strength), transparent);
    --shadow-soft: 0 5px 14px color-mix(in srgb, var(--shadow-ink) var(--shadow-strength), transparent);
    --shadow-side: -18px 0 42px color-mix(in srgb, var(--shadow-ink) var(--shadow-strength), transparent);
    /* 选中态的光晕用纯强调色，比墨底更明显 */
    --shadow-glow: 0 4px 10px color-mix(in srgb, var(--accent) var(--shadow-glow-strength), transparent);
  }
  /* 深色背景上彩色阴影会糊成一片：墨底压到近黑，浓度稍高才看得出层次 */
  :root[data-theme="night"] {
    --shadow-ink: color-mix(in srgb, var(--accent) 18%, #05070f);
    --shadow-strength: 18%;
    --shadow-glow-strength: 22%;
  }
}

/* ── 预设主题（body[data-theme] 切换） ── */
:root[data-theme="sky"] {
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, .14);
  --text-main: #1e3a5f;
  --text-sub: #5b7594;
}
:root[data-theme="mint"] {
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, .14);
  --text-main: #12402f;
  --text-sub: #4b7a66;
}
:root[data-theme="dusk"] {
  --accent: #f97316;
  --accent-soft: rgba(249, 115, 22, .15);
  --text-main: #4a2c14;
  --text-sub: #8a6a4c;
}
:root[data-theme="night"] {
  --glass-bg: rgba(20, 24, 40, .72);
  --glass-border: rgba(255, 255, 255, .12);
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, .18);
  --text-main: #e8ecff;
  --text-sub: #9aa5c4;
  /* 夜间阴影由上面 @supports 里的 --shadow-ink / --shadow-strength 派生，
     不再写死一条黑色 --shadow，否则会盖掉随主题变化的那一版 */
}
:root[data-theme="ink"] {
  --accent: #475569;
  --accent-soft: rgba(71, 85, 105, .13);
  --text-main: #2d333c;
  --text-sub: #64748b;
}

/* ── 字体族（设置面板 fontFamily 值） ──
   一套字体栈要覆盖 Win / macOS / iOS / Android / HarmonyOS / Linux：
   以前只写 mac 的名字（Yuanti SC、Songti SC），Windows 上直接落回 sans-serif，
   表现就是「换字体没反应」。现在每个键都把各平台的同风格字体名按序排好，
   最后兜到通用族，所以只要设备装了其中任何一种就能生效。
   列表里只放这四种（大多设备都有）；楷体 / 仿宋 / 圆体各平台装的不一样，
   且中文都是 1em 宽、测不出差别，列出来只会「选了没反应」，故不提供 */
:root[data-font="system"] {
  --font-main: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
               "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei",
               system-ui, sans-serif;
}
:root[data-font="hei"] {
  --font-main: "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC", "Heiti SC",
               "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", sans-serif;
}
:root[data-font="song"] {
  --font-main: "Songti SC", "STSong", SimSun, "NSimSun", "Noto Serif CJK SC",
               "Source Han Serif SC", "Songti TC", "AR PL UMing CN", serif;
}
:root[data-font="mono"] {
  --font-main: "SF Mono", "Cascadia Code", Consolas, Menlo, "DejaVu Sans Mono",
               "Noto Sans Mono CJK SC", monospace;
}

/* ── 背景层 ── */
#bg-layer {
  position: fixed; inset: 0; z-index: 0;
  background: linear-gradient(135deg, #7dd3fc, #a5b4fc 50%, #fbcfe8);
  background-size: cover;
  background-position: center;
  transition: background .5s ease, filter .3s ease;
}
body[data-bg="color"] #bg-layer { background-image: none; }
body[data-bg="image"] #bg-layer {
  background-image: var(--bg-img, none);
  background-repeat: no-repeat;
}
