/* =========================================================
   English Reader · Theme System
   3 themes via CSS variables: light (default) / sepia / dark
   Persisted in localStorage + SQLite (via /api/settings)
   ========================================================= */

/* ---- Default: 浅色（蓝色系 · 克制） ---- */
:root,
:root[data-theme=""] {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #1a1f2e;
  --text-2: #5a6378;
  --text-3: #95a0b3;
  --border: #e5e8ed;
  --border-strong: #cdd3dd;
  --accent: #2563eb;
  --accent-hover: #1d4fd1;
  --accent-soft: #eaf1ff;
  --highlight: #fff5b3;
  --highlight-trans: #fff8d6;
  --danger: #dc2626;
  --danger-soft: #fde8e8;
  --warning: #ea8a1f;
  --warning-soft: #fef3e2;
  --success: #16a34a;
  --success-soft: #e8f5ed;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 30, 50, 0.1);
  --radius: 4px;
  --radius-sm: 6px;
  --radius-lg: 10px;
  /* 练习分区：单词蓝 / AI 紫（不可串色） */
  --practice-word: #2563eb;
  --practice-word-soft: #eaf1ff;
  --practice-ai: #7c3aed;
  --practice-ai-soft: #f3eaff;
  --practice-word-bg: #f4f5f7;
  --practice-ai-bg: #f7f2ff;
  --practice-ai-border: #d4c4f5;
  --practice-ai-card-bg: #ffffff;
  --practice-ai-card-border: #cbb8f0;
}

/* ---- Sepia：护眼（米黄 + 深蓝 / 紫隔离） ---- */
:root[data-theme="sepia"] {
  --bg: #efe9d8;
  --surface: #faf4e2;
  --surface-2: #e6dec5;
  --text: #3a2f20;
  --text-2: #6a5a40;
  --text-3: #8a7858;
  --border: #d6c8a8;
  --border-strong: #b8a578;
  --accent: #2c5e9e;
  --accent-hover: #1e4a82;
  --accent-soft: #d8e2f0;
  --highlight: #d4b87a;
  --highlight-trans: #c8a868;
  --danger-soft: #f5d0d0;
  --warning-soft: #fae2bf;
  --success-soft: #d8efde;
  --practice-word: #2c5e9e;
  --practice-word-soft: #d8e2f0;
  --practice-ai: #7c3aed;
  --practice-ai-soft: #e8dcf5;
  --practice-word-bg: #ebe3cd;
  --practice-ai-bg: #ebe0d4;
  --practice-ai-border: #c9aed8;
  --practice-ai-card-bg: #faf4e2;
  --practice-ai-card-border: #b89ac8;
}

/* ---- Dark：深色（深蓝灰 + 亮蓝 / 亮紫） ---- */
:root[data-theme="dark"] {
  --bg: #0e1420;
  --surface: #161e2e;
  --surface-2: #1d2538;
  --text: #e4e8f0;
  --text-2: #9aa3b8;
  --text-3: #6b7488;
  --border: #252e42;
  --border-strong: #34405a;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-soft: #1e2b48;
  --highlight: #4a4118;
  --highlight-trans: #2e2a14;
  --danger-soft: #2a0e0e;
  --warning-soft: #2e1f0a;
  --success-soft: #0e2a1a;
  --practice-word: #60a5fa;
  --practice-word-soft: #1e2b48;
  --practice-ai: #a78bfa;
  --practice-ai-soft: #2a1f3e;
  --practice-word-bg: #141b2a;
  --practice-ai-bg: #1a1528;
  --practice-ai-border: #3d2f5c;
  --practice-ai-card-bg: #161e2e;
  --practice-ai-card-border: #4a3a6a;
}

/* 全局过渡（仅在非首次加载时启用，避免初始闪烁） */
.theme-ready * {
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* 应用：base 通用 */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 主题切换器: 嵌入 titlebar (.right 区域), 不挡其他按钮 */
.theme-switch {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 3px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.theme-switch button {
  padding: 5px 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: 15px;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
}
.theme-switch button:hover {
  color: var(--text);
}
.theme-switch button.active {
  background: var(--accent);
  color: #fff;
}
.theme-switch button svg {
  width: 11px;
  height: 11px;
}
