
:root {
  --bg:           #0d0e15;
  --bg-soft:      #15171f;
  --bg-card:      #1a1d28;
  --bg-warm:      #211a18;
  --ink:          #e8e6e3;
  --ink-soft:     #b8b6b3;
  --ink-mute:     #7a7770;
  --rule:         rgba(255, 215, 100, 0.10);
  --rule-strong:  rgba(255, 215, 100, 0.22);

  --gold:         #ffd700;
  --gold-soft:    rgba(255, 215, 0, 0.18);
  --fire:         #ff6b35;
  --fire-soft:    rgba(255, 107, 53, 0.14);
  --ice:          #4fc3f7;
  --ice-soft:     rgba(79, 195, 247, 0.12);
  --twilight:     #9c6bdb;
  --twilight-soft:rgba(156, 107, 219, 0.14);
  --metal:        #4a5568;

  --pivot:        #ff6b35;
  --echo:         #9c6bdb;

  /* tts plugin variables */
  --ltts-bg:           #15171f;
  --ltts-fg:           #e8e6e3;
  --ltts-rule:         rgba(255, 215, 100, 0.30);
  --ltts-accent:       #ffd700;
  --ltts-accent-hover: #ffe066;
  --ltts-shadow:       0 2px 14px rgba(255, 215, 0, 0.18);
  --ltts-mute:         #7a7770;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 90% 10%, rgba(255, 107, 53, 0.10), transparent 50%),
    radial-gradient(ellipse at 10% 90%, rgba(79, 195, 247, 0.08), transparent 50%),
    radial-gradient(ellipse at 50% 30%, rgba(255, 215, 0, 0.05), transparent 70%);
  color: var(--ink);
  font-family: 'Newsreader', Georgia, serif;
  font-size: 18px;
  line-height: 1.78;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 27% 67%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 41% 31%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 58% 84%, rgba(255,255,255,0.45), transparent),
    radial-gradient(1px 1px at 73% 12%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 88% 53%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 95% 79%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 6% 47%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 33% 8%, rgba(255,215,0,0.4), transparent);
  opacity: 0.7;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(13, 14, 21, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.topbar a { color: var(--ink); text-decoration: none; }
.topbar .brand {
  font-family: 'Cinzel', 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.16em;
  color: var(--gold);
  text-transform: uppercase;
}
.topbar-tools { display: flex; align-items: center; gap: 14px; }
.topbar-tools .ltts-mount-slot { display: inline-flex; align-items: center; }
.topbar .home {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: all .25s;
}
.topbar .home:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.progress {
  position: fixed;
  top: 56px; left: 0; right: 0;
  height: 1px;
  background: var(--rule);
  z-index: 99;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--fire), var(--gold));
  transition: width .12s ease-out;
}

.hero {
  max-width: 800px;
  margin: 132px auto 56px;
  padding: 0 28px;
  text-align: center;
  position: relative;
}
.hero::before {
  content: "";
  position: absolute;
  top: -32px; left: 50%;
  transform: translateX(-50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--gold), var(--fire) 60%, transparent 75%);
  opacity: 0.85;
  filter: blur(2px);
  pointer-events: none;
  animation: sun-pulse 7s ease-in-out infinite;
}
@keyframes sun-pulse {
  0%, 100% { opacity: 0.85; transform: translateX(-50%) scale(1); }
  50%      { opacity: 1.0;  transform: translateX(-50%) scale(1.08); }
}
.hero h1 {
  font-family: 'Cinzel', 'Cormorant Garamond', 'Playfair Display', serif;
  font-weight: 600;
  font-size: 72px;
  line-height: 1.1;
  letter-spacing: 0.04em;
  margin-bottom: 18px;
  color: var(--ink);
  text-transform: uppercase;
  text-shadow: 0 2px 24px rgba(255, 215, 0, 0.18);
}
.hero h1 .accent {
  color: var(--gold);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.01em;
}
.hero .tagline {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 21px;
  line-height: 1.55;
  max-width: 640px;
  margin: 0 auto 18px;
}
.hero .meta {
  font-size: 13px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.hero::after {
  content: "";
  display: block;
  width: 96px;
  height: 1px;
  background: var(--rule-strong);
  margin: 38px auto 0;
}

.intro-block {
  max-width: 720px;
  margin: 0 auto 64px;
  padding: 0 28px;
  font-size: 19px;
  color: var(--ink-soft);
}
.intro-block p { margin-bottom: 18px; }
.intro-block em {
  font-style: italic;
  color: var(--gold);
  font-weight: 500;
}

.world-strip {
  max-width: 920px;
  margin: 0 auto 72px;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}
.world-strip .pill {
  padding: 16px 14px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-soft);
  position: relative;
}
.world-strip .pill .name {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.world-strip .pill .desc { font-style: italic; line-height: 1.45; }
.world-strip .pill.fire .name { color: var(--fire); }
.world-strip .pill.fire { box-shadow: inset 0 -2px 0 var(--fire-soft); }
.world-strip .pill.twilight .name { color: var(--twilight); }
.world-strip .pill.twilight { box-shadow: inset 0 -2px 0 var(--twilight-soft); }
.world-strip .pill.ice .name { color: var(--ice); }
.world-strip .pill.ice { box-shadow: inset 0 -2px 0 var(--ice-soft); }

.chapter-graph { max-width: 1080px; margin: 0 auto 88px; padding: 0 28px; }

.part-divider {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin: 56px 0 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule-strong);
}
.part-divider .part-num {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 0.20em;
  text-transform: uppercase;
}
.part-divider span:last-child {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  color: var(--ink);
  font-weight: 500;
  font-style: italic;
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
}
.chapter-node {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-decoration: none;
  color: var(--ink);
  transition: all .35s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.chapter-node:hover {
  border-color: var(--gold);
  box-shadow: 0 10px 30px rgba(255, 215, 0, 0.18);
  transform: translateY(-3px);
}
.chapter-node .cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-warm);
  overflow: hidden;
  position: relative;
}
.chapter-node .cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 1.2s cubic-bezier(.2,.8,.2,1);
}
.chapter-node:hover .cover img { transform: scale(1.05); }
.chapter-node .body { padding: 14px 16px 18px; }
.chapter-node .num {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.20em;
  margin-bottom: 4px;
}
.chapter-node .title {
  font-family: 'Cormorant Garamond', 'Newsreader', serif;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.25;
  margin-bottom: 6px;
  color: var(--ink);
}
.chapter-node .subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.45;
  margin-bottom: 8px;
  min-height: 38px;
}
.chapter-node .kind-label {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding-top: 6px;
  border-top: 1px solid var(--rule);
}
.chapter-node[data-kind="pivot"] .kind-label { color: var(--pivot); }
.chapter-node[data-kind="echo"]  .kind-label { color: var(--echo); }
.chapter-node[data-kind="pivot"] .num { color: var(--pivot); }
.chapter-node[data-kind="echo"]  .num { color: var(--echo); }

/* ----- Chapter page ----- */

.chapter-page {
  max-width: 720px;
  margin: 96px auto 80px;
  padding: 0 28px;
}
.chapter-meta {
  text-align: center;
  margin-bottom: 24px;
}
.chapter-meta .num {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.chapter-page h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 44px;
  line-height: 1.18;
  text-align: center;
  margin: 0 auto 36px;
  max-width: 580px;
  color: var(--ink);
}
.chapter-page h1::after {
  content: "";
  display: block;
  width: 64px;
  height: 1px;
  background: var(--rule-strong);
  margin: 24px auto 0;
}
.chapter-cover-block {
  margin: 0 auto 40px;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  background: var(--bg-warm);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.chapter-cover-block img { width: 100%; height: 100%; object-fit: cover; }

.chapter-body {
  font-size: 19px;
  line-height: 1.82;
}
.chapter-body p {
  margin-bottom: 22px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}
.chapter-body p.visible {
  opacity: 1;
  transform: translateY(0);
}
.chapter-body em {
  font-style: italic;
  color: var(--gold);
}
.chapter-body strong {
  color: var(--fire);
  font-weight: 600;
}
.chapter-body hr {
  border: none;
  height: 1px;
  background: var(--rule-strong);
  margin: 36px auto;
  width: 96px;
}

.chapter-nav {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--rule-strong);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
}
.chapter-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .25s;
  max-width: 45%;
  line-height: 1.4;
}
.chapter-nav a:hover { color: var(--gold); }
.chapter-nav .prev::before { content: "← "; }
.chapter-nav .next::after { content: " →"; }
.chapter-nav .next { text-align: right; }

@media (max-width: 720px) {
  .hero h1 { font-size: 44px; }
  .hero .tagline { font-size: 18px; }
  .chapter-page h1 { font-size: 30px; }
  .chapter-list { grid-template-columns: 1fr 1fr; gap: 14px; }
  .chapter-node .title { font-size: 16px; }
  .chapter-node .subtitle { font-size: 12px; min-height: auto; }
  .world-strip { grid-template-columns: 1fr; }
}
