:root {
  color-scheme: light;
  --bg: #f3f1eb;
  --surface: #fbfaf6;
  --surface-2: #e7e5de;
  --ink: #1c2328;
  --muted: #687177;
  --line: #c8cbc7;
  --accent: #e6532f;
  --accent-soft: #f4c5b8;
  --nav: rgba(243, 241, 235, .88);
  --shadow: 0 22px 60px rgba(48, 52, 47, .13);
  --radius: 14px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171b1d;
  --surface: #202629;
  --surface-2: #2b3235;
  --ink: #edf0eb;
  --muted: #a8b0b2;
  --line: #3d4649;
  --accent: #ff6b45;
  --accent-soft: #6f3326;
  --nav: rgba(23, 27, 29, .88);
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 clamp(18px, 4vw, 64px);
  background: var(--nav);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--surface);
  background: var(--ink);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 22px;
}
.desktop-nav { display: flex; gap: 34px; font-size: 14px; color: var(--muted); }
.desktop-nav a:hover { color: var(--ink); }
.icon-button {
  justify-self: end;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}
.icon-button:active, button:active, .primary-button:active { transform: translateY(1px); }

main { overflow: hidden; }
.hero {
  position: relative;
  min-height: calc(100dvh - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, .98fr);
  align-items: center;
  gap: clamp(40px, 7vw, 110px);
  max-width: 1440px;
  margin: 0 auto;
  padding: 48px clamp(22px, 6vw, 90px) 78px;
}
.hero-copy { position: relative; z-index: 2; max-width: 650px; }
.eyebrow {
  margin: 0 0 20px;
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 28px;
  font-size: clamp(52px, 6.2vw, 96px);
  line-height: .98;
  letter-spacing: -.065em;
}
h1 em { color: var(--accent); font-style: normal; }
.hero-note { max-width: 440px; color: var(--muted); font-size: 17px; }
.hero-actions { display: flex; align-items: center; gap: 24px; margin-top: 34px; }
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 24px;
  color: #fff8f4;
  background: var(--accent);
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform .18s ease, filter .18s ease;
}
.primary-button:hover { filter: brightness(.94); transform: translateY(-2px); }
.text-button {
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.hero-visual { position: relative; min-height: 540px; }
.paper-stack { position: absolute; inset: 7% 5% 4% 4%; }
.paper-stack img {
  position: absolute;
  width: min(100%, 470px);
  border: 1px solid #b7b7b0;
  border-radius: 5px;
  box-shadow: var(--shadow);
}
.paper-back { top: 7%; right: -5%; transform: rotate(7deg); filter: saturate(.8); }
.paper-front { top: 0; left: 0; transform: rotate(-4deg); }
.score-stamp {
  position: absolute;
  right: 0;
  bottom: 2%;
  display: grid;
  width: 126px;
  height: 126px;
  place-items: center;
  align-content: center;
  color: var(--accent);
  border: 4px solid currentColor;
  border-radius: 50%;
  background: var(--surface);
  transform: rotate(-9deg);
  box-shadow: 0 12px 30px rgba(45, 42, 37, .12);
}
.score-stamp strong { font-size: 50px; line-height: .9; }
.score-stamp span { font-size: 13px; font-weight: 800; letter-spacing: .12em; }
.countdown-panel {
  position: absolute;
  left: clamp(22px, 6vw, 90px);
  bottom: 22px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}
.countdown-panel strong { color: var(--accent); font-size: 17px; }
.countdown-panel small { color: var(--muted); }

.score-map {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 48px;
  padding: 90px clamp(22px, 6vw, 90px);
  color: #f4f5f1;
  background: #22292c;
}
.score-map > div:first-child { max-width: 420px; }
.score-map p { color: #9ba4a6; font-size: 13px; }
.score-map h2, .section-heading h2, .question-intro h2, .formula-head h2 {
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.05;
  letter-spacing: -.045em;
}
.score-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: #475053;
}
.score-numbers div { padding: 28px; background: #22292c; }
.score-numbers strong { display: block; font-size: 48px; line-height: 1; }
.score-numbers span { color: #aeb5b6; font-size: 13px; }
.score-numbers .accent-score { color: #fff; background: var(--accent); }
.score-numbers .accent-score span { color: #fff5f1; }

.route-section, .templates-section, .questions-section, .formula-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 120px clamp(20px, 5vw, 64px);
}
.section-heading { max-width: 700px; margin-bottom: 48px; }
.section-heading p, .question-intro p, .formula-head p { color: var(--muted); max-width: 600px; }
.day-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.day-tab, .filter-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 15px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.day-tab.active, .filter-button.active { color: var(--surface); background: var(--ink); border-color: var(--ink); }
.progress-copy { margin-left: auto; color: var(--muted); font-size: 13px; }
.progress-copy strong { color: var(--accent); }
.route-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 14px; }
.route-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.route-item:nth-child(3n + 1) { grid-row: span 2; min-height: 190px; }
.route-check {
  width: 24px;
  height: 24px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}
.route-time { color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.route-item h3 { margin: 4px 0 6px; font-size: 19px; }
.route-item p { margin: 0; color: var(--muted); font-size: 14px; }
.route-tag { color: var(--muted); font-size: 12px; white-space: nowrap; }
.route-item.complete { opacity: .58; }
.route-item.complete h3 { text-decoration: line-through; }

.templates-section { max-width: none; background: var(--surface-2); }
.templates-section > * { max-width: 1152px; margin-left: auto; margin-right: auto; }
.template-layout { display: grid; grid-template-columns: 260px 1fr; gap: 28px; }
.template-nav { display: flex; flex-direction: column; gap: 8px; }
.template-tab {
  display: flex;
  justify-content: space-between;
  padding: 15px 16px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.template-tab.active { color: var(--surface); background: var(--ink); }
.template-sheet {
  min-height: 420px;
  padding: clamp(24px, 5vw, 58px);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(40, 45, 43, .08);
}
.template-sheet header { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.template-sheet h3 { margin-bottom: 10px; font-size: clamp(30px, 4vw, 52px); line-height: 1.05; }
.template-sheet .points { color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; white-space: nowrap; }
.template-formula {
  margin: 28px 0;
  padding: 18px 20px;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  overflow-x: auto;
}
.template-formula .katex { font-size: 1.18em; }
.answer-steps { counter-reset: answer; display: grid; gap: 13px; padding: 0; list-style: none; }
.answer-steps li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.answer-steps li::before {
  counter-increment: answer;
  content: counter(answer);
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  color: var(--surface);
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.questions-section { display: grid; grid-template-columns: 330px 1fr; gap: 70px; }
.question-intro { position: sticky; top: 98px; align-self: start; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.question-list { display: grid; gap: 16px; }
.question-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.question-top { padding: 24px; }
.question-meta { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.question-meta strong { color: var(--accent); }
.question-card h3 { margin: 10px 0 8px; font-size: 23px; }
.question-card p { color: var(--muted); margin-bottom: 0; }
.question-actions { display: flex; gap: 10px; margin-top: 18px; }
.small-button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.small-button.primary { color: #fff8f4; background: var(--accent); border-color: var(--accent); }
.solution { display: none; padding: 0 24px 26px; }
.solution.open { display: block; animation: reveal .3s ease both; }
.solution h4 { margin: 0 0 8px; color: var(--accent); }
.solution ol { padding-left: 20px; }
.solution code, .formula-card code, .unit-card code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .93em;
}

.formula-section { max-width: none; color: #edf0eb; background: #22292c; }
.formula-section > * { max-width: 1152px; margin-left: auto; margin-right: auto; }
.formula-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 44px; }
.formula-head p { color: #aab2b4; }
.search-box { display: grid; gap: 6px; min-width: 290px; color: #aab2b4; font-size: 12px; }
.search-box input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid #525c5f;
  border-radius: 10px;
  outline: none;
  color: #edf0eb;
  background: #171b1d;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230, 83, 47, .22); }
.formula-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.formula-card {
  grid-column: span 4;
  min-height: 180px;
  padding: 22px;
  border: 1px solid #424c4f;
  border-radius: var(--radius);
  background: #293033;
}
.formula-card:nth-child(5n + 1), .formula-card:nth-child(5n + 4) { grid-column: span 6; }
.formula-card h3 { color: #fff; }
.formula-card code { display: block; margin: 14px 0; color: #ff967d; font-size: 16px; }
.formula-math {
  min-height: 48px;
  display: flex;
  align-items: center;
  margin: 16px 0;
  color: #ff967d;
  overflow-x: auto;
  overflow-y: hidden;
}
.formula-math .katex-display { margin: 0; }
.formula-math .katex { font-size: 1.12em; }
.math-inline { display: inline-block; white-space: nowrap; }
.math-inline .katex { font-size: 1em; }
.formula-card p { color: #aeb6b8; font-size: 13px; }
.formula-card.hidden { display: none; }
.empty-result { grid-column: 1 / -1; padding: 40px 0; color: #aeb6b8; }

.exam-section {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  max-width: 1280px;
  margin: 0 auto;
  padding: 120px clamp(20px, 5vw, 64px);
  gap: 18px;
}
.exam-poster, .unit-card { border-radius: var(--radius); }
.exam-poster { position: relative; padding: clamp(32px, 6vw, 72px); color: #fff8f4; background: var(--accent); }
.poster-time { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; letter-spacing: .15em; }
.exam-poster h2 { max-width: 680px; margin: 46px 0; font-size: clamp(42px, 6vw, 78px); line-height: .95; letter-spacing: -.055em; }
.exam-poster ol { max-width: 680px; padding-left: 22px; }
.exam-poster li { margin: 12px 0; }
.unit-card { display: flex; flex-direction: column; justify-content: center; padding: 36px; background: var(--ink); color: var(--surface); }
.unit-card h3 { font-size: 25px; }
.unit-card code { padding: 15px 0; border-bottom: 1px solid color-mix(in srgb, var(--surface) 18%, transparent); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(20px, 5vw, 64px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
footer p { margin: 0; }

.paper-dialog {
  width: min(94vw, 1050px);
  max-height: 94dvh;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.paper-dialog::backdrop { background: rgba(13, 16, 17, .78); backdrop-filter: blur(6px); }
.paper-dialog img { display: block; width: 100%; height: auto; }
.dialog-close {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #202629;
  font-size: 24px;
  cursor: pointer;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 900px) {
  .desktop-nav { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
  .hero { grid-template-columns: 1fr; padding-top: 54px; }
  .hero-visual { min-height: 460px; }
  .countdown-panel { position: static; grid-column: 1; flex-wrap: wrap; }
  .score-map, .questions-section, .exam-section { grid-template-columns: 1fr; }
  .route-grid { grid-template-columns: 1fr; }
  .route-item:nth-child(3n + 1) { grid-row: auto; min-height: 0; }
  .template-layout { grid-template-columns: 1fr; }
  .template-nav { flex-direction: row; overflow-x: auto; padding-bottom: 8px; }
  .template-tab { flex: 0 0 auto; }
  .question-intro { position: static; }
  .formula-card, .formula-card:nth-child(5n + 1), .formula-card:nth-child(5n + 4) { grid-column: span 6; }
}

@media (max-width: 620px) {
  .hero { min-height: auto; padding-bottom: 48px; }
  h1 { font-size: clamp(46px, 15vw, 66px); }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 14px; }
  .hero-visual { min-height: 400px; }
  .paper-stack { inset: 6% 7% 5% 2%; }
  .score-stamp { width: 96px; height: 96px; right: 2%; }
  .score-stamp strong { font-size: 38px; }
  .countdown-panel { display: grid; gap: 2px; margin-top: 10px; }
  .score-map { padding-top: 70px; padding-bottom: 70px; }
  .score-numbers { grid-template-columns: repeat(2, 1fr); }
  .score-numbers div { padding: 22px; }
  .route-section, .templates-section, .questions-section, .formula-section, .exam-section { padding-top: 82px; padding-bottom: 82px; }
  .day-switch { align-items: flex-start; flex-wrap: wrap; }
  .progress-copy { width: 100%; margin: 8px 0 0; }
  .route-item { grid-template-columns: auto 1fr; }
  .route-tag { grid-column: 2; }
  .template-sheet { padding: 24px 20px; }
  .template-sheet header { align-items: start; flex-direction: column; }
  .formula-head { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; }
  .formula-card, .formula-card:nth-child(5n + 1), .formula-card:nth-child(5n + 4) { grid-column: 1 / -1; }
  .exam-poster h2 { margin: 34px 0; }
  footer { flex-direction: column; }
}
