/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ==================================================
   * COLOR PRINCIPAL: Naranja Conocimiento #f97316
   * Estadísticas: color #1 en apps de contenido/lectura,
   * presente en 38% de portadas de bestsellers,
   * máxima asociación con «sabiduría» y «calidez».
   * ================================================== */
  --bg: #0c0900;           /* negro cálido — no frío */
  --surface: #15100a;      /* oscuro cálido */
  --surface2: #1f1710;     /* marrón muy oscuro */
  --border: #352512;       /* borde ámbar oscuro */
  --accent: #f97316;       /* NARANJA CONOCIMIENTO ← color principal */
  --accent2: #a855f7;      /* violeta complementario */
  --accent3: #22d3ee;      /* cyan para highlights */
  --accent-add: #10b981;   /* verde esmeralda */
  --grad-brand: linear-gradient(135deg, #f97316 0%, #a855f7 100%);
  --grad-add: linear-gradient(135deg, #10b981 0%, #0891b2 100%);
  --text: #fef0dc;         /* blanco cálido */
  --text-muted: #8a7055;   /* muted cálido */
  --danger: #ef4444;
  --success: #10b981;
  --radius: 14px;
  --shadow: 0 4px 28px rgba(0,0,0,0.65);
}

html, body {
  min-height: 100%;
  background: radial-gradient(ellipse 90% 40% at 50% -5%, rgba(249,115,22,0.12) 0%, var(--bg) 55%);
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Vista biblioteca ocupa toda la pantalla */
#vista-biblioteca {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ===== HEADER ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12,9,0,0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}

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

.logo { font-size: 1.6rem; }

header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 560px;
  margin-left: auto;
}

#buscador {
  flex: 1;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
#buscador:focus { border-color: var(--accent); }
#buscador::placeholder { color: var(--text-muted); }

#btn-actualizar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
#btn-actualizar:hover { background: var(--accent2); }
#btn-actualizar:active { transform: scale(0.97); }

.icono-refresh { font-size: 1.1rem; display: inline-block; transition: transform 0.5s; }
.girando { animation: girar 0.7s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ===== MAIN ===== */
main {
  flex: 1;
  padding: 28px 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ===== ESTADO VACÍO ===== */
.estado-vacio {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 2;
}
.estado-vacio strong { color: var(--accent2); }

/* ===== GRID DE LIBROS ===== */
.grid-libros {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* ===== TARJETA DE LIBRO ===== */
.libro-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.libro-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 6px 28px rgba(249,115,22,0.22);
}

.libro-portada {
  width: 58px;
  height: 78px;
  aspect-ratio: unset;
  flex-shrink: 0;
  background: linear-gradient(145deg, var(--surface2), #2a1a08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  border: 1px solid var(--border);
  overflow: hidden;
}

.libro-portada img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

/* Cuerpo de la tarjeta (columna derecha) */
.card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.libro-nombre {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.libro-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Barra de progreso en tarjeta */
.progreso-barra {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progreso-fill-card {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progreso-texto {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
}

/* Badge "nuevo" */
.badge-nuevo {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}

/* ===== LECTOR ===== */
#vista-lector {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #111118;
}

.lector-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

#btn-volver {
  padding: 6px 14px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
#btn-volver:hover { background: var(--border); }

.lector-titulo {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent2);
}

.lector-nav, .lector-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lector-nav button, .lector-zoom button {
  width: 32px;
  height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lector-nav button:hover, .lector-zoom button:hover { background: var(--accent); border-color: var(--accent); }
.lector-nav button:disabled { opacity: 0.35; cursor: default; }
.lector-nav button:disabled:hover { background: var(--surface2); border-color: var(--border); }

#lector-pagina, #nivel-zoom {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 64px;
  text-align: center;
}

#lector-contenedor {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  background: #0a0a0f;
}

#pdf-canvas {
  box-shadow: var(--shadow);
  border-radius: 4px;
  max-width: 100%;
  display: block;
}

#barra-progreso-lector {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}
#progreso-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.3s ease;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 9999;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== UTILIDADES ===== */
.oculto { display: none !important; }

/* ===== MARCADORES ===== */
.lector-marcadores-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

#btn-marcar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
#btn-marcar:hover { background: #2e2840; border-color: var(--accent); }
#btn-marcar.marcado {
  background: #2e2840;
  border-color: var(--accent);
  color: var(--accent2);
}

#btn-ver-marcadores {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
#btn-ver-marcadores:hover { background: #2e2840; border-color: var(--accent); color: var(--accent2); }

/* Panel lateral de marcadores */
.panel-marcadores {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
  animation: slideIn 0.22s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

#vista-lector { position: relative; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--accent2);
  flex-shrink: 0;
}
#btn-cerrar-panel {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}
#btn-cerrar-panel:hover { background: var(--surface2); color: var(--text); }

#lista-marcadores {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 10px 0;
}
#lista-marcadores li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.13s;
  border-bottom: 1px solid var(--border);
}
#lista-marcadores li:hover { background: var(--surface2); }
#lista-marcadores li.activo { background: #1e1a30; border-left: 3px solid var(--accent); }

.marcador-info { flex: 1; }
.marcador-pagina {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent2);
}
.marcador-fecha {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.btn-borrar-marcador {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.13s, color 0.13s;
  flex-shrink: 0;
}
.btn-borrar-marcador:hover { background: var(--danger); color: #fff; }

.panel-vacio {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.8;
}

/* Indicador de marcador en tarjeta de biblioteca */
.marcador-card {
  font-size: 0.72rem;
  color: var(--accent2);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== CHIP DE USUARIO ===== */
.chip-usuario {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.chip-usuario:hover { border-color: var(--accent); background: #1e1a30; color: var(--accent2); }

.chip-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--grad-brand);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ===== MODAL DE USUARIO ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.oculto { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 42px 36px 36px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.6);
  animation: popIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-logo { font-size: 3rem; line-height: 1; }

.modal-box h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.modal-box p#modal-subtitulo {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: -6px;
}

.modal-input {
  width: 100%;
  padding: 11px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  letter-spacing: 0.02em;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: var(--text-muted); font-weight: 400; }

.modal-btn {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 4px;
}
.modal-btn:hover { background: var(--accent2); }
.modal-btn:active { transform: scale(0.98); }
.modal-btn:disabled { opacity: 0.4; cursor: default; }

/* ===== BOTÓN VISTA TEMAS ===== */
#btn-vista-temas {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
#btn-vista-temas:hover { border-color: var(--accent); color: var(--accent2); }
#btn-vista-temas.activo {
  background: rgba(124,106,247,0.18);
  border-color: var(--accent);
  color: var(--accent2);
}

/* ===== ETIQUETA DE TEMA EN TARJETA ===== */
.libro-tema-tag {
  display: inline-block;
  background: rgba(124,106,247,0.14);
  color: var(--accent2);
  border: 1px solid rgba(124,106,247,0.3);
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Botón asignar tema (se muestra al hacer hover en la tarjeta) */
.btn-asignar-tema {
  position: absolute;
  bottom: 9px;
  right: 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 0.72rem;
  padding: 3px 7px;
  cursor: pointer;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 2;
}
.libro-card:hover .btn-asignar-tema { opacity: 1; }
.btn-asignar-tema:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== TABS DE TEMAS ===== */
.tabs-temas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 22px;
}

.tab-tema {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.12s;
}
.tab-tema:hover {
  border-color: var(--accent);
  color: var(--accent2);
  background: rgba(124,106,247,0.08);
}
.tab-tema.activo {
  background: rgba(124,106,247,0.22);
  border-color: var(--accent);
  color: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(124,106,247,0.25);
}

.tab-nombre { line-height: 1; }

.tab-count {
  background: rgba(124,106,247,0.18);
  color: var(--accent2);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
  transition: background 0.18s, color 0.18s;
}
.tab-tema.activo .tab-count {
  background: var(--accent);
  color: #fff;
}

/* ===== MODAL DE TEMAS ===== */
.modal-tema-box {
  max-width: 420px !important;
  gap: 12px !important;
}

.modal-tema-libro-nombre {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: -4px;
}

.tema-chips-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 32px;
  width: 100%;
}

.tema-chip {
  padding: 6px 15px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tema-chip:hover { border-color: var(--accent); color: var(--accent2); background: rgba(124,106,247,0.1); }
.tema-chip.activo { background: rgba(124,106,247,0.22); border-color: var(--accent); color: var(--accent2); }

.tema-chips-vacio {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  width: 100%;
}

.modal-tema-nuevo {
  display: flex;
  gap: 8px;
  width: 100%;
}
.modal-tema-nuevo input {
  flex: 1;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.modal-tema-nuevo input:focus { border-color: var(--accent); }
.modal-tema-nuevo input::placeholder { color: var(--text-muted); }

#btn-crear-tema {
  padding: 9px 15px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
#btn-crear-tema:hover { background: var(--accent2); }

.modal-tema-acciones {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: flex-end;
}

.btn-sm {
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.btn-sm:hover { background: var(--border); }
.btn-danger-sm { background: rgba(248,113,113,0.1); border-color: var(--danger); color: var(--danger); }
.btn-danger-sm:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ===== RESPONSIVE ===== */

/* --- Tablet (640px – 1023px) --- */
@media (min-width: 640px) {
  .header-actions { max-width: 520px; }
  .grid-libros { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
}

/* --- Desktop (1024px+) --- */
@media (min-width: 1024px) {
  header { padding: 14px 40px; }
  .header-actions { max-width: 600px; }
  main { padding: 32px 40px; max-width: 1500px; }
  .grid-libros { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
  .tabs-temas { gap: 10px; padding-bottom: 26px; }
  .tab-tema { padding: 10px 20px; font-size: 0.9rem; }
}

/* --- Large Desktop (1440px+) --- */
@media (min-width: 1440px) {
  header { padding: 16px 56px; }
  .header-actions { max-width: 720px; }
  main { padding: 36px 56px; max-width: 1700px; }
  .grid-libros { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
  .libro-nombre { font-size: 0.92rem; }
  .libro-portada { font-size: 4rem; }
}

/* --- Extra Large (1920px+) --- */
@media (min-width: 1920px) {
  header { padding: 18px 80px; }
  .header-actions { max-width: 900px; }
  main { padding: 40px 80px; max-width: 1920px; }
  .grid-libros { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
  header h1 { font-size: 1.5rem; }
  .logo { font-size: 1.9rem; }
  .libro-nombre { font-size: 0.95rem; }
  .libro-portada { font-size: 4.5rem; }
}

/* --- Mobile (< 640px) --- */
@media (max-width: 639px) {
  header { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .header-actions { max-width: 100%; width: 100%; flex-wrap: wrap; }
  #buscador { min-width: 0; }
  main { padding: 16px; }
  .grid-libros { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .tabs-temas { gap: 6px; padding-bottom: 16px; }
  .tab-tema { padding: 7px 13px; font-size: 0.82rem; }
  .lector-toolbar { gap: 8px; padding: 8px 12px; }
  .lector-titulo { font-size: 0.8rem; }
  .panel-marcadores { width: 100%; }
  .modal-box { padding: 32px 20px 28px; margin: 0 16px; }
  .btn-asignar-tema { opacity: 1; }
  .seccion-nav { padding: 10px 16px; gap: 6px; }
  .seccion-tab { padding: 8px 14px; font-size: 0.82rem; }
}

/* ===== NAVEGACIÓN DE SECCIONES ===== */
.seccion-nav {
  display: flex;
  gap: 8px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.seccion-nav::-webkit-scrollbar { display: none; }

.seccion-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s;
  letter-spacing: 0.01em;
}
.seccion-tab:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(249, 115, 22, 0.1);
}
.seccion-tab.activo {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 18px rgba(249, 115, 22, 0.45);
}
.seccion-badge {
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.9);
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
}
.seccion-tab:not(.activo) .seccion-badge {
  background: var(--surface2);
  color: var(--text-muted);
}

/* ===== BOTÓN AGREGAR / QUITAR EN TARJETA ===== */
.btn-biblioteca {
  width: 100%;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  margin-top: 2px;
}
.btn-agregar {
  border: none;
  background: var(--grad-add);
  color: #fff;
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.35);
}
.btn-agregar:hover { filter: brightness(1.15); transform: translateY(-1px); }

.btn-en-lista {
  border: 1px solid rgba(16,185,129,0.4);
  background: rgba(16,185,129,0.1);
  color: var(--success);
}
.btn-en-lista:hover {
  background: rgba(244,63,94,0.12);
  border-color: rgba(244,63,94,0.4);
  color: var(--danger);
}

.btn-quitar {
  border: 1px solid rgba(244,63,94,0.3);
  background: rgba(244,63,94,0.08);
  color: var(--danger);
}
.btn-quitar:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ===== ESTADO VACÍO PERSONAL ===== */
.estado-vacio-personal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  text-align: center;
}
.estado-vacio-icon { font-size: 4rem; line-height: 1; }
.estado-vacio-personal h3 { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.estado-vacio-personal p { color: var(--text-muted); font-size: 0.95rem; max-width: 340px; line-height: 1.7; }
.estado-vacio-personal strong { color: var(--accent2); }

.btn-ir-pueblo {
  margin-top: 4px;
  padding: 12px 28px;
  background: var(--grad-brand);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s;
  box-shadow: 0 4px 18px rgba(249,115,22,0.4);
  letter-spacing: 0.01em;
}
.btn-ir-pueblo:hover { filter: brightness(1.12); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(249,115,22,0.5); }

/* ===== MODAL SUBIR LIBRO ===== */
#btn-subir {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s;
}
#btn-subir:hover { background: var(--accent2); }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.oculto { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px 28px;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 20px;
}
.modal-box h2 { font-size: 1.2rem; }

.zona-drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.zona-drop:hover, .zona-drop.drag-over {
  border-color: var(--accent);
  background: rgba(124,106,247,0.07);
}
.zona-drop-icono { font-size: 2.4rem; }
.zona-drop p { color: var(--text-muted); font-size: 0.9rem; }

.subir-progreso {
  display: flex; flex-direction: column; gap: 8px;
}
.subir-progreso.oculto { display: none; }
.subir-barra {
  width: 100%; height: 6px; background: var(--surface2);
  border-radius: 99px; overflow: hidden;
}
.subir-barra-fill {
  height: 100%; width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s;
}
#subir-nombre-archivo { font-size: 0.82rem; color: var(--text-muted); }

.subir-mensaje { padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; }
.subir-mensaje.oculto { display: none; }
.subir-mensaje.ok  { background: rgba(74,222,128,0.12); color: var(--success); }
.subir-mensaje.err { background: rgba(248,113,113,0.12); color: var(--danger); }

.modal-acciones { display: flex; gap: 10px; justify-content: flex-end; }
.btn-primario {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 9px 20px; cursor: pointer;
  font-size: 0.9rem; transition: background 0.2s;
}
.btn-primario:hover:not(:disabled) { background: var(--accent2); }
.btn-primario:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secundario {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 20px; cursor: pointer;
  font-size: 0.9rem; transition: background 0.2s;
}
.btn-secundario:hover { background: var(--border); }
