
:root {
  color-scheme: light;
  --page: #f7f9f4;
  --surface: #ffffff;
  --ink: #17211c;
  --muted: #667067;
  --line: #dce2d8;
  --accent: #9b4938;
  --accent-strong: #743022;
  --jade: #286a67;
  --gold: #b8872f;
  --shadow: 0 18px 50px rgba(23, 33, 28, 0.12);
  --reader-font-size: 19px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111411;
  --surface: #191f1b;
  --ink: #eef3e8;
  --muted: #a9b4a9;
  --line: #30382f;
  --accent: #d7785c;
  --accent-strong: #f1a07f;
  --jade: #72b7af;
  --gold: #d8b160;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(40, 106, 103, 0.08), transparent 34%, rgba(155, 73, 56, 0.08)),
    var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: 4px;
  background: transparent;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--jade));
  transition: width 0.12s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  max-width: 100vw;
  padding: 12px 28px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 18%);
  background: color-mix(in srgb, var(--surface), transparent 10%);
  backdrop-filter: blur(18px);
}

.brand {
  font-weight: 800;
  text-decoration: none;
  font-size: 20px;
}

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

.tool-button,
.toc-close,
.back-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: none;
}

.tool-button:hover,
.toc-close:hover,
.back-top:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tool-button.compact {
  width: 44px;
  padding: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 40px;
  align-items: center;
  width: min(1180px, calc(100% - 48px));
  min-height: 460px;
  margin: 0 auto;
  padding: 40px 0 32px;
}

.hero-copy {
  display: grid;
  gap: 18px;
  align-content: center;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: "SimSun", "Songti SC", serif;
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
}

.hero-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 20px;
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.primary-link {
  background: var(--ink);
  color: var(--surface);
}

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

.cover {
  position: relative;
  margin: 0;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #253331;
}

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

.cover figcaption {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 26px;
  color: #f5f2e7;
  text-shadow: 0 5px 24px rgba(0, 0, 0, 0.42);
}

.cover span {
  writing-mode: vertical-rl;
  font-family: "SimSun", "Songti SC", serif;
  font-size: 68px;
  font-weight: 900;
}

.cover strong {
  padding: 6px 12px;
  border: 1px solid rgba(245, 242, 231, 0.48);
  background: rgba(18, 25, 23, 0.32);
  font-size: 15px;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: 80px;
}

.toc {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 108px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface), transparent 2%);
  box-shadow: 0 12px 34px rgba(23, 33, 28, 0.08);
}

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

.toc-head p,
.toc-head strong {
  margin: 0;
}

.toc-head p {
  color: var(--accent-strong);
  font-weight: 800;
}

.toc-head strong {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.toc-close {
  display: none;
  width: 40px;
  min-width: 40px;
  font-size: 22px;
}

.search {
  display: grid;
  gap: 7px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.search span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--page);
  color: var(--ink);
  outline: none;
}

.search input:focus {
  border-color: var(--accent);
}

.toc-list {
  max-height: calc(100vh - 256px);
  overflow: auto;
  padding: 8px;
}

.toc-link {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.toc-link span {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.toc-link strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-link:hover,
.toc-link.is-active {
  background: color-mix(in srgb, var(--jade), transparent 88%);
}

.reader {
  min-width: 0;
}

.chapter {
  scroll-margin-top: 86px;
  padding: 46px 0 64px;
  border-top: 1px solid var(--line);
}

.chapter:first-child {
  border-top: 0;
  padding-top: 10px;
}

.chapter-kicker {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.chapter h2 {
  margin: 0 0 30px;
  font-family: "SimSun", "Songti SC", serif;
  font-size: 34px;
  line-height: 1.25;
}

.chapter-body {
  max-width: 760px;
  font-family: "SimSun", "Songti SC", "Noto Serif CJK SC", serif;
  font-size: var(--reader-font-size);
  line-height: 2;
}

.chapter-body p {
  margin: 0 0 0.95em;
}

.back-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 35;
  width: 46px;
  border-color: transparent;
  background: var(--ink);
  color: var(--surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform: translateY(8px);
}

.back-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .topbar {
    padding: 10px 16px;
  }

  .brand {
    font-size: 18px;
  }

  .tool-button {
    min-width: 42px;
    min-height: 38px;
    padding: 0 10px;
  }

  .hero,
  .layout {
    width: min(680px, calc(100% - 32px));
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
    min-height: auto;
    padding: 26px 0 20px;
  }

  h1 {
    font-size: 46px;
  }

  .hero-subtitle {
    font-size: 18px;
  }

  .cover {
    max-width: 320px;
  }

  .layout {
    display: block;
  }

  .toc {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 60;
    width: min(88vw, 360px);
    max-height: none;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }

  .toc.is-open {
    transform: translateX(0);
  }

  .toc-close {
    display: inline-flex;
  }

  .toc-list {
    max-height: calc(100vh - 176px);
  }

  .chapter {
    padding: 38px 0 52px;
  }

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

  .chapter-body {
    font-size: calc(var(--reader-font-size) - 1px);
    line-height: 1.95;
  }
}

@media (max-width: 520px) {
  .toolbar {
    gap: 6px;
  }

  .tool-button {
    min-width: 38px;
    padding: 0 8px;
    font-size: 14px;
  }

  .tool-button.compact {
    display: none;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .primary-link,
  .secondary-link {
    min-width: 0;
    padding: 0 10px;
    font-size: 14px;
    white-space: nowrap;
  }

  .cover {
    width: min(100%, 260px);
    max-width: 260px;
  }

  .cover span {
    font-size: 52px;
  }

  .chapter-body {
    line-height: 1.9;
  }
}
