
:root {
  --bg: #101420;
  --bg-soft: #181e2c;
  --panel: rgba(214, 228, 248, 0.06);
  --panel-strong: rgba(214, 228, 248, 0.1);
  --text: #eef4f8;
  --text-soft: #bcc9dd;
  --text-dim: #8b9cb4;
  --line: rgba(240, 201, 106, 0.2);
  --primary: #f0c96a;
  --accent: #7aa7f0;
  --danger: #ee8877;
  --reading-width: 47rem;
  --header-height: 56px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 20px); }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.85;
  font-size: 1.0625rem;
  background:
    linear-gradient(115deg, rgba(122, 167, 240, 0.12), transparent 34%),
    linear-gradient(245deg, rgba(240, 201, 106, 0.13), transparent 30%),
    linear-gradient(180deg, #0f141f 0%, #121828 54%, #0d121c 100%);
  background-attachment: fixed;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.book-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: rgba(13, 18, 28, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.book-header__menu, .book-header__home {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  min-height: 40px;
}
.book-header__menu {
  width: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
}
.book-header__home {
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  border-radius: 8px;
  font-weight: 750;
  white-space: nowrap;
}
.book-header__current {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 0.95rem;
}
.book-progress {
  position: fixed;
  top: var(--header-height);
  left: 0;
  z-index: 51;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.book-toc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.book-toc-backdrop.is-open { opacity: 1; pointer-events: auto; }
.book-toc {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 61;
  width: min(25rem, 86vw);
  padding: 1rem;
  overflow-y: auto;
  background: #131a28;
  border-right: 1px solid var(--line);
  display: none;
  transform: translateX(calc(-100% - 24px));
}
.book-toc.is-open { display: block; transform: translateX(0); visibility: visible; }
.book-toc__title {
  margin: 0.25rem 0 1rem;
  color: var(--primary);
  font-weight: 850;
}
.book-toc__part {
  margin: 1rem 0 0.35rem;
  color: var(--text-dim);
  font-size: 0.86rem;
}
.book-toc__link {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  color: var(--text-soft);
}
.book-toc__link > span:first-child { white-space: nowrap; color: var(--accent); font-weight: 700; }
.book-toc__link:hover, .book-toc__link.is-current {
  background: rgba(240, 201, 106, 0.11);
  color: var(--text);
  text-decoration: none;
}

.book-layout {
  width: 100%;
}

.book-layout__main {
  min-width: 0;
}

.book-rail--chapters { grid-column: 1; }
.book-layout__main { grid-column: 2; }
.book-rail--outline { grid-column: 3; }

.book-rail {
  display: none;
}

.book-rail__title {
  margin: 0 0 0.75rem;
  color: var(--primary);
  font-weight: 850;
  font-size: 0.92rem;
}

.book-rail__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.book-rail__part {
  margin: 1rem 0 0.35rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 800;
}

.book-rail__part:first-child {
  margin-top: 0;
}

.book-rail__link,
.book-rail__outline-link {
  display: grid;
  gap: 0.25rem;
  padding: 0.46rem 0.55rem;
  border-radius: 8px;
  color: var(--text-soft);
  line-height: 1.35;
}

.book-rail__link {
  grid-template-columns: 2.2rem minmax(0, 1fr);
}

.book-rail__link:hover,
.book-rail__outline-link:hover {
  background: rgba(240, 201, 106, 0.1);
  color: var(--text);
  text-decoration: none;
}

.book-rail__link.is-current,
.book-rail__outline-link.is-current {
  background: rgba(240, 201, 106, 0.15);
  color: var(--text);
}

.book-rail__num {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 850;
}

.book-rail__name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.book-rail__outline-item--sub .book-rail__outline-link {
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.book-rail__empty {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.cover {
  min-height: 78vh;
  display: grid;
  place-items: center;
  padding: 7rem 1.25rem 4rem;
}
.cover__inner {
  width: min(68rem, 100%);
}
.cover__eyebrow, .chapter__eyebrow, .toc-part {
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 0;
}
.cover h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(3.2rem, 7vw, 6.5rem);
  line-height: 1.02;
  letter-spacing: 0;
}
.cover__lead {
  max-width: 48rem;
  color: var(--text-soft);
  font-size: 1.22rem;
}
.cover__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 2rem 0 1rem;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-weight: 800;
}
.button--primary { background: var(--primary); color: #15130c; }
.button--ghost { color: var(--text); background: rgba(255,255,255,0.05); }
.muted { color: var(--text-dim); }

.toc-section {
  width: min(72rem, calc(100% - 2rem));
  margin: 0 auto 5rem;
}
.toc-section h2 {
  margin-top: 0;
  font-size: 2rem;
}
.toc-section__hint { color: var(--text-soft); }
.book-roadmap {
  margin-bottom: 3.5rem;
  padding: 1.5rem;
  border: 1px solid rgba(122, 167, 240, 0.28);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(122, 167, 240, 0.11), rgba(240, 201, 106, 0.06));
}
.book-roadmap > p { max-width: 58rem; color: var(--text-soft); }
.book-roadmap__eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1.25rem;
}
.roadmap-card {
  display: grid;
  gap: 0.3rem;
  min-height: 10rem;
  padding: 0.9rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  background: rgba(12, 18, 29, 0.48);
  color: var(--text);
}
.roadmap-card:hover { text-decoration: none; border-color: rgba(240, 201, 106, 0.45); }
.roadmap-card span { color: var(--primary); font-size: 0.78rem; font-weight: 850; }
.roadmap-card strong { line-height: 1.35; }
.roadmap-card small { color: var(--text-dim); line-height: 1.55; }
.book-roadmap__aside { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.toc-heading { margin-bottom: 2rem; }
.toc-heading > p:last-child { color: var(--text-soft); }
.toc-part-block { margin: 0 0 3.5rem; scroll-margin-top: calc(var(--header-height) + 1.5rem); }
.toc-part-header {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--primary);
  background: rgba(255,255,255,0.025);
}
.toc-part-header h2 { margin: 0.2rem 0 0.45rem; font-size: 1.65rem; }
.toc-part-header p { margin: 0.25rem 0; color: var(--text-soft); }
.toc-part-header .toc-part-question { color: var(--text); font-weight: 720; }
.toc-part-badge { color: var(--primary); font-size: 0.8rem; font-weight: 850; }
.toc-part-block--special .toc-part-header { border-left-color: var(--accent); }
.toc-part-block--special .toc-part-badge { color: var(--accent); }
.toc-part-block--appendix .toc-part-header { border-left-color: var(--text-dim); }
.toc-part-block--appendix .toc-part-badge { color: var(--text-dim); }
.toc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 2rem;
}
.toc-card {
  display: grid;
  gap: 0.25rem;
  min-height: 9.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}
.toc-card:hover {
  text-decoration: none;
  border-color: rgba(240, 201, 106, 0.42);
  background: rgba(255, 255, 255, 0.07);
}
.toc-card__num { color: var(--accent); font-weight: 800; font-size: 0.92rem; }
.toc-card__title { font-size: 1.18rem; font-weight: 850; }
.toc-card__desc { color: var(--text-soft); font-size: 0.96rem; }

/* GitHub 右上角翻角 */
.github-corner {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: 88px;
  height: 88px;
}
.github-corner svg {
  width: 100%;
  height: 100%;
  display: block;
}
.github-corner__ribbon { fill: #f0c96a; }
.github-corner__arm,
.github-corner__body { fill: #101420; }
.github-corner:hover .github-corner__ribbon { fill: #f6d98a; }

/* 关于本书 */
.about {
  margin-top: 1rem;
  padding: 1.6rem 1.8rem;
  border: 1px solid var(--line);
  border-left: 3px solid rgba(240, 201, 106, 0.55);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.about h2 { margin-top: 0; font-size: 1.5rem; }
.about p { color: var(--text-soft); }
.about__meta { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 0; }
@media (max-width: 640px) {
  .github-corner { width: 64px; height: 64px; }
}

.chapter {
  padding: calc(var(--header-height) + 2.4rem) 1.2rem 2rem;
}
.chapter__inner {
  max-width: var(--reading-width);
  margin: 0 auto;
}
.chapter h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1.14;
  letter-spacing: 0;
}
.lead {
  margin: 0 0 2.5rem;
  color: var(--text);
  font-size: 1.18rem;
  line-height: 1.8;
}
.chapter-context {
  margin: -0.8rem 0 2rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(122, 167, 240, 0.24);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: rgba(122, 167, 240, 0.06);
}
.chapter-context p { margin: 0.45rem 0; }
.chapter-context__meta { display: flex; flex-wrap: wrap; gap: 0.75rem; color: var(--text-dim); font-size: 0.84rem; }
.chapter-context__badge { color: var(--accent); font-weight: 850; }
.chapter-context__outcome { font-size: 0.95rem; }
.chapter-context--special { border-left-color: var(--primary); background: rgba(240, 201, 106, 0.055); }
.chapter-context--special .chapter-context__badge { color: var(--primary); }
.chapter-context--appendix { border-left-color: var(--text-dim); background: rgba(255,255,255,0.03); }
.chapter-context--appendix .chapter-context__badge { color: var(--text-dim); }
.chapter p {
  margin: 1rem 0;
  color: var(--text-soft);
}
.chapter h2 {
  margin: 3rem 0 1rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  line-height: 1.2;
  letter-spacing: 0;
}
.chapter h3 {
  margin: 2.2rem 0 0.8rem;
  font-size: 1.28rem;
  color: var(--text);
}
.case-study {
  margin: 2.6rem 0;
  padding: 1.2rem 1.25rem 1.25rem;
  border: 1px solid rgba(240, 201, 106, 0.24);
  border-left: 4px solid var(--primary);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(240, 201, 106, 0.09), rgba(122, 167, 240, 0.045));
}
.case-study__label {
  display: inline-flex;
  padding: 0.2rem 0.52rem;
  border-radius: 999px;
  background: rgba(240, 201, 106, 0.15);
  color: var(--primary);
  font-size: 0.62em;
  font-weight: 850;
  letter-spacing: 0.08em;
  vertical-align: 0.22em;
  margin-right: 0.4rem;
}
.chapter h2.case-heading,
.chapter h3.case-heading { /* 标签进标题内,继承原 h2/h3 分隔规则,无需额外处理 */ }

.case-study h2,
.case-study h3 {
  margin-top: 0.65rem;
  padding-top: 0;
  border-top: 0;
}
.case-study p:last-child { margin-bottom: 0; }
.summary, .quiz, .glossary-list, .references {
  border-left: 2px solid rgba(240, 201, 106, 0.28);
  padding-left: 1.1rem;
}
ul, ol { padding-left: 1.35rem; }
li + li { margin-top: 0.25rem; }
strong { color: #ffffff; }

.table-wrap {
  overflow-x: auto;
  margin: 1.2rem 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 40rem;
  background: rgba(255, 255, 255, 0.035);
}
th, td {
  border: 1px solid rgba(240, 201, 106, 0.18);
  padding: 0.68rem 0.75rem;
  vertical-align: top;
}
th {
  color: var(--primary);
  text-align: left;
  background: rgba(240, 201, 106, 0.07);
}

pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
}

code {
  font-family: var(--font-mono);
}

.code-walk__code {
  display: block;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid rgba(240, 201, 106, 0.18);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text-soft);
  line-height: 1.55;
}

.callout {
  margin: 1.2rem 0;
  padding: 1rem 1rem 1rem 0.95rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--panel);
}

.callout__title {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--accent);
}

.callout p { margin: 0; }

.callout--note { border-left-color: var(--primary); background: rgba(240, 201, 106, 0.07); }
.callout--note .callout__title { color: var(--primary); }
.callout--warn { border-left-color: var(--danger); background: rgba(238, 136, 119, 0.09); }
.callout--warn .callout__title { color: var(--danger); }
.callout--tip { border-left-color: var(--accent); }

/* 正文内短语级金色高亮("双引号"关键说法) */
.hl {
  color: #ffd97a;
  font-weight: 650;
}

/* 金融术语:天青点线,与 deeplearning 书 .term 一致 */
.term {
  color: var(--accent);
  font-weight: 700;
  border-bottom: 1px dotted rgba(122, 167, 240, 0.55);
}
.term-link {
  text-decoration: none;
  text-underline-offset: 0.18em;
}
.term-link:hover {
  color: #a9c8ff;
  border-bottom-style: solid;
  text-decoration: none;
}
.term-link:focus-visible {
  border-radius: 3px;
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* 数值锚点:数字+单位 */
.num {
  color: #ffd97a;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 已有 .hl/.term/.num 在 strong 内优先显示金色 */
strong .hl, strong .term, strong .num { color: #ffd97a; }

.objectives {
  margin: 1.6rem 0 2rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.objectives h2 {
  margin: 0 0 0.6rem;
  padding: 0;
  border: 0;
  color: var(--accent);
  font-size: 1rem;
}

.objectives ul {
  margin: 0;
}

.figure {
  margin: 1.8rem 0 2.2rem;
}

.figure--reading {
  padding: 0;
}

.chapter-map {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
}

.chapter-diagram {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
  background: rgba(18, 29, 49, 0.55);
  border: 1px solid rgba(122, 167, 240, 0.22);
  padding: 0.4rem;
}

.figure__cap {
  margin: 0.55rem 0 0;
  color: var(--text-dim);
  font-size: 0.92rem;
  text-align: center;
}
.summary {
  margin-top: 3rem;
  padding: 1rem 1rem 1rem 1.25rem;
  border: 1px solid rgba(240, 201, 106, 0.22);
  border-radius: 8px;
  background: rgba(240, 201, 106, 0.06);
}
.summary h2, .quiz h2, .glossary-list h2, .references h2 { margin-top: 0; }
.quiz {
  margin-top: 2rem;
  padding: 1rem 0 0 1.1rem;
}
.quiz__item {
  margin: 0.8rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}
.quiz__item summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
}
.quiz__item p { color: var(--text-soft); }
.chapter-handoff {
  margin: 3rem 0 0;
  padding: 1.2rem 1.3rem;
  border: 1px solid rgba(122, 167, 240, 0.28);
  border-radius: 12px;
  background: rgba(122, 167, 240, 0.065);
}
.chapter-handoff h2 { margin: 0.2rem 0 0.5rem; padding: 0; border: 0; font-size: 1.35rem; }
.chapter-handoff p { margin: 0.45rem 0 0.75rem; }
.chapter-handoff__label { color: var(--accent); font-size: 0.8rem; font-weight: 850; }
.chapter-handoff__actions { display: flex; flex-wrap: wrap; gap: 0.7rem 1.1rem; }
.chapter-handoff--choice { border-color: rgba(240, 201, 106, 0.3); background: rgba(240, 201, 106, 0.06); }
.chapter-handoff--choice .chapter-handoff__label { color: var(--primary); }

.map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1.2rem 0;
}
.map-grid div {
  min-height: 7rem;
  padding: 1rem;
  border: 1px solid rgba(240, 201, 106, 0.2);
  border-radius: 8px;
  background: rgba(255,255,255,0.045);
}
.map-grid strong, .map-grid span { display: block; }
.map-grid span { color: var(--text-soft); margin-top: 0.35rem; }

.glossary-list ul {
  list-style: none;
  padding: 0;
}
.glossary-list li {
  padding: 1rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}
.glossary-list li:target {
  margin-inline: -0.75rem;
  padding-inline: 0.75rem;
  border-radius: 8px;
  background: rgba(240, 201, 106, 0.1);
  box-shadow: inset 3px 0 0 var(--primary);
}
.glossary-list p { margin: 0.2rem 0 0; color: var(--text-soft); }
.references li { overflow-wrap: anywhere; }

.chapter-nav {
  width: min(var(--reading-width), calc(100% - 2rem));
  margin: 3rem auto 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.chapter-nav a {
  flex: 1;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.chapter-nav a:last-child { text-align: right; }

.reveal { opacity: 0; transform: translateY(10px); transition: opacity 260ms ease, transform 260ms ease; }
.reveal.is-visible { opacity: 1; transform: none; }

@media (max-width: 760px) {
  body { font-size: 1rem; }
  .cover { min-height: 72vh; padding-top: 6rem; }
  .cover h1 { font-size: 3rem; }
  .cover__lead, .lead { font-size: 1.08rem; }
  .toc-grid, .map-grid, .roadmap-grid { grid-template-columns: 1fr; }
  .book-roadmap { padding: 1.1rem; }
  .roadmap-card { min-height: auto; }
  .toc-card { min-height: auto; }
  .chapter { padding-left: 1rem; padding-right: 1rem; }
  .chapter h1 { font-size: 2.25rem; }
  .chapter h2 { font-size: 1.42rem; }
  .summary, .quiz, .glossary-list, .references { padding-left: 0.85rem; }
  .book-header__home { max-width: 7.5rem; overflow: hidden; text-overflow: ellipsis; }
}

@media (min-width: 1180px) {
  .chapter {
    padding: calc(var(--header-height) + 1.4rem) 1rem 4rem;
  }

  .book-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, var(--reading-width)) minmax(180px, 220px);
    gap: 2rem;
    align-items: start;
    max-width: 1280px;
    width: auto;
    margin: 0 auto;
  }

  .book-layout__main .chapter__inner {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .book-rail {
    display: block;
    position: sticky;
    top: calc(var(--header-height) + 1.25rem);
    max-height: calc(100vh - var(--header-height) - 2rem);
    overflow-y: auto;
    padding: 0.2rem 0.2rem 1rem 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    scrollbar-width: none;
  }

  .book-rail.is-fixed {
    position: fixed;
    top: calc(var(--header-height) + 1.25rem);
    z-index: 20;
  }

  .book-rail::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }

  .book-rail::-webkit-scrollbar-thumb {
    background: rgba(240, 201, 106, 0.25);
    border-radius: 999px;
  }

  .chapter-nav {
    width: 100%;
  }
}

@media (min-width: 1320px) {
  .book-layout {
    max-width: 1480px;
    grid-template-columns: 248px minmax(0, 52rem) 248px;
    gap: 2.4rem;
  }
}

@media (min-width: 1680px) {
  .book-layout {
    max-width: 1600px;
    grid-template-columns: 280px minmax(0, 56rem) 300px;
    gap: 3rem;
  }
}

/* ============ 代码走读卡片(code-walk) ============ */
.code-walk {
  margin: 1.8rem auto;
  max-width: 54rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1220;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.code-walk__file {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.code-walk__file::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 14px 0 0 var(--primary), 28px 0 0 var(--danger);
  margin-right: 1.6rem;
}

.code-walk__code {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.7;
  color: #d7e3f7;
  border: none;
  background: none;
  tab-size: 2;
}

.code-walk__code code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.cw-tag {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.4rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: var(--primary);
  color: #10120f;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 800;
  vertical-align: middle;
}

.code-walk__notes {
  margin: 0;
  padding: 1rem 1.4rem 1.2rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  counter-reset: cw;
  list-style: none;
}

.code-walk__notes li {
  position: relative;
  margin: 0.7rem 0;
  padding-left: 2rem;
  color: var(--text-soft);
}

.code-walk__notes li::before {
  counter-increment: cw;
  content: counter(cw);
  position: absolute;
  left: 0;
  top: 0.15rem;
  width: 1.4rem;
  height: 1.4rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(122, 167, 240, 0.16);
  border: 1px solid rgba(122, 167, 240, 0.4);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
}

.code-walk__notes li code {
  font-size: 0.85em;
}

@media (max-width: 720px) {
  .code-walk { border-radius: 10px; }
  .code-walk__code { font-size: 0.78rem; padding: 0.8rem 0.9rem; }
}

/* ============ 交互实验台(lab,data-lab 注入) ============ */
.lab {
  margin: 1.8rem auto;
  max-width: 54rem;
  border: 1px solid rgba(122, 167, 240, 0.22);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(122, 167, 240, 0.05), rgba(240, 201, 106, 0.03)), #0f1626;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.36);
  overflow: hidden;
}

/* 顶部窗口栏 */
.lab__head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(122, 167, 240, 0.18);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}
.lab__head-tag {
  color: #f0c96a;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.lab__head-name { opacity: 0.75; }

/* 内部主标题 */
.lab__title {
  padding: 0.95rem 1.2rem 0.4rem;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* 滑杆控件 */
.lab__ctl {
  display: grid;
  grid-template-columns: 9rem 5.5rem 1fr;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 1.2rem;
}
.lab__lab {
  font-size: 0.92rem;
  color: var(--text-soft);
}
.lab__val {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: #ffd97a;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lab__range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(122, 167, 240, 0.18);
  outline: none;
}
.lab__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #f0c96a;
  border: 2.5px solid #101420;
  box-shadow: 0 1px 8px rgba(240, 201, 106, 0.55);
  cursor: pointer;
}
.lab__range::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: #f0c96a;
  border: 2.5px solid #101420;
  box-shadow: 0 1px 8px rgba(240, 201, 106, 0.55);
  cursor: pointer;
}
.lab__range:focus-visible {
  box-shadow: 0 0 0 3px rgba(240, 201, 106, 0.22);
}

/* 图表区 */
.lab__chart {
  display: block;
  width: calc(100% - 2.4rem);
  margin: 0.7rem 1.2rem 0.4rem;
  border-radius: 10px;
  background: rgba(8, 13, 24, 0.72);
  border: 1px solid rgba(122, 167, 240, 0.1);
}

/* 结论行 */
.lab__out {
  padding: 0.4rem 1.2rem 0.2rem;
}
.lab__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  font-size: 0.94rem;
  color: var(--text-soft);
  border-top: 1px dashed rgba(160, 180, 215, 0.14);
}
.lab__row:first-child { border-top: none; }
.lab__row strong {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #ffd97a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.lab__row strong.lab__accent { color: #7aa7f0; font-weight: 800; }
.lab__hint {
  font-size: 0.84rem;
  color: var(--text-dim);
}

/* 教师注 */
.lab__tip {
  margin: 0.7rem 1.2rem 1.1rem;
  padding: 0.65rem 0.95rem;
  border-left: 3px solid rgba(240, 201, 106, 0.5);
  border-radius: 0 8px 8px 0;
  background: rgba(240, 201, 106, 0.055);
  font-size: 0.86rem;
  color: var(--text-dim);
  line-height: 1.7;
}

@media (max-width: 720px) {
  .lab { border-radius: 11px; margin-left: -0.4rem; margin-right: -0.4rem; }
  .lab__ctl { grid-template-columns: 1fr auto; row-gap: 0.1rem; }
  .lab__lab { grid-column: 1; }
  .lab__val { grid-column: 2; }
  .lab__range { grid-column: 1 / -1; height: 7px; }
  .lab__chart { width: calc(100% - 1.4rem); margin: 0.6rem 0.7rem 0.3rem; }
}


/* ---- book search ---- */
.book-search {
  position: fixed; inset: 0; z-index: 80; display: none;
}
.book-search.is-open { display: block; }
.book-search__backdrop {
  position: absolute; inset: 0;
  background: rgba(3, 8, 16, 0.62);
  backdrop-filter: blur(3px);
}
.book-search__panel {
  position: relative; max-width: 720px; margin: 7vh auto 0;
  max-height: 82vh; background: rgba(23, 32, 45, 0.96);
  border: 1px solid rgba(122, 167, 240, 0.35); border-radius: 16px;
  box-shadow: 0 18px 60px rgba(3, 8, 16, 0.5); overflow: hidden;
  display: flex; flex-direction: column; animation: book-search-pop 180ms ease;
}
@keyframes book-search-pop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.book-search__bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line);
}
.book-search__icon { display: inline-grid; place-items: center; flex: 0 0 auto; color: var(--text-dim); }
.book-search__icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.book-search__input {
  flex: 1 1 auto; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--text); font-size: 1.05rem; font-family: inherit; padding: 0.4rem 0.2rem;
}
.book-search__input::placeholder { color: var(--text-dim); }
.book-search__kbd {
  flex: 0 0 auto; padding: 0.22rem 0.55rem; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05); color: var(--text-dim); font-size: 0.72rem; font-weight: 600;
  font-family: var(--font-mono); letter-spacing: 0.02em; white-space: nowrap; user-select: none;
}
.book-search__close {
  flex: 0 0 auto; padding: 0.3rem 0.6rem; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04); color: var(--text-dim); font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.book-search__close:hover { color: var(--text); border-color: rgba(122, 167, 240, 0.35); }
.book-search__status { padding: 0.5rem 0.9rem; color: var(--text-dim); font-size: 0.82rem; border-bottom: 1px solid var(--line); }
.book-search__results { overflow-y: auto; padding: 0.4rem; display: grid; gap: 0.15rem; }
.book-search__result { display: block; padding: 0.6rem 0.7rem; border-radius: 10px; border: 1px solid transparent; color: var(--text-soft); }
.book-search__result:hover, .book-search__result.is-active { text-decoration: none; background: rgba(122, 167, 240, 0.12); border-color: rgba(122, 167, 240, 0.3); }
.book-search__result-chapter { display: block; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); }
.book-search__result-heading { display: block; font-weight: 700; color: var(--text); margin: 0.12rem 0; }
.book-search__result-snippet { display: block; font-size: 0.9rem; line-height: 1.55; color: var(--text-soft); }
.book-search mark { background: rgba(240, 201, 106, 0.3); color: var(--text); border-radius: 3px; padding: 0 0.12em; }
mark.hl-query { background: rgba(240, 201, 106, 0.45); color: var(--text); border-radius: 3px; padding: 0 0.08em; box-shadow: inset 0 -0.09em 0 rgba(240, 201, 106, 0.35); }
.book-search__empty { padding: 1.4rem; text-align: center; color: var(--text-dim); }
@media (max-width: 720px) { .book-search__panel { margin: 0; height: 100%; max-height: 100vh; border-radius: 0; } }

.book-header__search { margin-left: auto; }
.book-header__button {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.22rem 0.6rem; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--text-soft);
  font-family: inherit; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.book-header__button:hover { color: var(--text); border-color: var(--line-strong); }
.book-header__button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.book-header__search-kbd { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-dim); padding: 0.1rem 0.3rem; border: 1px solid var(--line); border-radius: 4px; }
@media (max-width: 720px) { .book-header__search-text, .book-header__search-kbd { display: none; } }

/* ---- glossary popover ---- */
.term--glossary {
  cursor: pointer; padding: 0; margin: 0; border: none; background: none;
  font: inherit; color: var(--accent); font-weight: 600;
  border-bottom: 1px dashed rgba(122, 167, 240, 0.55); text-decoration: none; border-radius: 2px;
  transition: color 0.15s ease, background 0.15s ease; touch-action: manipulation;
}
.term--glossary:hover, .term--glossary:focus-visible { color: #bcd4ff; background: rgba(122, 167, 240, 0.14); outline: none; }
.term--glossary.is-active, .term-link.is-glossary-active { color: #e2eeff; background: rgba(122, 167, 240, 0.22); border-bottom-style: solid; }
.glossary-popover {
  position: fixed; z-index: 1200; width: min(22rem, calc(100vw - 2rem)); padding: 0;
  border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(23, 32, 45, 0.98);
  box-shadow: 0 18px 60px rgba(3, 8, 16, 0.5); color: var(--text);
  animation: glossary-pop-in 0.14s ease-out;
}
@keyframes glossary-pop-in { from { opacity: 0; transform: translateY(4px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.glossary-popover__inner { padding: 0.85rem 1rem 0.75rem; }
.glossary-popover__title { margin: 0 0 0.45rem; font-size: 0.95rem; font-weight: 700; color: var(--accent); line-height: 1.4; }
.glossary-popover__body { margin: 0; font-size: 0.88rem; line-height: 1.65; color: var(--text-soft); }
.glossary-popover__foot { display: flex; gap: 0.75rem; margin-top: 0.7rem; padding-top: 0.55rem; border-top: 1px solid var(--line); font-size: 0.8rem; }
.glossary-popover__link { color: var(--accent); text-decoration: none; }
.glossary-popover__link:hover { text-decoration: underline; }
.glossary-popover__hint { margin-left: auto; color: var(--text-dim); }


/* ================= evolution-book 新增组件 ================= */
.chapter__meta { color: var(--text-dim); font-size: 0.95rem; margin: -0.4rem 0 1.2rem; }

.figure__img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.figure--plate { margin: 1.4rem 0 1.8rem; }
.figure__img--plate { box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35); }

.species-grid { display: grid; gap: 0.9rem; margin: 1rem 0 1.6rem; }
.species-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.9rem 1.1rem;
}
.species-card h3 { margin: 0 0 0.45rem; font-size: 1.02rem; color: var(--primary); }
.species-card p { margin: 0.3rem 0; font-size: 0.98rem; color: var(--text-soft); }

.chapter-sources .source-list,
.source-list { padding-left: 1.4rem; color: var(--text-soft); font-size: 0.95rem; }
.source-list li { margin-bottom: 0.5rem; overflow-wrap: anywhere; }
.source-list--refs { columns: 2; column-gap: 2.4rem; }
@media (max-width: 860px) { .source-list--refs { columns: 1; } }

.toc-line { margin-top: 2.6rem; }
.toc-line__question { margin: 0.4rem 0 0.4rem; font-size: 1.32rem; }

.sum-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; margin: 1rem 0 1.8rem; }
@media (max-width: 720px) { .sum-grid { grid-template-columns: 1fr; } }
.sum-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.85rem 1.05rem;
}
.sum-card h3 { margin: 0 0 0.4rem; font-size: 1.02rem; }
.sum-card__chap { font-size: 0.8rem; color: var(--text-dim); font-weight: 500; margin-left: 0.4rem; }
.sum-card p { margin: 0.25rem 0; font-size: 0.96rem; color: var(--text-soft); }

.table-wrap { overflow-x: auto; margin: 1rem 0 1.8rem; }
.sum-table { border-collapse: collapse; width: 100%; font-size: 0.92rem; color: var(--text-soft); }
.sum-table th, .sum-table td {
  border: 1px solid var(--line); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top;
}
.sum-table th { background: var(--panel-strong); color: var(--primary); white-space: nowrap; }
.sum-table--timeline th, .sum-table--timeline td { border: none; border-bottom: 1px solid var(--line); }
.sum-timeline__era { white-space: nowrap; color: var(--accent); font-weight: 600; width: 11rem; }

.glossary-list ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 1.6rem; padding-left: 0; list-style: none; }
@media (max-width: 720px) { .glossary-list ul { grid-template-columns: 1fr; } }
.glossary-list li { border-bottom: 1px dashed var(--line); padding: 0.35rem 0; }
.glossary-list li p { margin: 0.15rem 0 0; font-size: 0.88rem; color: var(--text-dim); }
