:root {
  color-scheme: light;
  --reader-bg: #f7f8fa;
  --reader-surface: #fff;
  --reader-text: #303236;
  --reader-heading: #202124;
  --reader-muted: #656b73;
  --reader-line: #dfe3e7;
  --reader-accent: #2f5f8f;
  --reader-accent-hover: #244b72;
  --reader-tag: #e7f1fb;
  --reader-font-size: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--reader-bg);
  color: var(--reader-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.is-dark {
  color-scheme: dark;
  --reader-bg: #171a1d;
  --reader-surface: #202428;
  --reader-text: #c4cad1;
  --reader-heading: #f1f3f4;
  --reader-muted: #aeb6bf;
  --reader-line: #4b5563;
  --reader-accent: #8ab4f8;
  --reader-accent-hover: #aecbfa;
  --reader-tag: rgba(80, 134, 181, .24);
}

a { color: var(--reader-accent); text-decoration: none; }
a:hover { color: var(--reader-accent-hover); text-decoration: underline; }
button { font: inherit; }

.book-site-header {
  border-bottom: 1px solid var(--reader-line);
  background: var(--reader-surface);
}

.book-site-header-inner {
  display: flex;
  width: min(1080px, calc(100% - 40px));
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
}

.book-site-name {
  color: var(--reader-heading);
  font-size: 18px;
  font-weight: 800;
}

.book-reader-tools { display: flex; align-items: center; gap: 6px; }

.book-icon-button {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--reader-muted);
  cursor: pointer;
}

.book-icon-button:hover,
.book-icon-button:focus-visible {
  background: var(--reader-bg);
  color: var(--reader-heading);
  outline: none;
}

.book-page {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.book-reader-page { --book-reader-line-height: 2; width: min(860px, calc(100% - 40px)); }

.book-breadcrumb {
  margin-bottom: 24px;
  color: var(--reader-muted);
  font-size: 15px;
  line-height: 1.7;
}

.book-breadcrumb span { margin: 0 7px; }

.book-intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 500px) minmax(0, 500px);
  gap: 80px;
  align-items: start;
}

.book-cover {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(32, 33, 36, .12);
}

.book-title {
  margin: 0 0 12px;
  color: var(--reader-heading);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.35;
}

.book-meta,
.book-summary,
.book-taxonomy {
  margin: 0 0 18px;
  font-size: 17px;
  line-height: 1.85;
}

.book-summary { white-space: pre-line; }

.book-field-label { font-weight: 800; }

.book-taxonomy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
}

.book-chip {
  padding: 2px 9px;
  border-radius: 4px;
  background: var(--reader-tag);
  color: var(--reader-accent);
  font-size: 16px;
  line-height: 1.7;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.book-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border: 1px solid var(--reader-accent);
  border-radius: 6px;
  background: transparent;
  color: var(--reader-accent);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}

.book-action:hover { text-decoration: none; }
.book-action.primary { background: var(--reader-accent); color: #fff; }
.book-action.official { border-color: #c62828; background: #c62828; color: #fff; }

.book-share-row {
  display: flex;
  justify-content: center;
  margin-top: 38px;
  padding-top: 20px;
  border-top: 1px solid var(--reader-line);
}

.book-directory-list + .book-share-row {
  margin-top: 36px;
  padding-top: 0;
  border-top: 0;
}

.book-share-button {
  border: 0;
  background: transparent;
  color: var(--reader-muted);
  cursor: pointer;
  font-size: 16px;
}

.book-directory-header { margin-bottom: 28px; text-align: center; }
.book-directory-header .book-title { text-align: center; }
.book-directory-summary { color: var(--reader-muted); font-size: 17px; line-height: 1.85; text-align: justify; }

.book-directory-title {
  margin: 32px 0 12px;
  color: var(--reader-heading);
  font-size: 20px;
  font-weight: 800;
}

.book-directory-header + .book-directory-title { margin-top: 0; }

.book-directory-list { margin: 0; padding: 0; border-top: 1px solid var(--reader-line); list-style: none; }
.book-directory-item { border-bottom: 1px solid var(--reader-line); }
.book-directory-link {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px;
  color: var(--reader-heading);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.55;
}
.book-directory-link:hover { color: var(--reader-accent); text-decoration: none; }
.book-directory-number { color: var(--reader-muted); font-size: 14px; white-space: nowrap; }

.book-chapter-head { margin-bottom: 24px; text-align: center; }
.book-series-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--reader-accent);
  cursor: pointer;
  font-size: 24px;
  font-weight: 800;
}

.book-chapter-date-shell {
  display: grid;
  grid-template-columns: 34px max-content 34px;
  gap: 10px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
}

.book-chapter-nav-button {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--reader-line);
  border-radius: 6px;
  background: var(--reader-surface);
  color: var(--reader-heading);
  font-size: 20px;
  line-height: 1;
}

.book-chapter-nav-button:hover { color: var(--reader-accent); text-decoration: none; }
.book-chapter-nav-button.is-disabled { opacity: .45; }

.book-chapter-date {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  color: var(--reader-muted);
  font-size: 17px;
  font-weight: 400;
  line-height: 34px;
}

.book-chapter-weekday { margin-left: .45em; }
.book-chapter-weekday.is-red { color: #d64545; }
.book-chapter-weekday.is-yellow { color: #b58500; }
.book-chapter-weekday.is-green { color: #2e8b57; }
.book-chapter-weekday.is-blue { color: #2874a6; }
.book-chapter-weekday.is-purple { color: #7e57c2; }
.book-chapter-weekday.is-cyan { color: #008c9a; }
.book-chapter-weekday.is-orange { color: #d66f12; }

.book-chapter-title { margin: 18px 0 0; color: var(--reader-heading); font-size: 20px; line-height: 1.45; }

.book-chapter-body {
  color: var(--reader-text);
  font-size: var(--reader-font-size);
  line-height: var(--book-reader-line-height);
  text-align: justify;
  text-align-last: left;
}

.book-chapter-body p { margin: 0 0 1em; }
.book-chapter-body h2 { margin: 1.65em 0 .65em; color: var(--reader-heading); font-size: 20px; line-height: 1.5; text-align: left; }

.book-chapter-source {
  margin-top: 0;
  padding-top: 18px;
  color: var(--reader-muted);
  font-size: 15px;
  line-height: var(--book-reader-line-height);
}

.book-page-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--reader-line);
}

.book-page-nav a {
  display: inline-flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--reader-line);
  border-radius: 6px;
  color: var(--reader-heading);
  font-size: 15px;
  font-weight: 700;
}

.book-page-nav a:hover { border-color: var(--reader-accent); color: var(--reader-accent); text-decoration: none; }
.book-page-nav .next { justify-content: flex-end; text-align: right; }
.book-page-nav .directory { justify-content: center; }
.book-page-nav .disabled { visibility: hidden; }

.book-chapter-actions { display: flex; justify-content: center; gap: 14px; margin-top: 24px; }
.book-chapter-actions button { border: 0; background: transparent; color: var(--reader-muted); cursor: pointer; }

.book-toc-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(25, 28, 32, .48);
}
.book-toc-overlay[hidden] { display: none; }
.book-toc-panel {
  width: min(520px, 100%);
  max-height: min(680px, 82vh);
  overflow: hidden;
  border-radius: 6px;
  background: var(--reader-surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .25);
}
.book-toc-head { display: flex; min-height: 58px; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--reader-line); }
.book-toc-title { margin: 0; color: var(--reader-heading); font-size: 19px; }
.book-toc-close { border: 0; background: transparent; color: var(--reader-muted); cursor: pointer; font-size: 20px; }
.book-toc-list { max-height: calc(min(680px, 82vh) - 58px); margin: 0; padding: 8px 18px 18px; overflow-y: auto; list-style: none; }
.book-toc-list li { border-bottom: 1px solid var(--reader-line); }
.book-toc-list a { display: block; padding: 12px 2px; color: var(--reader-heading); font-size: 16px; line-height: 1.5; }
.book-toc-list a[aria-current="page"] { color: var(--reader-accent); font-weight: 800; }

.book-footer { padding: 24px 20px 34px; color: var(--reader-muted); font-size: 13px; line-height: 1.7; text-align: center; }

@media (max-width: 767px) {
  .book-site-header-inner,
  .book-page,
  .book-reader-page { width: calc(100% - 20px); }
  .book-reader-page { --book-reader-line-height: 1.9; }
  .book-page { padding-top: 26px; }
  .book-intro-grid { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .book-title { font-size: 24px; text-align: center; }
  .book-meta { text-align: center; }
  .book-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-action { padding-right: 10px; padding-left: 10px; }
  .book-directory-header { text-align: left; }
  .book-directory-header .book-title { text-align: left; }
  .book-chapter-body { font-size: 18px; }
  .book-chapter-title { font-size: 20px; }
  .book-page-nav { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; }
  .book-page-nav a { min-height: 36px; padding: 6px 8px; font-size: 13px; }
  .book-page-nav .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .book-toc-overlay { padding: 10px; }
  .book-toc-panel { width: 100%; max-height: 86vh; }
}

@media print {
  .book-site-header,
  .book-breadcrumb,
  .book-page-nav,
  .book-chapter-actions,
  .book-footer,
  .book-toc-overlay { display: none !important; }
  body { background: #fff; color: #000; }
  .book-page, .book-reader-page { width: 100%; padding: 0; }
}
