/* ── Layout ────────────────────────────────────────────── */
.reader-wrap {
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 100vh;
  padding-top: 64px;
}
.reader-main   { overflow-y: auto; }
.reader-sidebar {
  border-left: 1px solid var(--line);
  background: var(--ink-2);
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ── Chapter selector ──────────────────────────────────── */
.chapter-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 64px;
  background: rgba(6,22,25,0.97);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; gap: 20px;
}
.chapter-bar-left { display: flex; align-items: center; gap: 20px; }
.cb-logo {
  font-family: var(--serif); font-size: 1rem; letter-spacing: 0.1em;
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ivory);
}
.cb-logo .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 10px var(--rose); }
.chapter-pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cp-pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cp-btn {
  padding: 5px 14px;
  border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer; border-radius: 2px; transition: all 0.15s;
}
.cp-btn:hover { border-color: var(--rose); color: var(--rose); }
.cp-btn.active { background: var(--rose); border-color: var(--rose); color: var(--ink); }
.cp-select {
  display: none;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em;
  background: var(--ink-2); border: 1px solid var(--line-strong);
  color: var(--ivory); padding: 5px 10px; border-radius: 2px;
  cursor: pointer; height: 30px;
}
.cp-select:focus { outline: none; border-color: var(--rose); }
/* >8 chapters: prefer the dropdown even on desktop. */
.chapter-pills.cp-force-dropdown .cp-pills { display: none; }
.chapter-pills.cp-force-dropdown .cp-select { display: inline-block; }
.chapter-bar-right { display: flex; align-items: center; gap: 14px; }
.auth-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--ivory);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.15em; text-transform: uppercase;
  cursor: pointer; border-radius: 2px; transition: all 0.15s;
}
.auth-btn:hover { border-color: var(--rose); color: var(--rose); }
.auth-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-strong); }
.auth-name { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--ivory-2); }
/* EPUB download button in the top bar (paid users only) */
.auth-btn.auth-epub {
  border-color: rgba(127,178,137,0.55);
  color: #7fb289;
  background: rgba(127,178,137,0.06);
}
.auth-btn.auth-epub:hover {
  border-color: #7fb289;
  background: rgba(127,178,137,0.18);
  color: #cfe8d4;
}
.auth-epub-icon { font-size: 0.95rem; line-height: 1; }

/* Gift / shop reward button (signed-in users) */
.auth-btn.auth-gift {
  padding: 6px 10px;
  border-color: rgba(244,206,116,0.4);
  background: rgba(244,206,116,0.06);
}
.auth-btn.auth-gift:hover {
  border-color: #f4ce74;
  background: rgba(244,206,116,0.16);
}
.auth-gift-icon { font-size: 1rem; line-height: 1; }

@media (max-width: 640px) {
  .auth-epub-label { display: none; }
  .auth-btn.auth-epub { padding: 6px 10px; }
  .auth-name { display: none; }
}

/* ── Gift / Review modal ─────────────────────────────── */
.gift-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6,14,16,0.78);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: gift-fade-in 0.2s ease;
}
@keyframes gift-fade-in { from { opacity: 0; } to { opacity: 1; } }
.gift-modal {
  background: var(--bg, #0b1a1c);
  border: 1px solid var(--line-strong, rgba(255,255,255,0.12));
  border-radius: 6px;
  max-width: 480px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  padding: 32px 28px;
  position: relative;
  font-family: var(--serif);
  color: var(--ivory);
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}
.gift-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.gift-close:hover { color: var(--ivory); background: rgba(255,255,255,0.06); }
.gift-header { text-align: center; margin-bottom: 24px; }
.gift-header-icon { font-size: 2.2rem; margin-bottom: 8px; }
.gift-header-title {
  font-family: var(--serif);
  font-size: 1.5rem; font-weight: 400;
  color: var(--ivory); margin: 0 0 6px;
}
.gift-header-sub {
  font-family: var(--serif); font-style: italic;
  color: var(--ivory-2, var(--ivory));
  font-size: 1.08rem;
  line-height: 1.55;
  max-width: 420px;
  margin: 0 auto;
}
.gift-tier-card {
  border: 1px solid rgba(127,178,137,0.4);
  background: rgba(127,178,137,0.07);
  border-radius: 4px;
  padding: 22px 20px;
  text-align: center;
}
.gift-tier-eyebrow {
  font-family: var(--mono); font-size: 0.58rem;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: #7fb289; margin-bottom: 8px;
}
.gift-tier-value {
  font-family: var(--serif); font-weight: 300;
  font-size: 2.4rem; line-height: 1;
  color: #cfe8d4; margin-bottom: 12px;
}
.gift-tier-sub {
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.1em; color: var(--muted);
  text-transform: uppercase; margin-bottom: 14px;
}
.gift-cta-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px;
  background: #7fb289; border: 1px solid #7fb289; color: #0a1f15;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em;
  text-transform: uppercase; text-decoration: none; border-radius: 2px;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.gift-cta-primary:hover { background: #6ba17a; border-color: #6ba17a; }

.gift-upgrade { margin-top: 28px; }
.gift-upgrade-eyebrow {
  font-family: var(--mono); font-size: 0.6rem;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px; text-align: center;
}
.gift-upgrade-eyebrow .price { color: #7fb289; }
.gift-paths { display: flex; flex-direction: column; gap: 10px; }
.gift-path-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 4px;
  text-align: left;
  cursor: pointer;
  font-family: var(--serif);
  color: var(--ivory);
  transition: border-color 0.15s, background 0.15s;
}
.gift-path-btn:not(.gift-path-btn--passive):hover {
  border-color: rgba(127,178,137,0.6);
  background: rgba(127,178,137,0.06);
}
.gift-path-btn--passive { cursor: default; }
.gift-path-icon { font-size: 1.4rem; flex-shrink: 0; }
.gift-path-title {
  font-size: 1rem; font-weight: 500; margin-bottom: 4px;
}
.gift-path-sub {
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.08em; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.gift-progress-bar {
  display: inline-block; height: 4px; width: 80px;
  background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden;
}
.gift-progress-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--teal, #4a9aaa), #7fb289);
  transition: width 0.6s ease;
}
.gift-progress-text { font-size: 0.62rem; }

.gift-footer {
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.gift-footer a {
  font-family: var(--mono); font-size: 0.66rem;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); text-decoration: none;
}
.gift-footer a:hover { color: var(--ivory); }

/* Review modal */
.review-modal { max-width: 540px; }

.review-thanks-rating {
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 4px;
  color: #f4ce74;
  margin: 6px 0 28px;
}
.review-thanks-goodreads {
  border: 1px solid rgba(127,178,137,0.3);
  background: rgba(127,178,137,0.05);
  border-radius: 4px;
  padding: 24px 22px;
  text-align: center;
}
.review-thanks-eyebrow {
  font-family: var(--mono); font-size: 0.6rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}
.review-thanks-body {
  font-family: var(--serif); font-size: 1.05rem;
  line-height: 1.6; color: var(--ivory);
  margin: 0 0 22px;
  text-align: left;
}
.review-thanks-skip { margin-top: 16px; }
.review-thanks-skip button {
  background: transparent; border: none;
  font-family: var(--mono); font-size: 0.58rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); cursor: pointer;
  padding: 6px 12px;
  transition: color 0.2s;
}
.review-thanks-skip button:hover { color: var(--ivory); }

.review-pane { display: flex; flex-direction: column; gap: 6px; }
.review-label {
  font-family: var(--mono); font-size: 0.58rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); margin-top: 6px;
}
.review-stars { display: flex; gap: 4px; margin: 4px 0 10px; }
.review-star {
  background: transparent; border: none; padding: 4px;
  font-size: 1.8rem; line-height: 1;
  color: rgba(255,255,255,0.18); cursor: pointer;
  transition: color 0.15s, transform 0.1s;
}
.review-star:hover { transform: scale(1.1); }
.review-star--filled { color: #f4ce74; }
.review-textarea, .review-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ivory);
  resize: vertical;
  transition: border-color 0.15s;
}
.review-textarea:focus, .review-input:focus {
  outline: none;
  border-color: #7fb289;
}
.review-counter {
  font-family: var(--mono); font-size: 0.58rem;
  color: var(--muted); text-align: right;
  margin: 4px 0 12px;
}
.review-hint {
  font-family: var(--serif); font-style: italic;
  color: var(--ivory-2, var(--ivory));
  font-size: 1.02rem;
  line-height: 1.55;
  margin: 10px 0 18px;
}
.review-hint a { color: var(--rose); }
.review-status {
  margin-top: 14px;
  font-family: var(--mono); font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--muted);
  min-height: 18px;
}
.review-status--ok  { color: #7fb289; }
.review-status--err { color: var(--rose); }

@media (max-width: 520px) {
  .gift-modal { padding: 24px 18px; }
  .gift-tier-value { font-size: 2rem; }
  .review-tabs { font-size: 0.6rem; }
}

/* ── Font size controls ────────────────────────────────── */
.font-size-controls { display: flex; gap: 4px; align-items: center; }
.fs-btn {
  padding: 4px 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 0.75rem; font-weight: 500;
  cursor: pointer; border-radius: 2px; transition: all 0.15s; line-height: 1;
}
.fs-btn:hover { border-color: var(--ivory); color: var(--ivory); }

/* ── Chapter content ───────────────────────────────────── */
.chapter-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 72px 56px 120px;
}
.ch-hero {
  text-align: center;
  padding: 56px 0 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.ch-eyebrow {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--rose); margin-bottom: 16px;
}
/* Subtle free-preview hint — only shown to unpaid users on chapters 1–8.
   Hidden globally once <body> picks up the .paid-reader class. */
.ch-preview-note {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(127,178,137,0.65);
  margin: -8px 0 14px;
  opacity: 0.85;
}
body.paid-reader .ch-preview-note { display: none; }
.ch-title {
  font-family: var(--serif); font-size: clamp(2.2rem, 4vw, 3.4rem);
  font-weight: 300; color: var(--ivory); margin-bottom: 10px; line-height: 1.1;
}
.ch-subtitle {
  font-family: var(--serif); font-style: italic; color: var(--muted);
  font-size: 1.05rem; margin-bottom: 40px;
}

/* ── Chapter narrate button ─────────────────────────────── */
.ch-narrate-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.ch-narrate-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0 0 0 4px; /* optical centre: ▶ glyph is slightly left-heavy */
  background: rgba(233,74,124,0.08);
  border: 1px solid rgba(233,74,124,0.45);
  border-radius: 50%;
  color: var(--rose);
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.15s;
  box-shadow: 0 0 28px rgba(233,74,124,0.18), inset 0 0 20px rgba(233,74,124,0.04);
  outline: none;
}

.ch-narrate-btn:hover,
.ch-narrate-btn:focus-visible {
  background: rgba(233,74,124,0.16);
  border-color: rgba(233,74,124,0.8);
  box-shadow: 0 0 48px rgba(233,74,124,0.35), 0 0 80px rgba(233,74,124,0.12), inset 0 0 24px rgba(233,74,124,0.08);
  transform: translateY(-2px);
}

.ch-narrate-btn:active {
  transform: scale(0.97) translateY(0);
  box-shadow: 0 0 20px rgba(233,74,124,0.2);
}

/* Pulsing ring — idle attention animation */
.ch-narrate-ring {
  position: absolute;
  inset: -1px;
  border-radius: 60px;
  border: 1px solid rgba(233,74,124,0.5);
  animation: chNarrateRing 2.8s ease-out infinite;
  pointer-events: none;
}
.ch-narrate-ring--2 {
  animation-delay: 1.4s;
}
@keyframes chNarrateRing {
  0%   { transform: scale(1);    opacity: 0.6; }
  60%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

/* Stop pulsing on hover — feels intentional */
.ch-narrate-btn:hover .ch-narrate-ring,
.ch-narrate-btn:focus-visible .ch-narrate-ring {
  animation: none;
  opacity: 0;
}

.ch-narrate-icon {
  font-size: 1.3rem;
  line-height: 1;
  margin-left: 3px; /* optical centre for ▶ */
  transition: transform 0.2s;
}
.ch-narrate-btn:hover .ch-narrate-icon {
  transform: scale(1.2);
}



.ch-narrate-hint {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
  opacity: 0.6;
  margin: 0;
}
.ch-divider {
  width: 48px; height: 1px; background: var(--rose); opacity: 0.5;
  margin: 48px 0;
}

/* ── Paragraphs ────────────────────────────────────────── */
.para {
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.9;
  letter-spacing: 0.012em;
  color: var(--ivory);
  margin-bottom: 1.7em;
  cursor: pointer;
  border-radius: 3px;
  padding: 6px 10px;
  margin-left: -10px;
  transition: background 0.15s;
  position: relative;
  text-wrap: pretty;
}
.para:hover { background: rgba(233,74,124,0.05); }
.para.active {
  background: rgba(233,74,124,0.08);
  border-left: 2px solid var(--rose);
  padding-left: 16px;
  margin-left: -18px;
}
.para.has-comments::after {
  content: attr(data-comment-count);
  position: absolute; right: -28px; top: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--teal); color: var(--ivory);
  font-family: var(--mono); font-size: 0.72rem;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ── Wiki link highlights ──────────────────────────────── */
.wiki-link {
  border-bottom: 1px dotted transparent;
  color: inherit;
  cursor: default; /* not clickable until para is active */
  transition: border-color 0.15s, color 0.15s;
  pointer-events: none; /* disabled by default */
}
/* Enable and show on active paragraph */
.para.active .wiki-link {
  border-bottom-color: var(--teal-soft);
  cursor: pointer;
  pointer-events: auto;
}
.para.active .wiki-link:hover { border-bottom-color: var(--rose); color: var(--rose-soft); }
/* Show always when hints-on, but still only clickable when active */
body.wiki-hints-on .wiki-link {
  border-bottom-color: var(--teal-soft);
  opacity: 0.8;
}
body.wiki-hints-on .para.active .wiki-link {
  pointer-events: auto;
  cursor: pointer;
  opacity: 1;
}

.ch-section-head {
  font-family: var(--serif); font-weight: 300; color: var(--muted);
  font-size: 1.1rem; margin-bottom: 28px;
}
.ch-location-head {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--teal-soft);
  margin: 48px 0 24px; display: flex; align-items: center; gap: 12px;
}
.ch-location-head::before {
  content: ''; display: inline-block;
  width: 24px; height: 1px; background: var(--teal-soft);
}

/* Heading paragraphs — narrable location/time stamps */
.heading-para {
  font-family: var(--mono) !important;
  font-size: 0.68rem !important;
  letter-spacing: 0.28em !important;
  text-transform: uppercase !important;
  text-align: center !important;
  color: var(--pink) !important;
  opacity: 0.82;
  margin: 40px 0 20px !important;
  padding: 6px 0 !important;
  border-top: 1px solid rgba(232,67,147,0.22) !important;
  border-bottom: 1px solid rgba(232,67,147,0.22) !important;
  font-style: normal !important;
  text-shadow: 0 0 12px rgba(232,67,147,0.3);
  display: block !important;
}
.heading-para::before { content: none !important; }
.heading-para:hover { background: rgba(232,67,147,0.04) !important; }

/* ── Uplink interlude ──────────────────────────────────── */
.uplink-block {
  margin: 56px -10px;
  padding: 20px 28px 12px;
  border-left: 2px solid var(--teal-soft);
  background: rgba(45,91,102,0.12);
  border-radius: 0 3px 3px 0;
}
.uplink-label {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.3em;
  text-transform: uppercase; color: #6ecfde; margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.uplink-label::before { content: '◉'; font-size: 0.7rem; }
.uplink-label a {
  color: inherit; border-bottom: 1px dotted currentColor;
  transition: color 0.15s;
}
.uplink-label a:hover { color: var(--ivory); }

/* Uplink heading as a narratable para */
.uplink-heading-para {
  font-family: var(--mono) !important;
  font-size: 0.72rem !important;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #6ecfde !important;
  margin-bottom: 10px !important;
  line-height: 1.4 !important;
  display: flex; align-items: center; gap: 10px;
}
.uplink-heading-para::before { content: '◉'; font-size: 0.7rem; opacity: 0.8; }
.uplink-heading-para:hover { background: rgba(74,154,170,0.06) !important; }
.uplink-heading-para.active { border-left-color: var(--teal-soft) !important; background: rgba(74,154,170,0.1) !important; }

/* Uplink paras are full .para elements — styles live there.
   These rules only add the mono font override and teal tint. */
.uplink-block .para {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.75;
  color: #b8d8de;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.uplink-block .para:hover  { background: rgba(74,154,170,0.08); }
.uplink-block .para.active {
  background: rgba(74,154,170,0.14);
  border-left-color: var(--teal-soft);
}

/* Assets variant — each entry on its own line, section headers as dividers */
.uplink-assets .para {
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ivory-2);
  letter-spacing: 0.01em;
  margin-bottom: 2px;
  padding: 5px 10px 5px 24px;
}
.uplink-section-divider {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #6ecfde;
  padding: 18px 10px 6px;
  margin-top: 10px;
  border-top: 1px solid rgba(74,154,170,0.25);
}
.uplink-section-divider:first-child { border-top: none; padding-top: 4px; margin-top: 0; }
.uplink-section-divider strong { font-weight: 600; }

/* ── Transcript paragraphs ─────────────────────────────── */
.transcript-speaker {
  display: block;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--teal-bright);
  opacity: 0.75;
  margin-bottom: 4px;
  padding-left: 1px;
}
.transcript-para {
  border-left: 2px solid rgba(74,154,170,0.25) !important;
  padding-left: 14px !important;
}
.transcript-para + .transcript-para {
  margin-top: -4px; /* tighten consecutive transcript lines */
}

/* Level 1: SOL SYSTEM, YREUS SYSTEM, MAIREE — prominent */
.uplink-s1 {
  font-size: 0.68rem;
  letter-spacing: 0.32em;
  color: var(--ivory);
  border-top-color: rgba(74,154,170,0.45);
  padding-top: 22px;
  margin-top: 16px;
}
.uplink-s1:first-child { border-top: none; padding-top: 4px; margin-top: 0; }

/* Level 2: En Route, In Orbit, The Landed — indented sub-headers */
.uplink-s2 {
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  color: var(--teal-soft);
  border-top: none;
  padding: 14px 10px 4px 24px;
  margin-top: 4px;
}

/* ── Scene break ───────────────────────────────────────── */
.scene-break {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 64px 0;
  opacity: 0.45;
}
.scene-break span {
  color: var(--rose);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

/* ── Epigraph ──────────────────────────────────────────── */
.epigraph-block {
  margin: 0 0 56px;
  padding: 28px 32px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
/* .para.epigraph-para inherits all .para interactivity;
   these rules only override the visual treatment */
.epigraph-block .para {
  font-style: italic;
  color: var(--ivory-2);
  margin-bottom: 0.8em;
}
.epigraph-block .para:last-child { margin-bottom: 0; }
.epigraph-block .para:hover { background: rgba(233,74,124,0.04); }

/* ── Code / transmission block ────────────────────────── */
.code-block {
  margin: 40px 0;
  padding: 20px 28px;
  background: rgba(6,22,25,0.7);
  border: 1px solid rgba(74,154,170,0.25);
  border-left: 3px solid var(--teal-bright);
  position: relative;
}
.code-block::before {
  content: '◉ TRANSMISSION';
  display: block;
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.3em;
  color: var(--teal-soft);
  margin-bottom: 12px;
  opacity: 0.7;
}
.code-block .para {
  font-family: var(--mono) !important;
  font-size: 0.88rem !important;
  line-height: 1.7 !important;
  letter-spacing: 0.06em;
  color: var(--teal-bright) !important;
  margin-bottom: 4px !important;
  padding: 3px 8px !important;
  margin-left: 0 !important;
}
.code-block .para:hover  { background: rgba(74,154,170,0.06) !important; }
.code-block .para.active { background: rgba(74,154,170,0.12) !important; border-left-color: var(--teal-bright) !important; }

/* ── Poem / verse block ────────────────────────────────── */
.poem-block {
  margin: 48px auto;
  padding: 28px 36px 24px;
  max-width: 620px;
  border-left: 2px solid var(--rose);
  background: linear-gradient(90deg, rgba(233,74,124,0.04), transparent 70%);
  position: relative;
}
.poem-block::before {
  content: '◌ VERSE';
  display: block;
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.3em;
  color: var(--rose);
  opacity: 0.55;
  margin-bottom: 16px;
}
.poem-block .para.poem-stanza-para {
  font-family: var(--serif) !important;
  font-style: italic;
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--ivory);
  letter-spacing: 0.01em;
  margin: 0 0 28px;
  padding: 6px 10px;
  border-left: none !important;
  text-indent: 0;
}
.poem-block .para.poem-stanza-para:last-child { margin-bottom: 0; }
.poem-block .para.poem-stanza-para .poem-line {
  display: block;
}
.poem-block .para.poem-stanza-para .poem-line + .poem-line {
  /* second and later lines slightly indented to suggest enjambment */
  text-indent: 0;
}
.poem-block .para.poem-stanza-para:hover  { background: rgba(233,74,124,0.06); }
.poem-block .para.poem-stanza-para.active {
  background: rgba(233,74,124,0.10);
  border-left: 2px solid var(--rose) !important;
  padding-left: 14px;
  margin-left: -16px;
}
.poem-block .para.poem-stanza-para .poem-line.active-word {
  color: var(--rose);
}

@media (max-width: 720px) {
  .poem-block { padding: 22px 22px 18px; margin: 36px 0; }
  .poem-block .para.poem-stanza-para { font-size: 1rem; line-height: 1.8; }
}

.para.drop-cap::first-letter {
  font-family: var(--serif);
  font-size: 4.2em; float: left; line-height: 0.82;
  padding: 0.1em 0.1em 0 0; color: var(--rose); font-weight: 500;
}

/* ── Paragraph toolbar ─────────────────────────────────── */
.para-toolbar {
  display: none;
  position: absolute; right: 0; top: -36px;
  background: var(--ink-2); border: 1px solid var(--line-strong);
  border-radius: 3px; padding: 4px;
  gap: 2px; z-index: 10;
}
.para.active .para-toolbar { display: flex; }
.pt-btn {
  padding: 5px 10px;
  background: transparent; border: none; color: var(--muted);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; border-radius: 2px; transition: all 0.12s; white-space: nowrap;
}
.pt-btn:hover { background: rgba(233,74,124,0.12); color: var(--rose); }
.pt-btn.pt-narrate { border-color: rgba(233,74,124,0.3); color: var(--rose-soft); }
.pt-btn.pt-narrate:hover { background: rgba(233,74,124,0.18); color: var(--rose); }

/* ── Sidebar panels ────────────────────────────────────── */
.sb-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; opacity: 0.35; padding: 32px;
  font-family: var(--serif); font-style: italic;
  font-size: 1rem; color: var(--muted); text-align: center;
}
.sb-empty svg { opacity: 0.4; }

.sb-panel { display: none; flex-direction: column; height: 100%; }
.sb-panel.visible { display: flex; }

.sb-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.sb-head-left { flex: 1; min-width: 0; }
.sb-para-preview {
  font-family: var(--serif); font-style: italic; font-size: 1rem;
  color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-top: 4px;
}
.sb-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: 2px 6px; flex-shrink: 0;
  transition: color 0.15s;
}
.sb-close:hover { color: var(--ivory); }

/* Comments list */
.comments-list {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.comment-item {
  background: rgba(6,22,25,0.5); border: 1px solid var(--line);
  border-radius: 4px; padding: 14px 16px;
  animation: fadeUp 0.2s ease both;
}
@keyframes fadeUp { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform:none; } }
.comment-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.c-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--teal); }
.c-name { font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0.08em; color: var(--ivory); font-weight: 500; }
.c-time { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); margin-left: auto; }
.c-body { font-family: var(--serif); font-size: 1.05rem; color: var(--ivory-2); line-height: 1.65; }
.c-delete { background: transparent; border: none; color: var(--muted); font-size: 0.8rem; cursor: pointer; padding: 0; margin-left: 6px; transition: color 0.15s; }
.c-delete:hover { color: var(--rose); }
.no-comments {
  font-family: var(--serif); font-style: italic; font-size: 1rem;
  color: var(--muted); text-align: center; padding: 24px 0;
}

/* Comment form */
.comment-form {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: rgba(6,22,25,0.4);
}
.cf-login {
  font-family: var(--serif); font-style: italic;
  font-size: 1rem; color: var(--muted); text-align: center;
  padding: 8px 0; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.cf-textarea {
  width: 100%; background: rgba(6,22,25,0.6);
  border: 1px solid var(--line-strong); color: var(--ivory);
  font-family: var(--serif); font-size: 1rem; line-height: 1.55;
  padding: 10px 12px; border-radius: 3px; resize: vertical; min-height: 80px;
  transition: border-color 0.15s;
}
.cf-textarea:focus { outline: none; border-color: var(--rose); }
.cf-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.cf-hint { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); letter-spacing: 0.08em; }
.cf-submit {
  padding: 8px 18px; background: var(--rose); border: none; color: var(--ink);
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase;
  cursor: pointer; border-radius: 2px; transition: background 0.15s;
}
.cf-submit:hover { background: var(--rose-deep); color: var(--ivory); }
.cf-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Wiki popup ────────────────────────────────────────── */
.wiki-popup-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(6,22,25,0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.wiki-popup-overlay.open { display: flex; }
.wiki-popup {
  background: var(--ink-2); border: 1px solid var(--line-strong);
  border-radius: 4px; max-width: 560px; width: 100%;
  max-height: 80vh; overflow-y: auto;
  animation: fadeUp 0.2s ease both;
}
.wp-head {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.wp-tag { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--rose); margin-bottom: 4px; }
.wp-title { font-family: var(--serif); font-size: 1.6rem; color: var(--ivory); }
.wp-role { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); margin-top: 4px; letter-spacing: 0.12em; }
.wp-close { background: transparent; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; transition: color 0.15s; padding: 0; }
.wp-close:hover { color: var(--ivory); }
.wp-body { padding: 20px 24px; }
.wp-desc { font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--ivory-2); line-height: 1.7; }
.wp-meta { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.wp-chip {
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 4px 10px; border: 1px solid var(--line); color: var(--muted); border-radius: 2px;
}
.wp-full-link {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 18px;
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--teal-soft); border-bottom: 1px solid var(--teal);
  transition: color 0.15s;
}
.wp-full-link:hover { color: var(--ivory); }

/* ── Word lookup popup ─────────────────────────────────── */
.lookup-popup {
  position: fixed; z-index: 600;
  background: var(--ink-2); border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 16px 20px;
  max-width: 340px; min-width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  display: none;
  animation: fadeUp 0.15s ease both;
}
.lookup-popup.open { display: block; }
.lp-word { font-family: var(--serif); font-size: 1.2rem; color: var(--ivory); margin-bottom: 12px; }
.lp-actions { display: flex; flex-direction: column; gap: 8px; }
.lp-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: transparent;
  border: 1px solid var(--line); color: var(--muted);
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; border-radius: 2px; transition: all 0.12s; text-decoration: none;
}
.lp-btn:hover { border-color: var(--rose); color: var(--rose); }

/* ── Podcast panel ─────────────────────────────────────── */
.podcast-fab {
  position: fixed; bottom: 28px; left: 28px; z-index: 250;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 22px;
  background: rgba(6,22,25,0.95); border: 1px solid var(--teal-soft);
  color: var(--teal-bright); font-family: var(--mono); font-size: 0.78rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer; border-radius: 2px;
  box-shadow: 0 0 24px rgba(74,154,170,0.2);
  backdrop-filter: blur(8px);
  transition: all 0.2s;
  opacity: 0; pointer-events: none;
}
.podcast-fab.visible { opacity: 1; pointer-events: auto; }
.podcast-fab:hover {
  background: rgba(74,154,170,0.15);
  border-color: var(--teal-bright);
  color: var(--ivory);
  box-shadow: 0 0 32px rgba(74,154,170,0.35);
}
.podcast-fab-icon {
  font-size: 1.6rem; line-height: 1;
  filter: drop-shadow(0 0 6px rgba(74,154,170,0.8));
}
.podcast-fab-label { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.podcast-fab-title { font-size: 0.78rem; letter-spacing: 0.18em; }
.podcast-fab-sub {
  font-size: 0.78rem; letter-spacing: 0.08em; color: var(--ivory-2);
  font-family: var(--serif); font-style: italic; text-transform: none;
  white-space: nowrap; transition: color 0.2s;
}
.podcast-fab:hover .podcast-fab-sub { color: var(--ivory-2); }

.podcast-panel {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 400;
  width: min(680px, 100vw);
  background: var(--ink);
  border-left: 1px solid var(--line-strong);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
}
.podcast-panel.open { transform: none; }
.podcast-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(6,22,25,0.97); flex-shrink: 0;
}
.pp-title {
  font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--teal-bright);
  display: flex; align-items: center; gap: 8px;
}
.pp-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; transition: color 0.15s;
}
.pp-close:hover { color: var(--ivory); }
.podcast-iframe {
  flex: 1; border: none; background: var(--ink);
}

/* Chapter end card */
.chapter-end-card {
  margin: 64px 0 0;
  padding: 36px 32px;
  border: 1px solid var(--line);
  background: rgba(11,34,39,0.4);
  text-align: center;
  display: none;
}
.chapter-end-card.visible { display: block; }
.cec-label { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.cec-title { font-family: var(--serif); font-size: 1.6rem; font-weight: 300; color: var(--ivory); margin-bottom: 8px; }
.cec-sub { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 0.95rem; margin-bottom: 24px; }
.cec-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.cec-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 24px; border: 1px solid var(--teal-soft);
  background: rgba(74,154,170,0.08); color: var(--teal-bright);
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.18em;
  text-transform: uppercase; cursor: pointer; border-radius: 2px; transition: all 0.2s;
}
.cec-btn:hover { background: var(--teal); color: var(--ink); }
.cec-btn.primary {
  background: var(--rose); border-color: var(--rose); color: var(--ink);
}
.cec-btn.primary:hover { background: #c72f63; border-color: #c72f63; }
.cec-btn.continue {
  background: #7fb289; border-color: #7fb289; color: #0a1f15;
  font-size: 0.78rem; padding: 14px 30px;
}
.cec-btn.continue:hover { background: #6ba17a; border-color: #6ba17a; }
.cec-paywall-note {
  margin-top: 22px;
  font-family: var(--serif);
  font-size: 1.02rem;
  color: var(--ivory);
  line-height: 1.55;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.cec-paywall-note .price { color: #7fb289; font-weight: 600; }
.cec-paywall-note .sub { display:block; margin-top:8px; font-size: 0.88rem; color: var(--muted); font-style: italic; }
/* ── Decoded podcast button ────────────────────────────── */
.decoded-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 14px;
  border: 1px solid rgba(74,154,170,0.4);
  background: rgba(74,154,170,0.07);
  color: var(--teal-bright, #4a9aaa);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.15em;
  text-transform: uppercase; text-decoration: none;
  cursor: pointer; border-radius: 2px; transition: all 0.2s;
  position: relative;
}
.decoded-btn:hover {
  background: rgba(74,154,170,0.18);
  border-color: var(--teal-bright, #4a9aaa);
  color: var(--ivory);
}
.decoded-icon { font-size: 1.4rem; line-height: 1; filter: drop-shadow(0 0 5px rgba(74,154,170,0.7)); }
.decoded-label { font-size: 0.72rem; }
.decoded-tooltip {
  display: none;
  position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--ink-2); border: 1px solid var(--line-strong);
  padding: 10px 16px; border-radius: 3px; white-space: nowrap;
  font-family: var(--serif); font-style: italic; font-size: 0.92rem;
  letter-spacing: 0; text-transform: none; color: var(--ivory-2);
  line-height: 1.7; z-index: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.decoded-tooltip::before {
  content: ''; position: absolute; top: -5px; right: 22px;
  width: 8px; height: 8px; background: var(--ink-2);
  border-left: 1px solid var(--line-strong);
  border-top: 1px solid var(--line-strong);
  transform: rotate(45deg);
}
.decoded-btn:hover .decoded-tooltip { display: block; }

/* ── Narrate hero button ───────────────────────────────── */
.narrate-hero-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 18px;
  border: 1px solid var(--rose);
  background: rgba(233,74,124,0.12);
  color: var(--rose);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.18em;
  text-transform: uppercase; cursor: pointer; border-radius: 2px;
  transition: all 0.2s;
  box-shadow: 0 0 12px rgba(233,74,124,0.2);
}
.narrate-hero-btn:hover {
  background: var(--rose); color: var(--ink);
  box-shadow: 0 0 20px rgba(233,74,124,0.45);
}
.narrate-hero-icon { font-size: 0.8rem; }

/* ── Narration disclaimer (first-time AI audio consent) ─── */
.narration-disclaimer {
  position: fixed; inset: 0; z-index: 1100;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(6,22,25,0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}
.narration-disclaimer.open { display: flex; }
.nd-card {
  max-width: 580px;
  background: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--rose);
  padding: 38px 36px 30px;
  border-radius: 2px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: ndIn 0.35s cubic-bezier(0.22,1,0.36,1);
}
@keyframes ndIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.nd-title {
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--ivory);
  margin: 0 0 22px;
  line-height: 1.2;
}
.nd-body {
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.7;
  color: var(--ivory-2);
  margin: 0 0 18px;
}
.nd-body em { color: var(--rose); font-style: italic; }
.nd-actions {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 28px;
}
.nd-accept {
  padding: 13px 26px;
  border: 1px solid var(--rose);
  background: var(--rose);
  color: var(--ink, #060810);
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.18s, transform 0.1s;
}
.nd-accept:hover  { background: #c72f63; }
.nd-accept:active { transform: scale(0.97); }
.nd-cancel {
  padding: 13px 22px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: color 0.18s, border-color 0.18s;
}
.nd-cancel:hover { color: var(--ivory); border-color: var(--ivory); }

/* ── Narration thread sidebar ──────────────────────────── */
.narration-thread {
  position: fixed; right: 0; top: 64px; bottom: 0; z-index: 310;
  width: 340px;
  background: var(--ink-2);
  border-left: 1px solid var(--line-strong);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.narration-thread.open { transform: none; }
.nt-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.nt-title { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--teal-bright); }
.nt-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; transition: color 0.15s;
}
.nt-close:hover { color: var(--ivory); }
.nt-preview {
  font-family: var(--serif); font-style: italic; font-size: 0.88rem;
  color: var(--muted); padding: 10px 20px 0; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nt-comments { flex: 1; overflow-y: auto; padding: 14px 20px; display: flex; flex-direction: column; gap: 12px; }
.nt-comments::-webkit-scrollbar { width: 4px; }
.nt-comments::-webkit-scrollbar-thumb { background: var(--teal); }
.nt-form { padding: 14px 20px; border-top: 1px solid var(--line); background: rgba(6,22,25,0.4); }
.narration-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: rgba(6,22,25,0.97);
  backdrop-filter: blur(12px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 48px 120px;
}
.narration-overlay.active { display: flex; }

/* Chapter end card fade-in */
@keyframes nFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.narration-text {
  max-width: 760px;
  width: 100%;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.2vw, 1.75rem);
  line-height: 2;
  letter-spacing: 0.015em;
  color: rgba(244,234,217,0.3);
  text-align: center;
  position: relative;
  transition: color 0.3s;
}

/* Each word is a span */
.nw {
  display: inline;
  transition: color 0.08s, text-shadow 0.08s;
  color: rgba(244,234,217,0.5);
}
.nw.spoken {
  color: rgba(244,234,217,0.55);
}
.nw.current {
  color: var(--ivory);
  text-shadow: 0 0 32px rgba(233,74,124,0.5);
}
/* Character voice sentence highlight — rose-tinted, slightly warmer */
.nw.current.char-voice {
  color: var(--rose-soft) !important;
  text-shadow: 0 0 28px rgba(233,74,124,0.45), 0 0 8px rgba(233,74,124,0.2);
}
.nw.nw-italic  { font-style: italic; }
.nw.nw-bold    { font-weight: 600; }
.nw.nw-smcaps  { font-variant: small-caps; letter-spacing: 0.06em; }

/* Progress bar */
.narration-progress {
  position: fixed; bottom: 0; left: 0; right: 0; height: 2px;
  background: rgba(74,154,170,0.15);
  z-index: 301;
}
.narration-progress-bar {
  height: 100%;
  background: linear-gradient(to right, var(--teal-soft), var(--rose));
  width: 0%;
  transition: width 0.1s linear;
}

/* Controls */
.narration-controls {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; z-index: 302;
}
.nc-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: 1px solid var(--line-strong);
  background: rgba(11,34,39,0.9); color: var(--ivory);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.15em;
  text-transform: uppercase; cursor: pointer; border-radius: 2px;
  transition: all 0.15s; backdrop-filter: blur(8px);
  white-space: nowrap; /* prevent text wrapping to second line */
  height: 44px; box-sizing: border-box;
}
.nc-btn:hover { border-color: var(--rose); color: var(--rose); }
.nc-btn.primary { background: var(--rose); border-color: var(--rose); color: var(--ink); }
.nc-btn.primary:hover { background: #c72f63; border-color: #c72f63; color: var(--ivory); }

/* Para counter */
.narration-counter {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.18em;
  color: var(--ivory-2); text-align: center; margin-bottom: 32px;
  text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 0;
}

/* Comment indicator in narration mode */
.narration-comment-hint {
  position: fixed; right: 32px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 302; opacity: 0; transition: opacity 0.3s;
}
.narration-comment-hint.visible { opacity: 1; }
.nch-count {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--teal); color: var(--ivory);
  font-family: var(--mono); font-size: 0.68rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 12px rgba(74,154,170,0.5);
}
.nch-label {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--muted);
}
.nch-btn {
  padding: 5px 12px; border: 1px solid var(--teal-soft);
  background: transparent; color: var(--teal-bright);
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.1em;
  text-transform: uppercase; cursor: pointer; border-radius: 2px; transition: all 0.15s;
}
.nch-btn:hover { background: rgba(74,154,170,0.1); }

/* Code block narration style */
.narration-overlay.code-mode .narration-text {
  font-family: var(--mono);
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  color: rgba(74,154,170,0.3);
  letter-spacing: 0.08em;
}
.narration-overlay.code-mode .nw         { color: rgba(74,154,170,0.3); }
.narration-overlay.code-mode .nw.spoken  { color: rgba(74,154,170,0.55); }
.narration-overlay.code-mode .nw.current {
  color: #6ecfde;
  text-shadow: 0 0 24px rgba(74,154,170,0.6);
}
.narration-overlay.code-mode::after {
  content: '◉ TRANSMISSION';
  position: absolute; top: 80px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.35em;
  color: var(--teal-soft); opacity: 0.6; text-transform: uppercase;
}
.narration-loading {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted); text-align: center;
  animation: nPulse 1.5s ease-in-out infinite;
}
@keyframes nPulse { 0%,100%{opacity:0.4} 50%{opacity:1} }

/* ── Poem mode (dreamlike, line-fade narration overlay) ─── */
.narration-overlay.poem-mode {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(233,74,124,0.10), transparent 55%),
    linear-gradient(180deg, rgba(6,22,25,0.96), rgba(6,22,25,0.99));
}
.narration-overlay.poem-mode .narration-text {
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  line-height: 2.0;
  letter-spacing: 0.015em;
  color: var(--ivory);
  max-width: 760px;
  filter: drop-shadow(0 0 22px rgba(233,74,124,0.18));
}
.narration-poem-eyebrow {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.35em;
  color: var(--rose);
  opacity: 0.6;
  text-transform: uppercase;
  margin-bottom: 36px;
  text-align: center;
  animation: nPoemEyebrowIn 1.4s ease-out 0.1s both;
}
@keyframes nPoemEyebrowIn {
  from { opacity: 0; letter-spacing: 0.2em; }
  to   { opacity: 0.6; letter-spacing: 0.35em; }
}
.narration-poem {
  display: flex; flex-direction: column; gap: 4px;
  align-items: center;
}
.narration-poem-line {
  display: block;
  opacity: 0;
  filter: blur(4px);
  transform: translateY(6px);
  animation: nPoemLineIn 1.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(0.35s + (var(--line-i, 0) * 0.55s));
}
@keyframes nPoemLineIn {
  from { opacity: 0; filter: blur(4px); transform: translateY(6px); }
  to   { opacity: 1; filter: blur(0);   transform: translateY(0);   }
}
/* Karaoke word states inside a poem — softer than the default, breath-like */
.narration-overlay.poem-mode .nw         { color: rgba(255,243,235,0.45); transition: color 0.5s ease, text-shadow 0.5s ease; }
.narration-overlay.poem-mode .nw.spoken  { color: rgba(255,243,235,0.85); }
.narration-overlay.poem-mode .nw.current {
  color: var(--rose);
  text-shadow: 0 0 26px rgba(233,74,124,0.55);
}
@media (max-width: 900px) {
  .narration-overlay.poem-mode .narration-text { font-size: 1.2rem; line-height: 1.85; }
  .narration-poem-line { animation-delay: calc(0.2s + (var(--line-i, 0) * 0.45s)); }
}

@media (max-width: 900px) {
  .narration-overlay { padding: 80px 24px 100px; }
  .narration-text { font-size: 1.2rem; }
}
.reader-sidebar::-webkit-scrollbar,
.comments-list::-webkit-scrollbar,
.wiki-popup::-webkit-scrollbar { width: 4px; }
.reader-sidebar::-webkit-scrollbar-track,
.comments-list::-webkit-scrollbar-track,
.wiki-popup::-webkit-scrollbar-track { background: var(--ink); }
.reader-sidebar::-webkit-scrollbar-thumb,
.comments-list::-webkit-scrollbar-thumb,
.wiki-popup::-webkit-scrollbar-thumb { background: var(--teal); }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink-2); border: 1px solid var(--line-strong);
  padding: 10px 20px; border-radius: 3px;
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.12em;
  color: var(--ivory); z-index: 9000;
  transition: opacity 0.3s; pointer-events: none;
}
.toast.hidden { opacity: 0; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .reader-wrap { grid-template-columns: 1fr; padding-top: 112px; }

  /* Chapter bar — two rows on mobile */
  .chapter-bar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    gap: 0;
  }
  .chapter-bar-left {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
  }
  .cb-logo { font-size: 0.9rem; }
  .chapter-pills { gap: 4px; }
  .cp-btn { padding: 4px 10px; font-size: 0.65rem; letter-spacing: 0.12em; }
  /* On mobile, replace the pill row with a dropdown. */
  .chapter-pills .cp-pills { display: none; }
  .chapter-pills .cp-select { display: inline-block; max-width: 100%; }

  .chapter-bar-right {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; gap: 8px;
    flex-wrap: nowrap; overflow-x: auto;
  }
  .chapter-bar-right::-webkit-scrollbar { display: none; }

  .font-size-controls { gap: 3px; }
  .fs-btn { padding: 5px 8px; font-size: 0.7rem; }

  .narrate-hero-btn {
    padding: 6px 12px; font-size: 0.65rem;
    letter-spacing: 0.12em; gap: 5px;
  }
  .narrate-hero-icon { font-size: 0.7rem; }

  /* Auth area — shrink avatar only */
  .auth-name { display: none; }
  .auth-avatar { width: 24px; height: 24px; }

  /* Chapter content */
  .chapter-content { padding: 32px 20px 100px; }
  .ch-title { font-size: clamp(1.8rem, 6vw, 2.6rem); }
  .ch-hero { padding: 36px 0 40px; }
  .ch-narrate-btn {
    width: 60px;
    height: 60px;
    padding: 0 0 0 3px;
  }
  .ch-narrate-icon { font-size: 1.1rem; }

  /* Paragraph text */
  .para {
    font-size: 1.05rem;
    line-height: 1.85;
    padding: 6px 8px;
    margin-left: -8px;
  }

  /* Para toolbar — stack if needed */
  .para-toolbar {
    flex-wrap: wrap; gap: 4px;
  }
  .pt-btn { font-size: 0.6rem; padding: 3px 8px; }

  /* Sidebar — full width slide-in from bottom on mobile */
  .reader-sidebar {
    position: fixed;
    right: 0; bottom: 0; left: 0; top: auto;
    width: 100%;
    height: 60vh;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 150;
    border-left: none;
    border-top: 1px solid var(--line-strong);
  }
  .reader-sidebar.open { transform: none; }

  /* Narration overlay — mobile: fills screen, text scrollable above fixed controls */
  .narration-overlay {
    padding: 60px 20px 0;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;          /* overlay itself doesn't scroll */
    flex-direction: column;
    /* display is controlled by .active class — do NOT set display:flex here */
  }
  .narration-overlay.active {
    display: flex;
  }
  /* Text area scrolls independently, leaves room for fixed controls */
  .narration-text {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 1.08rem;
    line-height: 1.85;
    text-align: center;
    max-width: 100%;
    padding: 12px 4px 20px;
    width: 100%;
  }
  /* When thread is open, shrink text area */
  .narration-overlay.thread-open .narration-text {
    max-height: 38vh;
  }
  .narration-counter {
    flex-shrink: 0;
    font-size: 0.58rem;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-bottom: 12px;
  }

  /* Controls: single row of equal icon buttons, fixed at bottom */
  .narration-controls {
    flex-shrink: 0;
    width: 100%;
    gap: 0;
    flex-wrap: nowrap;
    justify-content: stretch;
    padding: 0;
    background: rgba(6,22,25,0.98);
    border-top: 1px solid var(--line-strong);
    box-sizing: border-box;
  }
  /* All buttons: equal flex, icon-sized, no text overflow */
  .nc-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 14px 4px;
    font-size: 0.95rem;      /* icon size */
    letter-spacing: 0;
    gap: 0;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--line);
    justify-content: center;
    background: rgba(6,22,25,0.98);
  }
  .nc-btn:last-child { border-right: none; }
  /* Hide label, show only icon on mobile */
  .nc-btn .nc-lbl { display: none; }
  .nc-btn .nc-icon { font-size: 1.05rem; line-height: 1; }
  /* Play/Pause: slightly accent colour, not full rose background */
  #nc-play-btn {
    order: 2; flex: 1 1 0;
    color: var(--rose);
    background: rgba(233,74,124,0.08);
    border-right: 1px solid var(--line);
  }
  #nc-play-btn.primary {
    background: rgba(233,74,124,0.15);
    color: var(--rose);
  }
  /* Transport row order */
  button.nc-btn[onclick="narrationPrev()"]  { order: 1; }
  button.nc-btn[onclick="narrationNext()"]  { order: 3; }
  /* Secondary row — hide the row break, put everything on one line */
  .nc-row-break                             { display: none; }
  #nc-thread-btn                            { order: 4; }
  #nc-voices-btn                            { order: 5; }
  #nc-music-btn                             { order: 6; }
  button.nc-btn[onclick="stopNarration()"]  { order: 7; }

  /* Comment hint: redundant on mobile */
  .narration-comment-hint { display: none; }

  /* Narration thread — full-width bottom sheet */
  .narration-thread {
    width: 100%;
    top: auto; bottom: 0;
    height: 58vh;
    transform: translateY(100%);
    border-left: none;
    border-top: 2px solid var(--teal-soft);
    border-radius: 12px 12px 0 0;
  }
  .narration-thread.open { transform: none; }
  /* Drag handle visual */
  .narration-thread::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--line-strong);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* Podcast fab — slightly smaller, stays bottom-left */
  .podcast-fab {
    bottom: 16px; left: 16px;
    padding: 10px 12px;
    min-width: 0;
  }
  .podcast-fab-label { display: none; }
  .podcast-fab-icon { font-size: 1.4rem; }

  /* Wiki popup */
  .wiki-popup {
    left: 12px; right: 12px; width: auto;
    max-height: 60vh;
  }

  /* Drop cap smaller on mobile */
  .para.drop-cap::first-letter {
    font-size: 3.2em;
  }

  /* Uplink / code blocks */
  .uplink-block .para { font-size: 0.8rem; }
  .code-block .para { font-size: 0.82rem !important; }
  .uplink-heading-para { font-size: 0.65rem !important; }

  /* Scene break */
  .scene-break { margin: 28px 0; }
}

/* Extra small phones */
@media (max-width: 390px) {
  .chapter-bar-right { padding: 6px 12px; }
  .narrate-hero-btn span:not(.narrate-hero-icon) { display: none; }
  .narrate-hero-btn { padding: 6px 10px; }
}
</style>