/* ==========================================================================
   MENEMBUS DINDING YANG TAK KASAT MATA — DIGITAL BOOK READER STYLESHEET
   Engineered for Neurodiversity, Focus, and Aesthetic Reading Comfort
   ========================================================================== */

/* --- 1. CSS CUSTOM PROPERTIES & COLOR THEMES --- */
:root {
  /* Default: 🌿 Calm Sage (Soft Mint & Warm Alabaster) */
  --bg-base: #FAF8F5;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F2EFE9;
  --bg-subtle: #E8F0EB;
  --text-primary: #1C2E28;
  --text-secondary: #425A50;
  --text-muted: #6E887E;
  --accent-primary: #245E44;
  --accent-secondary: #3D8C68;
  --accent-hover: #17422F;
  --accent-subtle: #D8EADF;
  --border-color: #E2DDD5;
  --border-light: #ECE7DF;
  --shadow-sm: 0 2px 8px rgba(28, 46, 40, 0.05);
  --shadow-md: 0 6px 20px rgba(28, 46, 40, 0.08);
  --shadow-lg: 0 16px 36px rgba(28, 46, 40, 0.12);
  --ruler-bg: rgba(36, 94, 68, 0.08);
  --ruler-border: rgba(36, 94, 68, 0.4);

  /* Typography Stacks */
  --font-serif: "Lora", "Merriweather", Georgia, Cambria, serif;
  --font-sans: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-dyslexic: "OpenDyslexic", "Comic Sans MS", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", Menlo, Consolas, monospace;
  --font-current: var(--font-serif);

  /* Reading Ergonomics Defaults */
  --reader-font-size: 1.15rem;
  --reader-line-height: 1.85;
  --reader-letter-spacing: 0.01em;
  --reader-max-width: 740px;
  --sidebar-width: 330px;
}

/* ☀️ Warm Sand (Parchment & Warm Amber) */
[data-theme="sand"] {
  --bg-base: #F6F1E8;
  --bg-surface: #FDFBF7;
  --bg-elevated: #EDE5D6;
  --bg-subtle: #E8DFC8;
  --text-primary: #2C2216;
  --text-secondary: #584632;
  --text-muted: #826E56;
  --accent-primary: #8F5215;
  --accent-secondary: #B8732A;
  --accent-hover: #6E3B09;
  --accent-subtle: #EADBC4;
  --border-color: #E0D3BE;
  --border-light: #EBE1D0;
  --shadow-sm: 0 2px 8px rgba(44, 34, 22, 0.05);
  --shadow-md: 0 6px 20px rgba(44, 34, 22, 0.08);
  --shadow-lg: 0 16px 36px rgba(44, 34, 22, 0.12);
  --ruler-bg: rgba(143, 82, 21, 0.08);
  --ruler-border: rgba(143, 82, 21, 0.4);
}

/* 📜 Classic Sepia (Vintage Book Paper) */
[data-theme="sepia"] {
  --bg-base: #EFE6D5;
  --bg-surface: #F8F3EA;
  --bg-elevated: #E5DAC5;
  --bg-subtle: #DCD0B8;
  --text-primary: #2B2117;
  --text-secondary: #564230;
  --text-muted: #7E6750;
  --accent-primary: #6E4424;
  --accent-secondary: #96633D;
  --accent-hover: #4F2E14;
  --accent-subtle: #E2CCA8;
  --border-color: #D6C7AE;
  --border-light: #E2D6C0;
  --shadow-sm: 0 2px 8px rgba(43, 33, 23, 0.06);
  --shadow-md: 0 6px 20px rgba(43, 33, 23, 0.09);
  --shadow-lg: 0 16px 36px rgba(43, 33, 23, 0.13);
  --ruler-bg: rgba(110, 68, 36, 0.09);
  --ruler-border: rgba(110, 68, 36, 0.4);
}

/* 🌙 Midnight Slate (Soft Low-Contrast OLED Dark) */
[data-theme="dark"] {
  --bg-base: #131716;
  --bg-surface: #1B211F;
  --bg-elevated: #242D2A;
  --bg-subtle: #2C3733;
  --text-primary: #E5EDE9;
  --text-secondary: #B0C4BC;
  --text-muted: #7F998F;
  --accent-primary: #52B788;
  --accent-secondary: #74C69D;
  --accent-hover: #95D5B2;
  --accent-subtle: #213A2E;
  --border-color: #2D3934;
  --border-light: #374640;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.55);
  --ruler-bg: rgba(82, 183, 136, 0.12);
  --ruler-border: rgba(82, 183, 136, 0.5);
}

/* Font Family Selection */
[data-font="serif"] { --font-current: var(--font-serif); }
[data-font="sans"] { --font-current: var(--font-sans); }
[data-font="dyslexic"] { --font-current: var(--font-dyslexic); }
[data-font="mono"] { --font-current: var(--font-mono); }

/* Font Size Selection */
[data-size="small"] { --reader-font-size: 1.02rem; }
[data-size="normal"] { --reader-font-size: 1.15rem; }
[data-size="large"] { --reader-font-size: 1.3rem; }
[data-size="xlarge"] { --reader-font-size: 1.48rem; }

/* Line Spacing Selection */
[data-spacing="compact"] { --reader-line-height: 1.6; --reader-letter-spacing: 0; }
[data-spacing="normal"] { --reader-line-height: 1.85; --reader-letter-spacing: 0.01em; }
[data-spacing="relaxed"] { --reader-line-height: 2.15; --reader-letter-spacing: 0.025em; }

/* Reading Width Selection */
[data-width="narrow"] { --reader-max-width: 620px; }
[data-width="normal"] { --reader-max-width: 740px; }
[data-width="wide"] { --reader-max-width: 880px; }

/* --- 2. GLOBAL RESET & BASE STYLES --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
}

/* --- 3. READING PROGRESS & FOCUS RULER --- */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  z-index: 1100;
  pointer-events: none;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  transition: width 0.1s ease-out;
}

.focus-ruler {
  position: fixed;
  left: 0;
  right: 0;
  height: 48px;
  background-color: var(--ruler-bg);
  border-top: 2px solid var(--ruler-border);
  border-bottom: 2px solid var(--ruler-border);
  pointer-events: none;
  z-index: 950;
  transform: translateY(-50%);
  transition: opacity 0.2s ease;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
}

.focus-ruler.hidden {
  display: none !important;
}

/* --- 4. APP LAYOUT STRUCTURE --- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Sticky Navigation Bar */
.top-nav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 800;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-indicator {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.indicator-part {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.indicator-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

/* Icon Buttons & Action Buttons */
.btn-icon {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-icon:hover {
  background: var(--bg-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: translateY(0);
}

.btn-icon.active {
  background: var(--accent-primary);
  color: #FFFFFF;
  border-color: var(--accent-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s ease;
  border: none;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #FFFFFF !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: #FFFFFF !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-primary) !important;
  border: 1.5px solid var(--border-color);
}

.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary) !important;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* --- 5. SLIDE-OVER SIDEBAR / TABLE OF CONTENTS --- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 14, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 990;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(var(--sidebar-width), 88vw);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

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

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.book-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  background-color: var(--accent-subtle);
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.sidebar-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.sidebar-author {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.sidebar-search-box {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-base);
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-input {
  width: 100%;
  background: transparent;
  border: none;
  font-size: 0.92rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.sidebar-nav-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  list-style: none;
}

.sidebar-nav-list::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

.part-divider-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 16px 8px 6px 8px;
}

.toc-item {
  margin-bottom: 3px;
}

.toc-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.toc-link:hover {
  background-color: var(--bg-subtle);
  color: var(--accent-primary);
}

.toc-link.active {
  background-color: var(--accent-subtle);
  color: var(--accent-primary);
  font-weight: 700;
}

.toc-link-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toc-link-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.toc-link-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-link-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* --- 6. FLOATING PERSISTENT AUDIO PLAYER --- */
.audio-player-bar {
  position: sticky;
  top: 64px;
  left: 0;
  right: 0;
  background-color: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 750;
  font-size: 0.88rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.audio-player-bar.hidden {
  display: none !important;
}

.audio-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}

.audio-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.wave-bar {
  width: 3px;
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
  animation: wavePulse 1.2s infinite ease-in-out;
}

.wave-bar:nth-child(2) { animation-delay: 0.2s; }
.wave-bar:nth-child(3) { animation-delay: 0.4s; }

@keyframes wavePulse {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-speed {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

/* --- 7. MAIN READER VIEWPORT & ARTICLE TYPOGRAPHY --- */
.reader-container {
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding: 48px 24px 80px 24px;
  width: 100%;
  transition: max-width 0.25s ease;
}

.chapter-meta-header {
  margin-bottom: 36px;
}

.chapter-part-tag {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.28;
  margin-bottom: 12px;
  text-wrap: balance;
}

.chapter-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.chapter-stat-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.reader-article {
  font-family: var(--font-current);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  letter-spacing: var(--reader-letter-spacing);
  color: var(--text-primary);
  transition: font-size 0.2s ease, line-height 0.2s ease;
}

.reader-article p {
  margin-bottom: 1.5em;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.reader-article h2 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2.4em;
  margin-bottom: 0.8em;
  line-height: 1.35;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.reader-article h3 {
  font-family: var(--font-sans);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  line-height: 1.4;
}

.reader-article strong {
  font-weight: 700;
  color: var(--text-primary);
}

.reader-article em {
  font-style: italic;
}

/* Epigraph Styling */
.book-epigraph {
  margin: 32px 0 40px 0;
  padding: 22px 28px;
  background-color: var(--bg-surface);
  border-left: 4px solid var(--accent-primary);
  border-radius: 0 12px 12px 0;
  box-shadow: var(--shadow-sm);
}

.book-epigraph blockquote p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15em;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.epigraph-author {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}

/* Validation Box (Safe Space for Neurodivergent Readers) */
.book-validation-box {
  margin: 32px 0;
  padding: 22px 26px;
  background-color: var(--bg-subtle);
  border: 1.5px solid var(--accent-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.validation-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  margin-bottom: 10px;
  font-family: var(--font-sans);
}

.validation-content {
  font-size: 0.98em;
  line-height: 1.75;
  color: var(--text-primary);
}

/* Flow Diagrams */
.flow-diagram {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 32px 0;
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.flow-step {
  display: inline-flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  position: relative;
}

.flow-step:not(:last-child)::after {
  content: "➔";
  margin-left: 12px;
  color: var(--accent-primary);
  font-weight: 700;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 28px 0;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
}

.book-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
  line-height: 1.6;
}

.book-table th {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 700;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
}

.book-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.book-table tr:last-child td {
  border-bottom: none;
}

.table-caption {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
  text-align: center;
}

/* Lists */
.book-list {
  margin: 20px 0 24px 28px;
}

.book-list li {
  margin-bottom: 10px;
  padding-left: 6px;
}

.chapter-divider {
  border: none;
  text-align: center;
  margin: 40px auto;
}

.chapter-divider::before {
  content: "•  •  •";
  font-size: 1.1rem;
  color: var(--border-color);
  letter-spacing: 0.5em;
}

/* Citation Pills */
.citation-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--accent-primary);
  font-family: var(--font-sans);
  font-size: 0.78em;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  vertical-align: baseline;
  user-select: none;
}

.citation-pill:hover {
  background-color: var(--accent-subtle);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

/* Bionic Lead Syllable */
b.bionic-lead {
  font-weight: 700;
  color: var(--text-primary);
}

/* --- 8. BOTTOM CHAPTER NAVIGATION CARDS --- */
.chapter-nav-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border-color);
}

.nav-direction-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.nav-direction-btn:hover {
  border-color: var(--accent-primary);
  background-color: var(--bg-subtle);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.nav-direction-btn.next {
  justify-content: flex-end;
  text-align: right;
}

.direction-arrow {
  font-size: 1.4rem;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.direction-text {
  display: flex;
  flex-direction: column;
}

.dir-sub {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.dir-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* --- 9. OPEN ACCESS SUPPORT CARD --- */
.reader-support-card {
  margin-top: 48px;
  padding: 30px;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.support-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  background-color: var(--accent-subtle);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.support-heading {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.support-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 580px;
  margin: 0 auto 24px auto;
  line-height: 1.6;
}

.support-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Reader Footer */
.reader-footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.reader-footer a {
  color: var(--text-secondary);
}

.footer-sub {
  margin-top: 6px;
  font-size: 0.78rem;
}

/* --- 10. APPEARANCE SETTINGS DRAWER --- */
.settings-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 14, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.settings-drawer-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 90vw);
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  z-index: 1060;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

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

.settings-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setting-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.segmented-grid {
  display: grid;
  gap: 6px;
}

.grid-2x2 {
  grid-template-columns: 1fr 1fr;
}

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

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

.seg-btn {
  background: var(--bg-base);
  border: 1.5px solid var(--border-color);
  color: var(--text-secondary);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
}

.seg-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.seg-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #FFFFFF;
}

.toggle-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-color);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* --- 11. CITATION POPOVER MODAL --- */
.citation-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 14, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.citation-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.citation-modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 26px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.citation-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.citation-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  background: var(--accent-subtle);
  padding: 3px 8px;
  border-radius: 6px;
}

.citation-modal-body {
  font-size: 0.96rem;
  line-height: 1.65;
  color: var(--text-primary);
}

/* --- 12. TOAST NOTIFICATION --- */
.toast-notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- 13. HOMEPAGE / LANDING HERO STYLES --- */
.hero-wrapper {
  text-align: center;
  padding: 40px 0 60px 0;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-primary);
  background-color: var(--accent-subtle);
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 14px;
  text-wrap: balance;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto 20px auto;
  line-height: 1.5;
  text-wrap: balance;
}

.hero-author {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.hero-stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

.stat-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 50px;
}

.hero-quote-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 640px;
  margin: 0 auto 50px auto;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.hero-quote-card blockquote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.12rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* Home Section Titles */
.section-header-block {
  text-align: center;
  margin-bottom: 30px;
}

.section-tag {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 6px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Table of Contents Cards Grid */
.toc-grid {
  display: grid;
  gap: 24px;
  margin-bottom: 50px;
}

.part-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.part-card-header {
  padding: 16px 22px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.part-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.part-card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.part-chapter-list {
  list-style: none;
}

.part-chapter-item {
  border-bottom: 1px solid var(--border-light);
}

.part-chapter-item:last-child {
  border-bottom: none;
}

.part-chapter-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.15s ease;
}

.part-chapter-link:hover {
  background: var(--bg-subtle);
  color: var(--accent-primary);
  padding-left: 26px;
}

.part-chap-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.part-chap-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.part-chap-name {
  font-size: 0.98rem;
  font-weight: 600;
}

.part-chap-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.part-chap-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-base);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

/* --- 14. RESPONSIVE BREAKPOINTS --- */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.1rem;
  }
  .hero-subtitle {
    font-size: 1.1rem;
  }
  .chapter-title {
    font-size: 1.8rem;
  }
  .chapter-nav-footer {
    grid-template-columns: 1fr;
  }
  .nav-direction-btn.next {
    justify-content: space-between;
    text-align: left;
  }
  .indicator-title {
    max-width: 180px;
  }
  .btn-hide-mobile {
    display: none !important;
  }
}
