:root {
  color-scheme: light;
  --paper: #f5efe4;
  --paper-deep: #e9dfcf;
  --ink: #172025;
  --ink-soft: #4c585d;
  --line: rgba(23, 32, 37, 0.15);
  --accent: #a66f2a;
  --accent-soft: #d9b67e;
  --night: #111c22;
  --reader-font-scale: 1;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111820;
  --paper-deep: #17232b;
  --ink: #e9e1d4;
  --ink-soft: #aeb8bb;
  --line: rgba(233, 225, 212, 0.17);
  --accent: #d4a15d;
  --accent-soft: #7e6136;
  --night: #091015;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(circle at 8% 6%, rgba(212, 161, 93, 0.1), transparent 26rem),
    var(--paper);
}

a {
  color: inherit;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 0.18em;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: -4rem;
  left: 1rem;
  z-index: 100;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: var(--paper);
}

.skip-link:focus {
  top: 1rem;
}

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: 3px;
  pointer-events: none;
}

.reading-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
}

.brand-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.55rem;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 0.12rem;
  color: var(--ink-soft);
  font: 600 0.6rem/1 var(--sans);
  letter-spacing: 0.18em;
}

.site-nav {
  display: flex;
  gap: 1.2rem;
  margin-left: auto;
  font-size: 0.88rem;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
}

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

.reading-tools {
  display: flex;
  gap: 0.35rem;
}

.reading-tools button {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

main {
  min-height: 70vh;
}

.hero {
  padding: clamp(4rem, 10vw, 8rem) 0 4rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--accent);
  font: 700 0.72rem/1.4 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1,
.page-title {
  max-width: 13ch;
  margin: 0.7rem 0 1rem;
  font: 600 clamp(2.6rem, 7vw, 5.6rem)/1.05 var(--serif);
  letter-spacing: -0.035em;
}

.hero-lead {
  max-width: 42rem;
  color: var(--ink-soft);
  font: 400 1.08rem/1.9 var(--serif);
}

.rule {
  width: 5rem;
  height: 1px;
  margin: 2rem 0;
  background: var(--accent);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  padding: 3.5rem 0 5rem;
}

.book-card {
  display: grid;
  grid-template-columns: minmax(10rem, 0.72fr) 1fr;
  min-height: 24rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--paper-deep) 78%, transparent);
}

.book-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.book-card h2 {
  margin: 0.35rem 0 0.8rem;
  font: 600 1.55rem/1.35 var(--serif);
}

.book-card p {
  color: var(--ink-soft);
  line-height: 1.75;
}

.book-card .card-actions {
  margin-top: auto;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7rem;
  padding: 0.75rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 600 0.86rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
}

.button.secondary {
  background: transparent;
  color: var(--ink);
}

.book-page {
  display: grid;
  grid-template-columns: minmax(16rem, 0.62fr) minmax(0, 1.25fr);
  gap: clamp(2rem, 6vw, 5rem);
  padding: clamp(3rem, 7vw, 6rem) 0;
}

.book-cover {
  position: sticky;
  top: 6.5rem;
  align-self: start;
}

.book-cover img {
  width: min(100%, 28rem);
  display: block;
  border-radius: 0.85rem;
  box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, 0.22);
}

.book-summary h1 {
  margin: 0.5rem 0 0.75rem;
  font: 600 clamp(2.25rem, 5vw, 4rem)/1.1 var(--serif);
}

.book-subtitle {
  color: var(--accent);
  font: 500 1.05rem/1.65 var(--serif);
}

.book-description {
  color: var(--ink-soft);
  font: 400 1rem/1.85 var(--serif);
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.5rem 0;
}

.pill {
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.fiction-notice {
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--paper-deep) 68%, transparent);
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.7;
}

.toc {
  margin-top: 4rem;
}

.toc h2 {
  font: 600 1.85rem/1.3 var(--serif);
}

.part-group {
  margin: 2rem 0;
}

.part-group h3 {
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
  font: 600 1rem/1.4 var(--sans);
  color: var(--accent);
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapter-list a {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

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

.chapter-order {
  color: var(--ink-soft);
  font: 600 0.7rem/1 var(--sans);
  letter-spacing: 0.08em;
}

.chapter-name {
  font: 500 1rem/1.5 var(--serif);
}

.chapter-time {
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.reader-shell {
  width: min(48rem, calc(100% - 2rem));
  margin-inline: auto;
  padding: clamp(3rem, 8vw, 6rem) 0;
}

.reader-header {
  margin-bottom: 3rem;
  text-align: center;
}

.reader-header .book-link {
  color: var(--accent);
  font-size: 0.84rem;
  text-decoration: none;
}

.reader-header h1 {
  margin: 0.65rem 0;
  font: 600 clamp(2rem, 5vw, 3.6rem)/1.2 var(--serif);
}

.reader-meta {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.prose {
  font: 400 calc(1.08rem * var(--reader-font-scale)) / 2 var(--serif);
  letter-spacing: 0.015em;
}

.prose > p {
  margin: 0 0 1.1em;
  text-align: justify;
  text-justify: inter-ideograph;
}

.prose blockquote {
  margin: 1.5em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 2px solid var(--accent-soft);
  color: var(--ink-soft);
}

.prose h2,
.prose h3 {
  margin: 2em 0 0.8em;
  font-family: var(--serif);
  line-height: 1.35;
}

.prose table {
  width: 100%;
  margin: 1.4em 0;
  border-collapse: collapse;
  font: 400 0.82rem/1.5 var(--sans);
}

.prose th,
.prose td {
  padding: 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--night);
  color: #eff5f4;
}

.share-row {
  display: flex;
  justify-content: center;
  margin-top: 2.5rem;
}

.share-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.share-links a,
.share-links button,
.quote-share,
.resume-position {
  min-height: 2.15rem;
  padding: 0.48rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: 500 0.74rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
}

.share-links a:hover,
.share-links button:hover,
.quote-share:hover,
.resume-position:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quote-share {
  display: block;
  margin: -0.4rem 0 1.25rem auto;
}

.selection-share {
  position: fixed;
  z-index: 70;
  padding: 0.62rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.28);
  font: 600 0.78rem/1 var(--sans);
  cursor: pointer;
}

.selection-share[hidden] {
  display: none;
}

.resume-position {
  margin: 1rem auto 0;
  color: var(--accent);
}

.quote-dialog {
  width: min(36rem, calc(100% - 2rem));
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 2rem 8rem rgba(0, 0, 0, 0.45);
}

.quote-dialog::backdrop {
  background: rgba(3, 8, 11, 0.72);
  backdrop-filter: blur(4px);
}

.quote-dialog blockquote {
  margin: 1.4rem 0;
  font: 500 1.5rem/1.7 var(--serif);
}

.quote-attribution {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.quote-share-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.5rem;
}

.quote-share-grid a,
.quote-share-grid button {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.dialog-close {
  position: absolute;
  top: 0.65rem;
  right: 0.8rem;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.5rem;
  cursor: pointer;
}

.chapter-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.chapter-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-decoration: none;
}

.chapter-nav-link.next {
  text-align: right;
}

.chapter-nav-link small,
.chapter-nav-center {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.chapter-nav-link span {
  font-family: var(--serif);
}

.chapter-nav-center {
  align-self: center;
}

.content-page {
  max-width: 46rem;
  margin-inline: auto;
  padding: clamp(3rem, 8vw, 6rem) 0;
}

.content-page h1 {
  font: 600 clamp(2.4rem, 6vw, 4.2rem)/1.1 var(--serif);
}

.content-page h2 {
  margin-top: 2.5rem;
  font-family: var(--serif);
}

.content-page p,
.content-page li {
  color: var(--ink-soft);
  line-height: 1.85;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2.5rem 0 1.5rem;
  background: var(--night);
  color: #e8e2d6;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
}

.site-footer p {
  max-width: 38rem;
  color: #aeb7b8;
  line-height: 1.7;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  color: #d7c5a8;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #8f9b9d;
  font-size: 0.75rem;
}

@media (max-width: 860px) {
  .header-inner {
    gap: 1rem;
  }

  .site-nav {
    display: none;
  }

  .book-grid,
  .book-page {
    grid-template-columns: 1fr;
  }

  .book-cover {
    position: static;
  }

  .book-cover img {
    width: min(22rem, 78vw);
    margin-inline: auto;
  }

  .book-card {
    grid-template-columns: 10rem 1fr;
  }

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

@media (max-width: 560px) {
  .shell {
    width: min(100% - 1.25rem, 1120px);
  }

  .brand small {
    display: none;
  }

  .reading-tools button {
    width: 2rem;
    height: 2rem;
  }

  .hero {
    padding-top: 3rem;
  }

  .book-card {
    grid-template-columns: 1fr;
  }

  .book-card img {
    max-height: 19rem;
  }

  .chapter-list a {
    grid-template-columns: 2rem 1fr;
  }

  .chapter-time {
    display: none;
  }

  .prose {
    line-height: 1.95;
  }

  .chapter-nav {
    grid-template-columns: 1fr 1fr;
  }

  .chapter-nav-center {
    display: none;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 0.4rem;
  }
}

@media print {
  .site-header,
  .site-footer,
  .reading-tools,
  .chapter-nav,
  .share-row,
  .reading-progress,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .reader-shell {
    width: 100%;
    padding: 0;
  }

  .prose {
    font-size: 11pt;
    line-height: 1.7;
  }
}
