/* ==========================================================================
   Warm Charcoal Reader Theme — Built for comfortable phone & desktop reading
   ========================================================================== */

:root {
  /* Warm charcoal / slate palette (not pure black) */
  --bg: #1b1a18;
  --bg-elevated: #24221f;
  --bg-hover: #2c2a26;
  --bg-glass: rgba(27, 26, 24, 0.88);
  --fg: #e6e1d6;
  --fg-heading: #f2ede2;
  --muted: #9e988e;
  --line: #32302b;
  --accent: #d4a359;
  --accent-soft: rgba(212, 163, 89, 0.14);

  /* Typography defaults (customizable by reader controls) */
  --font-serif:
    "Source Serif 4", Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --reader-font-size: 1.15rem; /* ~18.4px default */
  --reader-line-height: 1.8;
  --reader-max-width: 38rem; /* Medium width default */

  color-scheme: dark;
}

/* Reader font size presets */
html[data-font-size="sm"] {
  --reader-font-size: 1.02rem;
}
html[data-font-size="md"] {
  --reader-font-size: 1.15rem;
}
html[data-font-size="lg"] {
  --reader-font-size: 1.3rem;
}
html[data-font-size="xl"] {
  --reader-font-size: 1.48rem;
}

/* Reader line spacing presets */
html[data-line-height="compact"] {
  --reader-line-height: 1.62;
}
html[data-line-height="normal"] {
  --reader-line-height: 1.8;
}
html[data-line-height="relaxed"] {
  --reader-line-height: 2.02;
}

/* Reader width presets */
html[data-width="narrow"] {
  --reader-max-width: 32rem;
}
html[data-width="medium"] {
  --reader-max-width: 38rem;
}
html[data-width="wide"] {
  --reader-max-width: 46rem;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Top Reading Progress Bar ---------- */
.progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.04);
  z-index: 100;
  pointer-events: none;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s ease-out;
}

/* ---------- Sticky Reader Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
  transition: transform 0.25s ease;
}

.topbar.hidden-bar {
  transform: translateY(-100%);
}

.topbar-inner {
  max-width: 56rem;
  margin: 0 auto;
  height: 54px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  border: 1px solid transparent;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  color: var(--fg-heading);
  background: var(--bg-elevated);
  border-color: var(--line);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  flex: 1;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Typography Settings Popover (Aa) ---------- */
.prefs-panel {
  position: fixed;
  top: calc(58px + env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  width: min(320px, calc(100vw - 32px));
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  z-index: 85;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
}

.prefs-panel[hidden] {
  display: none;
}

.prefs-group + .prefs-group {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.prefs-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.seg-btn {
  padding: 8px 6px;
  min-height: 36px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.seg-btn:hover {
  color: var(--fg);
}

.seg-btn.active {
  background: var(--bg-hover);
  color: var(--accent);
  font-weight: 500;
}

/* ---------- Table of Contents Drawer ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.backdrop.visible {
  opacity: 1;
}

.backdrop[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(340px, 86vw);
  background: var(--bg-elevated);
  border-right: 1px solid var(--line);
  z-index: 90;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 8px;
}

.book-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg-heading);
  margin: 0 0 4px;
  line-height: 1.25;
}

.book-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.drawer-close {
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
}

.drawer-close:hover {
  color: var(--fg);
  background: var(--bg-hover);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
}

.toc-item + .toc-item {
  margin-top: 4px;
}

.toc-btn {
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.15s ease;
}

.toc-btn:hover {
  background: var(--bg-hover);
}

.toc-btn.active {
  background: var(--accent-soft);
}

.toc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.toc-btn.active .toc-meta {
  color: var(--accent);
}

.toc-name {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--fg-heading);
  line-height: 1.35;
}

.toc-btn.active .toc-name {
  color: var(--accent);
}

.drawer-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.drawer-foot a {
  text-decoration: none;
  color: var(--accent);
}

.drawer-foot a:hover {
  text-decoration: underline;
}

/* ---------- Main Reader Column ---------- */
.reader-wrap {
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding-top: 48px;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  transition: max-width 0.2s ease;
}

.chapter-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.chapter-kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-bottom: 12px;
}

.chapter-kicker .dot {
  color: var(--muted);
  opacity: 0.6;
}

.chapter-kicker .read-time {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.02em;
}

.chapter-title {
  font-size: clamp(1.85rem, 5vw, 2.55rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--fg-heading);
  margin: 0 0 14px;
  text-wrap: balance;
}

.chapter-subtitle {
  font-size: 1.12em;
  line-height: 1.55;
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

/* ---------- Chapter Prose Typography ---------- */
.chapter-body p {
  margin: 0 0 1.25em;
  word-wrap: break-word;
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}
.chapter-body p.dialogue {
  text-indent: 1.5em;
  margin-bottom: 0.85em; /* slightly tighter spacing between back-and-forth lines */
}
.chapter-body p.cont-para {
  text-indent: 0;
}
.chapter-body > :last-child {
  margin-bottom: 0;
}

.chapter-body p.lead-para::first-letter {
  float: left;
  font-size: 3.1em;
  line-height: 0.84;
  padding-right: 10px;
  padding-top: 4px;
  color: var(--fg-heading);
  font-weight: 600;
}

.chapter-body h2 {
  font-size: 1.35em;
  font-weight: 600;
  color: var(--fg-heading);
  line-height: 1.3;
  margin: 2em 0 0.7em;
  letter-spacing: -0.01em;
}

.chapter-body blockquote {
  margin: 1.8em 0;
  padding: 4px 0 4px 20px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.chapter-body hr.scene-break {
  border: 0;
  text-align: center;
  margin: 2.4em 0;
  height: 1.5em;
  line-height: 1.5em;
}

.chapter-body hr.scene-break::before {
  content: "*   *   *";
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

/* ---------- Previous / Next Chapter Navigation ---------- */
.chapter-nav {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.nav-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  text-align: left;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.nav-card.next {
  text-align: right;
  grid-column: 2;
}

.nav-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.nav-card:active {
  transform: scale(0.99);
}

.nav-dir {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.nav-title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--fg-heading);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- Resume Toast Pill ---------- */
.resume-toast {
  position: fixed;
  bottom: max(76px, calc(env(safe-area-inset-bottom, 0px) + 70px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 70;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
}

.resume-toast[hidden] {
  display: none;
}

.resume-toast button {
  color: var(--accent);
  font-weight: 500;
  padding: 2px 4px;
}

/* ---------- Paged (Page-Turn) Mode ---------- */
html[data-mode="paged"] body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

html[data-mode="paged"] .reader-wrap {
  flex: 1;
  width: 100%;
  padding-top: 28px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

html[data-mode="paged"] .chapter-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
}

.page-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.page-bar[hidden] {
  display: none;
}

.page-bar-inner {
  max-width: var(--reader-max-width);
  margin: 0 auto;
  height: 54px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-heading);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-indicator {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Phone Optimizations ---------- */
@media (max-width: 600px) {
  .reader-wrap {
    padding-top: 32px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  html[data-mode="paged"] .reader-wrap {
    padding-top: 20px;
  }

  .chapter-header {
    margin-bottom: 28px;
    padding-bottom: 22px;
  }

  .chapter-nav {
    grid-template-columns: 1fr;
    margin-top: 48px;
  }

  .nav-card.next {
    grid-column: 1;
    text-align: left;
  }

  .btn-label-hide-mobile {
    display: none;
  }
}

/* ==========================================================================
   WIP (Work In Progress) Subpages Styling
   ========================================================================== */
.wip-body {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top, 0px))
    max(20px, env(safe-area-inset-right, 0px))
    max(24px, env(safe-area-inset-bottom, 0px))
    max(20px, env(safe-area-inset-left, 0px));
}

.wip-wrap {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.wip-top {
  display: flex;
  align-items: center;
}

.wip-back {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.wip-back:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.wip-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wip-pill {
  align-self: flex-start;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(212, 163, 89, 0.25);
}

.wip-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  color: var(--fg-heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.wip-lead {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--fg);
}

.wip-desc {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--muted);
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.wip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.wip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.wip-btn.primary {
  background: var(--accent);
  color: #161513;
}

.wip-btn.primary:hover {
  background: #dfb26b;
  transform: translateY(-1px);
}

.wip-btn.ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
}

.wip-btn.ghost:hover {
  border-color: var(--muted);
  background: var(--bg-hover);
}

.wip-foot {
  text-align: center;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--muted);
}

/* ==========================================================================
   Tree Navigation Main Page (index.html)
   ========================================================================== */
.tree-page {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Ambient soft lamp glow in background */
.tree-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      55rem 38rem at 50% 12%,
      rgba(212, 163, 89, 0.08),
      transparent 70%
    ),
    radial-gradient(
      40rem 30rem at 50% 95%,
      rgba(212, 163, 89, 0.06),
      transparent 60%
    );
  z-index: 0;
}

.tree-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top, 0px))
    max(20px, env(safe-area-inset-right, 0px))
    max(36px, env(safe-area-inset-bottom, 0px))
    max(20px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tree-head {
  text-align: center;
  margin-bottom: 28px;
}

.tree-brand-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.tree-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.tree-site-title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 600;
  color: var(--fg-heading);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.tree-tagline {
  margin: 0 auto;
  max-width: 44ch;
  font-size: 1.08rem;
  line-height: 1.55;
  color: var(--muted);
  font-style: italic;
}

/* Tree Container / Stage */
.tree-stage {
  position: relative;
  width: 100%;
  max-width: 920px;
  margin: 0 auto 36px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

/* 1. Featured Book Hero Branch */
.hero-branch {
  width: 100%;
}

.hero-book-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px 36px;
  background: linear-gradient(
    135deg,
    rgba(212, 163, 89, 0.12) 0%,
    var(--bg-elevated) 65%
  );
  border: 1px solid rgba(212, 163, 89, 0.35);
  border-radius: 14px;
  text-decoration: none;
  color: var(--fg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.hero-book-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: linear-gradient(
    135deg,
    rgba(212, 163, 89, 0.18) 0%,
    var(--bg-hover) 65%
  );
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5);
}

.hero-book-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.hero-book-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-badge-meta {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.hero-book-title {
  margin: 2px 0 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 600;
  color: var(--fg-heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
  transition: color 0.15s ease;
}

.hero-book-card:hover .hero-book-title {
  color: var(--accent);
}

.hero-book-desc {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--fg);
  max-width: 68ch;
}

.hero-book-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hero-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #161513;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14px;
  padding: 10px 22px;
  border-radius: 6px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.hero-book-card:hover .hero-cta-btn {
  background: #dfb26b;
  transform: translateY(-1px);
}

.hero-subtext {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--muted);
}

/* 2. Satellite Companion Branches */
.satellites-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.satellites-label {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.satellites-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.satellite-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--fg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.satellite-card:hover {
  transform: translateY(-2px);
  border-color: var(--muted);
  background: var(--bg-hover);
}

.satellite-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.satellite-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.satellite-num {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.05em;
}

.branch-badge {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
}

.branch-badge.active {
  color: #161513;
  background: var(--accent);
}

.branch-badge.wip {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.satellite-title {
  margin: 6px 0 2px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg-heading);
  letter-spacing: -0.015em;
  line-height: 1.25;
  transition: color 0.15s ease;
}

.satellite-card:hover .satellite-title {
  color: var(--fg);
}

.satellite-desc {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
}

.satellite-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s ease;
}

.satellite-card:hover .satellite-cta {
  color: var(--accent);
}

.tree-foot {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--muted);
}

/* Mobile & Tablet layout */
@media (max-width: 820px) {
  .satellites-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .hero-book-card {
    padding: 24px 22px;
  }

  .tree-shell {
    padding-top: 24px;
    padding-bottom: 24px;
  }
}
