:root {
  --bg: #f4efe6;
  --bg-deep: #ebe3d4;
  --paper: #fbf7f0;
  --ink: #2b241c;
  --ink-soft: #5c5348;
  --muted: #8a7f72;
  --line: #d9cbb8;
  --red: #8b3a2a;
  --red-soft: #c45c48;
  --teal: #2c4a4e;
  --gold: #b08d57;
  --gold-light: #e6d3a8;
  --ok: #2f6b45;
  --bad: #a33b32;
  --shadow: 0 10px 30px rgba(43, 36, 28, 0.08);
  --radius: 16px;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.65;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse at 12% -10%, rgba(176, 141, 87, 0.18), transparent 50%),
    radial-gradient(ellipse at 90% 0%, rgba(139, 58, 42, 0.08), transparent 45%);
  z-index: 0;
}

.app { position: relative; z-index: 1; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(251, 247, 240, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.seal {
  width: 42px; height: 42px;
  border: 2px solid var(--red);
  color: var(--red);
  border-radius: 4px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  transform: rotate(-8deg);
  letter-spacing: 1px;
}
.brand h1 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}
.brand p { font-size: 12px; color: var(--muted); }
.progress-wrap { min-width: 180px; }
.progress-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .4s ease; }

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.nav button.active, .nav button:hover {
  background: var(--ink);
  color: var(--paper);
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 14px;
  box-shadow: var(--shadow);
}
.sidebar h3 {
  font-family: var(--serif);
  font-size: 14px;
  padding: 0 8px 10px;
  color: var(--red);
}
.unit-btn {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}
.unit-btn small { display: block; color: var(--muted); font-size: 11px; }
.unit-btn:hover, .unit-btn.active { background: var(--bg-deep); }
.lesson-list { margin: 4px 0 10px 8px; padding-left: 10px; border-left: 2px solid var(--line); }
.lesson-list button {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent;
  padding: 6px 8px; font-size: 12px;
  color: var(--ink-soft); cursor: pointer; font-family: inherit;
  border-radius: 6px;
}
.lesson-list button:hover, .lesson-list button.active { color: var(--red); background: #f3e6dc; }

.view { display: none; }
.view.active { display: block; }

.hero {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "1840—1921";
  position: absolute;
  right: 24px; top: 18px;
  font-family: var(--serif);
  font-size: 42px;
  color: rgba(139, 58, 42, 0.08);
  letter-spacing: 2px;
}
.kicker { color: var(--red); font-size: 12px; letter-spacing: 3px; margin-bottom: 8px; }
.hero h2 { font-family: var(--serif); font-size: 30px; margin-bottom: 8px; }
.hero .lead { color: var(--ink-soft); max-width: 640px; }

.lines { display: grid; gap: 12px; margin-top: 22px; }
.line-card {
  background: var(--bg);
  border-left: 4px solid var(--red);
  padding: 12px 16px;
  border-radius: 8px;
}
.line-card b { display: block; font-family: var(--serif); margin-bottom: 4px; }
.line-card span { font-size: 14px; color: var(--ink-soft); }

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 22px;
}
.unit-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.unit-card:hover { transform: translateY(-3px); }
.unit-card .num { font-size: 12px; color: var(--gold); letter-spacing: 1px; }
.unit-card h3 { font-family: var(--serif); font-size: 16px; margin: 6px 0; }
.unit-card p { font-size: 12px; color: var(--muted); }

.section-title {
  font-family: var(--serif);
  font-size: 22px;
  margin: 8px 0 16px;
  display: flex; align-items: baseline; gap: 10px;
}
.section-title span { font-size: 13px; color: var(--muted); font-family: var(--sans); }

.lesson-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.lesson-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.lesson-head h3 { font-family: var(--serif); font-size: 20px; }
.years { font-size: 12px; color: var(--red); background: #f3e6dc; padding: 2px 8px; border-radius: 99px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--ink-soft);
}
.outline h4 {
  font-size: 14px;
  margin: 14px 0 6px;
  color: var(--teal);
  font-family: var(--serif);
}
.outline ul { padding-left: 18px; }
.outline li { margin: 4px 0; font-size: 14px; }
.mnemonic {
  margin-top: 16px;
  background: #f7efd8;
  border: 1px dashed var(--gold);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
}
.mnemonic b { color: var(--red); margin-right: 6px; }

.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 8px; top: 0; bottom: 0;
  width: 2px;
  background: var(--line);
}
.t-item {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.t-item::before {
  content: "";
  position: absolute;
  left: -24px; top: 18px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--paper);
}
.t-item .y { font-family: var(--serif); color: var(--red); font-size: 13px; }
.t-item h4 { font-size: 15px; }
.t-item p { font-size: 13px; color: var(--ink-soft); }
.chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  margin-left: 6px;
  background: var(--bg-deep);
  color: var(--ink-soft);
}
.chip.侵略 { background: #f3d9d4; color: var(--red); }
.chip.条约 { background: #eadcc0; color: #6b4e16; }
.chip.探索 { background: #dce8e4; color: var(--teal); }
.chip.革命, .chip.建党 { background: #f3d9d4; color: var(--red); }
.chip.思想 { background: #e4dcee; color: #4a3566; }
.chip.抗争 { background: #dce6d8; color: var(--ok); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-row button {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 6px 12px;
  border-radius: 99px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.filter-row button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 22px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--bg-deep); font-family: var(--serif); font-weight: 700; }
.treaty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.treaty {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.treaty h3 { font-family: var(--serif); }
.treaty .meta { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.treaty li { font-size: 13px; margin: 3px 0; }
.impact { margin-top: 8px; font-size: 13px; color: var(--red); }

.flash-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
}
.flash-box .side { font-size: 12px; color: var(--muted); letter-spacing: 2px; margin-bottom: 12px; }
.flash-box .q { font-family: var(--serif); font-size: 24px; max-width: 640px; }
.flash-box .a { font-size: 18px; max-width: 680px; color: var(--teal); }
.flash-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
button.btn {
  border: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
button.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.btn.ok { background: var(--ok); }
button.btn.bad { background: var(--bad); }

.quiz-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.quiz-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; }
.quiz-stem { font-family: var(--serif); font-size: 20px; margin-bottom: 16px; }
.option {
  display: block; width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  font-family: inherit;
}
.option:hover { border-color: var(--gold); }
.option.correct { background: #e5f3ea; border-color: var(--ok); }
.option.wrong { background: #f8e4e2; border-color: var(--bad); }
.explain {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 14px;
}
.fill-row { display: flex; gap: 8px; }
.fill-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  background: var(--bg);
}
.judge-row { display: flex; gap: 10px; }

.pitfall {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.pitfall .w { color: var(--bad); font-size: 14px; }
.pitfall .r { color: var(--ok); font-size: 14px; margin-top: 4px; }

.result {
  text-align: center;
  padding: 28px;
}
.result .score {
  font-family: var(--serif);
  font-size: 64px;
  color: var(--red);
  line-height: 1;
}
.wrong-list { margin-top: 16px; text-align: left; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.stat b { display: block; font-size: 28px; font-family: var(--serif); color: var(--red); }
.stat span { font-size: 12px; color: var(--muted); }

.search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 12px;
  font-family: inherit;
  background: var(--bg);
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 16px 28px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px 12px 60px; }
  .sidebar { position: static; }
  .grid-4, .treaty-grid, .stat-row { grid-template-columns: 1fr 1fr; }
  .topbar { flex-wrap: wrap; }
  .hero h2 { font-size: 24px; }
  .flash-box .q { font-size: 20px; }
}
@media (max-width: 560px) {
  .grid-4, .treaty-grid, .stat-row { grid-template-columns: 1fr; }
  .nav { width: 100%; }
}
