:root {
  color-scheme: light;
  --paper: #f4efe6;
  --paper-soft: #fbf8f1;
  --surface: rgba(255, 253, 247, 0.78);
  --surface-solid: #fffdf7;
  --ink: #17201c;
  --muted: #66706b;
  --line: rgba(23, 32, 28, 0.13);
  --accent: #20765a;
  --accent-strong: #124d3a;
  --accent-soft: rgba(32, 118, 90, 0.12);
  --button-ink: #fffdf7;
  --shadow: 0 22px 58px rgba(54, 47, 36, 0.14);
  --reader-width: 760px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151817;
  --paper-soft: #1c201e;
  --surface: rgba(30, 35, 32, 0.82);
  --surface-solid: #202521;
  --ink: #ebe8df;
  --muted: #a7afa9;
  --line: rgba(235, 232, 223, 0.14);
  --accent: #74c8a3;
  --accent-strong: #9ee0bf;
  --accent-soft: rgba(116, 200, 163, 0.14);
  --button-ink: #102018;
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, var(--accent-soft), transparent 28rem),
    linear-gradient(180deg, var(--paper-soft), var(--paper));
  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  min-height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(18px);
}

.brand,
.nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: 0;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--button-ink);
  background: var(--accent);
  font-size: 16px;
}

.nav {
  justify-content: center;
  gap: 24px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.nav a {
  border-bottom: 2px solid transparent;
  padding: 22px 0 20px;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--accent-strong);
  border-color: var(--accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}

main {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 1.04;
}

h2 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.16;
}

.library-hero {
  padding: 86px 0 42px;
}

.library-hero .summary {
  max-width: 620px;
  margin-top: 18px;
}

.summary {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.9;
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  padding: 18px 0 88px;
}

.shelf-card {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 230px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(54, 47, 36, 0.08);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.shelf-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: var(--shadow);
}

.shelf-card img {
  width: 132px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 14px 28px rgba(54, 47, 36, 0.18);
}

.shelf-card span,
.shelf-card small,
.shelf-card strong,
.shelf-card em,
.shelf-card b {
  display: block;
}

.shelf-card small {
  color: var(--accent);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}

.shelf-card strong {
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.22;
}

.shelf-card em {
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  font-style: normal;
  line-height: 1.75;
}

.shelf-card b {
  margin-top: 20px;
  color: var(--accent-strong);
  font-size: 14px;
}

.book-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 72px;
  align-items: center;
  min-height: calc(100dvh - 64px);
  padding: 48px 0 64px;
}

.book-visual {
  display: grid;
  place-items: center;
}

.book-cover {
  position: relative;
  width: min(310px, 72vw);
  aspect-ratio: 2 / 3;
  border-radius: 8px 12px 12px 8px;
  background: var(--paper-soft);
  box-shadow: var(--shadow);
  transform: perspective(900px) rotateY(-8deg);
}

.book-cover::before {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: 26px;
  border-radius: 8px 0 0 8px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.3), rgba(255, 255, 255, 0.16), transparent);
  content: "";
  pointer-events: none;
}

.book-cover::after {
  position: absolute;
  right: -13px;
  bottom: 10px;
  z-index: -1;
  width: 22px;
  height: calc(100% - 24px);
  border-radius: 0 10px 10px 0;
  background: repeating-linear-gradient(
    90deg,
    color-mix(in srgb, var(--paper-soft) 92%, var(--ink)) 0,
    color-mix(in srgb, var(--paper-soft) 92%, var(--ink)) 2px,
    color-mix(in srgb, var(--paper-soft) 82%, var(--ink)) 3px,
    color-mix(in srgb, var(--paper-soft) 82%, var(--ink)) 4px
  );
  box-shadow: 12px 16px 26px rgba(54, 47, 36, 0.14);
  content: "";
}

.book-cover img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.author {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  max-width: 540px;
  margin: 32px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.stats div {
  padding: 18px;
  background: var(--surface);
}

.stats strong,
.stats span {
  display: block;
}

.stats strong {
  font-size: 24px;
  line-height: 1.15;
}

.stats span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.reader-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.actions {
  margin-top: 34px;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  min-height: 46px;
  border-radius: 8px;
  padding: 0 22px;
  font-weight: 800;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.primary-btn {
  color: var(--button-ink);
  background: var(--accent);
  box-shadow: 0 14px 28px color-mix(in srgb, var(--accent) 20%, transparent);
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.secondary-btn {
  border: 1px solid var(--line);
  background: var(--surface);
}

.secondary-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}

.primary-btn:active,
.secondary-btn:active,
.theme-toggle:active,
.shelf-card:active {
  transform: translateY(1px);
}

.section {
  padding: 54px 0 88px;
  border-top: 1px solid var(--line);
}

.section-head {
  margin-bottom: 24px;
}

.chapter-list {
  border-top: 1px solid var(--line);
}

.chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.chapter-row strong,
.chapter-row small {
  display: block;
}

.chapter-row strong {
  font-size: 19px;
}

.chapter-row small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.read-state {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.reader {
  width: min(var(--reader-width), 100%);
  margin: 0 auto;
  padding: 64px 0 96px;
}

.reader-head {
  margin-bottom: 42px;
  text-align: center;
}

.reader-head h1 {
  max-width: none;
  font-size: clamp(34px, 5vw, 58px);
}

.chapter-note {
  margin: 18px auto 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.chapter-body {
  padding: 8px 0;
}

.chapter-body p {
  margin: 0 0 1.12em;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 20px;
  line-height: 2.05;
  text-align: justify;
}

.chapter-body code {
  border-radius: 6px;
  padding: 0.1em 0.34em;
  background: var(--accent-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
}

.reader-footer {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.reader-footer p {
  margin: 0 0 22px;
  font-size: 15px;
  line-height: 1.8;
}

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

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    padding: 0 18px;
  }

  .nav {
    justify-content: flex-end;
    gap: 14px;
  }

  main {
    width: min(100% - 28px, 680px);
  }

  .library-hero {
    padding-top: 54px;
  }

  .shelf-grid {
    grid-template-columns: 1fr;
    padding-bottom: 56px;
  }

  .book-shell {
    grid-template-columns: 1fr;
    gap: 34px;
    min-height: 0;
    padding: 34px 0 52px;
  }

  .book-cover {
    width: min(236px, 68vw);
    transform: perspective(800px) rotateY(-5deg);
  }

  h1 {
    font-size: 40px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .summary {
    font-size: 16px;
  }

  .reader {
    padding-top: 42px;
  }

  .chapter-body p {
    font-size: 19px;
    line-height: 2;
  }
}

@media (max-width: 560px) {
  .brand span:last-child {
    display: none;
  }

  .topbar {
    min-height: 58px;
  }

  .nav {
    gap: 12px;
    font-size: 13px;
  }

  .nav a {
    padding: 19px 0 17px;
  }

  .theme-toggle {
    min-width: 52px;
    min-height: 34px;
    font-size: 13px;
  }

  .shelf-card {
    grid-template-columns: 92px minmax(0, 1fr);
    min-height: 0;
    padding: 16px;
  }

  .shelf-card img {
    width: 92px;
  }

  .shelf-card strong {
    font-size: 22px;
  }

  .actions,
  .reader-nav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
  }

  .chapter-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}
