/* ==========================================================================
   LUMINA LIBROS — CORE DESIGN SYSTEM & STYLES (CONTINUOUS SCROLL & FLUID GESTURE)
   ========================================================================== */

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: #151e32;
  --bg-card-hover: #1c2742;
  --bg-glass: rgba(21, 30, 50, 0.85);
  
  --accent-primary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.35);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 30px var(--accent-glow);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-card-hover);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Container */
#app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ==========================================================================
   NAVBAR & RESPONSIVE SEARCH BAR
   ========================================================================== */

.app-header, .navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 1.25rem;
}

.header-container, .nav-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-wrap, .logo-area {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.logo-wrap:hover, .logo-area:hover {
  transform: scale(1.02);
}

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.logo-text {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.logo-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}

/* High-Visibility Search Box */
.search-box {
  flex: 1;
  max-width: 720px;
  min-width: 280px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1.15rem;
  color: #c7d2fe;
  font-size: 1.1rem;
  pointer-events: none;
  z-index: 2;
}

.search-box input {
  width: 100%;
  height: 52px;
  padding: 0 5rem 0 3.2rem;
  background: #151e32;
  border: 2px solid rgba(165, 180, 252, 0.32);
  border-radius: 18px;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-size: 1.05rem;
  font-weight: 500;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-normal);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.18);
}

.search-box input::placeholder {
  color: #8b9cb5;
  opacity: 0.9;
}

.search-box input:focus {
  border-color: var(--accent-primary);
  background: #1c2640;
  box-shadow: 0 0 20px var(--accent-glow), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-clear {
  position: absolute;
  right: 4.2rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background var(--transition-fast), color var(--transition-fast);
  z-index: 5;
}
.search-clear:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.search-shortcut {
  position: absolute;
  right: 0.8rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 6px;
  border-radius: 4px;
  pointer-events: none;
}

/* ==========================================================================
   LIVE SEARCH RESULTS DROPDOWN (JUSTO DEBAJO DEL BUSCADOR)
   ========================================================================== */
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: 420px;
  overflow-y: auto;
  background: rgba(17, 24, 39, 0.98);
  border: 1.5px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7), 0 0 25px rgba(99, 102, 241, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: fadeIn 0.2s ease;
}

.search-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.76rem;
  font-weight: 700;
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(15, 23, 42, 0.8);
}

.search-dropdown-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.2rem;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}
.search-dropdown-close:hover {
  color: #ffffff;
  transform: scale(1.15);
}

.search-dropdown-list {
  display: flex;
  flex-direction: column;
  padding: 0.4rem;
  gap: 0.35rem;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-result-item:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateX(3px);
}

.search-result-thumb {
  width: 40px;
  height: 58px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.search-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.search-result-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.search-result-author {
  font-size: 0.73rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-read-btn {
  background: var(--accent-gradient);
  border: none;
  color: white;
  padding: 0.35rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.search-result-read-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Buscador de libros: resultados grandes y legibles */
.search-results-dropdown {
  max-height: min(620px, 72vh);
  border-radius: 18px;
}

.search-dropdown-header {
  padding: 0.9rem 1.15rem;
  font-size: 0.86rem;
}

.search-dropdown-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
}

.search-dropdown-list {
  padding: 0.7rem;
  gap: 0.6rem;
}

.search-result-item {
  align-items: stretch;
  gap: 1rem;
  min-height: 108px;
  padding: 0.7rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.1);
}

.search-result-item:hover {
  transform: translateY(-2px);
}

.search-result-thumb {
  width: 64px;
  height: 92px;
  border-radius: 8px;
}

.search-result-info {
  justify-content: center;
  gap: 0.4rem;
}

.search-result-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  font-size: 1.05rem;
  line-height: 1.3;
}

.search-result-author {
  font-size: 0.88rem;
  color: #cbd5e1;
}

.search-result-read-btn {
  align-self: center;
  min-height: 44px;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.search-result-item:focus-visible,
.search-result-read-btn:focus-visible,
.search-dropdown-close:focus-visible,
.search-clear:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  border-color: #fbbf24;
}

@media (prefers-reduced-motion: reduce) {
  .search-results-dropdown,
  .search-result-item,
  .search-result-read-btn,
  .search-dropdown-close {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}

@media (max-height: 520px) {
  .search-results-dropdown { max-height: 58dvh; }
  .search-result-item { min-height: 88px; padding: 0.5rem; }
  .search-result-thumb { width: 52px; height: 76px; }
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

/* Icon-Only Buttons for Sleek Alignment */
.nav-btn.icon-only-nav-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
}

.nav-btn:hover, .nav-btn.icon-only-nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
}

.nav-btn.icon-only-nav-btn:active {
  transform: scale(0.92);
}

/* ==========================================================================
   MAIN CONTENT & SECTIONS
   ========================================================================== */

.main-content {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* HERO SECTION — MOBILE FIRST COLUMN LAYOUT */
.hero-section {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(135deg, #18223c 0%, #111827 100%);
  border: 1px solid var(--border-color);
  padding: 1.25rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  box-shadow: var(--shadow-md);
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(35px) brightness(0.18);
  opacity: 0.7;
  z-index: 1;
  pointer-events: none;
  transition: background-image 0.5s ease;
}

/* Cover at top, full width on mobile */
.hero-cover-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.hero-cover {
  width: 120px;
  height: 178px;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), 0 0 20px rgba(99, 102, 241, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.18);
  transition: transform var(--transition-normal);
  flex-shrink: 0;
}

.hero-cover:hover {
  transform: translateY(-4px) scale(1.03);
}

/* Content below cover */
.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.hero-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.2rem;
  letter-spacing: -0.3px;
  color: #ffffff;
}

.hero-author {
  font-size: 0.88rem;
  color: #a5b4fc;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.hero-overview {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  width: 100%;
}

.hero-buttons .btn {
  padding: 0.45rem 0.95rem;
  font-size: 0.83rem;
  flex: 0 0 auto;
}

/* Desktop: side by side */
@media (min-width: 641px) {
  .hero-section {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    gap: 2rem;
    min-height: 200px;
  }
  .hero-cover-wrap {
    width: auto;
    flex-shrink: 0;
  }
  .hero-cover {
    width: 130px;
    height: 195px;
  }
  .hero-content {
    flex: 1;
    max-width: 680px;
  }
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  font-family: inherit;
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-download {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.btn-download:hover {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  transform: translateY(-2px);
}

.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: 0.95rem;
}

/* GENRES SECTION (HORIZONTAL SLIDING) */
.genres-section {
  width: 100%;
  overflow-x: auto;
  padding: 0.25rem 0 0.5rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.genres-section::-webkit-scrollbar {
  display: none;
}

.genres-scroll-wrap, .genres-wrapper {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 0.55rem;
  width: max-content;
  padding: 2px;
}

.genre-chip {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
  background: rgba(21, 30, 50, 0.75);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.45rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.genre-chip:hover {
  background: rgba(30, 41, 59, 0.95);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
}

.genre-chip.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
}

/* OFFLINE PLUS NAVBAR BUTTON & PILL */
.offline-plus-nav-btn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 95, 70, 0.25) 100%) !important;
  border: 1.5px solid rgba(52, 211, 153, 0.4) !important;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2) !important;
}

.offline-plus-nav-btn:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(6, 95, 70, 0.4) 100%) !important;
  border-color: #34d399 !important;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35) !important;
}

.offline-plus-pill {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: #10b981;
  color: #042f2e;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 0.3rem;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* OFFLINE PLUS VAULT BANNER */
.offline-vault-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.offline-vault-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.offline-vault-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #34d399;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.offline-vault-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.2rem;
}

.offline-vault-info h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.15rem;
}

.offline-vault-info p {
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.35;
  margin: 0;
}

/* RECENT READS & DOWNLOADS (COMPACT HORIZONTAL SLIDER) */
.recent-section {
  width: 100%;
  margin-bottom: 0.5rem;
}

#continue-grid, #downloads-grid {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 0.85rem;
  overflow-x: auto !important;
  padding: 0.4rem 0 0.75rem !important;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#continue-grid::-webkit-scrollbar, #downloads-grid::-webkit-scrollbar {
  display: none;
}

#continue-grid .book-card, #downloads-grid .book-card {
  flex: 0 0 115px !important;
  width: 115px !important;
  min-width: 115px !important;
  max-width: 115px !important;
  position: relative;
}

#continue-grid .book-card-cover-wrap, #downloads-grid .book-card-cover-wrap {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
}

#continue-grid .book-card-title, #downloads-grid .book-card-title {
  font-size: 0.8rem !important;
  line-height: 1.25 !important;
}

#continue-grid .book-card-author, #downloads-grid .book-card-author {
  font-size: 0.72rem !important;
}

.recent-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 5;
  transition: all var(--transition-fast);
}

.recent-delete-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  transform: scale(1.1);
}

.btn-text-action {
  background: transparent;
  border: none;
  color: #a5b4fc;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-text-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.btn-text-action.danger {
  color: #f87171;
}

.btn-text-action.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* SECTION HEADERS */
.section-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.view-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* UNIFORM MEDIUM-SIZED BOOK GRID ACROSS THE WHOLE APP */
.books-grid, .book-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)) !important;
  gap: 0.85rem !important;
  width: 100% !important;
}

@media (max-width: 640px) {
  .books-grid, .book-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.65rem !important;
  }
}

/* UNIFORM MEDIUM-SIZED BOOK CARD */
.book-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: all var(--transition-smooth);
  cursor: pointer;
  position: relative;
  width: 100%;
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(99, 102, 241, 0.2);
}

.book-card-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #0d131f;
}

.book-card-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-smooth);
}
.book-card:hover .book-card-cover {
  transform: scale(1.04);
}

.book-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0) 60%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.6rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.book-card:hover .book-card-overlay {
  opacity: 1;
}

.quick-read-badge {
  background: var(--accent-primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.book-card-info {
  padding: 0.45rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.book-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card-author {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* PAGINATION / LOAD MORE */
.pagination-wrapper {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0;
}

.btn-load-more {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.85rem 2.2rem;
  border-radius: 50px;
  font-size: 0.95rem;
}
.btn-load-more:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* LOADING STATE */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   BOOK DETAIL MODAL
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 10;
}
.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.modal-body {
  padding: 2.5rem;
  display: flex;
  gap: 2rem;
}

.modal-cover-col {
  flex-shrink: 0;
}

.modal-cover-img {
  width: 220px;
  height: 330px;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.modal-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.genre-tag {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.modal-author {
  font-size: 1.05rem;
  color: #cbd5e1;
  font-weight: 500;
}

.modal-metadata {
  display: flex;
  gap: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0;
}

.modal-description-wrapper {
  margin: 0.5rem 0;
  max-height: 180px;
  overflow-y: auto;
}

.meta-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.modal-overview {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   FULLSCREEN CONTINUOUS FLUID SCROLL READER (EYE-COMFORT CREAM / NO CUTOFF)
   ========================================================================== */

.reader-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  user-select: none;
  transition: background 0.25s ease, color 0.25s ease;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.reader-container::-webkit-scrollbar {
  display: none !important;
}

/* TEMA CREMA / PAPEL CÁLIDO (FONDO CREMA, LETRAS NEGRAS - CERO FATIGA) */
.reader-theme-cream,
.reader-theme-sepia {
  background: #FAF6EE !important;
  color: #1A1D20 !important;
}

.reader-theme-cream .reader-toolbar,
.reader-theme-sepia .reader-toolbar {
  background: #F2ECE0 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
  color: #1A1D20 !important;
}

.reader-theme-cream .reader-btn,
.reader-theme-sepia .reader-btn,
.reader-theme-cream .reader-footer-nav,
.reader-theme-sepia .reader-footer-nav {
  background: rgba(0, 0, 0, 0.06) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #1A1D20 !important;
}

.reader-theme-cream .reader-btn:hover,
.reader-theme-sepia .reader-btn:hover,
.reader-theme-cream .reader-footer-nav:hover,
.reader-theme-sepia .reader-footer-nav:hover {
  background: rgba(0, 0, 0, 0.12) !important;
}

.reader-theme-cream .reader-footer,
.reader-theme-sepia .reader-footer {
  background: #F2ECE0 !important;
  border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
  color: #1A1D20 !important;
}

.reader-theme-cream .toc-drawer,
.reader-theme-sepia .toc-drawer {
  background: #F4EEE2 !important;
  border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #1A1D20 !important;
}

.reader-theme-cream .toc-item:hover,
.reader-theme-sepia .toc-item:hover {
  background: rgba(0, 0, 0, 0.06) !important;
}

/* TEMA OSCURO */
.reader-theme-dark {
  background: #121824 !important;
  color: #e2e8f0 !important;
}
.reader-theme-dark .reader-toolbar,
.reader-theme-dark .reader-footer {
  background: #0f141f !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #e2e8f0 !important;
}

/* TEMA AMOLED */
.reader-theme-amoled {
  background: #000000 !important;
  color: #d1d5db !important;
}
.reader-theme-amoled .reader-toolbar,
.reader-theme-amoled .reader-footer {
  background: #0a0a0a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #d1d5db !important;
}

/* TEMA BLANCO PURO */
.reader-theme-light {
  background: #ffffff !important;
  color: #111827 !important;
}
.reader-theme-light .reader-toolbar,
.reader-theme-light .reader-footer {
  background: #f3f4f6 !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #111827 !important;
}

/* Reader Top Toolbar — 100% Fit, zero horizontal overflow */
.reader-toolbar {
  height: 50px;
  padding: 0 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
  z-index: 30;
  flex-shrink: 0;
  gap: 0.35rem;
  overflow: visible;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.reader-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.reader-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.reader-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.reader-btn.icon-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.reader-btn.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  transform: translateY(-1px);
}

.reader-btn.icon-btn:active {
  transform: scale(0.92);
}

.reader-title-wrap,
.reader-book-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0 0.35rem;
  overflow: hidden;
}

.reader-book-title {
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.reader-chapter-title {
  font-size: 0.7rem;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Settings Popover */
.dropdown-wrapper {
  position: relative;
}

.settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  width: 260px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  z-index: 50;
  color: #f8fafc;
}

.popover-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.popover-section label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
}

.font-family-options {
  display: flex;
  gap: 0.35rem;
}

.font-opt {
  flex: 1;
  padding: 0.4rem;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}
.font-opt.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.font-size-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
}

.font-size-controls button {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.theme-opt {
  height: 34px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
}
.theme-opt.cream, .theme-opt.sepia { background: #FAF6EE; border: 1px solid #D6CEBE; }
.theme-opt.dark { background: #121824; }
.theme-opt.amoled { background: #000000; }
.theme-opt.light { background: #ffffff; border: 1px solid #E2E8F0; }
.theme-opt.active { border-color: var(--accent-primary) !important; box-shadow: 0 0 8px var(--accent-primary); }

/* TOC Drawer */
.toc-drawer {
  position: absolute;
  top: 48px;
  bottom: 44px;
  left: 0;
  width: 300px;
  max-width: 85vw;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 40;
  display: flex;
  flex-direction: column;
  animation: slideRight 0.25s ease;
}

.toc-header {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-header button {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.toc-item {
  padding: 0.7rem 1.1rem;
  font-size: 0.82rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.toc-item.active {
  border-left-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.15);
  font-weight: 700;
}

/* ==========================================================================
   AUDIOBOOK / TTS NATURAL VOICE FLOATING PLAYER
   ========================================================================== */

.tts-highlight-btn {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%) !important;
  border-color: rgba(99, 102, 241, 0.4) !important;
  color: #a5b4fc !important;
}
.tts-highlight-btn:hover {
  background: var(--accent-gradient) !important;
  color: white !important;
}

.tts-player-bar {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 620px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border: 1.5px solid rgba(99, 102, 241, 0.4);
  border-radius: 50px;
  padding: 0.35rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.25);
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  color: #ffffff;
}

.tts-player-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Sound Wave Animation */
.tts-wave-animation {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  padding: 0 2px;
}
.tts-wave-animation span {
  width: 3px;
  height: 4px;
  background: #6366f1;
  border-radius: 2px;
  transition: height 0.2s ease;
}
.tts-wave-animation.playing span {
  animation: soundwave 1s infinite ease-in-out;
}
.tts-wave-animation.playing span:nth-child(1) { animation-delay: 0.1s; }
.tts-wave-animation.playing span:nth-child(2) { animation-delay: 0.2s; }
.tts-wave-animation.playing span:nth-child(3) { animation-delay: 0.3s; }
.tts-wave-animation.playing span:nth-child(4) { animation-delay: 0.4s; }

@keyframes soundwave {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

.tts-voice-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
}
.tts-voice-wrap select {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.75rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  max-width: 125px;
}
.tts-voice-wrap select option {
  background: #1e293b;
  color: #ffffff;
}

.tts-player-center {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tts-ctrl-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}
.tts-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.tts-ctrl-btn.play-btn {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  font-size: 0.9rem;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.tts-ctrl-btn.play-btn:hover {
  transform: scale(1.06);
}

.tts-speed-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #a5b4fc;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 20px;
  cursor: pointer;
}

.tts-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.2rem;
  display: flex;
}
.tts-close-btn:hover {
  color: #ffffff;
}

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -15px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================================
   READER STAGE & TOUCH SLIDING CANVAS
   ========================================================================== */

.reader-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden !important;
  width: 100vw;
  height: calc(100% - 92px);
  padding: 0;
  margin: 0;
}

/* EPUB Viewer Area */
.epub-viewer-area {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  position: relative;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.epub-viewer-area::-webkit-scrollbar {
  display: none !important;
}

.epub-viewer-area iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  box-sizing: border-box !important;
}

/* Con la barra de narración activa, el área de lectura baja para que la
   barra flotante NO tape las primeras líneas del texto. */
.reader-container.tts-active .epub-viewer-area {
  padding-top: 60px !important;
}

.reader-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: inherit;
  z-index: 25;
}

.reader-loading-overlay .reader-loading-bar {
  width: min(260px, 70vw);
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-top: 0.25rem;
}

.reader-loading-overlay .reader-loading-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-gradient);
  transition: width 0.2s ease;
}

/* Reader Bottom Toolbar (Left: Anterior, Center: Slider, Right: Siguiente) */
.bottom-toolbar {
  height: 52px;
  padding: 0 0.85rem env(safe-area-inset-bottom, 0.4rem);
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
  z-index: 30;
  flex-shrink: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.reader-theme-cream .bottom-toolbar,
.reader-theme-sepia .bottom-toolbar {
  background: #F2ECE0 !important;
  border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
  color: #1A1D20 !important;
}

.reader-nav-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.reader-theme-cream .reader-nav-btn,
.reader-theme-sepia .reader-nav-btn {
  background: rgba(0, 0, 0, 0.06) !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  color: #1A1D20 !important;
}

.reader-nav-btn:active {
  transform: scale(0.94);
  background: var(--accent-primary) !important;
  color: white !important;
}

.progress-center-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
}

.progress-center-wrap input[type=range] {
  width: 100%;
  max-width: 320px;
  height: 4px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.progress-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.8;
}

#reader-save-bookmark-btn {
  transition: all var(--transition-fast);
}

#reader-save-bookmark-btn.saved-active {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #cbd5e1 !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6) !important;
  animation: bookmarkPulse 0.35s ease;
}

#reader-save-bookmark-btn.saved-active i {
  color: #e2e8f0 !important;
}

.reader-theme-cream #reader-save-bookmark-btn.saved-active,
.reader-theme-sepia #reader-save-bookmark-btn.saved-active {
  background: #334155 !important;
  border-color: #1e293b !important;
  color: #f8fafc !important;
}

@keyframes bookmarkPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 3000;
  font-size: 0.9rem;
  animation: slideUp 0.3s ease;
}

.toast-icon {
  color: #34d399;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideRight {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* ==========================================================================
   MOBILE RESPONSIVE TWEAKS (EXPANDED DEDICATED SEARCH BAR)
   ========================================================================== */

@media (max-width: 640px) {
  .app-header, .navbar {
    padding: 0.5rem 0.75rem;
  }

  .header-container, .nav-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
  }

  .logo-wrap, .logo-area {
    order: 1;
    flex-shrink: 0;
  }

  /* Nav actions — compact row of circular icon buttons */
  .nav-actions {
    order: 2;
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-shrink: 0;
    overflow: visible;
  }

  .nav-btn.icon-only-nav-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 0.95rem;
  }

  /* Buscador móvil grande: una fila completa y resultados legibles */
  .search-box {
    order: 3;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-top: 0.45rem;
  }

  .search-box input {
    height: 56px;
    padding: 0 3.6rem 0 3.15rem !important;
    font-size: 16px !important;
    font-weight: 600;
    background: #151e32 !important;
    border: 2px solid rgba(165, 180, 252, 0.38) !important;
    border-radius: 16px;
    color: #ffffff !important;
  }

  .search-box input::placeholder {
    color: #b6c2d7;
    opacity: 1;
  }

  .search-icon {
    left: 1.05rem;
    font-size: 1.1rem;
  }

  .search-clear {
    right: 0.55rem !important;
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }

  .search-shortcut {
    display: none !important;
  }

  .search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    width: 100%;
    max-height: min(68dvh, 560px);
    border-radius: 18px;
  }

  .search-dropdown-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0.9rem 1rem;
    font-size: 0.9rem;
  }

  .search-result-item {
    min-height: 116px;
    gap: 0.85rem;
    padding: 0.75rem;
  }

  .search-result-thumb {
    width: 68px;
    height: 100px;
  }

  .search-result-title {
    font-size: 1.08rem;
  }

  .search-result-author {
    font-size: 0.9rem;
  }

  .search-result-read-btn {
    min-width: 72px;
  }

  .btn-text {
    display: none !important;
  }

  .reader-toolbar {
    height: 48px;
    padding: 0 0.4rem;
    gap: 0.25rem;
  }

  .reader-btn.icon-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 0.88rem;
    padding: 0;
  }

  .reader-book-title {
    font-size: 0.76rem;
  }

  .reader-chapter-title {
    font-size: 0.65rem;
  }

  .tts-player-bar {
    width: 96%;
    padding: 0.3rem 0.5rem;
    top: 52px;
  }
}

/* ===========================================================================
   AI SCENE ILLUSTRATION MODAL
   ========================================================================== */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(12px);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-modal-card {
  background: #151d2f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(99, 102, 241, 0.25);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(21, 29, 47, 0.9);
}

.ai-modal-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.ai-modal-title i {
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.ai-modal-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.ai-modal-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.ai-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-image-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0f1523;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.ai-generated-img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: var(--radius-md);
  transition: transform 0.3s ease;
}

.ai-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  color: #a5b4fc;
  text-align: center;
}

.ai-loader .spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366F1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.ai-scene-quote {
  font-size: 0.85rem;
  font-style: italic;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent-primary);
  padding: 0.6rem 0.85rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.5;
}

.ai-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(21, 29, 47, 0.9);
}

/* OFFLINE DOWNLOADS BADGE & SECTION */
.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.offline-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
  z-index: 5;
  transition: all var(--transition-fast);
}

.offline-delete-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Layout móvil definitivo: acciones arriba, búsqueda debajo a ancho completo */
@media (max-width: 640px) {
  .header-container {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    align-items: center;
    width: 100%;
    gap: 0.55rem 0.65rem;
  }

  .logo-wrap {
    grid-column: 1;
    grid-row: 1;
    order: initial;
    min-width: 0;
  }

  .home-users-count {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .nav-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    order: initial;
    width: 100%;
    justify-content: flex-start;
  }

  .search-box {
    grid-column: 1 / -1;
    grid-row: 3;
    order: initial;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  .search-results-dropdown {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: min(68dvh, 620px);
  }

  .search-result-title {
    display: block;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    -webkit-line-clamp: unset;
  }

  .search-result-read-btn {
    width: 48px;
    min-width: 48px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .search-result-read-btn i {
    font-size: 1.05rem;
  }
}

@media (max-width: 480px) {
  .hero-cover {
    width: 140px;
    height: 210px;
    transform: none !important;
  }
  .hero-title {
    font-size: 1.6rem;
  }
  .hero-buttons {
    justify-content: center;
  }
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
  }
}

/* ==========================================================================
   MODAL DE DETALLE EN MÓVIL — LAYOUT VERTICAL TIPO PÓSTER
   Carátula arriba → descripción → botones. Todo cabe en pantalla sin cortes,
   adaptándose como una sola imagen (unidades vh + clamps).
   ========================================================================== */
@media (max-width: 520px) {
  .modal-overlay {
    padding: 0.7rem;
    align-items: center;
  }
  .modal-card {
    max-height: calc(100dvh - 1.4rem);
    height: auto;
    overflow: hidden;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
  }
  .modal-close-btn {
    top: 0.4rem !important;
    right: 0.4rem !important;
    width: 30px !important;
    height: 30px !important;
  }
  .modal-body {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    padding: 0.7rem 0.9rem 0.85rem !important;
    gap: 0.45rem !important;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .modal-cover-col {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 100%;
    /* ligeramente más arriba: menos margen superior */
    margin-top: -0.15rem;
  }
  .modal-cover-img {
    width: auto !important;
    height: clamp(88px, 18vh, 150px) !important;
    aspect-ratio: 2 / 3;
    border-radius: 10px;
  }
  .modal-info-col {
    gap: 0.22rem !important;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: 0;
  }
  .modal-title {
    font-size: 1.05rem !important;
    line-height: 1.2;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .modal-author {
    font-size: 0.8rem !important;
    color: #a5b4fc;
  }
  .modal-genres {
    gap: 0.25rem !important;
    justify-content: center;
  }
  .genre-tag {
    font-size: 0.62rem;
    padding: 2px 6px;
  }
  .modal-metadata {
    font-size: 0.66rem !important;
    gap: 0.5rem !important;
    margin: 0.05rem 0 !important;
    justify-content: center !important;
    flex-wrap: wrap;
  }
  .modal-metadata .meta-tag {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45vw;
  }
  .meta-heading {
    font-size: 0.72rem;
    margin-bottom: 0.1rem;
  }
  /* Fix: la app usa .modal-overview-wrap (el CSS viejo apuntaba a .modal-description-wrapper) */
  .modal-description-wrapper, .modal-overview-wrap {
    max-height: none !important;
    overflow: hidden !important;
    margin: 0.1rem 0 0.35rem !important;
    width: 100%;
  }
  .modal-overview {
    font-size: 0.76rem !important;
    line-height: 1.4 !important;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .modal-actions {
    flex-direction: row !important;
    gap: 0.4rem !important;
    margin-top: auto !important;
    padding-top: 0.5rem !important;
    justify-content: stretch !important;
    flex-shrink: 0;
    width: 100%;
  }
  .modal-actions .btn {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.4rem !important;
    font-size: 0.78rem !important;
    white-space: nowrap;
  }
}

.brightness-controls{display:flex;align-items:center;gap:.65rem;color:#fbbf24}.brightness-controls input{flex:1;accent-color:#6366f1}.home-users-count{display:inline-flex;align-items:center;gap:.38rem;padding:.42rem .7rem;border-radius:999px;background:rgba(16,185,129,.14);border:1px solid rgba(52,211,153,.42);color:#6ee7b7;font-size:.8rem;font-weight:800;white-space:nowrap}.home-users-count small{color:#a7f3d0;font-size:.68rem;font-weight:600}.presence-dot{width:7px;height:7px;border-radius:50%;background:#34d399;box-shadow:0 0 0 3px rgba(52,211,153,.16),0 0 10px #34d399}
