@charset "UTF-8";

:root {
  color-scheme: light;
  --paper: #f7f7f3;
  --white: #fff;
  --ink: #252b32;
  --muted: #656b73;
  --accent: #315aa0;
  --accent-light: #edf2fa;
  --line: #e4e5e1;
  --warning: #886024;
  --body-size: 18px;
  --reader-width: 860px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 82px; }
html[data-font="large"] { --body-size: 21px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 15px; line-height: 1.6; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
button, a, summary, select { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .35; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
a { color: var(--accent); text-underline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip { position: fixed; top: -60px; left: 16px; z-index: 50; padding: 9px 15px; background: var(--accent); color: white; }
.skip:focus { top: 8px; }

.topbar {
  position: sticky; top: 0; z-index: 10; height: 64px;
  display: flex; align-items: center; gap: 28px;
  padding: 0 max(28px, calc((100vw - 1180px) / 2));
  background: #f7f7f3f5; border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: baseline; gap: 13px; white-space: nowrap;
  text-decoration: none; color: var(--ink); font-size: 19px; font-weight: 650; letter-spacing: .5px;
}
.brand span { font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.progress-overview {
  margin-left: auto; display: flex; align-items: center; gap: 12px;
  font-size: 12px; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums;
}
.progress-overview strong { font-weight: 600; color: var(--ink); }
.progress-track { width: 68px; height: 3px; background: #e0e4e9; overflow: hidden; border-radius: 3px; }
.progress-track span { display: block; height: 100%; background: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 5px; }
.quiet, .directory-toggle, .study-shortcut, .page-button {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  min-height: 44px; padding: 9px 12px; border-radius: 7px;
}
.quiet:hover, .study-shortcut:hover, .page-button:hover:not(:disabled) { background: #eceeea; color: var(--ink); }
.quiet[aria-pressed="true"] { background: var(--accent-light); color: var(--accent); }
.directory-toggle { margin-left: 5px; color: var(--accent); border-color: #cbd5e4; font-size: 13px; }
.directory-toggle:hover { background: var(--accent-light); }

.reader { max-width: var(--reader-width); margin: 0 auto; padding: 0 0 24px; }
.reader-context {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 70px; padding: 10px 4px; font-size: 12px; color: var(--muted);
}
.study-shortcut { color: var(--accent); font-size: 12px; padding-right: 0; white-space: nowrap; }
.study-shortcut span { margin-left: 6px; }
.exercise { background: var(--white); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.exercise-top { padding: 32px 40px 20px; }
.question-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.question-id { color: var(--accent); font-weight: 600; }
.source-status { font-size: 11px; }
.important-toggle {
  margin-left: auto; padding: 7px 0 7px 12px; border: 0; background: transparent;
  color: var(--muted); font-size: 12px; min-height: 44px;
}
.important-toggle.marked { color: var(--warning); }
.exercise h1 { margin: 12px 0 18px; font-size: 28px; line-height: 1.5; font-weight: 650; letter-spacing: -.3px; color: #202936; }
.exercise h1:focus { outline: none; }
.question-body { font-size: 16px !important; color: #444c56; }
.review-guidance {
  display: flex; align-items: baseline; gap: 12px; margin: 0 40px;
  padding: 15px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.review-tag { flex-shrink: 0; font-weight: 600; color: var(--accent); }
.review-guidance p { margin: 0; line-height: 1.8; }
.reading-controls { display: flex; align-items: center; justify-content: space-between; padding: 8px 40px 10px; color: var(--muted); font-size: 12px; }
.reading-position { font-variant-numeric: tabular-nums; }
.self-test { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.self-test input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.answer-area, .knowledge-area { padding: 22px 40px 0; }
.answer-area { border-top: 1px solid var(--line); }
.knowledge-area { margin-top: 30px; padding-top: 27px; border-top: 1px solid var(--line); }
.block-label { display: flex; align-items: center; gap: 10px; margin: 0 0 17px; color: #35465f; font-size: 14px; font-weight: 600; letter-spacing: .6px; }
.block-label::before { content: ""; height: 13px; width: 3px; background: #7891b6; border-radius: 2px; }
.rich-text { font-size: var(--body-size); font-weight: 400; line-height: 1.85; overflow-wrap: anywhere; }
.rich-text p { margin: 16px 0; }
.rich-text > :first-child { margin-top: 0; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text strong { font-weight: 650; color: #273a54; }
.rich-text .key-term { background: transparent; padding: 0; color: #284f89; font-weight: 650; }
.rich-text ol, .rich-text ul { padding-left: 1.5em; margin: 16px 0; }
.rich-text li { padding-left: 4px; margin: 0 0 17px; }
.rich-text li:last-child { margin-bottom: 0; }
.rich-text li::marker { color: #6e8096; font-size: .85em; font-weight: 500; }
.rich-text h4, .rich-text h5, .rich-text h6 { font-size: 1em; font-weight: 600; margin: 24px 0 12px; }
.rich-text figure { margin: 22px 0; }
.rich-text img { max-width: 100%; height: auto; }
.diagram-image { display: block; width: 100%; height: auto; }
.rich-text figcaption { margin-top: 12px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.rich-text table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; margin: 20px 0; font-size: .85em; }
.rich-text th, .rich-text td { border: 1px solid var(--line); padding: 10px 13px; vertical-align: top; }
.rich-text th { font-weight: 600; background: #f5f7f8; }
.rich-text pre { overflow: auto; white-space: pre; background: #f5f7f8; padding: 18px; border-radius: 6px; font-size: .85em; }
.rich-text code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.rich-text blockquote { border-left: 2px solid #bdcbdc; margin: 18px 0; padding-left: 18px; color: var(--muted); }
.rich-text .formula, .rich-text .math-block, .rich-text .equation {
  overflow-x: auto; margin: 20px 0; padding: 16px; border: 1px solid #e7ebf0;
  border-radius: 6px; background: #f8fafc; font-size: 1em;
}
.rich-text math { max-width: 100%; overflow-x: auto; }
.study-reference { font-size: 12px; color: var(--muted); line-height: 1.8; margin: 20px 0 0; }
.pitfall-area { margin: 30px 40px 0; padding: 20px 0 0; border-top: 1px solid #e8dfcf; }
.pitfall-area .block-label { color: var(--warning); }
.pitfall-area .block-label::before { background: #b59460; }
.pitfall-area .rich-text { color: #66543a; font-size: calc(var(--body-size) - 1px); }
.derivation { margin: 26px 40px 0; border-top: 1px solid var(--line); padding-top: 8px; }
.derivation summary { cursor: pointer; min-height: 44px; padding: 12px 0; font-size: 13px; color: var(--accent); }
.derivation > .rich-text { padding: 15px 0 4px; font-size: calc(var(--body-size) - 1px); }
.hidden-answer { padding: 42px 30px; border-top: 1px solid var(--line); text-align: center; }
.hidden-answer p { font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.primary, .secondary { min-height: 44px; padding: 10px 16px; border: 1px solid #ccd5e0; border-radius: 6px; background: white; color: var(--accent); font-size: 14px; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.secondary:hover { background: var(--accent-light); }
.exercise-bottom { margin: 28px 40px 0; padding: 12px 0 20px; border-top: 1px solid var(--line); }
.sources summary { min-height: 44px; cursor: pointer; padding: 12px 0; font-size: 12px; color: var(--muted); }
.source-row { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted); line-height: 1.8; padding: 10px 0; }
.section-source { width: 100%; }
.question-origin { font-size: 12px; line-height: 1.7; color: var(--muted); }
.content-footer { text-align: center; font-size: 11px; color: var(--muted); margin-top: 24px; }
.pagination { max-width: var(--reader-width); margin: 0 auto 36px; padding: 8px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.page-button { color: var(--accent); font-size: 14px; }
.page-button:first-child { justify-self: start; }
.page-button:last-child { justify-self: end; }
.mastery-buttons { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.mastery-button { background: transparent; border: 0; border-radius: 5px; padding: 9px 13px; min-height: 44px; color: var(--muted); font-size: 13px; }
.mastery-button:hover { background: #f3f5f6; }
.mastery-button[aria-pressed="true"] { color: var(--accent); background: var(--accent-light); font-weight: 600; }
.mastery-button[data-state="retry"][aria-pressed="true"] { color: #855f24; background: #f7f0e3; }
.mastery-button[data-state="done"][aria-pressed="true"] { color: #27634e; background: #edf5ef; }
.empty-state { text-align: center; padding: 80px 25px; border: 1px solid var(--line); background: white; border-radius: 10px; }
.empty-state h1 { font-size: 23px; font-weight: 600; }
.empty-state p { color: var(--muted); margin: 12px 0 22px; }

.dialog { color: var(--ink); background: #fff; padding: 0; border: 0; box-shadow: 0 15px 80px #202b3b20; }
.dialog::backdrop { background: #202b3b45; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); background: white; }
.dialog-heading h2 { font-size: 18px; margin: 0; font-weight: 600; }
.dialog-heading .quiet { padding-right: 0; font-size: 13px; }
.directory { position: fixed; inset: 0 0 0 auto; width: 430px; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border-radius: 12px 0 0 12px; }
.directory[open], .resources[open] { display: flex; flex-direction: column; }
.directory-body { padding: 22px; overflow: auto; overscroll-behavior: contain; }
.bank-controls { display: grid; grid-template-columns: 40px minmax(0,1fr); gap: 10px; align-items: center; font-size: 13px; }
select { width: 100%; min-height: 44px; padding: 8px 30px 8px 11px; color: var(--ink); background: #fff; border: 1px solid #d8dce1; border-radius: 6px; font-size: 13px; }
select:disabled { color: var(--muted); background: #f6f6f4; }
.search { display: flex; align-items: center; gap: 7px; border: 1px solid #d8dce1; border-radius: 6px; padding: 0 11px; margin: 16px 0; }
.search:focus-within { border-color: var(--accent); }
.search input { min-width: 0; width: 100%; min-height: 44px; border: 0; background: transparent; font-size: 14px; color: var(--ink); }
.search input:focus { outline: 0; }
.search kbd { color: #6d7682; font-size: 12px; }
.chapter-picker { border-bottom: 1px solid var(--line); margin-bottom: 14px; padding-bottom: 8px; }
.chapter-picker summary { min-height: 44px; font-size: 13px; cursor: pointer; padding: 10px 0; }
.chapter-picker summary span { margin-left: 12px; color: var(--muted); }
#chapterNav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px 0 10px; }
.chapter-button { border: 0; background: transparent; padding: 10px 8px; min-height: 44px; text-align: left; color: #4c5665; border-radius: 6px; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.chapter-button:hover { background: #f4f6f9; }
.chapter-button.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.chapter-count { margin-left: auto; color: var(--muted); font-size: 11px; }
.chapter-check { margin-left: 4px; color: #27634e; }
.review-filter-row { display: grid; align-items: center; grid-template-columns: 66px 1fr; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 20px; }
.filter-button { min-height: 44px; background: #fff; color: var(--muted); border: 1px solid var(--line); padding: 8px 13px; border-radius: 6px; font-size: 12px; }
.filter-button span { margin-left: 5px; font-variant-numeric: tabular-nums; }
.filter-button[aria-pressed="true"] { background: var(--accent-light); border-color: #b7c8e2; color: var(--accent); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.section-heading h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0; }
.section-heading > span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.question-nav { display: flex; flex-direction: column; gap: 4px; }
.question-pill { display: grid; grid-template-columns: 83px minmax(0,1fr) 16px; gap: 9px; align-items: start; min-height: 48px; padding: 12px 10px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--ink); text-align: left; }
.question-pill:hover { background: #f5f6f8; }
.question-pill.active { color: var(--accent); background: var(--accent-light); }
.question-pill .nav-id { font-size: 11px; line-height: 1.8; color: var(--muted); overflow-wrap: anywhere; }
.question-pill .nav-title { font-size: 13px; line-height: 1.6; }
.nav-status { font-size: 12px; color: #6c788a; line-height: 1.8; text-align: center; }
.question-pill[data-state="done"] .nav-status { color: #27634e; }
.question-pill[data-state="retry"] .nav-status { color: var(--warning); }
.nav-star { color: var(--warning); margin-right: 4px; }
.directory-empty { text-align: center; font-size: 13px; color: var(--muted); padding: 28px 0; }
.resources { width: 560px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 64px); border-radius: 12px; }
.resources-body { padding: 4px 26px 25px; overflow: auto; }
.resources-body section { padding: 23px 0; border-bottom: 1px solid var(--line); }
.resources-body section:last-child { border-bottom: 0; padding-bottom: 0; }
.resources h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
.resources p { color: var(--muted); font-size: 13px; line-height: 1.8; margin: 0 0 13px; }
.resources .resource-notice { margin: 14px 0 0; color: var(--accent); }
.resources .resource-notice.error { color: #805023; }
.handout-links, .backup-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.handout-links a { display: inline-block; padding: 10px 14px; min-height: 44px; border: 1px solid #d6deea; border-radius: 6px; text-decoration: none; font-size: 13px; }
.handout-links a:hover { background: var(--accent-light); }
.resource-links { display: flex; flex-direction: column; gap: 12px; font-size: 13px; padding: 4px 0; }
.notice { position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); z-index: 40; padding: 12px 18px; max-width: min(580px,90vw); border-radius: 7px; background: #273a54; color: white; font-size: 13px; }
.notice.error { background: #805023; }

@media (max-width: 960px) {
  .reader, .pagination { margin-left: 28px; margin-right: 28px; }
  .progress-track { display: none; }
}
@media (max-width: 600px) {
  :root { --body-size: 17px; }
  html[data-font="large"] { --body-size: 20px; }
  html { scroll-padding-top: 68px; }
  .topbar { height: 58px; padding: 0 14px; gap: 10px; }
  .brand { font-size: 17px; letter-spacing: 0; }
  .brand span, .desktop-label { display: none; }
  .progress-overview { font-size: 10px; margin-left: auto; }
  .top-actions { gap: 0; }
  .top-actions .quiet, .directory-toggle { padding: 8px; font-size: 12px; min-width: 44px; }
  .directory-toggle { margin-left: 2px; }
  .reader { margin: 0; padding-bottom: 100px; }
  .reader-context { min-height: 58px; padding: 6px 20px; gap: 8px; font-size: 11px; }
  #readingContext { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .study-shortcut { font-size: 11px; }
  .exercise { border-radius: 0; border-left: 0; border-right: 0; }
  .exercise-top { padding: 18px 22px 17px; }
  .question-meta { gap: 8px; font-size: 11px; }
  .source-status { font-size: 10px; }
  .important-toggle { font-size: 11px; }
  .exercise h1 { font-size: 23px; line-height: 1.55; margin: 7px 0 15px; }
  .question-body { font-size: 15px !important; }
  .review-guidance { margin: 0 22px; gap: 9px; padding: 12px 0; font-size: 12px; }
  .review-tag { font-size: 11px; }
  .reading-controls { padding: 2px 22px 8px; font-size: 11px; }
  .answer-area, .knowledge-area { padding-left: 22px; padding-right: 22px; }
  .answer-area { padding-top: 22px; }
  .knowledge-area { margin-top: 26px; padding-top: 24px; }
  .block-label { font-size: 13px; margin-bottom: 15px; }
  .rich-text { line-height: 1.85; }
  .rich-text li { margin-bottom: 17px; }
  .rich-text table { font-size: .8em; }
  .rich-text th, .rich-text td { padding: 8px; }
  .rich-text .formula, .rich-text .math-block, .rich-text .equation { padding: 12px; }
  .rich-text figcaption { font-size: 12px; }
  .pitfall-area { margin: 25px 22px 0; }
  .derivation { margin: 25px 22px 0; }
  .exercise-bottom { margin: 24px 22px 0; padding-bottom: 16px; }
  .content-footer { margin: 22px 15px 0; font-size: 10px; }
  .pagination {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
    max-width: none; margin: 0; padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
    gap: 4px; background: #fff; border-top: 1px solid var(--line);
  }
  .page-button { font-size: 12px; padding: 9px 6px; min-height: 44px; }
  .mastery-buttons { padding: 2px; gap: 1px; }
  .mastery-button { font-size: 12px; min-height: 44px; padding: 8px; }
  .directory { border-radius: 0; width: min(100%,430px); }
  .dialog-heading { padding: 12px 20px; }
  .directory-body { padding: 18px 20px 28px; }
  .resources { max-width: calc(100vw - 24px); max-height: calc(100dvh - 40px); }
  .resources-body { padding-left: 21px; padding-right: 21px; }
  .notice { bottom: calc(90px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  body { background: white; }
  .topbar, .reader-context, .reading-controls, .pagination, .dialog, .notice, .content-footer, .important-toggle { display: none !important; }
  .reader { max-width: none; margin: 0; padding: 0; }
  .exercise { border: 0; }
  .exercise-top, .answer-area, .knowledge-area { padding-left: 0; padding-right: 0; }
  .review-guidance, .pitfall-area, .exercise-bottom { margin-left: 0; margin-right: 0; }
  .answer-content[hidden] { display: block !important; }
  .hidden-answer, .derivation, .sources { display: none !important; }
  .rich-text { font-size: 11pt; }
  .diagram-image { max-height: 22cm; object-fit: contain; }
  .rich-text figure { break-inside: avoid; }
}
