:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --paper: #fffdf8;
  --ink: #25211b;
  --muted: #706a60;
  --line: #ded7c8;
  --accent: #7a2f25;
  --accent-2: #1e5d5a;
  --shadow: 0 14px 36px rgba(44, 37, 26, 0.10);
  --sidebar: 240px;
  --annotation-width: min(420px, 92vw);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  line-height: 1.88;
}
a { color: inherit; }
.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .22s ease;
}
body.sidebar-collapsed .layout { grid-template-columns: 0 minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  background: #eee8da;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 10;
  transition: transform .22s ease, visibility .22s ease;
}
body.sidebar-collapsed .sidebar { transform: translateX(-100%); visibility: hidden; }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; margin-bottom: 26px; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px;
  background: var(--accent); color: #fffdf8; border-radius: 50%; font-weight: 700;
}
.brand strong { display: block; font-size: 1.1rem; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; margin-top: 3px; }
.toc { display: grid; gap: 6px; }
.toc-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #3b352c;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.35;
}
.toc-link strong { font-weight: 600; }
.toc-link:hover, .toc-link.is-current { background: rgba(122, 47, 37, 0.10); color: var(--accent); }
.content { width: min(100%, 980px); padding: 56px 42px 80px; margin: 0 auto; }
.page-head { margin-bottom: 26px; }
.kicker { margin: 0 0 8px; color: var(--accent-2); font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif; font-size: .92rem; }
h1 { margin: 0; font-size: clamp(2.1rem, 5vw, 4rem); line-height: 1.12; font-weight: 700; letter-spacing: 0; }
.pager {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-top: 18px; font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
.pager a { color: var(--accent); text-decoration: none; padding: 8px 0; font-weight: 600; }
.version-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-top: 16px;
  color: var(--muted);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: .92rem;
}
.version-switcher label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.version-switcher select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 34px 4px 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
.version-hint {
  color: var(--muted);
  font-size: .86rem;
}
.book-audio {
  --audio-strip-height: 88px;
  --audio-frame-height: 360px;
  position: relative;
  height: var(--audio-strip-height);
  margin: 0 0 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171411;
  box-shadow: var(--shadow);
}
.book-audio iframe {
  position: absolute;
  left: 0;
  top: calc(var(--audio-strip-height) - var(--audio-frame-height));
  width: 100%;
  height: var(--audio-frame-height);
  border: 0;
}
.text-body {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 58px);
}
body.parallel-view .content {
  width: min(100%, 1280px);
}
.parallel-body {
  display: grid;
  gap: 0;
  padding: clamp(18px, 3vw, 34px);
}
.parallel-head,
.parallel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 36px);
}
.parallel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: calc(clamp(18px, 3vw, 34px) * -1) calc(clamp(18px, 3vw, 34px) * -1) 18px;
  padding: 12px clamp(18px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .96);
  color: var(--muted);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: .88rem;
  backdrop-filter: blur(6px);
}
.parallel-row {
  padding: 12px 0;
  border-bottom: 1px solid rgba(222, 215, 200, .58);
}
.parallel-row:last-child {
  border-bottom: 0;
}
.parallel-cell p {
  margin-bottom: 0;
}
.parallel-version {
  color: #37312a;
  font-family: "Noto Serif", "Georgia", "Times New Roman", "Noto Serif SC", serif;
}
.parallel-empty {
  color: var(--muted);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: .9rem;
}
.text-body p { margin: 0 0 1.05em; font-size: clamp(1.04rem, 1.2vw, 1.18rem); }
.text-body p.dialogue { text-indent: 0; }
.text-body p.note { color: var(--muted); font-size: .94rem; line-height: 1.72; margin-left: 1.2em; }
.text-body p.stage { color: #4d473f; }
.annotation-link {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
  border-bottom: 0;
  text-decoration-line: underline;
  text-decoration-color: rgba(122, 47, 37, .42);
  text-decoration-thickness: .06em;
  text-underline-offset: .22em;
  border-radius: 3px;
}
.annotation-link:hover,
.annotation-link:focus-visible,
.annotation-link.annotation-range-focus {
  color: var(--accent);
  background: rgba(122, 47, 37, .07);
  text-decoration-color: var(--accent);
}
.mobile-inline-annotation {
  display: none;
  margin: 10px 0 18px;
  padding: 14px 16px 16px;
  background: #fbfaf5;
  border: 1px solid var(--line);
  border-left: 4px solid rgba(122, 47, 37, .48);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(44, 37, 26, .08);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}
.mobile-inline-annotation h4 { margin: 0 0 8px; color: var(--accent); font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif; font-size: 1rem; line-height: 1.35; }
.mobile-inline-annotation p { margin: 0 0 10px; font-size: .95rem; line-height: 1.72; }
.mobile-inline-annotation .inline-note-close {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--accent); font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
.intro { font-size: 1.12rem; max-width: 760px; margin-bottom: 30px; color: #413a31; }
.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.book-card {
  display: block; padding: 22px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; text-decoration: none; box-shadow: var(--shadow);
}
.book-card h2 { margin: 0 0 8px; font-size: 1.5rem; line-height: 1.2; }
.book-card p { margin: 0; color: var(--muted); font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.menu-toggle {
  position: fixed; left: 16px; top: 16px; z-index: 30; display: grid; place-items: center;
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--paper); box-shadow: var(--shadow); padding: 11px; cursor: pointer;
}
.menu-toggle span { display: block; width: 20px; height: 2px; margin: 2px 0; background: var(--ink); }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 8; }
.annotation-toggle {
  position: fixed; right: 16px; top: 16px; z-index: 32;
  min-width: 52px; height: 44px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--accent); box-shadow: var(--shadow);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif; font-weight: 700; cursor: pointer;
}
.annotation-panel {
  position: fixed; top: 0; right: 0; z-index: 20;
  width: var(--annotation-width); height: 100vh; padding: 26px 22px 42px;
  background: #fbfaf5; border-left: 1px solid var(--line); box-shadow: -14px 0 36px rgba(44, 37, 26, 0.12);
  overflow-y: auto; transform: translateX(100%); visibility: hidden;
  transition: transform .24s ease, visibility .24s ease;
}
body.annotations-open .annotation-panel { transform: translateX(0); visibility: visible; }
body.annotations-open .annotation-toggle { right: calc(var(--annotation-width) + 16px); }
body.annotation-resizing {
  cursor: ew-resize;
  user-select: none;
}
body.annotation-resizing .layout,
body.annotation-resizing .annotation-panel,
body.annotation-resizing .annotation-toggle {
  transition: none !important;
}
.annotation-resize-handle {
  position: fixed;
  top: 0;
  right: calc(var(--annotation-width) - 5px);
  z-index: 31;
  width: 10px;
  height: 100vh;
  cursor: ew-resize;
  touch-action: none;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .16s ease, visibility .16s ease;
}
body.annotations-open .annotation-resize-handle {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
.annotation-resize-handle::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 22px;
  bottom: 22px;
  width: 2px;
  border-radius: 999px;
  background: rgba(122, 47, 37, .28);
  opacity: .35;
  transition: opacity .16s ease, background .16s ease;
}
.annotation-resize-handle:hover::before,
body.annotation-resizing .annotation-resize-handle::before {
  opacity: 1;
  background: rgba(122, 47, 37, .72);
}
.annotation-head { margin: 14px 0 18px; }
.annotation-head p, .annotation-anchor {
  margin: 0 0 6px; color: var(--accent-2); font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif; font-size: .84rem;
}
.annotation-head h2 { margin: 0; font-size: 1.65rem; line-height: 1.2; }
.annotation-card {
  padding: 18px 0 20px; border-top: 1px solid var(--line);
  font-size: .98rem; line-height: 1.76;
}
.annotation-card h3 { margin: 0 0 12px; font-size: 1.22rem; line-height: 1.3; }
.annotation-card :target {
  scroll-margin-top: 18px;
  background: rgba(122, 47, 37, .08);
  border-radius: 6px;
}
.annotation-card .annotation-focus {
  scroll-margin-top: 18px;
  background: rgba(122, 47, 37, .13);
  border-radius: 6px;
  outline: 2px solid rgba(122, 47, 37, .28);
  outline-offset: 4px;
  animation: annotation-focus-pulse 2.4s ease;
}
.annotation-card h4 {
  margin: 18px 0 6px; color: var(--accent); font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif; font-size: .98rem;
}
.annotation-card p { margin: 0 0 12px; }
.annotation-quote {
  color: #4f4940; padding-left: 12px; border-left: 3px solid rgba(122, 47, 37, .28);
  font-family: "Noto Serif", "Times New Roman", "Noto Serif SC", serif;
}
@keyframes annotation-focus-pulse {
  0% { background: rgba(122, 47, 37, .22); outline-color: rgba(122, 47, 37, .5); }
  100% { background: rgba(122, 47, 37, .13); outline-color: rgba(122, 47, 37, .28); }
}
@media (min-width: 861px) {
  body:not(.sidebar-collapsed) .menu-toggle { left: calc(var(--sidebar) + 16px); }
}
@media (min-width: 1180px) {
  body.has-annotations.annotations-open .layout { margin-right: var(--annotation-width); }
}
@media (min-width: 700px) and (max-width: 1179px) {
  body.has-annotations.annotations-open .content {
    width: calc(100vw - var(--annotation-width));
    margin: 0;
    padding-left: 32px;
    padding-right: 24px;
  }
  body.has-annotations.annotations-open .annotation-panel { width: var(--annotation-width); }
  body.has-annotations.annotations-open .annotation-toggle { right: calc(var(--annotation-width) + 16px); }
}
@media (min-width: 700px) {
  body.annotations-open .annotation-link {
    color: #4b352f;
    font-weight: 600;
    background: rgba(122, 47, 37, .035);
    text-decoration-color: rgba(122, 47, 37, .58);
    text-decoration-thickness: .075em;
  }
  body.annotations-open .annotation-link:hover,
  body.annotations-open .annotation-link:focus-visible,
  body.annotations-open .annotation-link.annotation-range-focus {
    color: var(--accent);
    background: rgba(122, 47, 37, .08);
    text-decoration-color: var(--accent);
  }
}
@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-105%); visibility: visible;
    width: min(84vw, 320px); transition: transform .2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.sidebar-collapsed .sidebar { transform: translateX(-105%); visibility: visible; }
  body.nav-open .scrim { display: block; }
  .content { padding: 76px 18px 54px; }
  .book-audio { margin-bottom: 22px; }
  .text-body { border-left: 0; border-right: 0; margin-left: -18px; margin-right: -18px; }
  .book-grid { grid-template-columns: 1fr; }
  .pager { gap: 6px; }
  .pager a { max-width: 48%; }
  body.annotations-open .annotation-toggle { right: 16px; }
  .annotation-panel { width: min(84vw, 360px); }
  .annotation-resize-handle { display: none; }
}
@media (max-width: 980px) {
  .parallel-head,
  .parallel-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .parallel-head {
    display: none;
  }
  .parallel-version {
    padding-left: 14px;
    border-left: 3px solid rgba(30, 93, 90, .24);
  }
}
@media (max-width: 699px) {
  .mobile-inline-annotation { display: block; }
}
@media (max-width: 520px) {
  body { line-height: 1.78; }
  .book-audio {
    --audio-strip-height: 96px;
    --audio-frame-height: 330px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    margin-left: -18px;
    margin-right: -18px;
  }
  .text-body p { font-size: 1rem; }
  .text-body p.note { font-size: .9rem; }
}
@media print {
  .sidebar, .menu-toggle, .annotation-toggle, .annotation-panel, .scrim, .pager, .book-audio { display: none !important; }
  .layout { display: block; }
  .content { width: auto; padding: 0; }
  .text-body { box-shadow: none; border: 0; padding: 0; }
}
