:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --paper: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d8e0ec;
  --brand: #1d4ed8;
  --brand-2: #0f766e;
  --warn: #b45309;
  --danger: #c2410c;
  --soft: #eef4ff;
  --soft-green: #e9f8f4;
  --soft-warn: #fff7e6;
  --soft-danger: #fff1ec;
  --shadow: 0 12px 30px rgba(23, 32, 51, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.72;
  overflow-x: hidden;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f7;
  font-family: Consolas, "SFMono-Regular", monospace;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
}

.brand {
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar { display: none; }

.nav a {
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
}

.nav a:hover, .nav a.active {
  background: var(--soft);
  color: var(--brand);
  text-decoration: none;
}

.hero {
  background: linear-gradient(135deg, #0b2440 0%, #0f5132 54%, #7c2d12 100%);
  color: #fff;
  padding: 42px 0 34px;
}

.wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero h1 {
  margin: 0 0 12px;
  max-width: 960px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.1;
  letter-spacing: 0;
  word-break: break-word;
}

.hero p {
  margin: 0;
  max-width: 900px;
  color: rgba(255,255,255,.9);
  font-size: 17px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  color: inherit;
  background: rgba(255,255,255,.12);
  font-size: 13px;
  font-weight: 700;
}

.key-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 6px 18px rgba(23, 32, 51, .05);
}

.key-legend span,
.key-badge,
.auto-key {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 900;
  line-height: 1.2;
}

.key-legend span {
  padding: 5px 8px;
  font-size: 12px;
}

.key-badge {
  margin-left: 8px;
  padding: 3px 7px;
  vertical-align: middle;
  font-size: 12px;
}

.auto-key {
  padding: 1px 5px;
  margin: 0 1px;
  font-size: .95em;
}

.key-must { color: #991b1b; background: #fee2e2; border: 1px solid #fecaca; }
.key-formula { color: #075985; background: #e0f2fe; border: 1px solid #bae6fd; }
.key-trap { color: #9a3412; background: #ffedd5; border: 1px solid #fed7aa; }
.key-paper { color: #166534; background: #dcfce7; border: 1px solid #bbf7d0; }
.key-english { color: #5b21b6; background: #ede9fe; border: 1px solid #ddd6fe; }

section:has(.key-badge.key-must) {
  border-top: 3px solid #ef4444;
}

section:has(.key-badge.key-trap) {
  border-top: 3px solid #f97316;
}

section:has(.key-badge.key-paper) {
  border-top: 3px solid #22c55e;
}

.page {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  padding: 22px 0 46px;
}

.side {
  position: sticky;
  top: 76px;
  align-self: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.side h2 {
  margin: 0;
  padding: 13px 15px;
  font-size: 17px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.side a {
  display: block;
  padding: 8px 14px;
  color: var(--ink);
  font-size: 14px;
}

.side a:hover {
  background: var(--soft);
  text-decoration: none;
}
.side a.toc-sub { padding-left: 24px; font-size: 13px; }
.side h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 16px 14px 4px; }

main { min-width: 0; }
section, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

h2 {
  margin: 0 0 14px;
  font-size: clamp(23px, 3vw, 32px);
  line-height: 1.24;
  letter-spacing: 0;
}

h3 {
  margin: 22px 0 10px;
  font-size: 20px;
  line-height: 1.3;
}

h4 { margin: 16px 0 8px; font-size: 17px; }
p { margin: 8px 0; }
ul, ol { margin: 8px 0; padding-left: 1.25em; }
li { margin: 5px 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}
.card h3, .card h4 { margin-top: 0; }

.note {
  margin: 12px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--soft);
}
.remember { border-left-color: var(--brand-2); background: var(--soft-green); }
.warn { border-left-color: var(--warn); background: var(--soft-warn); }
.danger { border-left-color: var(--danger); background: var(--soft-danger); }

.tag {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 3px 8px;
  border-radius: 999px;
  color: #15345c;
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
}
.tag.hot { color: #7c2d12; background: var(--soft-warn); }
.tag.must { color: #075c46; background: var(--soft-green); }
.tag.risk { color: #9a3412; background: var(--soft-danger); }

.formula {
  display: block;
  padding: 12px;
  border-radius: var(--radius);
  background: #101827;
  color: #eef6ff;
  font-family: Consolas, "Microsoft YaHei", monospace;
  overflow-x: auto;
  line-height: 1.7;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  margin: 12px 0;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

th {
  background: #f1f5f9;
  font-weight: 900;
  white-space: nowrap;
}

tr:last-child td { border-bottom: 0; }

.question {
  display: grid;
  grid-template-columns: minmax(240px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.question img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.question-text {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
  margin: 12px 0;
}

.question-text h3 {
  margin-top: 0;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.option {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.image-panel {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.image-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  font-weight: 900;
}

.image-panel-header a {
  font-size: 13px;
  white-space: nowrap;
}

.image-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
}

.question-image {
  display: block;
  width: auto;
  max-width: none;
  min-width: min(860px, 100%);
  height: auto;
  border-radius: 6px;
  background: white;
}

.answer {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--soft-green);
  color: #075c46;
  font-weight: 900;
}

.wrong-extra {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  margin: 12px 0;
  overflow: hidden;
}

.wrong-extra summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 900;
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
}

.wrong-extra[open] summary {
  color: var(--brand);
}

.wrong-extra-body {
  padding: 14px;
}

.wrong-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.wrong-meta div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfe;
}

.nextprev {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 0;
}

.nextprev a {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.mindmap {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin: 14px 0;
}

.mind-center {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  color: white;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.branches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.branch {
  position: relative;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 14px;
}

.branch h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.branch ul {
  margin: 0;
  padding-left: 1.1em;
}

.branch li {
  margin: 3px 0;
}

.branch.green { border-left-color: var(--brand-2); }
.branch.warn { border-left-color: var(--warn); }
.branch.danger { border-left-color: var(--danger); }

.mini-map {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.mini-map span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: #15345c;
  font-size: 13px;
  font-weight: 800;
}

.mini-map span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
}

.paper-article {
  max-width: 900px;
}

.paper-article h1 {
  margin: 0 0 16px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.16;
}

.paper-article h2 {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.paper-article blockquote {
  margin: 12px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--brand);
  background: var(--soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.paper-article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}

.paper-article .source-note {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.paper-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

footer {
  padding: 20px 0 42px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 980px) {
  body { font-size: 15px; line-height: 1.62; }
  .topbar-inner { width: calc(100% - 22px); align-items: flex-start; flex-direction: column; gap: 8px; padding: 8px 0; }
  .nav { width: 100%; }
  .nav a { padding: 7px 9px; font-size: 13px; }
  .wrap { width: calc(100% - 22px); }
  .page { grid-template-columns: 1fr; padding-top: 14px; }
  .side { position: static; box-shadow: none; }
  .side nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
  .side h2 { padding: 10px 12px; font-size: 15px; }
  .side a {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fbfcfe;
    font-size: 13px;
    line-height: 1.25;
  }
  .grid, .grid.two { grid-template-columns: 1fr; }
  .question { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .mindmap { grid-template-columns: 1fr; }
  .branches { grid-template-columns: 1fr; }
  .mind-center { min-height: auto; border-radius: var(--radius); }
  .paper-list { grid-template-columns: 1fr; }
  .wrong-meta { grid-template-columns: 1fr; }
  section, .panel { padding: 16px; }
}

@media (max-width: 560px) {
  body { font-size: 14px; line-height: 1.56; }
  .topbar { position: static; }
  .brand { font-size: 14px; line-height: 1.2; }
  .topbar-inner { gap: 7px; min-height: auto; padding: 8px 0 9px; }
  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
  }
  .nav a {
    display: block;
    min-width: 0;
    padding: 5px 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fbfcfe;
    font-size: 11.5px;
    line-height: 1.1;
    text-align: center;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .nav a.active {
    border-color: #c7d7fe;
    background: var(--soft);
  }
  .hero { padding: 18px 0 15px; }
  .hero h1 { font-size: 22px; line-height: 1.16; margin-bottom: 7px; }
  .hero p { font-size: 13px; line-height: 1.55; }
  .chips { gap: 6px; margin-top: 12px; }
  .chip { padding: 4px 8px; font-size: 12px; }
  .key-legend { gap: 5px; margin: 8px 0 10px; padding: 8px; }
  .key-legend span { padding: 4px 7px; font-size: 11.5px; }
  .key-badge { margin-left: 5px; padding: 2px 6px; font-size: 11px; }
  .auto-key { padding: 0 4px; }
  h2 { font-size: 21px; margin-bottom: 10px; }
  h3 { font-size: 17px; margin: 16px 0 8px; }
  h4 { font-size: 15px; }
  p { margin: 6px 0; }
  ul, ol { padding-left: 1.15em; }
  .side { border-radius: 8px; }
  .side nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px; }
  .side a {
    flex: 0 1 auto;
    min-height: 0;
    padding: 5px 8px;
    font-size: 12px;
    line-height: 1.2;
  }
  section, .panel { padding: 12px; margin-bottom: 12px; }
  .card, .question-text, .note { padding: 10px; }
  .mindmap {
    display: block;
    margin: 8px 0 10px;
  }
  .mind-center {
    display: inline-flex;
    min-height: 0;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 16px;
    box-shadow: none;
  }
  .branches {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }
  .branch {
    padding: 8px 9px;
    border-left-width: 4px;
  }
  .branch h3 {
    margin-bottom: 5px;
    font-size: 14px;
  }
  .branch ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-left: 0;
    list-style: none;
  }
  .branch li {
    margin: 0;
    padding: 2px 5px;
    border-radius: 5px;
    background: #f8fafc;
    font-size: 11.5px;
    line-height: 1.25;
  }
  .table-wrap { margin: 8px 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
  table { min-width: 520px; font-size: 12.5px; }
  table.mobile-card-table {
    width: 100%;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 8px;
    font-size: 12.8px;
  }
  table.mobile-card-table thead { display: none; }
  table.mobile-card-table tbody { display: block; }
  table.mobile-card-table tr {
    display: block;
    margin: 0 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 5px 14px rgba(23, 32, 51, .05);
  }
  table.mobile-card-table td {
    display: grid;
    grid-template-columns: minmax(72px, 30%) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  table.mobile-card-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
  }
  table.mobile-card-table td:last-child { border-bottom: 0; }
  th, td { padding: 6px 7px; line-height: 1.42; }
  th { white-space: normal; }
  .formula { padding: 9px; font-size: 12.5px; line-height: 1.5; }
  .wrong-extra { margin: 9px 0; }
  .wrong-extra summary { padding: 10px 11px; font-size: 14px; line-height: 1.35; }
  .wrong-extra-body { padding: 10px; }
  .image-panel { margin: 9px 0; }
  .image-panel-header { padding: 8px 9px; font-size: 13px; }
  .image-scroll { padding: 7px; }
  .question-image { min-width: min(700px, 100%); }
  .answer { padding: 4px 7px; font-size: 13px; }
  .nextprev { flex-direction: column; }
}
