:root {
  --paper: #f5f1e8;
  --surface: #fffdf7;
  --ink: #182033;
  --muted: #667084;
  --line: #d9d2c4;
  --blue: #1e52c5;
  --blue-soft: #e9efff;
  --red: #d64f3d;
  --red-soft: #fff0ec;
  --green: #247a5a;
  --green-soft: #e7f4ee;
  --yellow: #f2c14e;
  --shadow: 0 16px 38px rgba(35, 40, 52, .09);
  --sidebar-width: 268px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 92px; }
body {
  margin: 0;
  background:
    linear-gradient(rgba(24,32,51,.028) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
  color: var(--ink);
  font-family: "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0;
}

button, input { font: inherit; }
button { cursor: pointer; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 12px; }
.skip-link:focus { top: 10px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 30px;
  background: rgba(255,253,247,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--yellow); font: 700 25px/1 Georgia, serif;
}
.brand div { display: grid; line-height: 1.25; }
.brand strong { font-size: 16px; }
.brand span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.progress-wrap { width: min(280px, 34vw); }
.progress-copy { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); }
.progress-copy strong { color: var(--ink); font-size: 14px; }
.progress-track { height: 5px; background: #ded8cc; margin-top: 5px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--green); transition: width .35s ease; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); max-width: 1540px; margin: 0 auto; }
.sidebar { border-right: 1px solid var(--line); min-height: calc(100vh - 74px); }
.sidebar-inner { position: sticky; top: 74px; padding: 30px 22px; max-height: calc(100vh - 74px); overflow: auto; }
.eyebrow { margin: 0 0 12px; color: var(--red); font-weight: 700; font-size: 12px; text-transform: uppercase; }
.day-switch { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); margin-bottom: 24px; }
.day-button { border: 0; border-right: 1px solid var(--line); padding: 8px 5px; background: transparent; color: var(--muted); font-size: 13px; }
.day-button:last-child { border-right: 0; }
.day-button.is-active { background: var(--ink); color: #fff; }
.search-label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.search-box { display: grid; grid-template-columns: 25px 1fr; align-items: center; border-bottom: 2px solid var(--ink); padding: 2px 0 6px; }
.search-box span { font-size: 21px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); min-width: 0; }
.search-box input::placeholder { color: #969082; }
.question-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 24px; }
.nav-link { position: relative; min-width: 0; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 12px; background: rgba(255,255,255,.38); }
.nav-link:hover, .nav-link:focus-visible { border-color: var(--blue); color: var(--blue); }
.nav-link.is-done::after { content: ""; position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; background: var(--green); border-radius: 50%; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; padding-top: 22px; margin-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-blue { background: var(--blue); } .dot-red { background: var(--red); } .dot-green { background: var(--green); }

main { min-width: 0; padding: 0 42px 80px; }
.intro { min-height: 440px; display: grid; grid-template-columns: minmax(0, .9fr) minmax(380px, 1.1fr); gap: 28px; align-items: center; border-bottom: 1px solid var(--line); }
.intro-copy { padding: 54px 0 38px; }
.intro h1 { margin: 0; max-width: 760px; font-family: "STSong", "SimSun", serif; font-size: 64px; line-height: 1.13; font-weight: 700; }
.intro-copy > p:last-child { max-width: 680px; color: var(--muted); font-size: 17px; margin: 24px 0 0; }
.chapter-map { align-self: stretch; display: grid; place-items: center; min-height: 320px; }
.chapter-map svg { width: 100%; max-width: 650px; overflow: visible; }
.map-line { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 6 8; }
.map-node circle { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.map-node text { text-anchor: middle; font-size: 15px; fill: var(--ink); font-weight: 700; }
.map-node-accent circle { fill: var(--yellow); }

.tool-strip { position: sticky; top: 74px; z-index: 12; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; background: rgba(245,241,232,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.topic-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.topic-button, .tool-actions button { min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.topic-button.is-active { border-color: var(--blue); color: var(--blue); box-shadow: inset 0 -2px var(--blue); }
.tool-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.tool-actions button { background: transparent; font-size: 13px; }

.lesson-list { display: grid; gap: 18px; padding-top: 28px; }
.day-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 26px 0 2px; }
.day-heading h2 { margin: 0; font-family: "STSong", "SimSun", serif; font-size: 34px; }
.day-heading span { color: var(--muted); font-size: 13px; }
.lesson-card { scroll-margin-top: 145px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 7px 20px rgba(35,40,52,.045); }
.lesson-card[data-category="逻辑"] { border-left: 4px solid var(--red); }
.lesson-card[data-category="集合"] { border-left: 4px solid var(--blue); }
.lesson-card[data-category="综合"] { border-left: 4px solid var(--green); }
.lesson-head { display: grid; grid-template-columns: 64px minmax(0,1fr) auto; gap: 18px; align-items: start; padding: 22px 24px 20px; }
.question-no { display: grid; place-items: center; width: 54px; height: 54px; border: 2px solid var(--ink); background: var(--paper); font-family: Georgia, serif; font-size: 21px; font-weight: 700; }
.lesson-title-wrap { min-width: 0; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 7px; }
.tag { display: inline-flex; align-items: center; min-height: 23px; padding: 1px 7px; font-size: 11px; border: 1px solid currentColor; }
.tag-topic { color: var(--blue); }
.tag-level { color: var(--muted); }
.lesson-head h3 { margin: 0; font-family: "STSong", "SimSun", serif; font-size: 22px; line-height: 1.5; overflow-wrap: anywhere; }
.done-control { display: flex; align-items: center; gap: 7px; padding-top: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.done-control input { appearance: none; width: 20px; height: 20px; margin: 0; border: 2px solid var(--ink); background: #fff; display: grid; place-items: center; }
.done-control input:checked { background: var(--green); border-color: var(--green); }
.done-control input:checked::after { content: "✓"; color: white; font-size: 14px; line-height: 1; }
.question-body { padding: 0 24px 22px 106px; }
.problem { margin: 0; color: #31394a; font-family: "STSong", "SimSun", serif; font-size: 18px; }
.lesson-details { border-top: 1px solid var(--line); }
.lesson-details summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 24px 15px 106px; cursor: pointer; font-weight: 700; color: var(--blue); }
.lesson-details summary::-webkit-details-marker { display: none; }
.lesson-details summary::after { content: "+"; width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--blue); font-size: 18px; font-weight: 400; }
.lesson-details[open] summary::after { content: "−"; }
.explanation { padding: 5px 24px 28px 106px; }
.answer-line { display: flex; gap: 12px; align-items: baseline; padding: 14px 16px; background: var(--ink); color: white; margin-bottom: 20px; }
.answer-line span { color: #cbd4e8; font-size: 12px; flex: 0 0 auto; }
.answer-line strong { font-size: 18px; font-family: "STSong", "SimSun", serif; }
.explain-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(270px, .75fr); gap: 22px; align-items: start; }
.block { margin-bottom: 20px; }
.block:last-child { margin-bottom: 0; }
.block-label { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; color: var(--red); font-weight: 700; }
.block-label::before { content: ""; width: 18px; height: 2px; background: currentColor; }
.block p { margin: 0; }
.steps { display: grid; gap: 11px; counter-reset: step; }
.step { position: relative; padding-left: 38px; min-height: 28px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 1px; width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--ink); background: var(--paper); font: 700 12px/1 Georgia, serif; }
.pitfall { padding: 12px 14px; border-left: 3px solid var(--red); background: var(--red-soft); font-size: 14px; }
.visual { min-height: 180px; padding: 12px; background: var(--blue-soft); border: 1px solid #c7d5fb; }
.visual svg { width: 100%; height: auto; display: block; overflow: visible; }
.visual-caption { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.math { font-family: "Cambria Math", "Times New Roman", serif; font-size: 1.06em; white-space: normal; }
.frac { display: inline-grid; vertical-align: -.5em; grid-template-rows: auto auto; text-align: center; margin: 0 .12em; line-height: 1.05; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 .16em .08em; }
.frac > span:last-child { padding: .08em .16em 0; }
.cases { display: inline-grid; grid-template-columns: auto 1fr; gap: 3px 8px; align-items: center; vertical-align: middle; margin: 0 4px; }
.cases::before { content: "{"; grid-row: 1 / span 4; font: 50px/.75 "Times New Roman", serif; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: 22px; }
footer { display: flex; justify-content: space-between; gap: 20px; margin-left: var(--sidebar-width); padding: 24px 42px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

@media (max-width: 1050px) {
  :root { --sidebar-width: 220px; }
  main { padding-left: 26px; padding-right: 26px; }
  .intro { grid-template-columns: 1fr; min-height: 0; }
  .chapter-map { min-height: 220px; padding-bottom: 30px; }
  .intro h1 { font-size: 52px; }
  .explain-grid { grid-template-columns: 1fr; }
  .visual { max-width: 620px; }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 68px; }
  .topbar { min-height: 64px; padding: 8px 14px; }
  .brand { min-width: 0; }
  .brand-mark { width: 38px; height: 38px; }
  .brand div span { display: none; }
  .progress-wrap { width: 120px; }
  .app-shell { display: block; }
  .sidebar { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-inner { position: static; max-height: none; padding: 16px 14px; }
  .sidebar .eyebrow, .search-label, .legend { display: none; }
  .day-switch { margin: 0 0 12px; max-width: 330px; }
  .search-box { max-width: 440px; }
  .question-nav { display: flex; overflow-x: auto; gap: 6px; margin-top: 14px; padding-bottom: 4px; }
  .nav-link { min-width: 38px; }
  main { padding: 0 14px 55px; }
  .intro { display: block; }
  .intro-copy { padding: 40px 0 16px; }
  .intro h1 { font-size: 40px; }
  .intro-copy > p:last-child { font-size: 15px; margin-top: 18px; }
  .chapter-map { min-height: 160px; padding-bottom: 20px; }
  .chapter-map svg { max-width: 520px; }
  .tool-strip { top: 64px; align-items: flex-start; overflow-x: auto; padding: 10px 0; }
  .topic-filters { flex-wrap: nowrap; }
  .topic-button { white-space: nowrap; }
  .tool-actions { display: none; }
  .day-heading h2 { font-size: 28px; }
  .lesson-head { grid-template-columns: 48px minmax(0, 1fr); gap: 12px; padding: 18px 16px 14px; }
  .question-no { width: 44px; height: 44px; font-size: 17px; }
  .lesson-head h3 { font-size: 19px; }
  .done-control { grid-column: 2; padding: 0; justify-self: start; }
  .question-body { padding: 0 16px 18px 76px; }
  .problem { font-size: 16px; }
  .lesson-details summary { padding: 13px 16px 13px 76px; }
  .explanation { padding: 4px 16px 22px; }
  .answer-line { margin-bottom: 18px; }
  footer { margin-left: 0; padding: 20px 14px; flex-direction: column; gap: 5px; }
}

@media (max-width: 420px) {
  .brand strong { font-size: 14px; }
  .progress-copy span { display: none; }
  .progress-wrap { width: 88px; }
  .intro h1 { font-size: 34px; }
  .chapter-map { min-height: 135px; }
  .lesson-head { grid-template-columns: 42px minmax(0, 1fr); }
  .question-no { width: 38px; height: 38px; }
  .question-body { padding-left: 16px; }
  .lesson-details summary { padding-left: 16px; }
  .meta-row { gap: 5px; }
  .tag { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
