:root {
  color-scheme: light;
  --paper: #f1f0e9;
  --ink: #202e29;
  --green: #19483a;
  --muted: #54645b;
  --line: #cfd9d0;
  font: 16px/1.55 system-ui, "PingFang TC", "Microsoft JhengHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
.wrap { max-width: 1340px; width: calc(100% - 44px); margin-inline: auto; }
h1 { margin: .15rem 0 0; font: 700 clamp(1.8rem, 4.3vw, 3.15rem)/1.2 "Songti TC", "PMingLiU", serif; letter-spacing: .075em; }
.library { padding-block: .7rem 3rem; }
.reader-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: .8rem;
  padding-block: .65rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.contents { position: relative; }
#contents > summary {
  padding: .45rem .8rem;
  border: 1px solid #b6c7ba;
  border-radius: .45rem;
  background: #fbfaf5;
  color: var(--green);
  white-space: nowrap;
}
#contents > summary:hover, #contents[open] > summary { background: #e3eee5; }
#chapter-index {
  position: absolute;
  inset: calc(100% + .45rem) auto auto 0;
  width: min(22rem, calc(100vw - 22px));
  max-height: min(65dvh, 34rem);
  padding: .4rem .65rem .6rem;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: #fffefa;
  box-shadow: 0 .55rem 1.45rem #19483a22;
}
.work-index + .work-index { border-top: 1px solid var(--line); }
.work-index > summary { padding: .7rem .4rem; overflow-wrap: anywhere; }
.section-index { padding: 0 .15rem .45rem 1rem; }
.contents a { display: block; padding: .47rem .5rem; color: var(--ink); text-decoration: none; border-radius: .3rem; }
.contents a:hover, .contents a[aria-current] { background: #e3eee5; color: #123a2b; }
.paragraphs { margin: .18rem 0 .35rem .5rem; border-inline-start: 1px solid var(--line); font-size: .875rem; }
.paragraphs > summary { padding: .35rem .5rem; color: var(--muted); }
.paragraphs a { line-height: 1.45; }
.paragraph-heading { font-weight: 700; }

main { min-width: 0; width: 100%; max-width: 940px; }
#reader-layout > main { max-width: none; padding-top: 1rem; }
#reading-head { margin-bottom: 1rem; padding: .35rem 0 .7rem; border-bottom: 1px solid var(--line); }
#reading-head h2 {
  margin: 0;
  color: var(--green);
  font: 700 clamp(1.65rem, 3.2vw, 2.5rem)/1.35 "Songti TC", "PMingLiU", serif;
}
#text { display: grid; gap: clamp(.85rem, 2vw, 1.5rem); }
.transcript { min-width: 0; }
#text :is(h3, [id]) { scroll-margin-top: calc(var(--reader-toolbar-height, 4rem) + .75rem); }
.reading-text [id]:target { border-radius: .2rem; box-shadow: 0 0 0 .24rem #eaf2e7; }
.draft-note { font-size: .86rem; color: var(--muted); }
.transcript .ocr-row { margin: .12rem 0; }
.video { display: inline-block; margin-block: .65rem; color: var(--green); font-weight: 700; }
.originals { border-top: 1px solid var(--line); margin-top: 1.35rem; padding-top: .7rem; color: var(--muted); font-size: .95rem; }
.source-group h3 { margin: .8rem 0 0; color: var(--green); font-size: 1rem; }
.source-options { display: flex; flex-wrap: wrap; gap: .4rem; padding-top: .45rem; }
.page-navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; justify-self: end; width: min(100%, 40rem); }
.page-navigation-bottom { margin-top: 1rem; margin-inline-start: auto; }
.page-navigation a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 0;
  gap: .5rem;
  padding: .35rem .65rem;
  border: 1px solid #b6c7ba;
  border-radius: .45rem;
  background: #fffefa;
  color: var(--green);
  font-size: .94rem;
  text-decoration: none;
}
.page-navigation .next-work { grid-column: 2; background: var(--green); color: #fffefa; border-color: var(--green); }
.page-navigation .previous-work:hover { background: #e3eee5; }
.page-navigation .next-work:hover { background: #28614e; }
.page-label { flex: none; font-weight: 700; }
.page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zoom-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .62rem; border: 1px solid var(--line); background: #fcfbf7; }
.zoom-actions { display: flex; align-items: center; gap: .35rem; }
button { font: inherit; color: inherit; border: 1px solid var(--line); background: #fff; border-radius: 6px; min-height: 44px; padding: .25rem .62rem; cursor: pointer; }
button:hover { background: #e3eee5; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid #b26d39; outline-offset: 2px; }
.scan-page { padding: 0; overflow: hidden; background: white; height: fit-content; border-radius: 0; cursor: zoom-in; }
.scan-page img { width: 100%; height: auto; display: block; }
dialog { width: min(1120px,96vw); max-width: 96vw; max-height: 93dvh; margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: #e9ece6; color: var(--ink); }
dialog::backdrop { background: #152921c9; }
.zoom-bar { justify-content: space-between; gap: .3rem; }
.zoom-view { overflow: auto; max-height: calc(93dvh - 82px); }
.zoom-view img { display: block; max-width: none; margin-inline: auto; }
#scale { min-width: 3rem; text-align: center; }
@media (max-width: 720px) {
  .wrap { width: calc(100% - 22px); }
  .library { padding-top: .35rem; }
  .reader-toolbar { gap: .4rem; padding-block: .4rem; }
  #contents > summary { padding: .58rem .5rem; font-size: .9rem; }
  .page-navigation { gap: .3rem; }
  .page-navigation a { padding-inline: .25rem; font-size: .9rem; }
  .reader-toolbar .page-title {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
  }
}

.transcript, .illustration {
  margin: 0;
  padding: clamp(1rem, 4vw, 3.4rem);
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: #fffefa;
}
.transcript {
  padding: clamp(1rem, 2.8vw, 2.65rem);
  font-size: clamp(1.0625rem, 1rem + .24vw, 1.2rem);
  line-height: 1.85;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 8px #19483a0a;
}
.transcript > h3 {
  margin: 0 0 .8rem;
  padding: 0 0 .55rem .65rem;
  border-bottom: 1px solid var(--line);
  border-inline-start: 3px solid #63927d;
  color: var(--green);
  font: 700 clamp(1.35rem, 3vw, 1.9rem)/1.4 "Songti TC", "PMingLiU", serif;
}
.transcript h4 { margin: 1.4em 0 .35em; color: var(--green); font-size: 1.2rem; }
.transcript p { margin: .8em 0; }
.transcript .attribution, .continuation, .gloss { color: var(--muted); }
.transcript :is(.overview-highlight, .book-highlight) {
  padding: .08em .12em;
  border-radius: .14em;
  background: #dcebd3;
  color: var(--green);
  font-weight: 700;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.transcript .question { border-inline-start: .2rem solid #89ac99; padding: .4rem .7rem; background: #eff5eb; }
.transcript :is(.question strong, blockquote .gloss, .text-glosses) { color: var(--green); }
.transcript blockquote { margin: .9rem 0; padding: .45rem clamp(.7rem, 2vw, 1.3rem); background: #eff4ee; border-radius: .4rem; }
.transcript blockquote footer { text-align: end; color: var(--muted); font-size: .9rem; }
.transcript ul { padding-inline-start: 1.35rem; }
.pronunciation { display: inline-flex; align-items: center; white-space: nowrap; color: var(--green); font-weight: 700; }
.listen { display: inline-grid; place-items: center; min-width: 32px; min-height: 32px; padding: .16rem; margin: 0 .12rem; vertical-align: middle; border-color: #bad4c4; border-radius: 50%; color: var(--green); background: #edf6ee; }
.listen:hover, .listen:active { background: #d4e9da; }
@media (pointer: coarse) { .listen { min-width: 44px; min-height: 44px; } }
.audio-credit { margin-block: 1.25rem .4rem; color: var(--muted); font-size: .875rem; }
.audio-credit a { color: var(--green); }
.transcript .pronunciation-table table { min-width: min(100%, 21rem); }
.pronunciation-table th:nth-child(-n+2) { white-space: nowrap; }
.gloss, .continuation { font-size: .83em; }
.illustration { padding: clamp(.4rem, 2vw, 1.2rem); }
.illustration figcaption { padding: .25rem .2rem .55rem; color: var(--green); font-size: 1.2rem; font-weight: 700; }
.illustration .scan-page { width: 100%; }
#speech-status { position: fixed; inset: auto 1rem 1rem auto; z-index: 4; margin: 0; padding: .6rem .8rem; background: #fff4dc; border: 1px solid #cfab66; border-radius: .4rem; }

.transcript h5 { font-size: 1.04rem; margin: 1em 0 .25em; }
.table-scroll { max-width: 100%; overflow-x: auto; margin: .75rem 0 1.6rem; }
.transcript table { width: 100%; min-width: 37rem; border-collapse: collapse; font-size: 1rem; line-height: 1.6; }
.transcript th, .transcript td { padding: .55rem .65rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.transcript thead th { background: #e3eee5; }
.transcript th:first-child, .transcript td:nth-child(2) { white-space: nowrap; }

.mind-map {
  --mind-line: #a0b9a9;
  --mind-indent: clamp(.78rem, 2vw, 1.2rem);
  margin-block-start: 1rem;
}
.mind-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .4rem;
  margin-block-end: .8rem;
}
.mind-controls button { min-height: 40px; font-size: .875rem; }
.mind-canvas {
  display: grid;
  grid-template-columns: minmax(7rem, .8fr) minmax(0, 3.4fr);
  align-items: start;
  border: 1px solid #dbe7df;
  border-radius: .75rem;
  padding: clamp(.7rem, 2vw, 1.35rem);
  background: #f7faf6;
}
.transcript .mind-root {
  margin: 0;
  padding: .55rem .8rem;
  border-radius: .45rem;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  line-height: 1.5;
}
.transcript .mind-branches { list-style: none; padding: 0 0 0 var(--mind-indent); margin: 0; }
.mind-branches > li { position: relative; padding: 0 0 .4rem var(--mind-indent); }
.mind-branches > li:last-child { padding-bottom: 0; }
.mind-branches > li::before,
.mind-branches > li::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  pointer-events: none;
}
.mind-branches > li::before { inset-block: 0; border-inline-start: 1px solid var(--mind-line); }
.mind-branches > li:last-child::before { inset-block-end: auto; height: 1.22rem; }
.mind-branches > li::after { top: 1.22rem; width: var(--mind-indent); border-block-start: 1px solid var(--mind-line); }
.mind-canvas > .mind-branches { position: relative; padding-top: .05rem; }
.mind-canvas > .mind-branches::before {
  content: "";
  position: absolute;
  top: 1.27rem;
  inset-inline-start: 0;
  width: var(--mind-indent);
  border-block-start: 1px solid var(--mind-line);
}
.mind-canvas > .mind-branches > li:first-child::before { inset-block-start: 1.22rem; }
.mind-node {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .45rem;
  min-height: 2.44rem;
  padding: .42rem .62rem;
  border: 1px solid #ceded3;
  border-radius: .4rem;
  background: #fff;
  color: var(--green);
  font-size: 1rem;
  line-height: 1.55;
}
.mind-node::-webkit-details-marker { display: none; }
.mind-node::after { content: "+" / ""; color: inherit; }
.mind-branch[open] > .mind-node::after { content: "−" / ""; }
.mind-node:hover { background: #e4efe6; }
.mind-node:target { outline: 2px solid #b26d39; outline-offset: 2px; }
.mind-canvas > .mind-branches > li > .mind-branch > .mind-node {
  background: #dcf0e4;
  border-color: #b9d8c5;
  font-size: 1.05rem;
}
.mind-canvas > .mind-branches > li:nth-child(2) > .mind-branch > .mind-node {
  background: #edf2dd;
  border-color: #d4dfb8;
  color: #374b25;
}
.mind-canvas > .mind-branches > li:nth-child(3) > .mind-branch > .mind-node {
  background: #e8eef7;
  border-color: #cbd9ef;
  color: #284766;
}
.mind-branch-content { padding-top: .35rem; }
.transcript .mind-description {
  margin: 0 0 .28rem var(--mind-indent);
  color: var(--green);
  font-size: .96rem;
  font-weight: 650;
}
.mind-branches > :is(.mind-leaf, .mind-explanation) {
  padding-block: .23rem .36rem;
  font-size: 1rem;
  line-height: 1.65;
}
.mind-branches > .mind-explanation { color: var(--muted); padding-block-start: 0; font-size: .94rem; }
.mind-branches > .mind-explanation::after,
.mind-branches > .mind-leaf::after { top: 1rem; width: calc(.72 * var(--mind-indent)); }
.mind-branches > .mind-explanation::after { border-block-start-style: dotted; }
.mind-branches > :is(.mind-leaf, .mind-explanation):last-child::before { height: 1rem; }
@media (max-width: 720px) {
  .mind-map { --mind-indent: .6rem; }
  .mind-controls { justify-content: flex-start; }
  .mind-canvas { grid-template-columns: minmax(0, 1fr); }
  .mind-root { justify-self: start; }
  .mind-canvas > .mind-branches::before { inset-block-start: 0; inset-inline-start: var(--mind-indent); height: 1.28rem; width: 0; border: 0; border-inline-start: 1px solid var(--mind-line); }
  .mind-canvas > .mind-branches { padding-top: .28rem; }
  .mind-canvas > .mind-branches::before { height: 1.5rem; }
}

.transcript .particle-table table { min-width: 0; }
.particle-table th:first-child { color: var(--green); }
.particle-in-context { color: var(--green); }
.transcript .particle-table :is(th, td) { padding: .45rem .55rem; }
.transcript .particle-table td:nth-child(3) { width: 36%; }
.practice-list { display: grid; gap: .9rem; }
.practice-card { padding: clamp(.75rem, 2.4vw, 1.2rem); border: 1px solid var(--line); border-radius: .55rem; background: #fff; }
.transcript .practice-card h4 { margin-block: 0 .4rem; }
.transcript .practice-question, .transcript .practice-answer-text { white-space: pre-line; }
.practice-source { color: var(--muted); font-size: .9rem; }
.practice-choices fieldset { min-width: 0; margin: 0 0 .5rem; padding: .35rem .65rem .65rem; border: 1px solid var(--line); border-radius: .35rem; }
.practice-choices legend { padding: 0 .3rem; font-size: .9rem; }
.practice-choices label { display: flex; gap: .45rem; align-items: baseline; padding-block: .18rem; cursor: pointer; }
.practice-choices input { flex: none; accent-color: var(--green); }
.transcript .practice-feedback { margin: .25rem 0; color: var(--green); font-weight: 650; }
.practice-feedback:empty { display: none; }
.practice-answer { margin-top: .65rem; padding: .55rem .7rem; background: #f2f7f0; border-radius: .35rem; }
.practice-answer > summary { color: var(--green); }
.transcript .practice-answer-text { margin: .45rem 0 .1rem; }
.transcript .practice-table table { min-width: 27rem; }
@media (max-width: 530px) {
  .transcript .particle-table :is(th, td) { padding: .4rem .27rem; font-size: .92rem; }
  .transcript .particle-table td:nth-child(3) { width: 31%; }
}

.transcript .text-lines { white-space: pre-line; }
.text-glosses { padding: .35rem .75rem; margin-block: .45rem .8rem; background: #f4f7ef; border-radius: .4rem; font-size: .96rem; }
.reading-reveal { margin-block: .65rem; padding-inline: .75rem; border: 1px solid var(--line); border-radius: .4rem; }
.reading-translation[open] { background: #eff5eb; }
.reading-reveal > summary { padding-block: .45rem; color: var(--green); font-weight: 700; }
.reading-reveal > summary :is(h4, h5) { display: inline; margin: 0; font: inherit; }
.transcript .text-glosses p { margin-block: .35rem; }
.classical-reference { display: inline-block; margin-top: .6rem; font-size: .9rem; color: var(--green); }

.practice-table input { width: 100%; min-width: 4.2rem; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: .25rem; font: inherit; color: var(--ink); }

.mast { padding-block: .55rem .25rem; }
.reader-book-links {
  display: flex;
  align-items: center;
  gap: clamp(.65rem, 2vw, 1.25rem);
  margin-bottom: .55rem;
  color: var(--green);
}
.reader-book-links a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  font-size: .9rem;
}
.reader-book-links a:hover { text-decoration: underline; text-underline-offset: .25em; }
.reader-book-links .reader-book-title {
  margin-inline-end: auto;
  gap: .55rem;
  font: 700 1.1rem/1.3 "Songti TC", "PMingLiU", serif;
  white-space: nowrap;
}
.reader-book-title img { border-radius: .28rem; }
.chapter-opener {
  position: relative;
  isolation: isolate;
  min-height: 12rem;
  display: grid;
  align-items: center;
  padding: clamp(1.5rem, 3.7vw, 3rem) clamp(1.5rem, 5vw, 4.25rem);
  overflow: hidden;
  background: #132e27;
  color: #fff8e7;
}
.chapter-opener::before, .chapter-opener::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.chapter-opener::before {
  inset: 0 0 0 auto;
  z-index: -1;
  width: 68%;
  background: url("dse-cover.webp") center 68% / cover no-repeat;
  mask-image: linear-gradient(to right, transparent, #000 73%);
  opacity: .85;
}
.chapter-opener::after { inset: .55rem; border: 1px solid #c8b48380; }
.chapter-heading { max-width: 45rem; }
#chapter-number {
  display: flex;
  align-items: center;
  gap: .58rem;
  margin: 0 0 .52rem;
  color: #e7d3a2;
  font-size: .9rem;
  font-weight: 650;
  letter-spacing: .18em;
}
#chapter-number::before { content: ""; width: 1.5rem; border-top: 1px solid currentColor; }
#chapter-title {
  margin: 0;
  font-size: clamp(1.75rem, 4.3vw, 3.8rem);
  letter-spacing: .05em;
  text-wrap: balance;
}
#chapter-theme { margin: .65rem 0 0; color: #f0e2c1; font-size: .95rem; letter-spacing: .08em; }
.chapter-tabs {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 1px;
  margin-top: .6rem;
  border: 1px solid #cdd4c8;
  background: #cdd4c8;
}
.chapter-tabs a {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: .24rem;
  min-width: 0;
  padding: .68rem .58rem .62rem;
  border-bottom: 3px solid transparent;
  background: #fcfbf5;
  color: #163a2d;
  text-decoration: none;
}
.chapter-tabs a:last-child { background: #f4efdf; }
.chapter-tabs a:hover { background: #e6efe6; }
.chapter-tabs a[aria-current] { background: #19483a; color: #fff8e7; border-color: #d5b879; }
.chapter-tabs a:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
.chapter-tab-label { color: #596456; font-size: .875rem; font-weight: 550; }
.chapter-tabs a[aria-current] .chapter-tab-label { color: #efdaa6; }
.chapter-tab-title { font-size: .95rem; font-weight: 700; line-height: 1.34; text-wrap: balance; overflow-wrap: anywhere; }
@media (max-width: 960px) {
  .chapter-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .chapter-opener { min-height: 9.75rem; }
  .chapter-opener::before { width: 85%; opacity: .63; }
  .chapter-heading { text-shadow: 0 1px 5px #102c23; }
  .chapter-tabs a { padding: .42rem .5rem .38rem; gap: .15rem; }
  .chapter-tab-title { font-size: .875rem; }
}
@media (max-width: 330px) {
  .reader-book-links { gap: .46rem; }
  .reader-book-links .reader-book-title { gap: .3rem; font-size: .95rem; }
}
