:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #fffdf7;
  --surface-strong: #ffffff;
  --ink: #1d211c;
  --muted: #646d62;
  --line: #d9ded4;
  --line-strong: #b9c1b4;
  --accent: #2f6f5e;
  --accent-strong: #214f43;
  --copper: #9a5a3d;
  --hero-ink: #f8f5e8;
  --hero-muted: #c7d3c4;
  --reader-scale: 1;
  --shadow-soft: 0 18px 48px -28px rgba(29, 33, 28, 0.34);
}

html[data-theme="light"] {
  --bg: #f7f8f4;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --ink: #181c18;
  --muted: #5e665d;
  --line: #dfe4da;
  --line-strong: #b8c2b2;
}

html[data-theme="night"] {
  color-scheme: dark;
  --bg: #161a17;
  --surface: #20251f;
  --surface-strong: #252b24;
  --ink: #eef2ea;
  --muted: #abb5a8;
  --line: #384137;
  --line-strong: #52604f;
  --accent: #70ad97;
  --accent-strong: #9ccbb9;
  --copper: #c98b69;
  --shadow-soft: 0 18px 52px -34px rgba(0, 0, 0, 0.72);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
}

body.is-locked {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(22, 26, 23, 0.86);
  color: var(--hero-ink);
  backdrop-filter: blur(18px);
}

.nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  width: min(1400px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
}

.brand {
  display: inline-grid;
  gap: 2px;
  line-height: 1.05;
}

.brand strong {
  font-size: 18px;
  font-weight: 700;
}

.brand span {
  color: var(--hero-muted);
  font-size: 12px;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.nav-links a {
  border-radius: 8px;
  color: rgba(248, 245, 232, 0.76);
  padding: 8px 12px;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--hero-ink);
}

.nav-links a:active,
.button:active,
.tool-button:active,
.toc-link:active,
.volume-tile:active {
  transform: translateY(1px);
}

.nav-action {
  border: 1px solid rgba(248, 245, 232, 0.28);
  border-radius: 8px;
  color: var(--hero-ink);
  padding: 9px 14px;
}

.hero {
  position: relative;
  min-height: 86dvh;
  overflow: hidden;
  background-image:
    linear-gradient(90deg, rgba(13, 16, 14, 0.96) 0%, rgba(13, 16, 14, 0.86) 38%, rgba(13, 16, 14, 0.36) 100%),
    linear-gradient(180deg, rgba(13, 16, 14, 0.26) 0%, rgba(13, 16, 14, 0.08) 46%, rgba(13, 16, 14, 0.42) 100%),
    url("./images/hero-battle.png");
  background-position: center center;
  background-size: cover;
  color: var(--hero-ink);
}

.hero::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(248, 245, 232, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(248, 245, 232, 0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(90deg, rgb(1 1 1) 0%, transparent 78%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  width: min(1400px, calc(100% - 40px));
  min-height: 86dvh;
  margin: 0 auto;
  padding: 72px 0 92px;
}

.eyebrow,
.section-kicker,
.reader-meta {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.hero .eyebrow {
  color: var(--hero-muted);
}

.hero h1 {
  max-width: 720px;
  margin: 18px 0 20px;
  font-size: 72px;
  font-weight: 800;
  line-height: 0.98;
}

.hero-lead {
  max-width: 650px;
  margin: 0;
  color: rgba(248, 245, 232, 0.82);
  font-size: 20px;
  line-height: 1.8;
}

.hero-actions,
.reader-actions,
.tool-group,
.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-actions {
  margin-top: 34px;
}

.button,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  padding: 10px 16px;
  font-weight: 700;
}

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

.button:hover,
.tool-button.is-active,
.tool-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

.button.secondary:hover {
  border-color: var(--accent);
  background: rgba(47, 111, 94, 0.08);
  color: var(--accent-strong);
}

.hero .button.secondary {
  border-color: rgba(248, 245, 232, 0.32);
  background: rgba(248, 245, 232, 0.06);
  color: var(--hero-ink);
}

.hero .button.secondary:hover {
  border-color: rgba(248, 245, 232, 0.62);
  background: rgba(248, 245, 232, 0.14);
  color: var(--hero-ink);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 150px));
  gap: 1px;
  width: fit-content;
  margin-top: 44px;
  border: 1px solid rgba(248, 245, 232, 0.18);
  background: rgba(248, 245, 232, 0.1);
}

.hero-stats div {
  min-height: 82px;
  padding: 14px 16px;
  background: rgba(19, 23, 20, 0.64);
}

.hero-stats dt {
  color: var(--hero-muted);
  font-size: 12px;
}

.hero-stats dd {
  margin: 6px 0 0;
  color: var(--hero-ink);
  font-family: "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  font-size: 28px;
  font-weight: 800;
}

.section {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 86px 0;
}

.intro-layout,
.world-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(300px, 1.08fr);
  gap: 56px;
  align-items: start;
}

.section h2,
.reader-heading h2 {
  margin: 12px 0 18px;
  font-size: 38px;
  line-height: 1.12;
}

.intro-copy p,
.world-copy p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.9;
}

.preface-block {
  border-left: 3px solid var(--accent);
  padding-left: 22px;
}

.preface-block strong {
  display: block;
  margin-bottom: 14px;
  color: var(--accent-strong);
  font-size: 18px;
}

.preface-block p {
  margin: 0 0 14px;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  line-height: 1.95;
}

.volume-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.volume-tile {
  display: grid;
  min-height: 132px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 18px;
  text-align: left;
  box-shadow: var(--shadow-soft);
  transition: border-color 180ms ease, transform 180ms ease;
}

.volume-tile:hover {
  border-color: var(--accent);
}

.volume-tile strong {
  font-size: 20px;
}

.volume-tile span {
  color: var(--copper);
  font-weight: 700;
}

.volume-tile small {
  color: var(--muted);
  line-height: 1.5;
}

.world-layout {
  grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.05fr);
  align-items: center;
}

.world-image {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
}

.world-image img {
  width: 100%;
}

.reader-section {
  border-block: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(47, 111, 94, 0.06), transparent 220px),
    var(--bg);
}

.reader-shell {
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto;
  padding: 82px 0;
}

.reader-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  margin-bottom: 24px;
}

.reader-heading p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.reader-tools {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.tool-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 4px;
}

.tool-button {
  min-width: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
}

.reader-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.toc-panel,
.reader-surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.toc-panel {
  position: sticky;
  top: 84px;
  max-height: calc(100dvh - 104px);
  overflow: hidden;
}

.toc-head {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.toc-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toc-title-row strong {
  font-size: 18px;
}

.toc-close {
  display: none;
}

.toc-search {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

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

.toc-list {
  display: grid;
  gap: 8px;
  max-height: calc(100dvh - 220px);
  overflow: auto;
  padding: 12px;
}

.toc-group {
  display: grid;
  gap: 6px;
}

.toc-group h3 {
  margin: 12px 4px 4px;
  color: var(--accent-strong);
  font-size: 13px;
}

.toc-link {
  display: grid;
  width: 100%;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 10px 11px;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.toc-link:hover,
.toc-link[aria-current="true"] {
  border-color: var(--line-strong);
  background: rgba(47, 111, 94, 0.08);
}

.toc-meta {
  color: var(--muted);
  font-size: 12px;
}

.toc-title {
  font-size: 14px;
  line-height: 1.45;
}

.toc-empty {
  margin: 0;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.reader-surface {
  --reader-max-width: 760px;
  overflow: hidden;
}

.reader-surface[data-width="compact"] {
  --reader-max-width: 660px;
}

.reader-surface[data-width="wide"] {
  --reader-max-width: 900px;
}

.reader-progress-track {
  height: 4px;
  background: rgba(47, 111, 94, 0.14);
}

.reader-progress {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 260ms ease;
}

.reader-header,
.chapter-body,
.reader-footer {
  width: min(var(--reader-max-width), calc(100% - 48px));
  margin-inline: auto;
}

.reader-header {
  padding: 46px 0 24px;
}

.reader-meta {
  color: var(--copper);
}

.reader-title {
  margin: 12px 0 0;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 36px;
  line-height: 1.25;
}

.chapter-body {
  min-height: 54dvh;
  padding-bottom: 28px;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
}

.chapter-body p {
  margin: 0 0 1.05em;
  color: var(--ink);
  font-size: calc(19px * var(--reader-scale));
  line-height: 2.05;
  text-align: justify;
  text-wrap: pretty;
}

.chapter-body .section-marker {
  margin: 2.1em 0 1em;
  color: var(--accent-strong);
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  font-size: calc(15px * var(--reader-scale));
  font-weight: 700;
  text-align: left;
}

.chapter-body .chapter-note {
  border-left: 3px solid var(--copper);
  color: var(--muted);
  padding-left: 14px;
  text-align: left;
}

.chapter-body .ellipsis {
  color: var(--muted);
  text-align: center;
}

.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 18px 0 34px;
}

.reader-counter {
  color: var(--muted);
  font-size: 14px;
}

.mobile-toc-button {
  display: none;
}

.data-error {
  width: min(720px, calc(100% - 40px));
  margin: 24px auto;
  border: 1px solid #b85644;
  border-radius: 8px;
  background: rgba(184, 86, 68, 0.08);
  color: #8f3325;
  padding: 14px 16px;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  align-items: start;
  gap: 20px;
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0;
  font-size: 14px;
}

.footer-main,
.footer-contact {
  display: grid;
  gap: 8px;
}

.footer-contact {
  justify-items: start;
  color: var(--ink);
  font-style: normal;
}

.footer-contact strong {
  color: var(--accent-strong);
}

.toc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 34;
  background: rgba(16, 20, 17, 0.45);
}

@media (max-width: 980px) {
  .nav {
    grid-template-columns: 1fr auto;
  }

  .nav-links {
    display: none;
  }

  .hero {
    background-position: center;
  }

  .hero h1 {
    font-size: 54px;
  }

  .intro-layout,
  .world-layout,
  .reader-top,
  .reader-layout {
    grid-template-columns: 1fr;
  }

  .reader-tools {
    justify-items: start;
  }

  .toc-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 35;
    width: calc(100vw - 34px);
    max-width: 360px;
    max-height: none;
    border-radius: 0 8px 8px 0;
    transform: translateX(-104%);
    transition: transform 220ms ease;
  }

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

  .toc-close,
  .mobile-toc-button {
    display: inline-flex;
  }

  .toc-list {
    max-height: calc(100dvh - 108px);
  }
}

@media (max-width: 680px) {
  .nav,
  .hero-inner,
  .section,
  .reader-shell,
  .footer-inner {
    width: min(100% - 28px, 1400px);
  }

  .topbar {
    position: static;
  }

  .nav-action {
    padding-inline: 10px;
  }

  .hero,
  .hero-inner {
    min-height: 82dvh;
  }

  .hero-inner {
    padding: 54px 0 70px;
  }

  .hero h1 {
    font-size: 44px;
  }

  .hero-lead {
    font-size: 17px;
  }

  .hero-stats {
    grid-template-columns: 1fr;
    width: min(100%, 320px);
  }

  .section,
  .reader-shell {
    padding: 58px 0;
  }

  .section h2,
  .reader-heading h2 {
    font-size: 30px;
  }

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

  .reader-header,
  .chapter-body,
  .reader-footer {
    width: min(100% - 32px, var(--reader-max-width));
  }

  .reader-title {
    font-size: 30px;
  }

  .chapter-body p {
    font-size: calc(18px * var(--reader-scale));
    line-height: 1.95;
  }

  .reader-footer {
    align-items: stretch;
    flex-direction: column;
  }

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

  .chapter-nav .button {
    width: 100%;
  }

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