:root {
  --paper: #f5f1e8;
  --ink: #1f2a25;
  --muted: #657169;
  --green: #145a4a;
  --blue: #224f87;
  --red: #a33c2b;
  --gold: #b27a21;
  --line: #d8cec0;
  --panel: #fffdf8;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(34,79,135,.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(20,90,74,.05) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  line-height: 1.72;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: end;
  padding: 34px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,248,.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.eyebrow,
.kicker {
  margin: 0 0 8px;
  color: var(--red);
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.28;
}

h1 {
  font-size: clamp(30px, 4vw, 52px);
  color: var(--green);
}

h2 {
  color: var(--green);
  font-size: clamp(23px, 2.5vw, 34px);
}

h3 {
  color: var(--blue);
  font-size: 19px;
}

.lead {
  max-width: 860px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.searchBox {
  display: block;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.searchBox span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.searchBox input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: white;
  font: inherit;
}

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px clamp(14px, 3vw, 38px) 60px;
}

.sidebar {
  position: sticky;
  top: 142px;
  align-self: start;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,253,248,.76);
  padding: 10px 12px;
  font-weight: 800;
}

.sidebar a:hover {
  color: var(--panel);
  background: var(--green);
}

.content {
  min-width: 0;
}

.panel,
.chapter {
  margin-bottom: 22px;
  padding: clamp(18px, 2.6vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,253,248,.92);
  box-shadow: 0 16px 38px rgba(46,38,25,.08);
}

.chapterHead {
  margin: -4px 0 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(20,90,74,.16);
}

.chapterHead span {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--panel);
  background: var(--green);
  font-weight: 900;
  font-size: 12px;
}

.chapterHead p {
  max-width: 880px;
  color: var(--muted);
}

.routeGrid,
.timeline,
.templateGrid,
.compare {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.routeGrid,
.compare {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.timeline,
.templateGrid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.routeGrid div,
.timeline article,
.templateGrid article,
.compare article,
.mustKnow,
.worked,
.formula,
.checkpoint {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.62);
  padding: 16px;
}

.routeGrid b,
.timeline b {
  display: block;
  color: var(--blue);
  margin-bottom: 4px;
}

.routeGrid span,
.timeline span {
  color: var(--muted);
}

.mustKnow {
  border-left: 5px solid var(--green);
  background: rgba(20,90,74,.08);
}

.mustKnow h3,
.worked h3 {
  margin-bottom: 8px;
}

.formula {
  margin: 16px 0;
  border-left: 5px solid var(--blue);
  background: rgba(34,79,135,.08);
}

.worked {
  margin-top: 14px;
  border-left: 5px solid var(--gold);
}

.takeaway {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: #5f4214;
  background: rgba(178,122,33,.12);
  font-weight: 800;
}

.checkpoint {
  margin-top: 14px;
  border-left: 5px solid var(--red);
  background: rgba(163,60,43,.08);
}

blockquote {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-left: 5px solid var(--red);
  border-radius: 8px;
  color: #61352f;
  background: rgba(163,60,43,.08);
}

ul,
ol {
  padding-left: 24px;
}

li {
  margin: 6px 0;
}

table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

th,
td {
  border: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--panel);
  background: var(--green);
}

td {
  background: rgba(255,255,255,.6);
}

mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

.hidden {
  display: none !important;
}

mark {
  background: rgba(178,122,33,.22);
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}

@media (max-width: 980px) {
  .topbar,
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .routeGrid,
  .timeline,
  .templateGrid,
  .compare {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    position: static;
    padding: 22px 16px;
  }

  .layout {
    padding: 16px;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .panel,
  .chapter {
    padding: 16px;
  }
}

@page {
  size: A4;
  margin: 12mm;
}

@media print {
  body {
    background: white;
    color: #111;
    font-size: 10.5pt;
    line-height: 1.55;
  }

  .no-print,
  .sidebar {
    display: none !important;
  }

  .topbar {
    position: static;
    display: block;
    padding: 0 0 8mm;
    border-bottom: 2px solid #145a4a;
    background: white;
  }

  h1 {
    font-size: 25pt;
  }

  h2 {
    font-size: 17pt;
  }

  h3 {
    font-size: 12.5pt;
  }

  .lead {
    font-size: 10.5pt;
  }

  .layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .panel,
  .chapter {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #d7d7d7;
    background: white;
    padding: 8mm;
    margin-bottom: 8mm;
  }

  .chapter {
    break-before: page;
  }

  #how,
  #plan {
    break-before: auto;
  }

  .routeGrid,
  .timeline,
  .templateGrid,
  .compare {
    grid-template-columns: 1fr 1fr;
  }

  .timeline,
  .templateGrid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .worked,
  .formula,
  .mustKnow,
  .checkpoint,
  blockquote,
  table {
    break-inside: avoid;
  }

  a {
    color: inherit;
  }

  mjx-container {
    overflow: visible;
  }
}

@media (max-width: 560px) {
  html,
  body {
    overflow-x: hidden;
  }

  body,
  .layout,
  .content,
  .panel,
  .chapter {
    max-width: 100%;
    overflow-x: clip;
  }

  table {
    display: block;
    overflow-x: hidden;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
  }

  table thead,
  table tbody,
  table tr,
  table th,
  table td {
    display: block;
    width: 100% !important;
  }

  table tr {
    border-bottom: 1px solid var(--line);
  }

  table th,
  table td {
    border: 0;
  }

  table th:not(:first-child) {
    display: none;
  }

  mjx-container {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
  }
}
