.book-reader-page { background: var(--paper); }
.reading-progress { position: fixed; z-index: 30; top: 78px; left: 0; width: 100%; height: 3px; background: rgba(16,35,44,.08); }
.reading-progress span { display: block; width: 0; height: 100%; background: #95b633; transition: width .08s linear; }
.book-reader { padding-bottom: 110px; }
.reader-hero { max-width: 880px; padding: 76px 0 48px; margin-inline: auto; border-bottom: 1px solid var(--line); }
.reader-hero h1 { margin: 18px 0 15px; font-size: clamp(48px, 7vw, 78px); line-height: 1.13; }
.reader-hero h1 em { color: #64851c; font-style: normal; }
.reader-hero > p:not(.eyebrow):not(.reader-search-status) { max-width: 650px; margin-bottom: 19px; color: #4e6268; font-size: 17px; line-height: 1.85; }
.reader-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 22px 27px; }
.reader-meta span { padding: 6px 10px; border: 1px solid #d5ddd7; color: #55696d; background: rgba(251,252,248,.7); font-size: 11px; }
.reader-search-label { display: block; margin-bottom: 7px; color: #607177; font-size: 12px; font-weight: 700; }
.reader-search { width: min(100%, 470px); min-height: 44px; padding: 0 13px; border: 1px solid #ccd7d0; border-radius: 3px; color: var(--ink); background: #fbfcf8; font-size: 14px; }
.reader-search-status { margin: 7px 0 0; color: #87928f; font-size: 11px; }
.reader-layout { display: grid; grid-template-columns: 250px minmax(0, 760px); justify-content: center; gap: clamp(36px, 6vw, 86px); align-items: start; padding-top: 45px; }
.reader-contents { position: sticky; top: 99px; max-height: calc(100vh - 122px); overflow: auto; padding: 16px 14px; border: 1px solid #dbe2dc; background: rgba(251,252,248,.9); scrollbar-width: thin; }
.reader-contents summary { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); font-family: var(--serif); font-size: 15px; font-weight: 700; cursor: pointer; list-style: none; }
.reader-contents summary::-webkit-details-marker { display: none; }
.reader-contents summary span { color: #87938f; font-family: var(--mono); font-size: 9px; font-weight: 400; }
.reader-toc { display: grid; gap: 2px; margin-top: 13px; }
.reader-toc a { display: block; padding: 6px 7px; border-left: 2px solid transparent; color: #607177; font-size: 11px; line-height: 1.55; transition: background .15s ease, color .15s ease; }
.reader-toc a:hover, .reader-toc a.active { border-left-color: #98b93f; color: #20383d; background: #edf2e6; }
.reader-toc a[hidden] { display: none; }
.reader-prose { min-width: 0; }
.reader-prose section { scroll-margin-top: 100px; padding: 0 0 52px; margin-bottom: 47px; border-bottom: 1px solid var(--line); }
.reader-prose section[hidden] { display: none; }
.reader-prose h1 { margin: 0 0 28px; color: var(--ink); font-size: clamp(34px, 4.2vw, 49px); line-height: 1.27; }
.reader-prose h2 { margin: 32px 0 12px; color: #1c373f; font-size: 24px; line-height: 1.4; }
.reader-prose h3 { margin: 27px 0 10px; color: #345258; font-size: 19px; line-height: 1.45; }
.reader-prose p, .reader-prose li { color: #354d53; font-family: var(--serif); font-size: 16px; line-height: 1.95; }
.reader-prose p { margin: 0 0 15px; }
.reader-prose li { padding-left: 2px; margin-bottom: 5px; }
.reader-prose ul, .reader-prose ol { padding-left: 1.45em; margin: 10px 0 20px; }
.reader-prose strong { color: #172f37; font-weight: 700; }
.reader-prose em { font-style: italic; }
.reader-prose code { padding: 2px 5px; color: #40561d; background: #edf3da; font-family: var(--mono); font-size: .87em; white-space: normal; }
.reader-prose a { color: #087c81; text-decoration: underline; text-decoration-color: rgba(8,124,129,.35); text-underline-offset: 3px; }
.reader-prose blockquote { padding: 12px 18px; margin: 18px 0; border-left: 3px solid #a2c442; background: #edf2e6; }
.reader-prose blockquote p { margin: 0; color: #485d54; }
.reader-prose table { width: 100%; border-collapse: collapse; background: rgba(251,252,248,.6); font-size: 13px; }
.reader-prose th, .reader-prose td { padding: 9px 11px; border: 1px solid #d8e0da; text-align: left; vertical-align: top; }
.reader-prose th { color: #2a4248; background: #e9eee8; font-weight: 700; }
.table-scroll { overflow-x: auto; margin-block: 17px 23px; }
.book-intro { padding-top: 13px !important; }
.book-intro h1 { display: none; }
.book-intro h3 { margin-top: 0; }
.book-appendix { border-bottom: 0 !important; }
.book-chapter { position: relative; }
.reader-prose .book-chapter > h1::before { display: block; margin-bottom: 9px; color: #7a8c87; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; }
.reader-prose .book-chapter#chapter-01 > h1::before { content: "第一部 · 从日常问题入门"; }
.reader-prose .book-chapter#chapter-04 > h1::before { content: "第二部 · 学会几种算法"; }
.reader-prose .book-chapter#chapter-09 > h1::before { content: "第三部 · 解开几个常见误会"; }
.reader-prose .book-chapter#chapter-13 > h1::before { content: "第四部 · 把概率用在判断中"; }
.reader-prose .book-chapter > h2:last-of-type { margin-top: 29px; padding-top: 17px; border-top: 1px solid #dce3dd; }
.reader-prose .book-chapter > p:last-child { margin-top: 8px; color: #78904a; font-family: var(--sans); font-size: 12px; font-weight: 700; }
.reader-prose .exercise-instructions { margin: -3px 0 17px; color: #657771; font-family: var(--sans); font-size: 12px; line-height: 1.7; }
.reader-prose .exercise-list { margin-top: 0; }
.reader-prose .exercise-question { position: relative; margin-bottom: 20px; padding-bottom: 3px; scroll-margin-top: 110px; }
.reader-prose h2[id^="exercises-"] { scroll-margin-top: 110px; }
.exercise-tools { display: flex; gap: 20px; margin-top: 4px; }
.exercise-help { position: static; }
.exercise-help summary { display: inline-block; padding: 6px 1px; color: #087c81; font-family: var(--sans); font-size: 13px; line-height: 1.65; cursor: pointer; list-style: none; text-decoration: underline; text-decoration-color: #82aeac; text-underline-offset: 4px; }
.exercise-help summary::-webkit-details-marker { display: none; }
.exercise-help summary:hover, .exercise-help[open] summary { color: #355b12; text-decoration-color: currentColor; }
.exercise-help summary:focus-visible { outline: 2px solid #087c81; outline-offset: 3px; border-radius: 2px; }
.exercise-popup { position: absolute; z-index: 15; top: 100%; left: 0; width: 100%; box-sizing: border-box; max-height: min(20rem, 50vh); overflow-y: auto; padding: 15px 18px; border: 1px solid #b8cbb6; border-radius: 5px; background: #fbfdf6; box-shadow: 0 8px 25px rgba(16,35,44,.13); }
.exercise-help[data-help-kind="answer"] .exercise-popup { border-color: #a9c4c5; background: #f5fbfa; }
.exercise-popup-label { display: block; margin-bottom: 6px; color: #647754; font-family: var(--sans); font-size: 12px; }
.reader-prose .exercise-popup p { margin: 0; font-size: 15px; line-height: 1.85; overflow-wrap: anywhere; }
.exercise-help.popup-above .exercise-popup { top: auto; bottom: calc(100% - 2px); }
@media (hover: none), (pointer: coarse) {
  .exercise-tools { display: block; }
  .exercise-help { margin-bottom: 2px; }
  .exercise-help summary { min-height: 38px; box-sizing: border-box; padding-block: 8px; }
  .exercise-popup { position: static; max-height: none; margin: 3px 0 10px; box-shadow: none; }
}
@media print {
  .exercise-tools, .exercise-instructions { display: none; }
}
@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 210px minmax(0, 1fr); gap: 25px; }
  .reader-contents { top: 93px; }
}
@media (max-width: 680px) {
  .reading-progress { top: 70px; }
  .reader-hero { padding-top: 52px; }
  .reader-hero h1 { font-size: 50px; }
  .reader-hero > p:not(.eyebrow):not(.reader-search-status) { font-size: 15px; }
  .reader-layout { display: flex; flex-direction: column; gap: 22px; padding-top: 24px; }
  .reader-contents { position: sticky; top: 73px; z-index: 10; width: 100%; max-height: min(45vh, 360px); padding: 12px 13px; }
  .reader-contents:not([open]) { max-height: none; }
  .reader-toc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-toc a { font-size: 10px; }
  .reader-prose { width: 100%; }
  .reader-prose h1 { font-size: 35px; }
  .reader-prose h2 { font-size: 21px; }
  .reader-prose p, .reader-prose li { font-size: 15px; }
  .reader-prose th, .reader-prose td { min-width: 115px; font-size: 11px; }
}
