:root {
  --paper: #eee9dc;
  --paper-light: #faf7ee;
  --ink: #252620;
  --muted: #707269;
  --blue: #285d67;
  --blue-deep: #193d43;
  --red: #ac3f32;
  --line: rgba(37, 38, 32, .17);
  --type-scale: 1;
  color-scheme: light;
  font-family: "Songti SC", STSong, SimSun, serif;
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 68px; }
body { margin: 0; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; }
.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-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 9px 13px; background: white; transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 8px clamp(18px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(238, 233, 220, .92);
  backdrop-filter: blur(16px);
}
.brand { font-size: 19px; font-weight: 600; letter-spacing: .18em; text-decoration: none; }
.site-header nav { display: flex; gap: clamp(18px, 3vw, 38px); }
.site-header nav a { color: #52554e; font: 14px/1.2 system-ui, sans-serif; text-decoration: none; }
.site-header nav a:hover, .site-header nav a:focus-visible { color: var(--blue); }

.reader-section { padding: clamp(72px, 9vw, 120px) clamp(10px, 4vw, 58px); color: #eeeae0; background: #202624; }
.reader-section.cover-mode {
  min-height: calc(100svh - 64px);
  padding: 0;
  color: var(--ink);
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.8), transparent 58%), var(--paper);
}
.reader-section.cover-mode > .section-title-row { display: none; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; max-width: 1370px; margin: 0 auto 26px; }
.section-title-row h2 { margin: 0; font-size: clamp(34px, 5vw, 55px); font-weight: 400; letter-spacing: .08em; }
.section-title-row > button, .section-title-row > span { padding: 0; color: #a8b2ac; border: 0; background: transparent; font: 13px/1.4 system-ui, sans-serif; }
.section-title-row > button { cursor: pointer; }
.section-title-row.light { color: var(--ink); }
.section-title-row.light > span { color: var(--muted); }
.reader-app { max-width: 1370px; margin: 0 auto; border: 1px solid rgba(255,255,255,.13); background: #151a18; box-shadow: 0 28px 74px rgba(0,0,0,.3); }
.reader-app.cover-mode { max-width: none; border: 0; background: transparent; box-shadow: none; }
.reader-app.cover-mode .reader-toolbar,
.reader-app.cover-mode .reader-bottom,
.reader-app.cover-mode .progress-track { display: none; }
.reader-toolbar, .reader-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; }
.reader-toolbar { border-bottom: 1px solid rgba(255,255,255,.1); }
.reader-location strong, .reader-location span { display: block; }
.reader-location strong { font-size: 16px; font-weight: 500; }
.reader-location span { margin-top: 4px; color: #8c9690; font: 11px/1.3 system-ui, sans-serif; }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; }
.toolbar-actions button, .reader-bottom button, .original-controls button {
  padding: 8px 11px;
  color: #dde1dd;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.toolbar-actions button:hover, .reader-bottom button:hover, .original-controls button:hover { color: white; border-color: #8cb1b6; }
.book-stage {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  min-height: min(82svh, 920px);
  padding: 24px 0;
  background: radial-gradient(circle at 50% 42%, #4b5550, #1b211f 70%);
  overflow: hidden;
}
.reader-app.cover-mode .book-stage {
  min-height: calc(100svh - 64px);
  padding: clamp(24px, 4vh, 48px) 0;
  background: transparent;
}
.book-spread { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 1080px); margin: auto; filter: drop-shadow(0 21px 34px rgba(0,0,0,.38)); }
.book-spread.is-solo { grid-template-columns: minmax(0, 520px); justify-content: center; }
.reader-app.cover-mode .book-spread.is-cover {
  grid-template-columns: minmax(0, 470px);
  width: min(72vw, 470px, calc((100svh - 116px) * .739));
  filter: drop-shadow(0 28px 34px rgba(43, 37, 26, .25));
}
.book-page {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 2 / 3;
  color: #171812;
  background:
    linear-gradient(90deg, rgba(80,67,44,.05), transparent 7%),
    radial-gradient(circle at 1px 1px, rgba(70,62,49,.04) 1px, transparent 1.1px) 0 0 / 17px 17px,
    #f7f3e9;
  container-type: size;
  overflow: hidden;
}
.book-page + .book-page { border-left: 1px solid rgba(58,52,42,.22); background: linear-gradient(270deg, rgba(80,67,44,.05), transparent 7%), #f7f3e9; }
.book-page.cover-page {
  aspect-ratio: 105 / 142;
  border: 1px solid rgba(41,49,43,.22);
  background: #e6e1d4;
  box-shadow: 0 28px 68px rgba(43,37,26,.24);
  cursor: e-resize;
  transition: transform .24s ease, box-shadow .24s ease;
}
.book-page.cover-page:hover { transform: translateY(-3px); box-shadow: 0 34px 76px rgba(43,37,26,.28); }
.book-page.cover-page:focus-visible { outline: 3px solid var(--blue); outline-offset: 5px; }
.page-content { position: absolute; inset: 0; }
.layout-line {
  position: absolute;
  z-index: 1;
  margin: 0;
  max-width: 88%;
  font-size: calc(var(--line-size) * var(--type-scale));
  line-height: 1.16;
  white-space: nowrap;
  transform-origin: left top;
}
.layout-line.title-line,
.layout-line.verse-line { left: 7% !important; width: 86% !important; max-width: 86%; font-family: "Kaiti SC", STKaiti, KaiTi, serif; text-align: center; }
.layout-line.title-line { font-weight: 700; letter-spacing: .05em; }
.layout-line.footnote-line { max-width: 78%; font-family: "Songti SC", STSong, SimSun, serif; line-height: 1.18; white-space: normal; }
.layout-line.prose-line { line-height: 1.2; }
.footnote-rule { position: absolute; z-index: 2; left: 12%; width: 28%; border-top: 1px solid rgba(37,38,32,.72); }
.note-marker { margin-left: .08em; font-size: .56em; line-height: 0; vertical-align: .62em; }
.printed-page-number { position: absolute; z-index: 2; bottom: 3.5%; left: 0; width: 100%; color: #33342d; font-size: 1.65cqh; letter-spacing: .3em; text-align: center; }
.page-art { position: absolute; inset: 5%; display: grid; place-items: center; }
.page-art img { width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.page-art.cover-art { inset: 0; }
.page-art.cover-art img { height: 100%; object-fit: cover; mix-blend-mode: normal; }
.frontmatter-page { position: absolute; inset: 0; padding: 10cqh 13% 7%; }
.frontmatter-title { margin: 0 0 6cqh; font: 700 2.85cqh/1.2 "Kaiti SC", STKaiti, KaiTi, serif; letter-spacing: .48em; text-align: center; }
.preface-copy { font-size: 1.74cqh; line-height: 1.78; text-align: justify; }
.preface-copy p { margin: 0 0 .9em; text-indent: 2em; }
.preface-copy .preface-thanks { margin-bottom: 0; }
.preface-copy .preface-close { margin: 0; text-indent: 0; }
.preface-signature { margin-top: .1em; padding-right: 4%; font-size: 1.7cqh; text-align: right; }
.contents-page { padding: 16cqh 14% 8%; }
.contents-page .frontmatter-title { margin-bottom: 5cqh; }
.contents-list { display: grid; gap: .38cqh; margin: 0; padding: 0; font-size: 1.88cqh; line-height: 1.32; list-style: none; }
.contents-row { display: grid; grid-template-columns: max-content 1fr max-content; align-items: end; gap: .45em; }
.contents-row::after { grid-column: 2; grid-row: 1; margin-bottom: .27em; border-bottom: .16em dotted currentColor; content: ""; opacity: .8; }
.contents-row .contents-name { grid-column: 1; }
.contents-row .contents-page-number { grid-column: 3; }
.contents-row .contents-author { grid-column: 3; font-weight: 600; }
.page-art.author-art { grid-template-columns: 32% 1fr; gap: 7%; align-content: center; padding: 8%; }
.page-art.author-art p { margin: 0; font-size: 2.5cqh; line-height: 2; text-indent: 2em; }
.page-art.blank-art { color: #a29e92; font-size: 2.3cqh; letter-spacing: .2em; }
.empty-page-text { position: absolute; top: 48%; width: 100%; margin: 0; color: #8f8c83; text-align: center; }
.turn-button {
  z-index: 4;
  width: 38px;
  height: 64px;
  margin: auto;
  padding: 0;
  color: #e0e5e1;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(0,0,0,.12);
  cursor: pointer;
  font: 31px/1 system-ui, sans-serif;
}
.turn-button:hover:not(:disabled) { border-color: #8cb1b6; background: rgba(64,105,112,.28); }
.turn-button:disabled { opacity: .18; cursor: default; }
.reader-app.cover-mode .turn-button { color: #44534d; border-color: rgba(37,38,32,.24); background: rgba(255,255,255,.34); }
.reader-app.cover-mode .turn-button:hover:not(:disabled) { color: var(--blue-deep); border-color: rgba(40,93,103,.55); background: rgba(255,255,255,.72); }
.reader-app.cover-mode .turn-button.previous { visibility: hidden; }
.reader-bottom { color: #8e9993; border-top: 1px solid rgba(255,255,255,.1); font: 12px/1.4 system-ui, sans-serif; }
.page-jump { display: flex; align-items: center; gap: 7px; }
.page-jump input { width: 75px; padding: 7px 8px; color: white; border: 1px solid rgba(255,255,255,.2); border-radius: 3px; background: #252c29; }
.progress-track { height: 3px; background: rgba(255,255,255,.07); }
.progress-track span { display: block; width: 0; height: 100%; background: #739ba2; transition: width .2s ease; }

.original-section { padding: clamp(76px, 10vw, 138px) clamp(14px, 5vw, 76px); background: var(--paper); }
.original-viewer { max-width: 1240px; margin: 0 auto; color: #e8ece9; background: #171b1a; box-shadow: 0 24px 66px rgba(41,37,28,.2); }
.original-stage { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center; min-height: min(78svh, 900px); background: #101312; }
.original-stage > button { width: 38px; height: 64px; margin: auto; color: white; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: transparent; cursor: pointer; font-size: 29px; }
.original-stage > button:disabled { opacity: .2; }
.original-image-wrap { display: grid; height: min(74svh, 840px); place-items: center; padding: 18px 0; overflow: auto; }
.original-image-wrap img { width: auto; max-width: 100%; height: 100%; object-fit: contain; }
.original-image-wrap p { color: #aeb7b2; }
.original-controls { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1); color: #9fa9a3; font: 12px/1.4 system-ui, sans-serif; }

.origin-section { padding: clamp(98px, 13vw, 190px) 24px; color: #f0eee5; background: var(--blue-deep); text-align: center; }
.origin-section h2 { margin: 0 0 32px; color: #b9cfd0; font-size: 16px; font-weight: 400; letter-spacing: .35em; }
.origin-section blockquote { margin: 0 auto 27px; font: 400 clamp(40px, 7vw, 82px)/1.25 "Kaiti SC", STKaiti, KaiTi, serif; }
.origin-section p { margin: 0; color: #c9d5d4; font-size: 16px; line-height: 1.9; }
body > footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(18px, 5vw, 72px); color: #939b96; background: #171b1a; font: 12px/1.5 system-ui, sans-serif; }

dialog { color: var(--ink); }
dialog::backdrop { background: rgba(14,18,17,.72); backdrop-filter: blur(5px); }
.panel-dialog { width: min(680px, calc(100vw - 28px)); max-height: 82svh; padding: 0; border: 0; background: var(--paper-light); box-shadow: 0 28px 80px rgba(0,0,0,.35); }
.dialog-head { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 20px 23px 14px; border-bottom: 1px solid var(--line); background: rgba(250,247,238,.95); }
.dialog-head h2 { margin: 0; font-size: 29px; font-weight: 500; }
.dialog-head button { padding: 8px 12px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
#toc-list { padding: 7px 23px 26px; }
.toc-item { display: grid; grid-template-columns: 1fr auto; gap: 18px; width: 100%; padding: 16px 2px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.toc-item span { color: var(--muted); font: 12px/1.5 system-ui, sans-serif; }
.search-field { display: block; padding: 20px 23px 12px; }
.search-field input { width: 100%; padding: 13px 15px; border: 1px solid var(--line); background: white; font-size: 17px; }
.search-results { max-height: 52svh; padding: 0 23px 23px; overflow: auto; }
.search-result { display: block; width: 100%; padding: 15px 0; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.search-result strong, .search-result span { display: block; }
.search-result strong { margin-bottom: 6px; color: var(--blue-deep); }
.search-result span { color: #565a52; line-height: 1.6; }
.search-empty { padding: 28px 0; color: var(--muted); text-align: center; }

@media (max-width: 920px) {
  .book-spread { grid-template-columns: minmax(0, 520px); justify-content: center; }
  .book-page:nth-child(2) { display: none; }
}

@media (max-width: 720px) {
  html { scroll-padding-top: 58px; }
  .site-header { min-height: 58px; padding-inline: 14px; }
  .brand { font-size: 16px; }
  .site-header nav { gap: 15px; }
  .site-header nav a { font-size: 12px; }
  .reader-section.cover-mode { min-height: calc(100svh - 58px); }
  .reader-section { padding-inline: 0; }
  .reader-section > .section-title-row { padding-inline: 16px; }
  .reader-toolbar { align-items: start; padding-inline: 13px; }
  .toolbar-actions { max-width: 60%; }
  .toolbar-actions button { padding: 7px 8px; font-size: 11px; }
  .book-stage { grid-template-columns: 30px minmax(0, 1fr) 30px; min-height: 72svh; padding-block: 12px; }
  .reader-app.cover-mode .book-stage { min-height: calc(100svh - 58px); }
  .reader-app.cover-mode .book-spread.is-cover { width: min(84vw, calc((100svh - 94px) * .739)); }
  .turn-button { width: 26px; height: 48px; font-size: 22px; }
  .reader-bottom { display: block; }
  .reader-bottom > span { display: none; }
  .page-jump { justify-content: end; }
  .original-section { padding-inline: 0; }
  .original-section > .section-title-row { padding-inline: 16px; }
  .original-stage { grid-template-columns: 30px minmax(0, 1fr) 30px; min-height: 70svh; }
  .original-stage > button { width: 26px; height: 48px; font-size: 22px; }
  .original-image-wrap { height: 68svh; padding-block: 10px; }
  .original-controls { display: block; }
  .original-controls > button { margin-bottom: 12px; }
  .original-controls .page-jump { justify-content: start; }
  body > footer { display: block; }
  body > footer span { display: block; }
  body > footer span + span { margin-top: 5px; }
}

@media (max-width: 430px) {
  .site-header nav a { font-size: 11px; }
  .reader-location span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toolbar-actions button:nth-child(3), .toolbar-actions button:nth-child(4) { display: none; }
  .book-spread { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
