:root {
  --bg: #101211;
  --bg-soft: #171a18;
  --panel: #1b1e1c;
  --panel-strong: #212522;
  --text: #eeeae0;
  --muted: #a9aaa3;
  --faint: #777b75;
  --line: rgba(238, 234, 224, 0.12);
  --accent: #c86955;
  --accent-soft: rgba(200, 105, 85, 0.18);
  --green: #8fa58d;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --sans: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 78% 5%, rgba(200, 105, 85, 0.08), transparent 28rem),
    var(--bg);
  font-family: var(--sans);
}
button, input { font: inherit; }
button { cursor: pointer; }

.site-shell { min-height: 100vh; }
.topbar {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--bg);
  background: var(--accent);
  font-family: var(--serif);
  font-size: 21px;
}
.brand strong { display: block; font-size: 15px; letter-spacing: 0.08em; }
.brand small { display: block; margin-top: 4px; color: var(--faint); font-size: 11px; }
.top-actions { display: flex; gap: 8px; }
.icon-button, .text-button, .secondary-button {
  border: 0;
  color: var(--muted);
  background: transparent;
}
.icon-button {
  width: 36px; height: 36px;
  border: 1px solid var(--line);
  color: var(--text);
}
.icon-button:hover, .text-button:hover { color: var(--accent); }
#menuToggle { display: none; }

main { width: min(1320px, calc(100% - 48px)); margin: 0 auto; }
.hero {
  min-height: 500px;
  padding: 58px 0 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 96px;
  align-items: center;
}
.hero-copy { max-width: 650px; }
.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 18px;
  font-family: var(--serif);
  font-size: clamp(56px, 8vw, 106px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: 0.03em;
}
.dek {
  margin-bottom: 28px;
  color: var(--green);
  font-size: 19px;
  letter-spacing: 0.18em;
}
.intro {
  max-width: 540px;
  margin-bottom: 28px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 2;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-bottom: 34px;
  color: var(--faint);
  font-size: 12px;
}
.hero-meta span::before { content: "·"; margin-right: 8px; color: var(--accent); }
.primary-button, .secondary-button {
  padding: 13px 18px;
  border: 1px solid var(--accent);
  color: var(--text);
  background: var(--accent);
  font-size: 13px;
}
.primary-button span { margin-left: 16px; font-size: 17px; }
.primary-button:hover { background: #d87861; }
.hero-art { position: relative; }
.hero-art img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.24;
  object-fit: cover;
  filter: saturate(0.76) contrast(1.04);
  box-shadow: 18px 18px 0 rgba(200, 105, 85, 0.14);
}
.cover-caption {
  position: absolute;
  right: -22px;
  bottom: 25px;
  max-width: 190px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(16, 18, 17, 0.9);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.7;
}

.reader-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 48px;
  padding: 30px 0 100px;
  border-top: 1px solid var(--line);
}
.chapter-panel {
  min-width: 0;
  position: sticky;
  top: 24px;
  align-self: start;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 18px;
}
.panel-heading h2 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 500; }
.chapter-count { color: var(--faint); font-size: 11px; }
.panel-heading-actions { display: flex; align-items: center; gap: 8px; }
.panel-close {
  display: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-size: 20px;
  line-height: 1;
}
.search-box {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  color: var(--faint);
}
.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 12px;
}
.search-box input::placeholder { color: var(--faint); }
#chapterList {
  margin-top: 18px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.chapter-link {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  line-height: 1.55;
}
.chapter-link:hover { color: var(--text); background: var(--bg-soft); }
.chapter-link.active {
  border-left-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.chapter-link .chapter-no { display: block; margin-bottom: 3px; color: var(--faint); font-size: 10px; }

.reading-surface { min-width: 0; }
.reader-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 38px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 0;
  background: var(--bg);
}
.text-button { padding: 6px 0; font-size: 12px; }
.text-button:disabled { color: var(--faint); cursor: default; }
.reading-status { color: var(--faint); font-size: 11px; }
.progress-track { height: 2px; margin: 6px 0 48px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 0.2s ease; }
.chapter-content { max-width: 760px; margin: 0 auto; }
.chapter-kicker { margin-bottom: 14px; color: var(--accent); font-size: 11px; letter-spacing: 0.15em; }
.chapter-content h2 {
  margin-bottom: 30px;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 500;
  line-height: 1.35;
}
.chapter-content p {
  margin-bottom: 1.05em;
  color: var(--text);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.95;
  text-wrap: pretty;
}
.chapter-content p.dialogue { color: #e1b3a6; }
.chapter-content p.labelled-dialogue {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  margin-top: -0.15em;
  margin-bottom: 0.85em;
  padding: 7px 12px;
  border-left: 2px solid rgba(200, 105, 85, 0.48);
  background: rgba(200, 105, 85, 0.055);
}
.dialogue-speaker {
  color: var(--accent);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.dialogue-text { min-width: 0; }
.chapter-content blockquote {
  margin: 34px 0;
  padding-left: 18px;
  border-left: 2px solid var(--accent);
  color: var(--green);
  font-family: var(--serif);
  line-height: 2;
}
.loading-state { color: var(--faint); font-family: var(--serif); }
.reader-footer {
  max-width: 760px;
  margin: 60px auto 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.secondary-button { border-color: var(--line); background: transparent; }
.secondary-button:hover { border-color: var(--accent); color: var(--accent); }
.reader-footer p { margin: 0; color: var(--faint); font-family: var(--serif); font-size: 12px; }

body.light {
  --bg: #eeeae0;
  --bg-soft: #e5e1d7;
  --panel: #e2ded4;
  --panel-strong: #d8d3c8;
  --text: #242422;
  --muted: #60605a;
  --faint: #8a887f;
  --line: rgba(36, 36, 34, 0.15);
  --accent: #a94e3d;
  --accent-soft: rgba(169, 78, 61, 0.12);
  --green: #58705a;
}

@media (max-width: 860px) {
  .topbar, main { width: min(100% - 32px, 680px); }
  .hero { grid-template-columns: 1fr 220px; gap: 38px; padding: 56px 0 70px; }
  .intro { font-size: 16px; }
  .reader-layout { grid-template-columns: 1fr; gap: 24px; }
  .chapter-panel {
    position: fixed;
    z-index: 5;
    inset: 0 auto 0 0;
    width: min(310px, 86vw);
    padding: 78px 18px 24px;
    overflow-y: auto;
    background: var(--bg);
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.28);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }
  .chapter-panel.open { transform: translateX(0); }
  #menuToggle { display: block; }
  .panel-close { display: block; }
  .reader-layout { padding-top: 0; border-top: 0; }
  .progress-track { margin-bottom: 44px; }
  .chapter-content p { font-size: 15px; line-height: 1.9; }
  .chapter-content p.labelled-dialogue {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 9px;
    padding: 6px 9px;
  }
}
@media (max-width: 560px) {
  .topbar { padding: 17px 0; }
  .brand small { display: none; }
  .hero { display: flex; flex-direction: column-reverse; align-items: stretch; gap: 24px; padding: 28px 0 46px; }
  .hero-art { width: min(56vw, 220px); align-self: flex-end; }
  .cover-caption { right: -12px; bottom: 14px; font-size: 12px; }
  h1 { margin-bottom: 14px; font-size: 52px; }
  .dek { font-size: 16px; }
  .intro { margin-bottom: 22px; font-size: 15px; line-height: 1.8; }
  .hero-meta { gap: 8px 14px; }
  .reader-toolbar { gap: 8px; }
  .reading-status { display: none; }
  .chapter-content h2 { margin-bottom: 26px; font-size: 28px; }
  .chapter-content p { font-size: 15px; line-height: 1.85; }
  .chapter-content p.labelled-dialogue {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 8px;
  }
  .reader-footer { align-items: flex-start; flex-direction: column; }
}
