.reader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,5,20,0.95);
  backdrop-filter: blur(8px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.reader-overlay.active { opacity: 1; pointer-events: all; }
.reader-modal {
  background: #0a1220;
  border: 1px solid rgba(1,219,254,0.2);
  border-radius: 14px;
  width: 100%;
  max-width: 960px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
}
.reader-overlay.active .reader-modal { transform: translateY(0) scale(1); }
.reader-modal.fullscreen { max-width: 100%; max-height: 100%; border-radius: 0; border: none; }
.reader-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #060e1e;
  border-bottom: 1px solid rgba(1,219,254,0.1);
  flex-shrink: 0;
}
.reader-book-info { flex: 1; min-width: 0; }
.reader-book-title { font-size: 0.85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-book-author { font-size: 0.65rem; color: rgba(186,185,186,0.5); }
.reader-fmt-badge { font-size: 0.6rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; letter-spacing: 0.06em; }
.reader-fmt-badge.pdf { background: rgba(254,204,9,0.2); color: #fecc09; border: 1px solid rgba(254,204,9,0.3); }
.reader-fmt-badge.epub { background: rgba(1,219,254,0.15); color: #01dbfe; border: 1px solid rgba(1,219,254,0.25); }
.reader-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.reader-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  padding: 6px 10px;
  color: rgba(186,185,186,0.8);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
  min-height: 36px;
}
.reader-btn svg { width: 14px; height: 14px; }
.reader-btn:hover { background: rgba(1,219,254,0.12); border-color: rgba(1,219,254,0.3); color: #01dbfe; }
.reader-btn.primary { background: rgba(0,77,145,0.6); border-color: rgba(0,77,145,0.8); color: #fff; }
.reader-btn.primary:hover { background: #004d91; }
.reader-btn.close-btn:hover { background: rgba(149,26,54,0.2); border-color: rgba(149,26,54,0.4); color: #ff7090; }

.epub-settings-bar {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: #070f1e;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.epub-settings-bar.visible { display: flex; }
.epub-setting { display: flex; align-items: center; gap: 6px; }
.epub-setting label { font-size: 0.65rem; font-weight: 600; color: rgba(186,185,186,0.5); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.epub-setting select, .epub-setting input[type=range] {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #fff;
  font-size: 0.75rem;
  font-family: 'DM Sans', sans-serif;
  padding: 4px 8px;
  outline: none;
}
.epub-setting input[type=range] { width: 80px; padding: 0; background: transparent; accent-color: #01dbfe; }

.reader-content {
  flex: 1;
  overflow: auto;
  position: relative;
  min-height: 0;
  background: #1a1a2e;
  -webkit-overflow-scrolling: touch;
}
.reader-pdf-frame { width: 100%; height: 100%; min-height: 500px; border: none; display: block; background: #1a1a2e; }
.reader-epub-wrap { width: 100%; height: 100%; min-height: 500px; overflow: auto; position: relative; background: #fff; }
.reader-epub-wrap.dark { background: #1a1a2a; }
.reader-epub-wrap.sepia { background: #f4e8c1; }
#epubViewer { width: 100%; height: 100%; }
#epubViewer iframe { border: none; width: 100%; height: 100%; }

.epub-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(10,18,32,0.85);
  border: 1px solid rgba(1,219,254,0.2);
  border-radius: 8px;
  width: 36px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #01dbfe;
  transition: all 0.2s;
  backdrop-filter: blur(6px);
}
.epub-nav:hover { background: rgba(1,219,254,0.15); }
.epub-nav svg { width: 16px; height: 16px; }
.epub-prev { left: 6px; }
.epub-next { right: 6px; }

.reader-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #0a1220;
  z-index: 5;
}
.reader-loading .spinner { width: 32px; height: 32px; border: 3px solid rgba(1,219,254,0.2); border-top-color: #01dbfe; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reader-loading p { font-size: 0.8rem; color: rgba(186,185,186,0.6); }
.reader-error { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px; text-align: center; }
.reader-error.visible { display: flex; }
.reader-error svg { width: 40px; height: 40px; color: rgba(186,185,186,0.3); }
.reader-error p { font-size: 0.85rem; color: rgba(186,185,186,0.5); }

@media (max-width: 768px) {
  .reader-modal { max-height: 98vh; border-radius: 10px; }
  .reader-topbar { padding: 8px 12px; gap: 6px; }
  .reader-btn span { display: none; } /* ocultar texto en móvil, solo icono */
  .reader-btn { padding: 6px 8px; min-height: 40px; }
  .epub-settings-bar { gap: 8px; justify-content: center; }
  .epub-setting { flex-wrap: wrap; }
  .epub-nav { width: 32px; height: 44px; }
  .reader-pdf-frame, .reader-epub-wrap { min-height: 400px; }
}
