:root {
  color-scheme: dark;
  --reader-font-size: 19px;
  --bg: #09111d;
  --bg2: #111b2b;
  --panel: rgba(10, 18, 31, 0.84);
  --surface-top: rgba(15, 24, 40, 0.9);
  --surface-bottom: rgba(8, 14, 24, 0.95);
  --reader-paper: rgba(10, 17, 28, 0.97);
  --line: rgba(150, 173, 210, 0.14);
  --text: #eff3fb;
  --muted: #aab8cd;
  --soft: #7f93b1;
  --chip-bg: rgba(255, 255, 255, 0.04);
  --chip-text: var(--muted);
  --link: #d6efff;
  --cyan: #8ce2ff;
  --rose: #ff97af;
  --gold: #f7c36d;
  --violet: #a9a2ff;
  --accent-grad: linear-gradient(135deg, var(--cyan), var(--violet) 52%, var(--gold));
  --accent-text: #07101b;
  --grid-line: rgba(255, 255, 255, 0.03);
  --glow-a: rgba(140, 226, 255, 0.18);
  --glow-b: rgba(255, 151, 175, 0.16);
  --glow-c: rgba(247, 195, 109, 0.14);
  --hero-glow: rgba(140, 226, 255, 0.2);
  --summary-bg: rgba(140, 226, 255, 0.06);
  --summary-line: rgba(140, 226, 255, 0.14);
  --quote-bg: rgba(255, 255, 255, 0.03);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --reader-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4efe7;
  --bg2: #efe4d5;
  --panel: rgba(255, 250, 243, 0.92);
  --surface-top: rgba(255, 250, 244, 0.96);
  --surface-bottom: rgba(247, 240, 231, 0.98);
  --reader-paper: rgba(255, 252, 247, 0.99);
  --line: rgba(103, 87, 66, 0.12);
  --text: #241c15;
  --muted: #5f5548;
  --soft: #8a7a67;
  --chip-bg: rgba(89, 70, 49, 0.05);
  --chip-text: #4f4337;
  --link: #8a4b25;
  --cyan: #87b8cf;
  --rose: #d98684;
  --gold: #e3bf81;
  --violet: #b19bc7;
  --accent-grad: linear-gradient(135deg, #f0d39d, #d69d66 50%, #b9735c);
  --accent-text: #2b1d11;
  --grid-line: rgba(59, 46, 34, 0.04);
  --glow-a: rgba(170, 122, 78, 0.15);
  --glow-b: rgba(132, 168, 193, 0.14);
  --glow-c: rgba(212, 160, 129, 0.13);
  --hero-glow: rgba(220, 175, 111, 0.22);
  --summary-bg: rgba(190, 155, 108, 0.1);
  --summary-line: rgba(176, 128, 68, 0.18);
  --quote-bg: rgba(132, 98, 58, 0.04);
  --shadow: 0 24px 70px rgba(95, 74, 48, 0.12);
  --reader-shadow: 0 20px 48px rgba(95, 74, 48, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0, var(--glow-a), transparent 28%),
    radial-gradient(circle at 84% 8%, var(--glow-b), transparent 24%),
    radial-gradient(circle at 82% 76%, var(--glow-c), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg2) 76%, var(--bg) 24%) 45%, var(--bg2) 100%);
  font-family: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 84px 84px;
  mask-image: radial-gradient(circle at center, #000 20%, transparent 88%);
  opacity: 0.16;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 32px;
}

.card {
  background: linear-gradient(180deg, var(--surface-top), var(--surface-bottom));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar,
.hero,
.layout,
.worlds,
.stats,
.grid,
.chapters,
.info,
.tags {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 18px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent-text);
  background: linear-gradient(135deg, var(--cyan), var(--violet) 45%, var(--rose));
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text) 88%, transparent);
}

h1,
h2,
h3,
h4,
.world strong,
.readerTitle {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

h1 {
  font-size: clamp(30px, 3vw, 42px);
}

h2 {
  max-width: 11ch;
  font-size: clamp(40px, 5.3vw, 72px);
  line-height: 0.96;
}

h2 span {
  background: linear-gradient(135deg, var(--cyan), var(--violet) 45%, var(--rose));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h3 {
  font-size: 28px;
}

.pageTitle {
  max-width: none;
  font-size: clamp(34px, 4.4vw, 58px);
  line-height: 1.02;
}

.pageLead,
.muted,
.body p,
.summary,
.quote,
.footer,
.readerFooter,
.readerSummary,
.readerSeries {
  color: var(--muted);
  line-height: 1.8;
}

.pageLead {
  margin: 12px 0 6px;
  font-size: 20px;
}

.nav,
.actions,
.navBtns,
.filters,
.cardActions,
.breadcrumbs,
.readerBarGroup,
.readerPagerActions,
.readerMapTools,
.readerMetaStrip,
.chapterPills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip,
.btn,
.mini,
.filter,
.cardBtn,
.book,
.chapter,
.world,
.chapterPill {
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.chip,
.filter,
.mini,
.chapterPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--chip-text);
}

.chip.current,
.filter.active,
.chapterPill.active {
  color: var(--accent-text);
  border-color: transparent;
  background: var(--accent-grad);
  font-weight: 700;
}

.chip:hover,
.btn:hover,
.mini:hover,
.filter:hover,
.book:hover,
.chapter:hover,
.world:hover,
.cardBtn:hover,
.chapterPill:hover {
  transform: translateY(-2px);
}

.hero {
  grid-template-columns: 1.2fr 0.88fr;
  margin-top: 18px;
}

.hero-main,
.hero-side,
.panel {
  padding: 24px;
}

.hero-main {
  position: relative;
  overflow: hidden;
}

.hero-main::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hero-glow), transparent 70%);
}

.pageHero,
.readerHero {
  display: grid;
  gap: 12px;
}

.badge {
  display: inline-flex;
  width: max-content;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--cyan) 36%, transparent);
  background: color-mix(in srgb, var(--cyan) 12%, transparent);
  color: color-mix(in srgb, var(--text) 86%, var(--cyan) 14%);
  font-size: 13px;
}

.btn,
.cardBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 18px;
  border-radius: 16px;
  font-weight: 700;
  cursor: pointer;
}

.cardBtn {
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--text);
}

.cardActions.compact .cardBtn,
.btn.compact {
  padding: 10px 14px;
}

.primary {
  color: var(--accent-text);
  background: var(--accent-grad);
}

.ghost {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--chip-bg);
}

.stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--chip-bg) 82%, transparent);
}

.stat .k {
  color: var(--soft);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.signal {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--cyan) 20%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--cyan) 10%, transparent), color-mix(in srgb, var(--rose) 8%, transparent));
}

.layout {
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  align-items: start;
  margin-top: 18px;
}

.pageLayout {
  align-items: stretch;
}

.readerPanel {
  min-height: 100%;
}

.stack {
  display: grid;
  gap: 16px;
}

.head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.split {
  align-items: center;
}

input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--chip-bg) 82%, transparent);
  color: var(--text);
  outline: none;
  margin-bottom: 12px;
}

input:focus {
  border-color: color-mix(in srgb, var(--cyan) 42%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cyan) 12%, transparent);
}

.filter {
  cursor: pointer;
}

.grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.book,
.chapter,
.world {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--chip-bg) 90%, transparent), color-mix(in srgb, var(--chip-bg) 65%, transparent));
}

.book.active,
.chapter.active,
.world.active {
  border-color: color-mix(in srgb, var(--cyan) 34%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--cyan) 8%, transparent), color-mix(in srgb, var(--rose) 8%, transparent));
}

.bookTop,
.meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.pill {
  display: inline-flex;
  width: max-content;
  padding: 8px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip-bg) 90%, transparent);
  border: 1px solid var(--line);
  color: color-mix(in srgb, var(--text) 84%, transparent);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book h4 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.meta {
  color: var(--soft);
  font-size: 13px;
}

.info {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.infoCard {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--chip-bg) 84%, transparent);
}

.infoCard span {
  display: block;
  color: var(--soft);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.infoCard strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  line-height: 1.45;
}

.quote {
  margin: 18px 0 0;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--quote-bg);
  font-size: 20px;
}

.tags {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin-top: 16px;
}

.tag {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--chip-bg) 84%, transparent);
  color: color-mix(in srgb, var(--text) 90%, transparent);
  font-size: 13px;
}

.chapters {
  max-height: 560px;
  overflow: auto;
}

.chapter strong {
  font-size: 17px;
  line-height: 1.35;
}

.chapter span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.mini {
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--chip-bg);
  color: var(--text);
  cursor: pointer;
}

.summary,
.readerSummary {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--summary-line);
  background: var(--summary-bg);
}

.body {
  display: grid;
  gap: 18px;
}

.body p {
  margin: 0;
  font-size: 17px;
}

.chapterBody p {
  max-width: 78ch;
}

.bodyNav {
  margin-top: 22px;
}

.worlds {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.world span {
  color: color-mix(in srgb, var(--text) 88%, transparent);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.breadcrumbs {
  align-items: center;
  color: var(--soft);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.breadcrumbs a,
.textLink,
.readerFooter a {
  color: var(--link);
}

.footer {
  margin-top: 18px;
  padding: 18px 20px 26px;
  text-align: center;
}

.readerPage::before {
  opacity: 0.1;
}

.readerBar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 12px 0;
}

.readerBarInner {
  width: min(1120px, calc(100% - 8px));
  margin: 0 auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(16px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.readerBarTitle {
  min-width: 0;
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
}

.readerBarTitle span {
  color: var(--soft);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.readerBarTitle strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.readerShell {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 36px;
  display: grid;
  gap: 18px;
}

.readerHero {
  padding: 28px;
}

.readerTitle {
  font-size: clamp(36px, 4.4vw, 58px);
  line-height: 1.04;
}

.readerSeries {
  margin: 0;
  font-size: 18px;
}

.readerMetaStrip {
  color: var(--soft);
  font-size: 13px;
  letter-spacing: 0.03em;
}

.readerMetaStrip span {
  padding: 8px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip-bg) 88%, transparent);
  border: 1px solid var(--line);
}

.readingCard {
  background: var(--reader-paper);
  border-radius: 34px;
  box-shadow: var(--reader-shadow);
  padding: clamp(22px, 3vw, 42px);
}

.readingSurface {
  gap: 22px;
}

.readingSurface p {
  max-width: none;
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: var(--reader-font-size);
  line-height: 2;
  letter-spacing: 0.01em;
}

.readingSurface p + p {
  text-indent: 0.6em;
}

.readerPager,
.readerMap {
  padding: 22px 24px;
}

.readerPager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.readerMap {
  display: grid;
  gap: 16px;
}

.readerSizeBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--chip-bg) 88%, transparent);
  color: var(--soft);
}

.chapterPills {
  gap: 12px;
}

.readerFooter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 8px 0 0;
  font-size: 14px;
}

@media (max-width: 1220px) {
  .hero,
  .layout,
  .worlds {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .readerBarInner {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .readerBarGroup {
    justify-content: center;
  }

  .readerPager {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .topbar,
  .grid,
  .info,
  .stats,
  .tags {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell,
  .readerShell {
    width: min(100% - 16px, 1480px);
    padding-top: 10px;
  }

  .hero-main,
  .hero-side,
  .panel,
  .readerHero,
  .readingCard,
  .readerPager,
  .readerMap {
    padding: 18px;
  }

  .brand {
    flex-direction: column;
  }

  h2,
  .pageTitle,
  .readerTitle {
    max-width: none;
    font-size: 42px;
  }

  .readingSurface p {
    line-height: 1.9;
  }
}
