*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #1a1814;
  --sidebar-bg: #211f1b;
  --text: #d9cfc0;
  --text-muted: #8a7f6e;
  --accent: #c8a96e;
  --accent-dim: #9a7d4f;
  --border: #352f25;
  --blockquote-bg: #252118;
  --wisdom-bg: #1e1c17;
  --chapter-active: #c8a96e;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Lato', sans-serif;
  font-size: 16px;
}

#root {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: 20rem;
  min-width: 16rem;
  max-width: 22rem;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 1.2rem;
  gap: 1.4rem;
  flex-shrink: 0;
}

#portrait-frame {
  text-align: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

#capybara-art {
  width: 80%;
  max-width: 160px;
  margin: 0 auto 0.6rem;
}

#george-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

#portrait-label {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--accent);
  letter-spacing: 0.03em;
}

#portrait-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.5;
}

#portrait-sub em {
  font-style: italic;
  color: var(--accent-dim);
}

/* ── Nav ── */
#chapter-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-heading {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.nav-link {
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  display: block;
}

.nav-link:hover {
  background: rgba(200, 169, 110, 0.1);
  color: var(--text);
}

.nav-link.active {
  background: rgba(200, 169, 110, 0.15);
  color: var(--accent);
}

/* ── Stats ── */
#george-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.stat-val {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 700;
}

/* ── Main content ── */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Book header ── */
#book-header {
  text-align: center;
  padding: 2rem 3rem 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.book-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

#book-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.book-subtitle {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.book-divider {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  color: var(--accent-dim);
  font-size: 0.7rem;
  opacity: 0.6;
}

/* ── Chapters container ── */
#chapters-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.chapter {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 2rem 3rem 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.chapter.active {
  opacity: 1;
  pointer-events: auto;
}

.chapter-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 1.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.chapter-body p {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 1.1rem;
}

.chapter-body .drop-cap::first-letter {
  font-family: 'Playfair Display', serif;
  font-size: 3.4em;
  float: left;
  line-height: 0.75;
  margin: 0.05em 0.08em 0 0;
  color: var(--accent);
}

blockquote {
  background: var(--blockquote-bg);
  border-left: 3px solid var(--accent-dim);
  margin: 1.4rem 0;
  padding: 1rem 1.4rem;
  border-radius: 0 6px 6px 0;
}

blockquote p,
blockquote {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #b8a88a;
}

cite {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  font-style: normal;
  color: var(--text-muted);
  font-family: 'Lato', sans-serif;
}

/* ── Routine grid ── */
.routine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: 1.2rem 0;
}

.routine-item {
  background: var(--blockquote-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  text-align: center;
}

.routine-time {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.3rem;
  font-weight: 700;
}

.routine-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Wisdom panel ── */
.wisdom-panel {
  background: var(--wisdom-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  margin-top: 1.4rem;
}

.wisdom-heading {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.8rem;
  font-style: italic;
}

.wisdom-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wisdom-list li {
  font-size: 0.85rem;
  color: var(--text);
  padding-left: 1.2rem;
  position: relative;
  line-height: 1.5;
}

.wisdom-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent-dim);
}

/* ── Final seal ── */
.final-seal {
  text-align: center;
  font-size: 3rem;
  margin-top: 2rem;
  opacity: 0.7;
}

/* ── Navigation buttons ── */
#chapter-nav-btns {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 3rem;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

#chapter-nav-btns button {
  background: rgba(200, 169, 110, 0.12);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'Lato', sans-serif;
}

#chapter-nav-btns button:hover:not(:disabled) {
  background: rgba(200, 169, 110, 0.22);
}

#chapter-nav-btns button:disabled {
  opacity: 0.3;
  cursor: default;
}

#chapter-indicator {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Scrollbar styling ── */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  #sidebar {
    display: none;
  }
  .chapter {
    padding: 1.2rem 1.4rem;
  }
  #book-header {
    padding: 1.2rem 1.4rem 0.8rem;
  }
  .routine-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  #chapter-nav-btns {
    padding: 0.8rem 1.2rem;
  }
}
