/* ==========================================================================
   黑夜模式（Dark Theme）
   思路：style.css 已经把结构色抽成语义变量，这里只需整体覆盖变量；
   少数直接写死颜色的组件（徽章、提示条、编辑器纸面、图表 SVG）做定向补丁。
   切换方式：<html data-theme="dark">，见 base.html 与 app.js。
   ========================================================================== */

[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-dark: #93c5fd;
  --bg: #0b111c;
  --card: #141d2e;
  --text: #e3eaf5;
  --muted: #93a4bd;
  --border: #27344a;
  --danger: #f87171;
  --warning: #fbbf24;
  --success: #4ade80;
  --info: #38bdf8;

  --topbar-bg: #0e1727;
  --topbar-border: #24314a;
  --on-accent: #ffffff;
  --accent-bg: #2f6fe4;
  --accent-bg-hover: #3b82f6;

  --surface-2: #1a2438;
  --surface-3: #1f2b41;
  --track: #2b3950;
  --border-strong: #3a4a63;
  --text-soft: #c2cee0;
  --text-faint: #8595ad;
  --grid-line: #27344a;

  --stat-from: #182742;
  --stat-to: #1d3157;
  --tint-blue: #16233b;
  --tint-red: #2a1720;
  --tint-amber: #2a2113;
  --tint-indigo: #241f45;
  --indigo-fg: #c4b5fd;

  --flash-ok-bg: #12291d;   --flash-ok-fg: #7fe0a4;
  --flash-err-bg: #2c1720;  --flash-err-fg: #fca5a5;
  --flash-warn-bg: #2b2313; --flash-warn-fg: #fcd34d;
  --flash-info-bg: #122433; --flash-info-fg: #7dd3fc;

  --series-total: #e3eaf5;
  --chart-grid: #27344a;
  --chart-axis: #8595ad;

  --shadow: 0 1px 3px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---- 顶栏 ---- */
[data-theme="dark"] .topbar nav a { color: rgba(226, 235, 247, .82); }
[data-theme="dark"] .topbar nav a:hover { background: rgba(255, 255, 255, .1); }
[data-theme="dark"] .topbar .brand { color: var(--text); }
[data-theme="dark"] .topbar select option { background: var(--card); color: var(--text); }

/* ---- 卡片阴影与描边：深色下靠边框分层，不用投影 ---- */
[data-theme="dark"] .card { box-shadow: none; }
[data-theme="dark"] .weekly-card:hover { box-shadow: 0 8px 22px rgba(0, 0, 0, .45); }
[data-theme="dark"] .weekly-sheet { box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }

/* ---- 学龄段徽章 ---- */
[data-theme="dark"] .badge-infant { background: #3a1d31; color: #f9a8d4; }
[data-theme="dark"] .badge-kindergarten { background: #362a12; color: #fcd34d; }
[data-theme="dark"] .badge-primary { background: #16294a; color: #93c5fd; }
[data-theme="dark"] .badge-junior { background: #102e1f; color: #86efac; }
[data-theme="dark"] .badge-senior { background: #251f45; color: #c4b5fd; }
[data-theme="dark"] .badge-adult { background: #24303f; color: #cbd5e1; }

/* ---- 提示消息加一圈描边，避免与卡片底混在一起 ---- */
[data-theme="dark"] .flash { border: 1px solid transparent; }
[data-theme="dark"] .flash-success { border-color: #1e5335; }
[data-theme="dark"] .flash-danger { border-color: #6b2230; }
[data-theme="dark"] .flash-warning { border-color: #6b5320; }
[data-theme="dark"] .flash-info { border-color: #1d4e68; }

/* ---- 表单控件 ---- */
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #6c7d95; }
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.8); }
[data-theme="dark"] .total-source { background: #16294a; color: #93c5fd; }
[data-theme="dark"] .total-source.is-manual { background: #251f45; color: #c4b5fd; }

/* ---- 表格 ---- */
[data-theme="dark"] .table-wrap { background: var(--card); }
[data-theme="dark"] tr:hover td { background: #1c2740; }
[data-theme="dark"] .total-summary-row { background: #1c2740; }

/* ---- 甘特图 ---- */
[data-theme="dark"] .gantt-head { background: var(--surface-2); }
[data-theme="dark"] .pin-label { box-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
[data-theme="dark"] .gantt-bar,
[data-theme="dark"] .rm-bar { text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }

/* ---- 阅读/运动/英语月历 ---- */
[data-theme="dark"] .checkin-cal td.cal-empty { background: #131b2a; }
[data-theme="dark"] .checkin-cal td.cal-future { background: #161f30; }
[data-theme="dark"] .checkin-cal td.cal-checked { background: #2a2113; }
[data-theme="dark"] .checkin-cal .cal-star { color: #fbbf24; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }

/* ---- 成绩走势柱状图 ---- */
[data-theme="dark"] .trend-bar {
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(0, 0, 0, .22)),
              var(--trend-color, #2563eb);
}
[data-theme="dark"] .trend-value { color: var(--text); }
[data-theme="dark"] .trend-bars::after { border-bottom-color: var(--border-strong); }

/* ---- 词汇量曲线 / 内联 SVG 图表 ---- */
[data-theme="dark"] .vocab-chart text { fill: var(--chart-axis); }
[data-theme="dark"] .vocab-chart line { stroke: var(--chart-grid); }
[data-theme="dark"] .vocab-chart circle { fill: var(--card); }

/* ---- 家庭周刊阅读版面 ---- */
[data-theme="dark"] .weekly-masthead { border-bottom-color: var(--accent, #60a5fa); }
[data-theme="dark"] .weekly-masthead-brand,
[data-theme="dark"] .weekly-deck,
[data-theme="dark"] .weekly-sub { color: var(--accent, #60a5fa); }
/* 期头配色里的 --soft 是浅色（内联写入），暗色下统一换成深色面板 */
[data-theme="dark"] .weekly-lead { background: var(--surface-2); }
[data-theme="dark"] .weekly-lead { color: var(--text-soft); }
[data-theme="dark"] .weekly-body pre { background: #0a1020; border: 1px solid var(--border); }
[data-theme="dark"] .weekly-body img { box-shadow: 0 4px 16px rgba(0, 0, 0, .4); }

/* ---- 周刊 Word 风格编辑器 ---- */
[data-theme="dark"] .weekly-toolbar { background: var(--surface-2); }
[data-theme="dark"] .tb-btn { color: var(--text-soft); }
[data-theme="dark"] .tb-btn:hover { background: #24314a; border-color: #33425c; }
[data-theme="dark"] .tb-btn.is-active { background: #1e3a63; border-color: #2f5c96; color: #bfdbfe; }
[data-theme="dark"] .tb-group + .tb-group { border-left-color: var(--border); }
[data-theme="dark"] .tb-select { background: var(--card); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .tb-color { color: var(--text-soft); }
[data-theme="dark"] .tb-color:hover { background: #24314a; border-color: #33425c; }
[data-theme="dark"] .weekly-editor { background: var(--card); color: var(--text); }
[data-theme="dark"] .weekly-editor:empty::before { color: #56657c; }
[data-theme="dark"] .weekly-editor blockquote { background: var(--surface-2); color: var(--text-soft); }
[data-theme="dark"] .weekly-editor pre { background: #0a1020; color: #dbe6f5; }
[data-theme="dark"] .weekly-editor-footer { background: var(--surface-2); }

/* ---- 图片：错题 PNG 为白底，加圆角与描边弱化突兀感 ---- */
[data-theme="dark"] .wrong-question-img,
[data-theme="dark"] img.q-img { border-radius: 6px; }

/* ---- 打印：始终按浅色输出，避免黑底耗墨/看不清 ---- */
@media print {
  [data-theme="dark"] {
    --bg: #ffffff; --card: #ffffff; --text: #000000; --muted: #555555;
    --border: #dddddd; --surface-2: #ffffff; --surface-3: #ffffff;
    --text-soft: #333333; --text-faint: #666666; --border-strong: #cccccc;
    --topbar-bg: #ffffff; --on-accent: #000000;
  }
  [data-theme="dark"] .topbar { display: none; }
}

/* ---- 周刊编辑器：AI 写作助手 ---- */
[data-theme="dark"] .tb-ai-group { border-left-color: var(--border); }
[data-theme="dark"] .tb-ai-hint { background: #17263f; border-color: #24406b; color: #dbeafe; }
[data-theme="dark"] .tb-ai-hint::placeholder { color: #5d7396; }
[data-theme="dark"] .tb-ai-hint:focus { border-color: #3b82f6; background: #1d3154; }
/* 中文译文随正文主题色（暗色下自动变浅），无底纹 */
[data-theme="dark"] .ai-trans { color: inherit; background: none; }
[data-theme="dark"] .ai-trans.t-en { color: #b79df8; background: rgba(139, 92, 246, .16); }
[data-theme="dark"] .en-text { color: #b79df8; }
[data-theme="dark"] .tb-ai-btn { background: #17263f; border-color: #24406b; color: #93c5fd; }
[data-theme="dark"] .tb-ai-btn:hover { background: #1d3154; border-color: #33578c; }
[data-theme="dark"] .ai-panel { background: var(--surface-2); border-top-color: var(--border); }
[data-theme="dark"] .ai-issue { background: var(--card); }
[data-theme="dark"] .ai-issue.sev-error { border-left-color: #f87171; }
[data-theme="dark"] .ai-issue.sev-warning { border-left-color: #fbbf24; }
[data-theme="dark"] .ai-issue.sev-suggestion { border-left-color: #60a5fa; }
[data-theme="dark"] .ai-tag { background: var(--surface-3); color: var(--text-soft); }
[data-theme="dark"] .ai-tag.t-error { background: #3a1c22; color: #fca5a5; }
[data-theme="dark"] .ai-tag.t-warning { background: #362a12; color: #fcd34d; }
[data-theme="dark"] .ai-tag.t-suggestion { background: #16294a; color: #93c5fd; }
[data-theme="dark"] .ai-orig { background: #3a1c22; color: #fca5a5; }
[data-theme="dark"] .ai-sugg { background: #12291d; color: #86efac; }
