@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap');

:root {
  --font-size: 20px;
  --line-height: 2.2;
  --bg: #f6f1ea;
  --bg-warm: #f0e9df;
  --text: #2d2419;
  --text-dialogue: #1a1208;
  --accent: #8b5e3c;
  --accent-warm: #a0573e;
  --muted: #9c8b78;
  --muted-dark: #c4b9ab;
  --muted-deeper: #d0c7ba;
  --sidebar-bg: rgba(244, 239, 231, 0.97);
  --border: rgba(180, 165, 145, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Songti SC', 'STSong', 'Noto Serif SC', 'Source Han Serif SC', 'SimSun', serif;
  font-weight: 500;
  font-size: var(--font-size);
  line-height: var(--line-height);
  letter-spacing: 0.05em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(200, 170, 140, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(180, 150, 120, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.progress-bar {
  position: fixed;
  top: 0; left: 0;
  width: 0%; height: 2px;
  background: linear-gradient(to right, var(--accent), var(--accent-warm));
  z-index: 1000;
  transition: width 0.1s linear;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 740px;
  margin: 0 auto;
  padding: 60px 32px 120px;
  overflow: hidden;
}

.chapter-header {
  margin-bottom: 56px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.series-title {
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-bottom: 16px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  color: #2d2419;
  margin-bottom: 4px;
  letter-spacing: 0.08em;
  display: inline;
}

.chapter-label {
  display: inline;
  font-size: 28px;
  font-weight: 700;
  color: #2d2419;
  letter-spacing: 0.08em;
}

.chapter-title-line { margin-bottom: 16px; }

.epigraph {
  text-align: center;
  font-size: 15px;
  font-weight: 300;
  color: #a09080;
  font-style: italic;
  margin: 40px 0 0;
  padding: 0 40px;
  line-height: 1.9;
}

.divider {
  text-align: center;
  margin: 52px 0;
  color: var(--muted-dark);
  font-size: 15px;
  letter-spacing: 1em;
  user-select: none;
}

.divider::before {
  content: '';
  display: inline-block;
  width: 48px; height: 1px;
  background: linear-gradient(to right, transparent, var(--muted-dark));
  vertical-align: middle;
  margin-right: 16px;
}

.divider::after {
  content: '';
  display: inline-block;
  width: 48px; height: 1px;
  background: linear-gradient(to left, transparent, var(--muted-dark));
  vertical-align: middle;
  margin-left: 16px;
}

p {
  margin-bottom: 1.8em;
  text-indent: 0;
  text-align: left;
}

.dialogue {
  text-indent: 0;
  color: var(--text-dialogue);
}

.emphasis-line { color: #8b4a32; }

.scene-illustration {
  margin: 48px -80px;
  text-align: center;
  position: relative;
}

.scene-illustration img {
  width: calc(100% + 160px);
  max-width: none;
  height: auto;
  display: block;
  border-radius: 0;
  opacity: 0.88;
  filter: contrast(0.95) saturate(0.75) brightness(1.04);
  mask-image:
    linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%),
    linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  mask-composite: intersect;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%),
    linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  -webkit-mask-composite: source-in;
  mix-blend-mode: multiply;
}

.hook {
  margin-top: 56px;
  padding: 32px 28px;
  border-left: 2px solid rgba(139, 94, 60, 0.4);
  background: linear-gradient(to right, rgba(200, 180, 150, 0.15), transparent);
  color: #4a3a28;
  font-size: calc(var(--font-size) - 1px);
}

.hook p {
  margin-bottom: 1.4em;
  text-indent: 0;
}

.hook p:last-child { margin-bottom: 0; }

.chapter-end {
  text-align: center;
  margin-top: 72px;
  font-size: 14px;
  letter-spacing: 0.4em;
  color: var(--muted-dark);
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 48px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.chapter-nav a, .chapter-nav span {
  font-size: 14px;
  color: #8a7a68;
  text-decoration: none;
  letter-spacing: 0.1em;
  transition: color 0.3s;
  padding: 8px 0;
}

.chapter-nav a:hover { color: var(--accent-warm); }

.sidebar {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-btn {
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #a09080;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
  text-decoration: none;
}

.sidebar-btn:hover {
  background: #ede6db;
  color: var(--accent-warm);
  border-color: rgba(139, 94, 60, 0.4);
}

.sidebar-btn .icon { font-size: 15px; line-height: 1; }

.font-panel {
  display: none;
  position: fixed;
  right: 84px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  z-index: 101;
  flex-direction: column;
  gap: 12px;
  min-width: 140px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.font-panel.show { display: flex; }

.font-panel-title {
  font-size: 11px;
  color: #9c8b78;
  letter-spacing: 0.2em;
  text-align: center;
}

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

.font-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 185, 165, 0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  transition: all 0.2s;
}

.font-btn:hover {
  background: rgba(139, 94, 60, 0.15);
  border-color: var(--accent);
}

.font-size-display {
  font-size: 13px;
  color: var(--text);
  min-width: 40px;
  text-align: center;
}

::selection {
  background: rgba(139, 94, 60, 0.2);
  color: #2d2419;
}

/* ── Cover page ── */
.cover {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.cover-title {
  font-size: 36px;
  font-weight: 700;
  color: #2d2419;
  letter-spacing: 0.12em;
  margin-bottom: 24px;
  line-height: 1.5;
}

.cover-epigraph {
  font-size: 15px;
  font-weight: 300;
  color: #a09080;
  font-style: italic;
  line-height: 2;
  margin-bottom: 56px;
  max-width: 400px;
}

.cover-toc {
  list-style: none;
  padding: 0;
  width: 100%;
  max-width: 360px;
}

.cover-toc li {
  border-bottom: 1px solid var(--border);
}

.cover-toc li:first-child {
  border-top: 1px solid var(--border);
}

.cover-toc a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 4px;
  text-decoration: none;
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0.08em;
  transition: color 0.25s;
}

.cover-toc a:hover { color: var(--accent-warm); }

.cover-toc .ch-num {
  font-size: 13px;
  color: var(--muted);
  font-weight: 300;
}

.cover-toc .coming {
  color: var(--muted-dark);
  cursor: default;
}

.cover-toc .coming:hover { color: var(--muted-dark); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .sidebar { right: 10px; }
  .sidebar-btn { width: 36px; height: 36px; }
  .sidebar-btn .icon { font-size: 13px; }
  .font-panel { right: 54px; }
}

@media (max-width: 768px) {
  .container { max-width: 100%; padding: 48px 20px 80px; }
  body { font-size: 18px; }
  h1, .chapter-label { font-size: 24px; }
  .epigraph { padding: 0 12px; font-size: 14px; }
  .scene-illustration { margin: 36px 0; }
  .scene-illustration img { width: 100%; max-width: 100%; }
  .sidebar { display: none; }
  .cover-title { font-size: 28px; }
  .hook { padding: 24px 20px; }
  .chapter-nav a, .chapter-nav span {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .container { padding: 32px 16px 64px; }
  body { font-size: 17px; line-height: 2; }
  .chapter-header { margin-bottom: 40px; padding-bottom: 24px; }
  .divider { margin: 40px 0; }
  .hook { padding: 20px 16px; margin-left: -4px; }
}

@media print {
  .sidebar, .progress-bar, .font-panel { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
}
