:root {
  --bg: #efe7d8;
  --paper: #fffaf0;
  --ink: #211d18;
  --muted: #746755;
  --line: #d8c6ab;
  --accent: #8d3f1f;
  --accent-soft: #ead3b5;
  --shadow: rgba(47, 30, 14, 0.14);
  --font-size: 20px;
  --line-height: 1.92;
}

html[data-theme="dark"] {
  --bg: #171818;
  --paper: #202120;
  --ink: #e8e1d4;
  --muted: #aaa193;
  --line: #393631;
  --accent: #d19a66;
  --shadow: rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, color-mix(in srgb, var(--accent-soft) 42%, transparent), transparent 30rem),
    linear-gradient(135deg, color-mix(in srgb, var(--bg) 86%, #fff), var(--bg));
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  min-width: 0;
}

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, var(--bg));
  padding: 24px 16px;
}

.brand {
  padding: 0 6px 18px;
  border-bottom: 1px solid var(--line);
}

.site-title {
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
}

.site-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.shelf-button {
  width: 100%;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--paper));
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 38px;
}

.shelf-button.active {
  background: var(--accent);
  color: var(--paper);
}

.book-cover {
  display: block;
  width: 82px;
  aspect-ratio: 1055 / 1491;
  margin: 0 0 10px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 8px;
  background: #151515;
  box-shadow: 0 8px 22px var(--shadow);
  object-fit: cover;
}

.book-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
}

.book-author {
  margin-top: 8px;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
}

.book-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.book-tagline {
  margin: 10px 0 0;
  color: color-mix(in srgb, var(--ink) 82%, var(--muted));
  font-size: 13px;
  line-height: 1.55;
}

.site-stats {
  margin-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toc {
  display: grid;
  gap: 4px;
  padding-top: 14px;
}

.toc-label {
  margin: 12px 12px 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toc button {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  padding: 9px 11px;
  text-align: left;
}

.toc button:hover,
.toc button.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.reader {
  min-width: 0;
}

.progress-track {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 4px;
  background: color-mix(in srgb, var(--line) 55%, transparent);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 120ms ease;
}

.topbar {
  position: sticky;
  top: 4px;
  z-index: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  padding: 12px 24px;
}

.current-title {
  overflow: hidden;
  color: var(--muted);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-text {
  min-width: 72px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.icon-button,
.tool-button,
.chapter-nav button,
.chapter-nav a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  min-height: 38px;
  padding: 7px 11px;
  text-decoration: none;
}

.tool-button.copied {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button {
  display: none;
}

.chapter {
  width: min(860px, calc(100% - 40px));
  margin: 34px auto 0;
  padding: 58px clamp(24px, 5vw, 74px) 46px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 28px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--line) 12%, transparent) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--paper);
  box-shadow: 0 22px 70px var(--shadow);
}

.chapter h1 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 36px;
  letter-spacing: 0;
}

.chapter .chapter-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
}

.chapter-stats {
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.chapter p {
  margin: 0 0 1.05em;
  font-size: var(--font-size);
  line-height: var(--line-height);
  text-align: justify;
  text-indent: 2em;
}

.chapter .note-title {
  margin-top: 44px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  text-indent: 0;
}

.chapter .note {
  color: color-mix(in srgb, var(--ink) 78%, var(--muted));
  font-size: calc(var(--font-size) - 2px);
  line-height: 1.78;
  text-indent: 0;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  width: min(860px, calc(100% - 40px));
  margin: 28px auto 70px;
}

.copyright-note {
  width: min(860px, calc(100% - 40px));
  margin: -42px auto 56px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.chapter-nav button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.chapter-nav span[aria-disabled="true"] {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--muted);
  opacity: 0.55;
}

.shelf-mode .chapter {
  width: min(1040px, calc(100% - 48px));
  margin: 34px auto 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.shelf-mode .chapter-nav {
  display: none;
}

.shelf-mode .chapter p {
  text-indent: 0;
}

.library {
  padding-bottom: 70px;
}

.library-header {
  margin: 0 0 22px;
}

.library-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
  text-indent: 0;
}

.library h1 {
  margin: 0;
  color: var(--accent);
  font-size: 34px;
  letter-spacing: 0;
}

.seo-home .library-header p {
  margin: 12px 0 0;
  color: color-mix(in srgb, var(--ink) 84%, var(--muted));
  font-size: 17px;
  line-height: 1.72;
  text-indent: 0;
}

.seo-summary {
  margin: 18px 0 24px;
}

.seo-summary p {
  margin: 0 0 12px;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  font-size: 16px;
  line-height: 1.78;
  text-indent: 0;
}

.seo-chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.seo-chapter-list a {
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 88%, var(--bg));
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  padding: 10px 12px;
  text-decoration: none;
}

.seo-chapter-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.static-page .static-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  padding: 12px clamp(16px, 4vw, 40px);
}

.static-header a,
.static-header span {
  overflow: hidden;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.static-header span {
  color: var(--muted);
  font-weight: 400;
}

.static-reader {
  min-height: 100vh;
}

.static-chapter {
  margin-top: 28px;
}

.static-nav {
  gap: 10px;
}

.book-shelf {
  display: grid;
  gap: 16px;
}

.shelf-book {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 24px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 92%, var(--bg));
  box-shadow: 0 18px 48px var(--shadow);
  padding: 18px;
}

.shelf-book img {
  width: 100%;
  aspect-ratio: 1055 / 1491;
  border-radius: 6px;
  background: #151515;
  object-fit: cover;
}

.shelf-book-body {
  min-width: 0;
  align-self: center;
}

.book-status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.shelf-book h2 {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 32px;
}

.shelf-book-author {
  margin-top: 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.shelf-book-tagline,
.shelf-book-summary {
  margin: 14px 0 0;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  font-size: 16px;
  line-height: 1.74;
}

.shelf-book-tagline {
  font-weight: 700;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.chapter-nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--paper);
  cursor: pointer;
  font: inherit;
  min-height: 40px;
  padding: 8px 14px;
  text-decoration: none;
}

.chapter-nav-button.secondary {
  background: var(--paper);
  color: var(--accent);
}

.chapter-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.book-page {
  max-width: 960px;
}

.book-page p {
  text-indent: 0;
}

.book-page h2 {
  margin: 34px 0 14px;
  color: var(--accent);
  font-size: 24px;
  letter-spacing: 0;
}

.book-page-hero {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

.book-page-hero img {
  width: 100%;
  aspect-ratio: 1055 / 1491;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 8px;
  background: #151515;
  box-shadow: 0 16px 42px var(--shadow);
  object-fit: cover;
}

.book-page-tagline {
  margin: 18px 0 0;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  font-size: 19px;
  font-weight: 700;
  line-height: 1.72;
}

.info-panel {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: none;
  justify-content: flex-end;
  background: rgba(18, 14, 10, 0.36);
}

body.info-open .info-panel {
  display: flex;
}

.info-card {
  width: min(460px, 100vw);
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--paper);
  box-shadow: -18px 0 54px var(--shadow);
  padding: 24px 24px 34px;
}

.info-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.info-title {
  color: var(--accent);
  font-size: 24px;
  font-weight: 700;
}

.info-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.info-section {
  padding: 22px 0 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
}

.info-section h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 17px;
}

.info-section p {
  margin: 0 0 12px;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  font-size: 15px;
  line-height: 1.72;
}

.intro-section .intro-author {
  color: var(--accent);
  font-weight: 700;
}

.intro-section .recommendation {
  margin-top: 16px;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--muted);
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.info-list li {
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--bg) 36%, transparent);
}

.info-list span {
  display: block;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}

.info-list p {
  margin: 5px 0 0;
  font-size: 14px;
}

@media (max-width: 820px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 5;
    inset: 0 auto 0 0;
    width: min(82vw, 320px);
    padding: 22px 16px;
    box-shadow: 0 18px 50px var(--shadow);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .icon-button {
    display: inline-flex;
    align-items: center;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 10px 12px;
  }

  .tools {
    grid-column: 1 / -1;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .progress-text {
    min-width: max-content;
    text-align: left;
  }

  .chapter {
    width: min(100% - 28px, 760px);
    margin-top: 18px;
    padding: 34px 18px 32px;
    border-radius: 18px;
  }

  .chapter h1 {
    font-size: 28px;
  }

  .shelf-mode .chapter {
    width: min(100% - 28px, 760px);
    margin-top: 18px;
  }

  .library h1 {
    font-size: 28px;
  }

  .shelf-book {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 14px;
    padding: 12px;
  }

  .book-cover {
    width: 74px;
  }

  .shelf-book h2 {
    font-size: 24px;
  }

  .shelf-book-tagline,
  .shelf-book-summary {
    font-size: 14px;
    line-height: 1.62;
  }

  .book-page-hero {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }

  .book-page h2 {
    font-size: 21px;
  }

  .book-page-tagline {
    font-size: 15px;
    line-height: 1.62;
  }

  .info-panel {
    justify-content: stretch;
  }

  .info-card {
    width: 100vw;
    padding: 20px 18px 30px;
  }
}
