:root {
  --bg: #f6f3ec;
  --bg-elev: #ffffff;
  --text: #2b2723;
  --text-soft: #6b6560;
  --accent: #8a5a2b;
  --accent-2: #3d5a80;
  --border: #e5dfd3;
  --cover-from: #2c3e50;
  --cover-to: #4a6a8a;
  --maxw: 760px;
}

[data-theme="dark"] {
  --bg: #1b1b1f;
  --bg-elev: #232329;
  --text: #e6e1d8;
  --text-soft: #a09a91;
  --accent: #c98d5e;
  --accent-2: #7fa3c9;
  --border: #33333a;
  --cover-from: #10151c;
  --cover-to: #23374d;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶部栏 ---------- */
.site-head,
.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.site-nav,
.reader-nav { display: flex; align-items: center; gap: 14px; }

.reader-nav a { font-size: .95rem; color: var(--text-soft); }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: .85rem;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 主体 ---------- */
.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 24px 48px;
}

.hero { padding: 48px 0 40px; text-align: center; }
.hero h1 { font-size: 2rem; margin: 0 0 12px; letter-spacing: .02em; }
.hero-sub { color: var(--text-soft); margin: 0; font-size: 1rem; }

.shelf-title {
  font-size: 1.1rem;
  color: var(--text-soft);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin: 24px 0 16px;
}

/* ---------- 书籍卡片 ---------- */
.book-card {
  display: flex;
  gap: 20px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: transform .15s ease, box-shadow .15s ease;
  color: var(--text);
}
.book-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.08); text-decoration: none; }

.book-cover {
  flex: 0 0 90px;
  height: 128px;
  border-radius: 8px;
  background: linear-gradient(160deg, var(--cover-from), var(--cover-to));
  color: #f2ecdc;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.05rem;
  letter-spacing: .2em;
  line-height: 1.5;
  writing-mode: vertical-rl;
  padding: 8px 0;
  user-select: none;
}
.book-cover.lg { flex: 0 0 140px; height: 200px; font-size: 1.3rem; }

.book-meta h3 { margin: 0 0 4px; font-size: 1.3rem; }
.book-author { margin: 0 0 8px; color: var(--text-soft); font-size: .92rem; }
.book-desc { margin: 0 0 10px; color: var(--text-soft); font-size: .95rem; line-height: 1.8; }
.book-stats { margin: 0; font-size: .85rem; color: var(--accent); }

/* ---------- 书籍详情 ---------- */
.book-head { display: flex; gap: 28px; padding: 24px 0 8px; }
.book-info h1 { margin: 0 0 6px; font-size: 1.8rem; }
.book-tags { margin: 12px 0 18px; display: flex; gap: 8px; }
.book-tags span {
  font-size: .8rem;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 20px;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 9px 26px;
  border-radius: 8px;
  font-size: .95rem;
}
.btn:hover { text-decoration: none; opacity: .92; }

.chapter-list { list-style: none; padding: 0; margin: 0; }
.chapter-list li { border-bottom: 1px solid var(--border); }
.chapter-list a {
  display: flex;
  justify-content: space-between;
  padding: 12px 4px;
  color: var(--text);
  font-size: 1rem;
}
.chapter-list a:hover { color: var(--accent); text-decoration: none; }
.chapter-list a span { color: var(--text-soft); }

/* ---------- 阅读页 ---------- */
.progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: transparent;
  z-index: 10;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .08s linear;
}

.reader-main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 24px 72px;
}

.chapter { padding: 24px 0 8px; }
.chapter-book { color: var(--text-soft); font-size: .9rem; margin: 0 0 6px; }
.chapter h1 { font-size: 1.7rem; margin: 0 0 28px; }
.chapter-body p {
  margin: 0 0 1.4em;
  font-size: calc(1.06rem * var(--reader-scale, 1));
  text-align: justify;
  letter-spacing: .01em;
}
.chapter-body p:first-child::first-letter {
  font-size: 1.8em;
  float: left;
  line-height: 1;
  margin: .12em .12em 0 0;
  color: var(--accent);
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.chapter-nav a {
  color: var(--text-soft);
  font-size: .95rem;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chapter-nav a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.chapter-nav .toc { color: var(--accent); }
.chapter-nav .disabled { opacity: .35; pointer-events: none; }

/* ---------- 页脚 ---------- */
.site-foot {
  text-align: center;
  padding: 24px;
  color: var(--text-soft);
  font-size: .82rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
  .book-head { flex-direction: column; gap: 18px; }
  .book-cover.lg { flex: 0 0 120px; height: 170px; }
  .hero h1 { font-size: 1.6rem; }
  .chapter h1 { font-size: 1.4rem; }
}
