:root {
  color-scheme: light;
  --bg: #f7f3ea;
  --paper: #fffaf0;
  --text: #241f1a;
  --muted: #766d61;
  --line: #ded3c2;
  --accent: #7a3f24;
  --accent-soft: #ead8c5;
  --shadow: rgba(58, 45, 30, 0.12);
  --max: 780px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151515;
  --paper: #1f1f1f;
  --text: #e9e2d6;
  --muted: #aaa093;
  --line: #393530;
  --accent: #d7a36f;
  --accent-soft: #352b22;
  --shadow: rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Serif SC", "Songti SC", "Microsoft YaHei", "PingFang SC", serif;
  font-size: 18px;
  line-height: 1.9;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  width: 0;
  height: 3px;
  background: var(--accent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(18px, calc((100vw - var(--max)) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  font-size: 17px;
  color: var(--muted);
}

.tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  min-width: 40px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
  box-shadow: 0 1px 6px var(--shadow);
}

.button:hover {
  border-color: var(--accent);
}

.page {
  width: min(var(--max), calc(100vw - 28px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.hero {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 16px;
}

h1 {
  margin: 0;
  font-size: 48px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: 0;
}

.subtitle {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.volume {
  margin: 40px 0 0;
}

.volume h2 {
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 24px;
  line-height: 1.35;
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chapter-list a {
  display: block;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 1px 8px var(--shadow);
}

.chapter-list .num {
  display: inline-block;
  min-width: 38px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.chapter-head {
  padding: 28px 0 22px;
  border-bottom: 1px solid var(--line);
}

.chapter-head h1 {
  font-size: 42px;
}

.chapter-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 16px;
}

.chapter {
  padding: 18px 0 30px;
  font-size: 22px;
}

.chapter p {
  margin: 1.05em 0;
  text-align: justify;
  word-break: break-word;
}

.chapter hr {
  width: 34%;
  margin: 34px auto;
  border: 0;
  border-top: 1px solid var(--line);
}

.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.nav a,
.nav span {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.nav .next {
  justify-content: flex-end;
  text-align: right;
}

.nav .home {
  justify-content: center;
}

.nav .disabled {
  color: var(--muted);
  opacity: 0.55;
}

.footer {
  width: min(var(--max), calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 16px;
}

@media (max-width: 560px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page {
    width: min(calc(100vw - 24px), var(--max));
    padding-top: 26px;
  }

  body {
    font-size: 17px;
  }

  h1 {
    font-size: 36px;
  }

  .chapter-head h1 {
    font-size: 34px;
  }

  .chapter {
    font-size: 20px;
  }

  .chapter-list {
    grid-template-columns: 1fr;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .nav .next,
  .nav .home {
    justify-content: flex-start;
    text-align: left;
  }
}