:root {
  --bg: #f7f0e6;
  --bg2: #efe4d4;
  --ink: #2c241c;
  --muted: #7a6a5a;
  --card: rgba(255,255,255,.72);
  --line: rgba(80,50,30,.12);
  --accent: #c47a3a;
  --accent2: #8b5a2b;
  --shadow: 0 10px 28px rgba(80,50,30,.10);
  --reader-bg: #faf6ef;
  --reader-ink: #2a221a;
  --max: 720px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120f; --bg2: #1e1814;
    --ink: #f3e9dc; --muted: #b5a494;
    --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.10);
    --accent: #e0a066; --accent2: #f0c090;
    --shadow: 0 10px 28px rgba(0,0,0,.35);
    --reader-bg: #1a1511; --reader-ink: #efe4d6;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 880px; margin: 0 auto; padding: 24px 18px 64px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 28px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; }
.brand small { font-weight: 500; color: var(--muted); font-size: .78rem; margin-left: 4px; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }
.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 18px 16px; box-shadow: var(--shadow);
  color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(80,50,30,.14); text-decoration: none; }
.card h2 { font-size: 1.2rem; margin-bottom: 4px; }
.card .sub { color: var(--accent); font-size: .85rem; margin-bottom: 8px; }
.card p { color: var(--muted); font-size: .92rem; line-height: 1.55; }
.card .meta { margin-top: 12px; font-size: .8rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent2); font-size: .75rem;
}
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  background: var(--card); border: 1px dashed var(--line); border-radius: 16px;
}
.book-head { margin-bottom: 22px; }
.book-head h1 { font-size: 1.7rem; margin: 6px 0 8px; letter-spacing: .02em; }
.book-head .sub { color: var(--accent); }
.chapters { list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.chapters li + li { border-top: 1px solid var(--line); }
.chapters a {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 14px 16px; color: inherit; text-decoration: none;
}
.chapters a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.chapters .no { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.2em; font-size: .9rem; }
.chapters .t { flex: 1; font-weight: 560; }
.chapters .wc { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* reader */
.reader-shell { max-width: var(--max); margin: 0 auto; padding: 12px 16px 80px; }
.reader-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 18px; flex-wrap: wrap; font-size: .9rem;
}
.reader-nav a, .reader-nav button {
  color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font: inherit;
}
.reader-nav a:hover, .reader-nav button:hover { color: var(--ink); border-color: var(--accent); text-decoration: none; }
.reader-nav .disabled { opacity: .35; pointer-events: none; }
.article {
  background: var(--reader-bg); color: var(--reader-ink);
  border-radius: 18px; padding: 28px 22px 36px; border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.article header { margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.article .book-link { font-size: .85rem; color: var(--muted); }
.article h1 { font-size: 1.45rem; margin: 8px 0 6px; line-height: 1.35; }
.article .meta { font-size: .8rem; color: var(--muted); }
.article .body {
  font-size: 1.08rem; line-height: 1.95; letter-spacing: .02em;
  word-break: break-word;
}
.article .body p { margin: 0 0 1.05em; text-indent: 2em; }
.article .body p:first-child { margin-top: 0; }
.footer-nav {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; flex-wrap: wrap;
}
.footer-nav a {
  flex: 1; min-width: 120px; text-align: center; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); text-decoration: none; font-size: .95rem;
}
.footer-nav a:hover { border-color: var(--accent); }
.footer-nav a.disabled { opacity: .35; pointer-events: none; }
.err {
  padding: 20px; border-radius: 12px; background: color-mix(in srgb, #c44 12%, transparent);
  color: #a33; border: 1px solid color-mix(in srgb, #c44 30%, transparent);
}
@media (prefers-color-scheme: dark) { .err { color: #f0a0a0; } }
.loading { text-align: center; padding: 40px; color: var(--muted); }
@media (min-width: 720px) {
  .article { padding: 36px 40px 48px; }
  .article .body { font-size: 1.12rem; }
}
