/* ===================================================================
   O LIVRO DOS ESPÍRITOS & MIRAMEZ - DESIGN SYSTEM & MOBILE STYLES
   Estética Espiritual, Moderna, Acolhedora e Sofisticada
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700;800&family=Inter:wght@300;400;500;600;700&family=Literata:ital,opsz,wght@0,7..72,300;0,7..72,400;0,7..72,500;0,7..72,600;1,7..72,400&display=swap');

/* --- THEME TOKENS --- */
:root {
  /* Common metrics */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-max-width: 460px;
  --header-height: 60px;
  --bottom-bar-height: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition-fast: 0.18s ease;
  --transition-med: 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Font Families */
  --font-title: 'Cinzel', serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-reading: 'Literata', Georgia, serif;

  /* Default Theme: Noite Serena (Cosmic Dark) */
  --bg-page: #060911;
  --bg-phone: #0b111e;
  --bg-surface: #131c2e;
  --bg-surface-elevated: #1a253c;
  --bg-glass: rgba(19, 28, 46, 0.82);
  --border-subtle: rgba(212, 175, 55, 0.14);
  --border-active: rgba(212, 175, 55, 0.45);
  
  --text-primary: #f0f4fc;
  --text-secondary: #a8bcd8;
  --text-muted: #7284a0;
  --text-gold: #e6be65;

  --accent-gold: #e5b955;
  --accent-gold-glow: rgba(229, 185, 85, 0.25);
  --accent-kardec: #8bb3e0;
  --accent-kardec-bg: rgba(139, 179, 224, 0.12);
  --accent-miramez: #c8b7e0;
  --accent-miramez-bg: rgba(200, 183, 224, 0.12);
  --accent-amethyst: #c8b7e0;
  --accent-success: #34d399;
  --accent-danger: #f87171;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 4px 20px rgba(229, 185, 85, 0.2);

  /* Reader font sizing default */
  --reader-font-size: 17.5px;
  --reader-line-height: 1.75;
}

/* Theme: Luz Espiritual (Warm Light) */
[data-theme="light"] {
  --bg-page: #ebe7df;
  --bg-phone: #fcfbf9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f4f1ea;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-subtle: rgba(160, 120, 40, 0.15);
  --border-active: rgba(180, 130, 30, 0.5);

  --text-primary: #1f2733;
  --text-secondary: #576579;
  --text-muted: #8a97a8;
  --text-gold: #996e14;

  --accent-gold: #b38018;
  --accent-gold-glow: rgba(179, 128, 24, 0.18);
  --accent-kardec: #2c5282;
  --accent-kardec-bg: rgba(44, 82, 130, 0.08);
  --accent-miramez: #6b4d8c;
  --accent-miramez-bg: rgba(107, 77, 140, 0.08);
  --accent-amethyst: #6b4d8c;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.09);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);
  --shadow-gold: 0 4px 18px rgba(179, 128, 24, 0.15);
}

/* Theme: Pergaminho Histórico (Sepia Classic) */
[data-theme="sepia"] {
  --bg-page: #d6ccba;
  --bg-phone: #f4ecd8;
  --bg-surface: #ede3cb;
  --bg-surface-elevated: #e4d8bd;
  --bg-glass: rgba(244, 236, 216, 0.9);
  --border-subtle: rgba(120, 80, 30, 0.16);
  --border-active: rgba(140, 90, 30, 0.45);

  --text-primary: #332314;
  --text-secondary: #634b35;
  --text-muted: #8c7358;
  --text-gold: #8c5715;

  --accent-gold: #965b18;
  --accent-gold-glow: rgba(150, 91, 24, 0.18);
  --accent-kardec: #2b5078;
  --accent-kardec-bg: rgba(43, 80, 120, 0.09);
  --accent-miramez: #7c3a20;
  --accent-miramez-bg: rgba(124, 58, 32, 0.09);
  --accent-amethyst: #7c3a20;

  --shadow-sm: 0 2px 8px rgba(60, 40, 20, 0.08);
  --shadow-md: 0 8px 20px rgba(60, 40, 20, 0.12);
  --shadow-lg: 0 16px 36px rgba(60, 40, 20, 0.18);
  --shadow-gold: 0 4px 18px rgba(150, 91, 24, 0.15);
}

/* Font Family setting */
[data-font="sans"] {
  --font-reading: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- RESET & GLOBAL BASE --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-ui);
  overflow: hidden;
  user-select: text;
  -webkit-font-smoothing: antialiased;
}

/* --- DESKTOP WRAPPER (Interactive Phone Frame) --- */
.app-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(circle at 50% 30%, rgba(26, 37, 60, 0.6) 0%, var(--bg-page) 80%);
}

/* --- APPLICATION CONTAINER --- */
.app-container,
.phone-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-phone);
  overflow: hidden;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .app-container,
  .phone-container {
    max-width: 860px;
    height: 100vh;
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.45);
  }
}

/* Bespoke Vector Icon Classes (Replaces cartoon emojis) */
.header-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  display: block;
}

.tab-svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  flex-shrink: 0;
  display: inline-block;
}

.btn-svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  display: inline-block;
  vertical-align: middle;
}

.nav-svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  display: block;
}

.screen-title-svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent-gold);
  flex-shrink: 0;
  display: inline-block;
}

.card-title-svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent-gold);
  flex-shrink: 0;
  display: inline-block;
}

.special-link-svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent-gold);
  flex-shrink: 0;
  display: inline-block;
}

.tts-ctrl-svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* --- APP HEADER --- */
.app-header {
  height: calc(var(--header-height) + var(--safe-top));
  min-height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 14px;
  padding-right: 14px;
  position: relative;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-gold);
  border: 1px solid var(--border-active);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.header-logo:hover {
  transform: scale(1.05);
}

.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-title-box {
  display: flex;
  flex-direction: column;
}

.header-app-name {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent-gold);
  line-height: 1.15;
}

.header-sub-name {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition-fast);
}

.icon-btn:hover, .icon-btn:focus-visible {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  color: var(--accent-gold);
}

.icon-btn.active {
  background: var(--accent-gold-glow);
  border-color: var(--border-active);
  color: var(--accent-gold);
}

/* Screen Isolation: Reader-only controls are hidden when on other screens */
.app-container:not([data-screen="reader"]) .jump-banner,
.app-container:not([data-screen="reader"]) .view-tabs-bar,
.phone-container:not([data-screen="reader"]) .jump-banner,
.phone-container:not([data-screen="reader"]) .view-tabs-bar {
  display: none !important;
}

/* --- QUESTION QUICK JUMP BAR --- */
.jump-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  z-index: 90;
}

.jump-trigger-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-gold);
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition-fast);
}

.jump-trigger-btn:hover {
  border-color: var(--accent-gold);
  background: var(--accent-gold-glow);
}

.progress-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
}

.progress-indicator:hover {
  background: rgba(212, 163, 89, 0.08);
  color: var(--text-primary);
}

.progress-indicator b {
  color: var(--text-primary);
}

.progress-pct {
  color: var(--accent-gold);
  font-weight: 600;
  font-size: 11px;
}

.progress-mini-bar {
  width: 75px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

[data-theme="light"] .progress-mini-bar {
  background: rgba(0, 0, 0, 0.08);
}

.progress-mini-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6c5ce7, var(--accent-gold));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* --- DUAL VIEW TABS (Kardec / Miramez / Ambos) --- */
.view-tabs-bar {
  display: flex;
  padding: 8px 14px;
  background: var(--bg-phone);
  border-bottom: 1px solid var(--border-subtle);
  gap: 6px;
  z-index: 80;
}

.view-tab {
  flex: 1;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.view-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.view-tab.active {
  background: var(--bg-surface-elevated);
  border-color: var(--border-active);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.view-tab.active[data-view="kardec"] {
  border-color: rgba(139, 179, 224, 0.45);
  color: var(--accent-kardec);
}
.view-tab.active[data-view="miramez"] {
  border-color: rgba(184, 165, 212, 0.45);
  color: var(--accent-miramez);
}
.view-tab.active[data-view="both"] {
  border-color: rgba(229, 185, 85, 0.45);
  color: var(--accent-gold);
}

/* --- FLOATING AUDIO TTS BAR --- */
.tts-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(26, 37, 60, 0.95), rgba(19, 28, 46, 0.95));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--accent-gold);
  font-size: 12.5px;
  color: var(--text-primary);
  z-index: 85;
  box-shadow: var(--shadow-gold);
  animation: slideDown 0.25s ease-out;
}

[data-theme="light"] .tts-bar {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 240, 230, 0.96));
}

[data-theme="sepia"] .tts-bar {
  background: linear-gradient(135deg, rgba(244, 236, 216, 0.96), rgba(230, 220, 195, 0.96));
}

.tts-bar.active {
  display: flex;
}

.tts-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

.tts-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.tts-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-tts-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition-fast);
}

.btn-tts-action:hover {
  background: var(--accent-gold);
  color: #000;
}

.btn-tts-action.btn-tts-play {
  background: var(--accent-gold);
  color: #000;
  width: 36px;
  height: 36px;
}

.tts-speed-selector {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-gold);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

/* --- MAIN CONTENT AREA (PAGES CONTAINER) --- */
.app-content {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding-bottom: calc(var(--bottom-bar-height) + 20px);
}

/* Section screens */
.app-screen {
  display: none;
  min-height: 100%;
  padding: 16px;
  animation: fadeIn 0.22s ease-out;
}

.app-screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- QUESTION READER CARD --- */
.reader-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 680px;
  margin: 0 auto;
}

/* Hierarchy Breadcrumb */
.hierarchy-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hierarchy-part {
  font-family: var(--font-title);
  font-size: 12px;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.hierarchy-chapter {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.hierarchy-section {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hierarchy-section::before {
  content: "•";
  color: var(--accent-gold);
}

/* Floating Navigation Arrows on Reader */
.nav-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 10px 0;
}

.nav-arrow-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-arrow-btn:hover:not(:disabled) {
  border-color: var(--border-active);
  background: var(--bg-surface-elevated);
  transform: translateY(-1px);
}

.nav-arrow-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Question Action Toolbar (Favorite, Note, Listen, Share) */
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: -4px;
}

.btn-tool {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-tool:hover {
  color: var(--accent-gold);
  border-color: var(--border-active);
  background: var(--bg-surface-elevated);
}

.btn-tool.favorited {
  color: #fbbf24;
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}

/* --- KARDEC SECTION CARD --- */
.kardec-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.kardec-card::before {
  display: none;
}

.card-author-header {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: inline-block;
}

.card-author-header.miramez {
  color: var(--text-muted);
}

.question-number-tag {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-gold);
  display: inline-block;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.question-title-text {
  font-family: var(--font-reading);
  font-size: calc(var(--reader-font-size) * 1.06);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.55;
  margin-bottom: 14px;
}

.spirits-answer-box {
  background: transparent;
  border-radius: 0;
  padding: 4px 0 16px 0;
  margin-bottom: 10px;
  border: none;
  font-family: var(--font-reading);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
  font-style: italic;
  text-align: left;
}

.subquestion-block {
  margin-top: 16px;
  margin-bottom: 8px;
}

.subquestion-q {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  font-family: var(--font-reading);
  font-size: var(--reader-font-size);
  line-height: 1.55;
}

.kardec-note-box {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: 18px 0 4px 0;
  margin-top: 20px;
}

.kardec-note-header {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kardec-note-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kardec-note-p {
  font-family: var(--font-reading);
  font-size: calc(var(--reader-font-size) * 0.95);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
  opacity: 0.95;
  text-indent: 0;
  text-align: left;
  margin: 0;
}

.kardec-note-p + .kardec-note-p {
  margin-top: 12px;
  text-indent: 0;
}

/* --- MIRAMEZ SECTION CARD --- */
.miramez-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.miramez-card::before {
  display: none;
}

.miramez-author-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  padding: 0;
  border: none;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 12px;
  color: var(--accent-miramez);
}

[data-theme="light"] .miramez-author-badge {
  color: var(--accent-miramez);
}
[data-theme="sepia"] .miramez-author-badge {
  color: var(--accent-miramez);
}

.miramez-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.miramez-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-gold);
  margin-bottom: 16px;
  line-height: 1.35;
}

.miramez-body {
  font-family: var(--font-reading);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.miramez-body p {
  text-indent: 1.2em;
}

.miramez-body p:first-of-type {
  text-indent: 0;
}

/* Highlight for TTS playback */
.tts-highlight {
  background: rgba(229, 185, 85, 0.28);
  border-radius: 4px;
  transition: background 0.2s ease;
}

/* User Note on Card */
.user-note-display {
  background: var(--bg-surface-elevated);
  border-left: 3px solid #fbbf24;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 13.5px;
}

.user-note-title {
  font-size: 11px;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* --- BOTTOM NAVIGATION BAR --- */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--bottom-bar-height);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  gap: 4px;
  padding: 6px 2px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.nav-item .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.nav-item:hover {
  color: var(--text-primary);
}

.nav-item.active {
  color: var(--accent-gold);
}

.nav-item.active .nav-icon {
  transform: translateY(-2px);
}

.nav-item.active .nav-svg {
  stroke: var(--accent-gold);
}

/* --- TABLE OF CONTENTS (SUMÁRIO SCREEN) --- */
.toc-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 680px;
  margin: 0 auto;
}

.screen-title {
  font-family: var(--font-title);
  font-size: 22px;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.screen-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.toc-special-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.special-link-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-fast);
}

.special-link-card:hover {
  border-color: var(--border-active);
  background: var(--bg-surface-elevated);
  transform: translateY(-1px);
}

.special-link-icon {
  font-size: 22px;
  color: var(--accent-gold);
}

.special-link-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.special-link-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- ACCORDION PARTS & CHAPTERS (SUMÁRIO) --- */
#tocListContainer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toc-part-accordion {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.toc-part-accordion:hover {
  border-color: rgba(212, 163, 89, 0.3);
}

.toc-part-accordion.expanded {
  border-color: var(--border-active);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.toc-part-header {
  padding: 14px 16px;
  background: var(--bg-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  user-select: none;
  transition: background var(--transition-fast);
}

.toc-part-header:hover {
  background: var(--bg-surface-elevated);
}

.toc-part-accordion.expanded .toc-part-header {
  border-bottom-color: var(--border-subtle);
  background: linear-gradient(180deg, var(--bg-surface-elevated), var(--bg-surface));
}

.toc-part-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toc-part-badge {
  background: var(--accent-gold-glow);
  border: 1px solid var(--border-active);
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.toc-part-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-part-title {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
  margin: 0;
}

.toc-part-range {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.toc-chevron {
  font-size: 15px;
  color: var(--accent-gold);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-part-accordion.expanded .toc-chevron {
  transform: rotate(180deg);
}

.toc-chapters-list {
  display: none;
  padding: 12px;
  background: rgba(0, 0, 0, 0.15);
  flex-direction: column;
  gap: 10px;
}

[data-theme="light"] .toc-chapters-list {
  background: rgba(0, 0, 0, 0.03);
}

.toc-part-accordion.expanded .toc-chapters-list {
  display: flex;
}

.toc-chapter-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition-fast);
}

.toc-chapter-item:hover {
  border-color: var(--border-active);
}

.toc-chapter-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toc-chapter-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.toc-ch-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(212, 163, 89, 0.12);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.toc-ch-title-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.toc-range-badge {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.toc-range-badge:hover {
  background: var(--accent-gold);
  color: #0d1117;
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.toc-btn-arrow {
  font-size: 9px;
}

.toc-sections-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .toc-sections-list {
  border-top-color: rgba(0, 0, 0, 0.05);
}

.toc-sec-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.toc-sec-chip:hover {
  background: var(--bg-surface);
  border-color: var(--accent-gold);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toc-sec-dot {
  font-size: 8px;
  color: var(--accent-gold);
}

.toc-sec-name {
  font-size: 11.5px;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.2;
}

.toc-sec-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(212, 163, 89, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

/* --- SEARCH SCREEN --- */
.search-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 680px;
  margin: 0 auto;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.search-input {
  width: 100%;
  padding: 14px 18px;
  padding-left: 46px;
  padding-right: 44px;
  font-size: 15px;
  font-family: var(--font-ui);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  outline: none;
  transition: all 0.22s ease;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-glow), var(--shadow-md);
  background: var(--bg-surface-elevated);
}

.search-input::placeholder {
  color: var(--text-muted);
  font-size: 13.5px;
}

.search-icon-inside {
  position: absolute;
  left: 18px;
  color: var(--text-gold);
  font-size: 16px;
  pointer-events: none;
  opacity: 0.85;
}

.search-clear-btn {
  position: absolute;
  right: 14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.search-clear-btn:hover {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
}

.search-clear-btn.visible {
  display: flex;
}

.search-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 12px 18px 12px;
  margin: -2px -12px -8px -12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.search-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.filter-chip:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.filter-chip.active {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
  color: #0b111e;
  border-color: var(--accent-gold);
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(229, 185, 85, 0.35);
}

.filter-chip[data-filter="kardec"].active {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 3px 12px rgba(59, 130, 246, 0.4);
}

.filter-chip[data-filter="miramez"].active {
  background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
  color: #ffffff;
  border-color: #c084fc;
  box-shadow: 0 3px 12px rgba(168, 85, 247, 0.4);
}

/* --- SEARCH EMPTY STATE --- */
.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 16px 24px 16px;
  animation: fadeIn 0.3s ease;
}

.search-empty-orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-gold-glow) 0%, rgba(229, 185, 85, 0.04) 70%);
  border: 1px solid rgba(229, 185, 85, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 0 24px rgba(229, 185, 85, 0.15);
}

.search-empty-icon {
  font-size: 28px;
}

.search-empty-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 8px;
  letter-spacing: 0.4px;
}

.search-empty-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 360px;
  margin-bottom: 24px;
}

.search-suggestions-container {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}

.search-suggestions-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-gold);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.search-suggestions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.search-suggest-chip {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.search-suggest-chip:hover {
  background: var(--accent-gold-glow);
  border-color: var(--accent-gold);
  color: var(--text-gold);
  transform: translateY(-1px);
}

/* --- SEARCH NO RESULTS --- */
.search-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 18px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  animation: fadeIn 0.25s ease;
}

.search-no-results-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.search-no-results-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.search-no-results-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* --- SEARCH RESULTS SUMMARY BAR --- */
.search-results-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 10px 4px;
}

.search-counter-box {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-counter-icon {
  color: var(--accent-gold);
  font-size: 14px;
}

.search-counter-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.search-counter-text b {
  color: var(--text-primary);
}

.search-active-filter-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-gold);
}

/* --- SEARCH RESULTS LIST & CARDS --- */
.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.search-result-card {
  background: linear-gradient(145deg, rgba(22, 33, 54, 0.88) 0%, rgba(13, 20, 35, 0.94) 100%);
  border: 1px solid rgba(212, 175, 55, 0.16);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-result-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent-gold) 0%, var(--accent-miramez) 100%);
}

.search-result-card:hover {
  border-color: rgba(212, 175, 55, 0.45);
  background: linear-gradient(145deg, rgba(26, 40, 66, 0.92) 0%, rgba(16, 25, 44, 0.98) 100%);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 20px rgba(229, 185, 85, 0.12);
}

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

.result-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-card-badges-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.result-q-badge {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-gold);
  background: rgba(229, 185, 85, 0.12);
  border: 1px solid rgba(229, 185, 85, 0.28);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  letter-spacing: 0.4px;
}

.result-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2.5px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.result-tag.tag-kardec {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.28);
}

.result-tag.tag-miramez {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.28);
}

.result-card-arrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-fast);
}

.search-result-card:hover .result-card-arrow {
  color: var(--accent-gold);
  transform: translateX(3px);
}

.result-card-title {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-gold);
  line-height: 1.4;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.result-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.meta-dot {
  color: rgba(212, 175, 55, 0.4);
  font-size: 10px;
}

.meta-part {
  color: var(--text-secondary);
}

.result-quote-box {
  background: rgba(8, 13, 23, 0.65);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-gold);
  padding: 10px 14px;
  position: relative;
}

.result-quote-text {
  font-family: var(--font-reading);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-primary);
  font-style: italic;
  margin: 0;
}

.search-highlight {
  background: rgba(229, 185, 85, 0.35);
  color: #ffffff;
  font-weight: 700;
  border-bottom: 2px solid var(--accent-gold);
  border-radius: 3px;
  padding: 1px 3px;
}

/* --- THEMATIC INDEX (TEMAS SCREEN) --- */
.thematic-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 680px;
  margin: 0 auto;
}

.alpha-scroller {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0;
  scrollbar-width: none;
}

.alpha-scroller::-webkit-scrollbar {
  display: none;
}

.alpha-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.alpha-btn:hover, .alpha-btn.active {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
}

.theme-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.theme-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-gold);
  margin-bottom: 4px;
}

.theme-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.theme-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.theme-q-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.theme-q-btn:hover {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
}

/* --- FAVORITES & STUDIES SCREEN --- */
.study-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 680px;
  margin: 0 auto;
}

.study-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-gold);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- MODALS & DIALOGS --- */
.modal-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-height: 88%;
  background: var(--bg-phone);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  border-top: 1px solid var(--border-active);
  padding: 20px 20px calc(20px + var(--safe-bottom)) 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-gold);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* Quick Jump Modal Controls */
.jump-input-row {
  display: flex;
  gap: 10px;
}

.jump-number-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--accent-gold);
}

.btn-primary {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--accent-gold);
  color: #000;
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-primary:hover {
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.jump-range-slider {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  outline: none;
  -webkit-appearance: none;
  accent-color: var(--accent-gold);
}

.quick-parts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.btn-part-quick {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-part-quick:hover {
  border-color: var(--border-active);
  background: var(--bg-surface-elevated);
}

/* Settings Controls (Themes, Fonts, Size) */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-options-row, .font-options-row {
  display: flex;
  gap: 8px;
}

.theme-btn, .font-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
}

.theme-btn.active, .font-btn.active {
  border-color: var(--accent-gold);
  color: var(--text-gold);
  background: var(--accent-gold-glow);
}

.size-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px 12px;
}

.size-btn {
  width: 38px;
  height: 38px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.size-value-display {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-gold);
}

/* Share modal & preview */
.share-tab-selector {
  display: flex;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 3px;
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.share-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  white-space: nowrap;
}

.share-tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--accent-gold);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-active);
}

.share-quote-card {
  background: linear-gradient(145deg, var(--bg-surface-elevated), var(--bg-surface));
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-gold);
  font-family: var(--font-reading);
  max-height: 240px;
  overflow-y: auto;
}

.share-preview-header {
  font-family: var(--font-title);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.share-preview-q {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.45;
}

.share-preview-body {
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.55;
  color: var(--text-primary);
  opacity: 0.95;
  margin-bottom: 8px;
}

.share-preview-footer {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  text-align: right;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 6px;
  margin-top: 6px;
}

.share-actions-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-share-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-glow));
  color: #0b111e;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(212, 163, 89, 0.25);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-share-main:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(212, 163, 89, 0.35);
}

.btn-share-main:active {
  transform: translateY(1px);
}



/* Toast notifications */
.toast-notice {
  position: absolute;
  bottom: calc(var(--bottom-bar-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(19, 28, 46, 0.94);
  color: #fff;
  border: 1px solid var(--accent-gold);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

/* Extra Texts Reader Modal */
.extra-content-body {
  font-family: var(--font-reading);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.extra-content-body h2 {
  font-family: var(--font-title);
  font-size: 18px;
  color: var(--accent-gold);
  margin-top: 10px;
}

.authors-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.author-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.author-avatar {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--accent-gold);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author-info h3 {
  font-family: var(--font-title);
  font-size: 15px;
  color: var(--accent-gold);
  margin-bottom: 2px;
}

.author-info p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Scrollbar polish */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.25);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* ==========================================================================
   ENHANCED MODULAR UI STYLES (READER, THEMATIC, STUDY, HISTORICAL MODAL)
   ========================================================================== */

/* --- READER REFINEMENTS --- */
.subquestion-letter {
  display: inline-block;
  font-weight: 700;
  color: var(--accent-gold);
  margin-right: 6px;
}

.reading-p {
  margin-bottom: 14px;
  font-family: var(--font-reading);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
}

.miramez-header-card {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.miramez-chapter-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-miramez);
  line-height: 1.35;
  margin: 0 0 6px 0;
  letter-spacing: 0.5px;
}

.miramez-subtitle {
  font-family: var(--font-reading);
  font-size: 13.5px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.4;
}

.miramez-body-text {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.miramez-p {
  font-family: var(--font-reading);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
  text-indent: 0;
  text-align: left;
  margin: 0;
}

.miramez-footer-seal {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.seal-vine {
  font-size: 20px;
}

.seal-text {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* --- THEMATIC INDEX INTEGRAL --- */
.thematic-filter-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 6px;
  transition: var(--transition-fast);
}

.thematic-filter-box:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px var(--accent-gold-glow);
}

.thematic-filter-icon {
  font-size: 14px;
  color: var(--text-muted);
}

.thematic-filter-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
}

.thematic-filter-input::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

.thematic-filter-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  display: none;
}

.thematic-filter-clear.active {
  display: block;
}

.thematic-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 10px 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

.thematic-stats-text {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.alpha-scroller {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 10px 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.alpha-scroller::-webkit-scrollbar {
  display: none;
}

.alpha-letter-btn {
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.alpha-letter-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transform: translateY(-1px);
}

.alpha-letter-btn.active {
  background: linear-gradient(135deg, var(--accent-gold), #b88628);
  color: #0d1117;
  border-color: var(--accent-gold);
  box-shadow: 0 2px 10px rgba(212, 163, 89, 0.4);
  transform: scale(1.08);
}

.thematic-term-card {
  background: var(--bg-surface);
  border: 1px solid rgba(212, 163, 89, 0.18);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.thematic-term-card:hover {
  border-color: var(--border-active);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.thematic-term-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(212, 163, 89, 0.15);
  padding-bottom: 8px;
}

.thematic-term-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thematic-term-name {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.6px;
  margin: 0;
}

.thematic-ref-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

[data-theme="light"] .thematic-ref-badge {
  background: rgba(0, 0, 0, 0.04);
}

.thematic-sub-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.thematic-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background var(--transition-fast);
}

.thematic-sub-row.clickable-row {
  cursor: pointer;
}

.thematic-sub-row:hover {
  background: rgba(212, 163, 89, 0.06);
}

.thematic-sub-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.thematic-sub-dot {
  font-size: 9px;
  color: var(--accent-gold);
  flex-shrink: 0;
  transform: translateY(-1px);
}

.thematic-sub-text {
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.thematic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.q-chip {
  background: linear-gradient(135deg, rgba(212, 163, 89, 0.12), rgba(212, 163, 89, 0.04));
  border: 1px solid rgba(212, 163, 89, 0.3);
  color: var(--accent-gold);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.q-chip:hover {
  background: var(--accent-gold);
  color: #0d1117;
  border-color: var(--accent-gold);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(212, 163, 89, 0.4);
}

.q-chip-ref {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* --- STUDY SCREEN --- */
.study-progress-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.study-card-header-title {
  font-family: var(--font-title);
  font-size: 14.5px;
  color: var(--accent-gold);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.study-parts-progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.part-progress-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.part-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.part-progress-name {
  color: var(--text-primary);
  font-weight: 500;
}

.part-progress-count {
  color: var(--text-secondary);
  font-size: 11px;
}

.part-progress-count b {
  color: var(--accent-gold);
}

.part-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

[data-theme="light"] .part-progress-track {
  background: rgba(0, 0, 0, 0.08);
}

.part-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6c5ce7, var(--accent-gold));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.study-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.study-chip:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.study-card-row {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition-fast);
}

.study-card-row:hover {
  border-color: var(--border-active);
  background: var(--bg-surface-elevated);
}

.study-q-badge {
  background: var(--accent-gold-glow);
  color: var(--accent-gold);
  border: 1px solid var(--border-active);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

.study-title-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-remove-fav {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.btn-remove-fav:hover {
  color: #ef4444;
}

.study-note-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.study-note-card:hover {
  border-color: var(--border-active);
  background: var(--bg-surface-elevated);
}

.study-note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.btn-edit-note {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.study-note-content {
  font-family: var(--font-reading);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-primary);
  font-style: italic;
}

/* --- HISTORICAL TEXTS MODAL --- */
.extra-text-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.extra-h2 {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 4px;
}

.extra-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.extra-nav-scroller {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}

.extra-nav-chip {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.extra-nav-chip:hover, .extra-nav-chip.active {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
}

.extra-sec-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 12px;
}

.extra-prose {
  font-family: var(--font-reading);
  font-size: var(--reader-font-size);
  line-height: 1.7;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.extra-modal-p {
  text-indent: 1.4em;
  margin: 0;
}

.prolegomenos-cepa-box {
  background: var(--accent-gold-glow);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-bottom: 18px;
}

.cepa-emblem-wrap {
  width: 90px;
  height: 90px;
  margin: 0 auto 12px auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-active);
}

.cepa-emblem-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.author-profile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}

.author-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.author-avatar-img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-gold);
}

.author-avatar-placeholder {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent-gold-glow);
  border: 2px solid var(--accent-gold);
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}

.author-card-name {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-gold);
}

.author-card-dates {
  font-size: 12px;
  color: var(--text-muted);
}

.author-card-bio {
  font-family: var(--font-reading);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
}

