/* ============================================================
   泛 432 应用统计真题墙 · 昼夜主题模块
   本模块为「纯新增」层：wall.css / reader.css / responsive.css 一字未改，
   本文件的暗色规则也只在 html[data-theme="dark"] 下生效。
   注意：亮色外观仍有变化，但那不来自本文件，而来自 /shared/tokens.css 把本 app
   漂移的色值收敛到全站规范值（纸 #f7f1e4→#f1ede1、墨 #25362f→#232b24、
   绿 #2f6758→#2f5d4e、金 #c39a54→#97803f）。实测亮色像素变化 5.2%。

   背景：本 app 原先完全没有暗色模式（明暗截图逐像素相同）。它的 41KB CSS
   里约 140 处颜色是硬编码字面量，只靠改那 10 个令牌无法变暗，故在此逐条覆盖。

   配色取自全站共享令牌（--fqy-*，见 /shared/tokens.css），不再自造色板。

   本文件也承载新增的顶栏昼夜开关样式（本 app 原先没有这个控件），
   以及把 .practice-cta 漂移的朱砂色对齐到规范值 —— 该 CTA 保持红色
   （朱砂是全站第二品牌色，用于「风」印章，突出跨模块入口是有意设计），
   只去掉 #c95b4f / #b14a3f 相对规范 --fqy-seal 的色偏。
   ============================================================ */

/* ── 顶栏昼夜开关（新增控件，明暗通用）──────────────────── */
.tongji-theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--fqy-panel);
  color: var(--fqy-ink-soft);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tongji-theme-toggle:hover {
  color: var(--fqy-accent);
  border-color: color-mix(in srgb, var(--fqy-accent) 40%, var(--line));
}

.tongji-theme-toggle:focus-visible {
  outline: 2px solid var(--fqy-accent);
  outline-offset: 2px;
}

/* ── 跨模块 CTA：保留朱砂语义，仅对齐到规范色 ─────────────── */
.practice-cta {
  background: linear-gradient(135deg, var(--fqy-seal), color-mix(in srgb, var(--fqy-seal) 82%, #000));
  color: var(--fqy-on-accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--fqy-seal) 26%, transparent);
}

html[data-theme="dark"] {
  color-scheme: dark;
}

/* ── 底与远山 ─────────────────────────────────────────── */
html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 18% 8%, rgba(201, 86, 74, 0.07), transparent 26rem),
    linear-gradient(168deg, var(--fqy-bg-a), var(--fqy-bg-b)),
    var(--fqy-bg);
}

html[data-theme="dark"] .ink-bg path:first-child { fill: #2b3a33; }
html[data-theme="dark"] .ink-bg path:last-child { fill: #223028; }

/* ── 顶栏 / 搜索 / 视图切换 ───────────────────────────── */
html[data-theme="dark"] .topbar { background: rgba(16, 23, 21, 0.9); }
html[data-theme="dark"] .search { background: rgba(24, 34, 29, 0.78); }
html[data-theme="dark"] .search:focus-within {
  border-color: rgba(93, 156, 133, 0.45);
  box-shadow: 0 0 0 3px rgba(93, 156, 133, 0.12);
}
html[data-theme="dark"] .mode-tabs { background: rgba(18, 26, 22, 0.68); }
html[data-theme="dark"] .mode-tabs button,
html[data-theme="dark"] .mode-tabs .tab-link,
html[data-theme="dark"] .toolbar-actions button,
html[data-theme="dark"] .next-list button { background: rgba(24, 34, 29, 0.82); }
html[data-theme="dark"] .mode-tabs button.is-active,
html[data-theme="dark"] .mode-tabs .tab-link.is-active,
html[data-theme="dark"] .toolbar-actions button:first-child { color: var(--fqy-on-accent); }

/* 跨模块 CTA 在暗底上的阴影需加深，颜色仍走规范朱砂 */
html[data-theme="dark"] .practice-cta {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.42);
}

html[data-theme="dark"] .brand-seal,
html[data-theme="dark"] .hero-seal {
  color: var(--fqy-on-accent);
  background: linear-gradient(145deg, #2f6758, #47816d);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.4);
}

/* ── 侧栏院校目录 ─────────────────────────────────────── */
html[data-theme="dark"] .sidebar {
  background: rgba(18, 26, 22, 0.72);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .side-title small { background: rgba(93, 156, 133, 0.12); }
html[data-theme="dark"] .school-btn { background: rgba(24, 34, 29, 0.7); }
html[data-theme="dark"] .school-btn:hover,
html[data-theme="dark"] .school-btn.is-active {
  border-color: rgba(93, 156, 133, 0.3);
  background: rgba(28, 43, 37, 0.86);
}
html[data-theme="dark"] .school-btn .logo { background: #1d2a24; }
html[data-theme="dark"] .school-btn em { background: rgba(93, 156, 133, 0.14); }
html[data-theme="dark"] .school-btn.is-active .school-chip { color: var(--fqy-on-accent); }

/* ── Hero 面板与概览 ─────────────────────────────────── */
html[data-theme="dark"] .hero-panel {
  background: linear-gradient(135deg, rgba(24, 34, 29, 0.92), rgba(20, 30, 26, 0.88));
}
html[data-theme="dark"] .fact { background: rgba(93, 156, 133, 0.12); }
html[data-theme="dark"] .fact-prog {
  color: var(--fqy-seal-2);
  background: rgba(201, 86, 74, 0.16);
}
html[data-theme="dark"] .hero-topic-chip { background: rgba(24, 34, 29, 0.82); }
html[data-theme="dark"] .hero-topic-chip.is-active { color: var(--fqy-on-accent); }

/* ── 筛选与区块容器 ─────────────────────────────────── */
html[data-theme="dark"] .chips button { background: rgba(24, 34, 29, 0.76); }
html[data-theme="dark"] .chips button.is-active { color: var(--fqy-on-accent); }
html[data-theme="dark"] .wall-section,
html[data-theme="dark"] .topic-section,
html[data-theme="dark"] .note-card {
  background: rgba(18, 26, 22, 0.76);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.34);
}

/* ── 卷面卡 ───────────────────────────────────────────── */
html[data-theme="dark"] .paper-card {
  border-color: rgba(58, 74, 64, 0.7);
  background:
    linear-gradient(180deg, rgba(93, 156, 133, 0.14) 0 8px, transparent 8px),
    linear-gradient(165deg, var(--fqy-paper), var(--fqy-panel-2));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
}
html[data-theme="dark"] .paper-card:hover { box-shadow: 0 18px 38px rgba(0, 0, 0, 0.46); }
html[data-theme="dark"] .paper-card::before { border-top-color: rgba(179, 154, 90, 0.26); }
html[data-theme="dark"] .paper-logo {
  background: #1d2a24;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .paper-year {
  border-color: rgba(201, 86, 74, 0.5);
  background: rgba(28, 40, 34, 0.86);
}
html[data-theme="dark"] .paper-actions button { background: rgba(24, 34, 29, 0.9); }
html[data-theme="dark"] .paper-actions button:first-child { color: var(--fqy-on-accent); }
html[data-theme="dark"] .paper-card mark,
html[data-theme="dark"] .hero-panel mark {
  background: rgba(179, 154, 90, 0.38);
  color: var(--fqy-ink);
}

/* ── 考点药丸 ─────────────────────────────────────────── */
html[data-theme="dark"] .topic-pill,
html[data-theme="dark"] .paper-meta span {
  color: var(--fqy-accent-2);
  background: rgba(93, 156, 133, 0.14);
}
html[data-theme="dark"] .topic-pill:nth-child(2n) {
  color: var(--fqy-seal-2);
  background: rgba(201, 86, 74, 0.14);
}
html[data-theme="dark"] .program-pill {
  color: var(--fqy-seal-2) !important;
  background: rgba(201, 86, 74, 0.16) !important;
}

/* ── 空态与热图 ───────────────────────────────────────── */
html[data-theme="dark"] .empty { border-color: rgba(93, 156, 133, 0.3); }
html[data-theme="dark"] .empty-actions button,
html[data-theme="dark"] .practice-cta-mobile { background: rgba(24, 34, 29, 0.9); }
html[data-theme="dark"] .heatmap-topic,
html[data-theme="dark"] .heatmap-cell { background: rgba(24, 34, 29, 0.72); }
html[data-theme="dark"] .heatmap-topic:hover,
html[data-theme="dark"] .heatmap-cell:hover { background: rgba(30, 44, 37, 0.92); }
html[data-theme="dark"] .heatmap-cell {
  color: var(--fqy-ink);
  background-color: rgba(93, 156, 133, calc(0.08 + var(--heat) * 0.5));
}
html[data-theme="dark"] .heatmap-cell:empty,
html[data-theme="dark"] .heatmap-cell.is-empty { background-color: rgba(140, 145, 131, 0.07); }
html[data-theme="dark"] .heatmap-topic.is-active,
html[data-theme="dark"] .heatmap-cell.is-active {
  border-color: rgba(201, 86, 74, 0.58);
  box-shadow: 0 0 0 2px rgba(201, 86, 74, 0.14);
}
html[data-theme="dark"] .topic-bars {
  background:
    linear-gradient(90deg, rgba(18, 26, 22, 0.96), transparent 18px) left / 22px 100% no-repeat,
    linear-gradient(270deg, rgba(18, 26, 22, 0.96), transparent 18px) right / 22px 100% no-repeat;
}

/* ── 公告 ─────────────────────────────────────────────── */
html[data-theme="dark"] .site-announcement {
  border-color: rgba(58, 74, 64, 0.7);
  background: rgba(22, 31, 27, 0.99);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .site-announcement::backdrop { background: rgba(0, 0, 0, 0.58); }
html[data-theme="dark"] .site-announcement-mark { color: var(--fqy-on-accent); }
html[data-theme="dark"] .site-announcement-actions button { background: var(--fqy-panel-2); }
html[data-theme="dark"] .site-announcement-actions button:first-child { color: var(--fqy-on-accent); }

/* ── PDF 导出对话框 ──────────────────────────────────── */
html[data-theme="dark"] .export-dialog {
  border-color: rgba(58, 74, 64, 0.7);
  background: rgba(22, 31, 27, 0.99);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
}
html[data-theme="dark"] .export-dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
html[data-theme="dark"] .export-dialog-panel > header { background: rgba(93, 156, 133, 0.08); }
html[data-theme="dark"] #exportClose,
html[data-theme="dark"] .export-dialog-body select,
html[data-theme="dark"] .export-dialog-panel > footer button,
html[data-theme="dark"] .solution-collection-button { background: var(--fqy-panel-2); }
html[data-theme="dark"] .export-dialog-hint { background: rgba(179, 154, 90, 0.1); }
html[data-theme="dark"] .export-dialog-panel > footer .export-primary,
html[data-theme="dark"] .solution-collection-button.is-active {
  color: var(--fqy-on-accent);
  background: var(--fqy-accent);
}

/* ── 阅读器 ───────────────────────────────────────────── */
html[data-theme="dark"] .reader {
  border-color: rgba(58, 74, 64, 0.7);
  background: rgba(22, 31, 27, 0.98);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
}
html[data-theme="dark"] .reader::backdrop { background: rgba(0, 0, 0, 0.62); }
html[data-theme="dark"] .reader-head { background: rgba(20, 29, 25, 0.94); }
html[data-theme="dark"] .reader-head button { background: var(--fqy-panel-2); }
html[data-theme="dark"] .reader-head button:hover { background: rgba(201, 86, 74, 0.18); }
html[data-theme="dark"] .reader-meta span { background: rgba(93, 156, 133, 0.14); }
html[data-theme="dark"] .reader-content { color: var(--fqy-ink); }
html[data-theme="dark"] .reader-content blockquote { background: rgba(93, 156, 133, 0.1); }
html[data-theme="dark"] .reader-content .exam-asset-note {
  border-color: rgba(93, 156, 133, 0.34);
  background: rgba(93, 156, 133, 0.08);
}
html[data-theme="dark"] .reader-content .exam-section { background: rgba(93, 156, 133, 0.1); }
html[data-theme="dark"] .reader-content .exam-q.is-jump-highlight {
  background: rgba(93, 156, 133, 0.12);
  box-shadow: 0 0 0 3px rgba(93, 156, 133, 0.1);
}
html[data-theme="dark"] .reader-content .exam-options li { background: rgba(230, 228, 214, 0.05); }
html[data-theme="dark"] .reader-tabs { background: rgba(20, 29, 25, 0.94); }
html[data-theme="dark"] .reader-tabs button { background: rgba(24, 34, 29, 0.78); }
html[data-theme="dark"] .reader-tabs button.is-active { color: var(--fqy-on-accent); }

/* ── 逐题解析 ─────────────────────────────────────────── */
html[data-theme="dark"] .solution-block { background: rgba(230, 228, 214, 0.04); }
html[data-theme="dark"] .solution-toolbar {
  border-color: rgba(93, 156, 133, 0.22);
  background: rgba(22, 31, 27, 0.95);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.34);
}
html[data-theme="dark"] .solution-question-nav button,
html[data-theme="dark"] .solution-toolbar-actions button { background: rgba(230, 228, 214, 0.07); }
html[data-theme="dark"] .solution-question-nav button.is-active { color: var(--fqy-on-accent); }
html[data-theme="dark"] .solution-toolbar-actions button[aria-pressed="true"] {
  border-color: rgba(93, 156, 133, 0.32);
  background: rgba(93, 156, 133, 0.12);
}
html[data-theme="dark"] .solution-question { background: rgba(230, 228, 214, 0.05); }
html[data-theme="dark"] .solution-question.is-jump-highlight {
  border-color: rgba(93, 156, 133, 0.52);
  background: rgba(230, 228, 214, 0.09);
  box-shadow: 0 0 0 4px rgba(93, 156, 133, 0.12);
}
html[data-theme="dark"] .solution-question.is-blocked {
  border-color: rgba(201, 86, 74, 0.38);
  background: rgba(44, 36, 23, 0.6);
}
html[data-theme="dark"] .solution-question-text { background: rgba(93, 156, 133, 0.07); }
html[data-theme="dark"] .solution-answer { background: rgba(93, 156, 133, 0.11); }
html[data-theme="dark"] .solution-callout {
  border-left-color: rgba(93, 156, 133, 0.4);
  background: rgba(93, 156, 133, 0.07);
}
html[data-theme="dark"] .solution-work {
  border-color: rgba(93, 156, 133, 0.22);
  background: rgba(230, 228, 214, 0.04);
}
html[data-theme="dark"] .solution-work summary::before { color: var(--fqy-on-accent); }
html[data-theme="dark"] .solution-details { background: rgba(230, 228, 214, 0.035); }
html[data-theme="dark"] .solution-warning {
  border-color: rgba(201, 86, 74, 0.26);
  color: #e8a58f;
  background: rgba(201, 86, 74, 0.1);
}
html[data-theme="dark"] .solution-exam-link,
html[data-theme="dark"] .exam-solution-link {
  border-color: rgba(93, 156, 133, 0.26);
  background: rgba(93, 156, 133, 0.09);
}
html[data-theme="dark"] .solution-empty {
  border-color: rgba(201, 86, 74, 0.36);
  background: rgba(201, 86, 74, 0.08);
}
html[data-theme="dark"] .solution-tags span { background: rgba(93, 156, 133, 0.14); }

/* ============================================================
   主态 / 激活态实底恢复
   上方的「基态」覆盖规则（如 .paper-actions button）特异度为 (0,2,2)，
   高于亮色 CSS 里给主按钮上绿底的 .paper-actions button:first-child (0,2,1)，
   会把主按钮的实底吃掉、只剩近黑文字浮在深底上（等于不可见）。
   故在此用 (0,3,2) 显式恢复实底；--fqy-accent 在暗色下自动为 #5d9c85。
   ============================================================ */
html[data-theme="dark"] .mode-tabs button.is-active,
html[data-theme="dark"] .mode-tabs .tab-link.is-active,
html[data-theme="dark"] .toolbar-actions button:first-child,
html[data-theme="dark"] .next-list button:first-child,
html[data-theme="dark"] .chips button.is-active,
html[data-theme="dark"] .paper-actions button:first-child,
html[data-theme="dark"] .hero-topic-chip.is-active,
html[data-theme="dark"] .reader-tabs button.is-active,
html[data-theme="dark"] .solution-question-nav button.is-active,
html[data-theme="dark"] .site-announcement-actions button:first-child {
  border-color: transparent;
  color: var(--fqy-on-accent);
  background: var(--fqy-accent);
}

html[data-theme="dark"] .school-btn.is-active .school-chip {
  color: var(--fqy-ink);
}

html[data-theme="dark"] .solution-work summary {
  color: var(--fqy-accent-2);
}

html[data-theme="dark"] .solution-work summary::before {
  color: var(--fqy-on-accent);
  background: var(--fqy-accent);
}
