:root {
  --paper: #f3ede2;
  --sheet: #fbf8f1;
  --card: #fffcf7;
  --ink: #2b2925;
  --muted: #5c564e;
  --pine: #1e3a2d;
  --green: #244f40;
  --bronze: #9c6b36;
  --bronze-ink: #6b4520;
  --line: #d3c9b6;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.85 var(--sans);
}
body > * { max-width: 100%; }
img { max-width: 100%; height: auto; object-fit: contain; }
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--bronze-ink); }
button, input, select { font: inherit; color: inherit; max-width: 100%; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid #a88140;
  outline-offset: 3px;
}
.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
header, main, section, footer, figure, nav, ul, ol, p, h1, h2, h3 { min-width: 0; }
section { margin: 1.4rem 0; }
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  color: var(--pine);
  line-height: 1.28;
  overflow-wrap: break-word;
}
h1 { font-size: clamp(36px, 4vw, 64px); margin: 0 0 16px; }
h2 { font-size: clamp(26px, 2.4vw, 32px); margin: 0 0 12px; }
h3 { font-size: 22px; margin: 0 0 8px; }
p { margin: 0.75em 0; }
ul, ol { margin: 0.6em 0; padding-left: 1.2em; }
.mast {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--pine);
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-decoration: none;
}
.brand span { color: var(--muted); letter-spacing: 0.06em; padding-left: 12px; }
.mast nav, .chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
}
.mast nav a, .chapter-nav a, a[data-continue] {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--pine);
  text-decoration: none;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 36px 7%;
  align-items: center;
  padding: 64px 0 72px;
}
.hero-copy { min-width: 0; }
@media (min-width: 901px) {
  .hero.hero-split {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--bronze-ink);
  font-size: 12px;
  letter-spacing: 0.16em;
}
.dek { max-width: 38em; margin: 0; color: #4e5850; font-size: 18px; line-height: 1.9; }
.hero figure, .hero-art { margin: 0; }
.hero img { width: 100%; max-height: 560px; background: #e7efe4; }
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 48px;
  margin: 28px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.stats dt { font: 40px/1.1 var(--serif); color: var(--pine); }
.stats dd { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.section-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  align-items: baseline;
  margin: 8px 0 20px;
}
.section-heading h2 { margin: 0; }
.section-heading p, .section-heading a { margin: 0; color: var(--muted); font-size: 14px; }
.library-tools {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 14px 16px;
  align-items: end;
  margin: 8px 0 32px;
  padding: 28px 0;
  border-block: 1px solid var(--line);
}
.library-tools > form {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 14px 16px;
  align-items: end;
}
.library-tools [data-result-count],
.library-tools [data-read-count],
.library-tools [data-empty],
.library-tools [data-search-note],
.library-tools a[data-continue] { grid-column: 1 / -1; }
label { display: block; min-width: 0; color: var(--muted); font-size: 13px; }
input[data-search], select[data-part-filter], .library-tools input, .library-tools select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 48px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid #c9bfae;
  border-radius: 0;
  background: var(--card);
}
button[data-reset-filter], button[data-mark-read], button[data-compare-choice], button[data-quiz-choice], button[data-image-close] {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--sheet);
  color: var(--ink);
}
button[aria-pressed="true"] {
  background: var(--pine);
  border-color: var(--pine);
  color: var(--sheet);
}
[data-result-count], [data-read-count] { color: var(--muted); font-size: 13px; }
[data-read-status] { color: var(--bronze-ink); font-size: 13px; }
[data-empty] {
  margin: 12px 0;
  padding: 32px 16px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 22px;
}
.book-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 22px 18px;
  background: var(--card);
  border: 1px solid #e3d9c8;
}
.book-card img { width: 100%; aspect-ratio: 3 / 2; background: #e7efe4; }
.book-card h2, .book-card h3 { margin: 0 0 8px; font-size: 22px; }
.book-card p { margin: 0; color: var(--muted); font-size: 14px; }
.unit-list { list-style: none; margin: 0; padding: 0; }
.unit-list > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  border-top: 1px solid var(--line);
}
.unit-list > li:last-child { border-bottom: 1px solid var(--line); }
.unit-list a {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  padding: 18px 4px;
  color: inherit;
  text-decoration: none;
}
.unit-list [data-read-status] { flex: 0 0 auto; white-space: nowrap; }
.unit-list a:hover { background: #efe8da; }
.reader-head { margin: 28px 0 8px; }
.header-sources { max-width: 100%; margin: 14px 0 0; }
.header-sources summary {
  box-sizing: border-box;
  min-height: 44px;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--pine);
  border: 1px solid var(--line);
  background: var(--sheet);
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.header-sources summary:focus-visible { outline: 2px solid var(--pine); outline-offset: 3px; }
.reading-block { margin: 12px 0 40px; }
.prose, .terms p, .case-study p { font-size: 18px; line-height: 1.95; }
.prose { max-width: 42em; }
.learning-figure { margin: 12px 0; }
.learning-figure button[data-figure-open] {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}
.learning-figure img, figure img { width: 100%; background: #e7efe4; }
figure { margin: 1rem 0; }
figcaption { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.terms, .case-study, .compare, .quiz, .source-note { max-width: 46em; }
.terms, .compare, .quiz {
  margin: 28px 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.case-study {
  margin: 28px 0;
  padding: 2px 0 2px 14px;
  border-left: 1px solid var(--bronze);
}
.compare button, .quiz button { margin: 0 8px 8px 0; }
[data-compare-output] { min-height: 1.8em; font-size: 17px; line-height: 1.8; }
.quiz [data-quiz-feedback] { margin-top: 8px; padding-top: 8px; }
.quiz [data-quiz-feedback] p { margin: 12px 0; font-size: 16px; line-height: 1.75; }
.source-note, a, .unit-list { overflow-wrap: anywhere; }
.source-note { color: var(--muted); font-size: 14px; line-height: 1.7; }
.chapter-nav { margin: 28px 0; }
.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 22px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.footer p { margin: 0; }
[data-storage-notice] {
  width: min(1120px, calc(100% - 64px));
  margin: 12px auto;
  color: var(--bronze-ink);
}
dialog[data-image-dialog] {
  width: min(1040px, calc(100% - 24px));
  max-width: calc(100% - 24px);
  max-height: calc(100svh - 24px);
  margin: auto;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--sheet);
  color: var(--ink);
  overflow: auto;
}
dialog[data-image-dialog]::backdrop { background: rgba(30, 58, 45, 0.32); }
dialog[data-image-dialog] img[data-image-large] {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 78svh;
  margin: 8px auto 0;
  object-fit: contain;
}
@media (min-width: 900px) {
  .reading-block {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.85fr);
    column-gap: 44px;
    row-gap: 12px;
    align-items: start;
  }
  .reading-block > .prose { grid-column: 1; max-width: none; }
  .reading-block > .learning-figure { grid-column: 2; grid-row: 1 / span 4; margin: 0; }
  .reading-block > :not(.prose):not(.learning-figure) { grid-column: 1 / -1; }
  .prose, .prose p { font-size: 19px; }
}
@media (min-width: 1440px) {
  .wrap, [data-storage-notice] { width: min(1160px, calc(100% - 160px)); }
}
@media (max-width: 900px) {
  .wrap, [data-storage-notice] { width: calc(100% - 36px); }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 36px 0 42px; }
  h1, .hero h1 { font-size: 40px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-tools, .library-tools > form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  button[data-reset-filter] { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 390px) {
  .wrap, [data-storage-notice] { width: calc(100% - 24px); }
  .mast { padding: 14px 0; }
  .hero { padding: 28px 0 32px; }
  h1, .hero h1 { font-size: 32px; }
  .dek, .prose, .prose p, .case-study p, .terms p { font-size: 17px; }
  .library-tools, .library-tools > form { grid-template-columns: minmax(0, 1fr); }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .book-card { padding: 14px 12px; }
  .stats { gap: 18px 28px; }
  .stats dt { font-size: 32px; }
  input, select { font-size: 16px; }
  .footer { gap: 10px 16px; }
}
@media (max-width: 320px) {
  .wrap, [data-storage-notice] { width: calc(100% - 16px); }
  body { font-size: 16px; }
  h1, .hero h1 { font-size: 28px; }
  h2, .section-heading h2 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
.knowledge-figure {
  max-width: 100%;
  margin: 0.4rem 0 1.2rem;
  padding: 10px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-top: 3px solid var(--pine);
}
.knowledge-figure h2 {
  margin: 0 0 8px;
  color: var(--pine);
  font-size: 22px;
}
.knowledge-figure figcaption { margin: 8px 0 0; }
.study-panels {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}
.study-panel {
  min-width: 0;
  max-width: 100%;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--bronze);
}
.study-panel h3 {
  min-width: 0;
  margin: 0 0 6px;
  color: var(--pine);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 20px;
  line-height: 1.35;
  overflow-wrap: break-word;
}
.study-panel p,
.study-steps,
.study-steps li,
.study-table {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: break-word;
  word-break: normal;
}
.study-panel p.study-note {
  margin: 8px 0 0;
  color: var(--bronze-ink);
}
.study-figure figcaption {
  font-size: 14px;
  line-height: 1.7;
}
.study-steps {
  margin: 0.2em 0 0;
  padding-left: 1.5em;
  list-style: decimal;
}
.study-steps li { margin: 0.3em 0; }
.study-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.study-table th,
.study-table td {
  min-width: 0;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: normal;
}
.study-table thead th {
  color: var(--bronze-ink);
  font-weight: 500;
}
.study-key { display: none; }
@media (max-width: 640px) {
  .study-table,
  .study-table tbody,
  .study-table tr,
  .study-table td {
    display: block;
    width: auto;
  }
  .study-table { table-layout: auto; }
  .study-table thead { display: none; }
  .study-table tr {
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    background: var(--sheet);
  }
  .study-table td {
    padding: 4px 0;
    border-bottom: 0;
  }
  .study-key {
    display: block;
    margin: 0 0 2px;
    color: var(--bronze-ink);
    font-size: 14px;
    line-height: 1.5;
  }
}
.source-line, .cite, .source-list, .book-entry { overflow-wrap: anywhere; }
.cite {
  color: var(--bronze-ink);
  font-family: var(--sans);
  font-size: 14px;
}
.cite a { margin-right: 0.4em; }
.role-label { margin: 0.2em 0; color: var(--bronze-ink); font-size: 14px; }
.source-list { margin: 0.4em 0 0; padding-left: 1.3em; list-style: decimal; }
.source-list li { margin: 0.85em 0; }
.book-entry {
  margin: 0 0 1.4rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}
.book-entry h3 { margin-bottom: 0.3rem; }
[data-search-note] { margin: 0; color: var(--muted); font-size: 13px; }

/* Native theme buttons: same reading layout, no custom select popup. */
.part-filter { grid-column:1 / -1; min-width:0; margin:0; padding:0; border:0; }
.part-filter legend { padding:0; color:var(--muted); font-size:13px; }
.part-filter-buttons { display:flex; flex-wrap:wrap; gap:8px; margin-top:6px; }
button[data-part-choice] { min-height:44px; max-width:100%; padding:8px 14px; border:1px solid var(--line); background:var(--sheet); color:var(--ink); overflow-wrap:anywhere; }
button[data-part-choice][aria-pressed="true"] { background:var(--ink); color:var(--sheet); }
