:root {
  color-scheme: dark;
  --reader-scale: 1;
  --bg: #07090e;
  --panel: rgba(11, 14, 21, 0.82);
  --panel-strong: rgba(17, 20, 29, 0.96);
  --text: #f4eddf;
  --muted: #aeb6c5;
  --line: rgba(255, 255, 255, 0.12);
  --ember: #f97316;
  --ember-soft: #fed7aa;
  --void: #7dd3fc;
  --gold: #f8c96b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  font-family: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(115deg, rgba(10, 14, 24, 0.96), rgba(12, 7, 9, 0.96)),
    #07090e;
  color: var(--text);
  overflow-x: hidden;
}

body[data-theme="void"] {
  --text: #e8f2fb;
  --muted: #a8b8c8;
  --ember: #67e8f9;
  --ember-soft: #cffafe;
  --gold: #b7c7ff;
  --panel: rgba(6, 13, 24, 0.86);
  --panel-strong: rgba(7, 18, 34, 0.97);
}

button {
  font: inherit;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.ambient::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 72% 22%, rgba(249, 115, 22, 0.2), transparent 28%),
    radial-gradient(circle at 16% 20%, rgba(125, 211, 252, 0.14), transparent 34%),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.44));
}

.ember {
  position: absolute;
  right: 8vw;
  top: 7vh;
  width: 34vw;
  height: 34vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 185, 92, 0.22), rgba(249, 115, 22, 0.05) 52%, transparent 70%);
  filter: blur(6px);
}

.voidline {
  position: absolute;
  left: -10vw;
  top: 42vh;
  width: 70vw;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(125, 211, 252, 0.46), rgba(249, 115, 22, 0.28), transparent);
  transform: rotate(-12deg);
}

.library {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 310px;
  padding: 28px 18px;
  background: linear-gradient(180deg, var(--panel-strong), rgba(5, 7, 12, 0.94));
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.brand {
  padding: 0 8px 22px;
  border-bottom: 1px solid var(--line);
}

.kicker,
.chapter-count {
  margin: 0;
  color: var(--gold);
  font-family: Inter, "PingFang SC", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1 {
  margin: 10px 0 0;
  font-size: 1.7rem;
  line-height: 1.2;
}

.chapter-list {
  display: grid;
  gap: 6px;
  padding-top: 18px;
}

.chapter-link {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}

.chapter-link span {
  color: var(--gold);
  font-family: Inter, "PingFang SC", sans-serif;
  font-size: 0.78rem;
}

.chapter-link strong {
  align-self: center;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.35;
}

.chapter-link:hover,
.chapter-link.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(248, 201, 107, 0.26);
}

.reader-shell {
  min-height: 100vh;
  margin-left: 310px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 14px clamp(20px, 5vw, 68px);
  background: rgba(7, 9, 14, 0.76);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.topbar-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.topbar-title span {
  color: var(--gold);
  font-family: Inter, "PingFang SC", sans-serif;
  font-size: 0.74rem;
}

.topbar-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 600;
}

.controls {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(248, 201, 107, 0.46);
}

.menu-button {
  display: none;
}

.menu-button span {
  width: 17px;
  height: 1px;
  background: currentColor;
}

.progress-track {
  position: sticky;
  top: 72px;
  z-index: 7;
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
}

.progress-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--void), var(--ember), var(--gold));
  transform: scaleX(0);
  transform-origin: left center;
}

.chapter {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(24px, 5vw, 60px) 0 36px;
  outline: none;
}

.chapter-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(320px, 0.9fr);
  gap: clamp(26px, 5vw, 56px);
  align-items: center;
  margin-bottom: clamp(34px, 7vw, 72px);
}

.hero-copy h2 {
  margin: 12px 0 18px;
  font-size: clamp(2.2rem, 5vw, 5.4rem);
  line-height: 1.05;
  font-weight: 650;
}

.hero-copy p:last-child {
  max-width: 44rem;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.85;
}

.illustration-wrap {
  margin: 0;
}

.illustration-wrap img {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
  background: #090b10;
}

.illustration-wrap figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-family: Inter, "PingFang SC", sans-serif;
  font-size: 0.76rem;
  line-height: 1.5;
}

.chapter-body {
  width: min(760px, 100%);
  margin: 0 auto;
  padding-bottom: 24px;
}

.chapter-body h3 {
  margin: 2.8em 0 1em;
  color: var(--ember-soft);
  font-size: calc(1.18rem * var(--reader-scale));
  line-height: 1.45;
  font-weight: 650;
}

.chapter-body p {
  margin: 0 0 1.18em;
  color: color-mix(in srgb, var(--text) 92%, var(--muted));
  font-size: calc(1.08rem * var(--reader-scale));
  line-height: 2.18;
  text-align: justify;
}

.chapter-body strong {
  color: var(--gold);
}

.aside-line {
  color: var(--gold) !important;
  text-align: center !important;
}

.chapter-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 0 20px 62px;
}

.chapter-nav button {
  min-width: 132px;
  min-height: 44px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.18), rgba(125, 211, 252, 0.1));
  border: 1px solid rgba(248, 201, 107, 0.3);
  border-radius: 6px;
  cursor: pointer;
}

.chapter-nav button:disabled {
  color: rgba(255, 255, 255, 0.32);
  border-color: var(--line);
  cursor: not-allowed;
}

.scrim {
  display: none;
}

@media (max-width: 920px) {
  .library {
    transform: translateX(-104%);
    transition: transform 180ms ease;
  }

  .menu-open .library {
    transform: translateX(0);
  }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 9;
    display: block;
    background: rgba(0, 0, 0, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .menu-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .reader-shell {
    margin-left: 0;
  }

  .menu-button {
    display: inline-grid;
  }

  .chapter-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 64px;
    padding: 12px 14px;
  }

  .controls {
    gap: 5px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    font-size: 0.8rem;
  }

  .progress-track {
    top: 64px;
  }

  .chapter {
    width: min(100% - 28px, 1120px);
  }

  .hero-copy h2 {
    font-size: 2.24rem;
  }

  .chapter-body p {
    line-height: 2.05;
    text-align: left;
  }

  .chapter-nav {
    flex-direction: column;
  }
}
