/* =========================================================
   考研数学一学习站 —— 复古报纸风格（支持黑暗模式）
   主题通过 html[data-theme="light|dark"] 切换，
   默认跟随系统 prefers-color-scheme，可用右上角按钮切换
   ========================================================= */

/* ---------- 主题变量 ---------- */
:root {
  --paper: #f4eddc;
  --paper-deep: #ece3cc;
  --card: #fbf6e9;
  --ink: #2a2419;
  --ink-soft: #71665a;
  --line: #c9bb98;
  --accent: #8c2b2b;
  --accent-soft: #f3e4e0;
  --ok: #2e6b45;
  --ok-soft: #e3ecdc;
  --err: #a13c2a;
  --err-soft: #f3e0d9;
  --shadow: 5px 5px 0 rgba(42, 36, 25, 0.10);
  --serif: Georgia, "Times New Roman", "SimSun", "Songti SC", "STSong", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

html[data-theme="dark"] {
  --paper: #191611;
  --paper-deep: #131009;
  --card: #221d14;
  --ink: #e4dcc8;
  --ink-soft: #9b917c;
  --line: #49422f;
  --accent: #d0806a;
  --accent-soft: #33231d;
  --ok: #7fae8b;
  --ok-soft: #1f2b20;
  --err: #d0806a;
  --err-soft: #332019;
  --shadow: 5px 5px 0 rgba(0, 0, 0, 0.45);
}

/* ---------- 全局 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, transparent 60%, rgba(42,36,25,0.05) 100%),
    var(--paper);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(ellipse at 20% 0%, transparent 60%, rgba(0,0,0,0.25) 100%),
    var(--paper);
}

.hidden { display: none !important; }

h1, h2, h3, h4, .q-num, .score { font-family: var(--serif); }

.katex { color: var(--ink); font-size: 1.02em; }

/* ---------- 报纸卡片 ---------- */
.glass {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.container { max-width: 1080px; margin: 0 auto; padding: 24px 18px 60px; }

/* ---------- 报头 ---------- */
.site-header {
  background: var(--card);
  border-bottom: 3px double var(--ink);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 12px; }
.home-link {
  font-family: var(--serif); font-size: 13px; color: var(--muted, #7a7268);
  text-decoration: none; white-space: nowrap;
}
.home-link:hover { color: inherit; text-decoration: underline; }
.logo-mark {
  width: 46px; height: 46px; border: 2px solid var(--ink);
  font-family: var(--serif); font-size: 26px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper);
}
.logo h1 {
  font-size: 20px; letter-spacing: 2px; font-weight: 800;
}
.logo p { font-size: 12px; color: var(--ink-soft); margin-top: 2px; letter-spacing: 1px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tab {
  border: none; cursor: pointer; font-size: 14px; padding: 8px 12px;
  background: transparent; color: var(--ink-soft); font-family: var(--sans);
  border-bottom: 2px solid transparent; letter-spacing: 1px;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--accent); }
.tab.active {
  color: var(--ink); font-weight: 700;
  border-bottom: 2px solid var(--accent);
  background: transparent;
}
.theme-toggle { font-size: 16px; margin-left: 6px; }

/* ---------- 通用元素 ---------- */
.view-title { margin: 30px 4px 18px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.view-title h2 {
  font-size: 24px; letter-spacing: 2px;
  display: flex; align-items: center; gap: 10px;
}
.view-title h2::before { content: "§"; color: var(--accent); }
.view-title p { font-size: 13px; color: var(--ink-soft); margin-top: 6px; letter-spacing: 0.5px; }

button.btn {
  border: 1px solid var(--ink); cursor: pointer; font-size: 14px;
  padding: 10px 20px; background: var(--ink); color: var(--paper);
  font-family: var(--sans); letter-spacing: 1px; border-radius: 1px;
  transition: all 0.15s ease;
}
button.btn:hover { background: var(--accent); border-color: var(--accent); }
button.btn.ghost {
  background: transparent; color: var(--ink);
}
button.btn.ghost:hover { background: var(--ink); color: var(--paper); }
button.btn.small { padding: 6px 12px; font-size: 13px; }

.placeholder { text-align: center; color: var(--ink-soft); padding: 80px 20px; font-size: 15px; }

.badge {
  display: inline-block; font-size: 12px; padding: 2px 10px;
  border: 1px solid var(--line); color: var(--ink-soft);
  letter-spacing: 1px; font-family: var(--sans);
}
.badge.done { border-color: var(--ok); color: var(--ok); }
.badge.warn { border-color: var(--accent); color: var(--accent); }

/* ---------- 学习路径 ---------- */
.chapter-card { padding: 22px 24px; margin-bottom: 22px; }
.chapter-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chapter-head h3 { font-size: 19px; display: flex; align-items: center; gap: 10px; letter-spacing: 1px; }
.chapter-num {
  width: 30px; height: 30px; border: 1.5px solid var(--ink);
  font-family: var(--serif); font-size: 15px; font-weight: bold;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--paper);
}
.chapter-bar { flex: 1 1 160px; max-width: 260px; height: 8px; background: var(--paper-deep); border: 1px solid var(--line); overflow: hidden; }
.chapter-bar-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.chapter-bar-label { font-size: 12px; color: var(--ink-soft); margin-left: 8px; white-space: nowrap; font-family: var(--serif); }

.section-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.section-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px dashed var(--line); cursor: pointer;
  transition: background 0.15s ease;
}
.section-item:last-child { border-bottom: none; }
.section-item:hover { background: var(--paper-deep); }
.section-item .check {
  width: 18px; height: 18px; border: 1.5px solid var(--ink-soft); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: transparent;
  font-family: var(--serif);
}
.section-item.done .check { background: var(--ok); border-color: var(--ok); color: var(--card); }
.section-item .sec-title { flex: 1; font-size: 14px; }
.section-item.done .sec-title { color: var(--ink-soft); }
.section-item .sec-time { font-size: 12px; color: var(--ink-soft); white-space: nowrap; font-family: var(--serif); }
.section-item .go { font-size: 12px; color: var(--accent); white-space: nowrap; letter-spacing: 1px; }

/* ---------- 讲义 ---------- */
.lecture-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.lecture-nav { padding: 16px; position: sticky; top: 100px; max-height: calc(100vh - 130px); overflow-y: auto; }
.lecture-nav h4 {
  font-size: 14px; margin: 12px 4px 8px; color: var(--ink);
  border-bottom: 1px solid var(--line); padding-bottom: 5px; letter-spacing: 2px;
}
.nav-sec {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  padding: 8px 10px; font-size: 13px; color: var(--ink-soft); cursor: pointer;
  font-family: var(--sans); border-left: 3px solid transparent; margin-bottom: 1px;
  transition: all 0.12s ease;
}
.nav-sec:hover { color: var(--accent); }
.nav-sec.active { color: var(--ink); font-weight: 700; border-left-color: var(--accent); background: var(--paper-deep); }
.nav-sec .dot { display: inline-block; width: 6px; height: 6px; border: 1px solid var(--ink-soft); margin-right: 7px; vertical-align: middle; }
.nav-sec.done .dot { background: var(--ok); border-color: var(--ok); }

.lecture-content { padding: 30px 36px; min-height: 400px; }
.lecture-content h2 { font-size: 22px; letter-spacing: 1px; border-bottom: 3px double var(--ink); padding-bottom: 10px; }
.lecture-meta { font-size: 12px; color: var(--ink-soft); margin: 10px 0 18px; font-family: var(--serif); letter-spacing: 1px; }
.lecture-body { font-size: 15px; line-height: 2; }
.lecture-body p { margin: 12px 0; }
.lecture-body h3 {
  font-size: 17px; margin: 28px 0 10px; padding-left: 12px;
  border-left: 4px double var(--accent); letter-spacing: 1px;
}
.lecture-body ul, .lecture-body ol { padding-left: 26px; margin: 10px 0; }
.lecture-body li { margin: 6px 0; }

.example {
  margin: 20px 0; padding: 18px 20px;
  background: var(--paper-deep); border: 1px solid var(--line); border-left: 4px solid var(--ink);
}
.example-title { font-weight: 700; font-size: 14px; color: var(--ink); font-family: var(--serif); letter-spacing: 1px; }
.example-title::before { content: "※ "; color: var(--accent); }
.solution-title { font-weight: 700; font-size: 14px; color: var(--ok); margin: 14px 0 6px; font-family: var(--serif); }
.key-box {
  margin: 18px 0; padding: 14px 18px;
  background: var(--ok-soft); border: 1px solid var(--ok);
}
.key-box strong { color: var(--ok); }
.tip-box {
  margin: 18px 0; padding: 14px 18px;
  background: var(--accent-soft); border: 1px solid var(--accent);
}
.tip-box strong { color: var(--accent); }

.lecture-actions { display: flex; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- 测试 ---------- */
.test-toolbar { padding: 14px 18px; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.test-toolbar .label { font-size: 14px; font-weight: 600; font-family: var(--serif); letter-spacing: 1px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  padding: 7px 18px; cursor: pointer; font-size: 14px; font-family: var(--sans);
  border-radius: 1px; letter-spacing: 1px; transition: all 0.15s ease;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.test-history { margin-left: auto; font-size: 13px; color: var(--ink-soft); font-family: var(--serif); }

.question-card { padding: 22px 24px; margin-bottom: 16px; }
.q-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 12px; }
.q-num { font-weight: 700; color: var(--accent); font-size: 15px; white-space: nowrap; }
.q-text { font-size: 15px; line-height: 1.8; }
.q-options { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.q-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px;
  border: 1px solid var(--line); cursor: pointer; font-size: 14px;
  transition: all 0.15s ease; line-height: 1.7; background: transparent;
}
.q-option:hover { border-color: var(--ink); }
.q-option input { margin-top: 5px; accent-color: var(--accent); }
.q-option.correct { border-color: var(--ok); background: var(--ok-soft); }
.q-option.wrong { border-color: var(--err); background: var(--err-soft); }
.q-option.disabled { pointer-events: none; opacity: 0.9; }

.q-explain {
  margin-top: 14px; padding: 14px 16px; font-size: 14px; line-height: 1.8;
  background: var(--paper-deep); border-left: 4px solid var(--ink);
}
.q-explain.good { border-left-color: var(--ok); }
.q-explain.bad { border-left-color: var(--err); }
.q-verdict { font-weight: 700; margin-bottom: 6px; font-family: var(--serif); }
.q-verdict.good { color: var(--ok); }
.q-verdict.bad { color: var(--err); }

.test-result { padding: 24px; margin-bottom: 18px; text-align: center; }
.test-result .score { font-size: 42px; font-weight: 800; color: var(--accent); }
.test-result .score-sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

/* ---------- 进度 ---------- */
.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 20px; }
.stat-card { padding: 20px 22px; }
.stat-card h4 { font-size: 15px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; font-family: var(--serif); letter-spacing: 1px; }
.stat-card h4 .val { color: var(--accent); font-size: 18px; }
.stat-card h4 .val.green { color: var(--ok); }
.pbar { height: 10px; background: var(--paper-deep); border: 1px solid var(--line); overflow: hidden; margin: 8px 0 4px; }
.pbar-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.pbar-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); }

.cal-card { padding: 20px 22px; grid-column: 1 / -1; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.cal-head h4 { font-size: 15px; font-family: var(--serif); letter-spacing: 1px; }
.cal-month { font-weight: 700; font-size: 15px; font-family: var(--serif); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { text-align: center; font-size: 12px; color: var(--ink-soft); padding: 4px 0; font-family: var(--serif); }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--ink); border: 1px solid transparent;
  font-family: var(--serif); transition: all 0.12s ease;
}
.cal-day.empty { visibility: hidden; }
.cal-day.today { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.cal-day.checked { background: var(--ink); color: var(--paper); cursor: pointer; }
.cal-day:not(.empty):not(.checked) { cursor: pointer; }
.cal-day:not(.empty):not(.checked):hover { background: var(--paper-deep); }
.cal-legend { font-size: 12px; color: var(--ink-soft); margin-top: 12px; }

.data-actions { padding: 20px 22px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.data-actions .note { font-size: 13px; color: var(--ink-soft); flex-basis: 100%; }

.wrong-card { padding: 20px 24px; margin-bottom: 14px; }
.wrong-card .wrong-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.empty-hint { text-align: center; padding: 30px; color: var(--ink-soft); font-size: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .lecture-layout { grid-template-columns: 1fr; }
  .lecture-nav { position: static; max-height: none; }
  .lecture-content { padding: 22px 18px; }
  .logo h1 { font-size: 16px; }
  .logo-mark { width: 38px; height: 38px; font-size: 22px; }
  .tab { padding: 7px 9px; font-size: 13px; }
  .header-inner { padding: 12px 14px; }
  .chapter-bar { max-width: none; }
}
