/* ============================================================
   SOAD — tema visual
   Paleta alegre y amigable para padres/madres y educadores:
   coral, turquesa y amarillo sobre fondo crema.
   ============================================================ */

:root {
  --soad-coral: #ff6b35;
  --soad-coral-dark: #e8590c;
  --soad-turquesa: #2ec4b6;
  --soad-turquesa-dark: #21a99d;
  --soad-amarillo: #ffbf69;
  --soad-crema: #fff9f2;
  --soad-tinta: #2d3142;
  --soad-suave: #8b8fa3;
  --soad-borde: #f0e6d8;
}

html { font-size: 16px; position: relative; min-height: 100%; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--soad-crema);
  color: var(--soad-tinta);
  margin-bottom: 0;
}

h1, h2, h3, h4, .font-display {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 700;
  color: var(--soad-tinta);
}

/* ---------- Navbar ---------- */
.navbar-soad {
  background: #fff;
  border-bottom: 3px solid var(--soad-amarillo);
  box-shadow: 0 2px 12px rgba(45, 49, 66, 0.06);
}
.brand-soad {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--soad-coral) !important;
}
.logo-navbar { height: 44px; width: auto; display: block; }
@media (max-width: 575.98px) { .logo-navbar { height: 34px; } }
.logo-hero { width: 100%; max-width: 340px; height: auto; margin: 0 auto 1rem; display: block; }

/* Dedicatoria destacada (Quiénes somos) */
.dedicatoria {
  display: flex; align-items: center; justify-content: center; gap: .8rem;
  background: linear-gradient(135deg, #fff4ec, #ffe9d9);
  border: 2px solid var(--soad-coral); border-radius: 18px;
  padding: 1.1rem 1.4rem; text-align: center;
  box-shadow: 0 4px 16px rgba(232, 89, 12, .12);
}
.dedicatoria .corazon { font-size: 1.8rem; line-height: 1; animation: latido 1.6s ease-in-out infinite; }
.dedicatoria .texto {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.3rem;
  color: var(--soad-coral-dark);
}
@keyframes latido { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* Banderas de idioma dibujadas en CSS (sin imágenes ni emoji, mismas en todos los SO) */
.bandera {
  display: inline-block; width: 24px; height: 16px; border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(45, 49, 66, .15); vertical-align: -2px; flex-shrink: 0;
}
.bandera-es { background: linear-gradient(180deg, #AA151B 0 25%, #F1BF00 25% 75%, #AA151B 75% 100%); }
.bandera-ca {
  background: linear-gradient(180deg,
    #FCDD09 0 11.1%, #DA121A 11.1% 22.2%, #FCDD09 22.2% 33.3%, #DA121A 33.3% 44.4%,
    #FCDD09 44.4% 55.6%, #DA121A 55.6% 66.7%, #FCDD09 66.7% 77.8%, #DA121A 77.8% 88.9%, #FCDD09 88.9% 100%);
}
.bandera-en {
  background:
    linear-gradient(90deg, transparent 0 42%, #C8102F 42% 58%, transparent 58% 100%),
    linear-gradient(0deg, transparent 0 42%, #C8102F 42% 58%, transparent 58% 100%),
    linear-gradient(90deg, transparent 0 34%, #fff 34% 66%, transparent 66% 100%),
    linear-gradient(0deg, transparent 0 32%, #fff 32% 68%, transparent 68% 100%),
    linear-gradient(58deg, transparent 0 45%, #fff 45% 55%, transparent 55% 100%),
    linear-gradient(-58deg, transparent 0 45%, #fff 45% 55%, transparent 55% 100%),
    #012169;
}

/* Select de idioma del libro con la bandera integrada dentro del control */
.select-idioma-wrap { position: relative; }
.select-idioma-wrap .bandera {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  pointer-events: none; z-index: 2;
}
/* Hueco suficiente para que la bandera (24px) no pise el texto del idioma */
.select-con-bandera { padding-left: 3.6rem; }

/* Resumen del libro (paso final del wizard) */
.resumen-libro {
  background: linear-gradient(135deg, #fff8f0, #fff); border: 2px solid var(--soad-borde);
  border-radius: 18px; padding: 1.1rem 1.2rem;
}
/* Medidor de seguridad de contraseña */
.barra-fuerza { height: 7px; border-radius: 999px; background: var(--soad-borde); margin-top: .4rem; transition: background .2s ease; position: relative; overflow: hidden; }
.barra-fuerza::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; transition: width .25s ease, background .25s ease; }
.barra-fuerza.fuerza-1::after { width: 33%; background: #e74c3c; }
.barra-fuerza.fuerza-2::after { width: 66%; background: #f1c40f; }
.barra-fuerza.fuerza-3::after { width: 100%; background: #2ecc71; }
.texto-fuerza { font-size: .78rem; font-weight: 700; color: var(--soad-suave); margin-top: .25rem; display: block; }

.tiempo-estimado {
  background: #effbfa; border: 1.5px solid var(--soad-turquesa); color: var(--soad-tinta);
  border-radius: 12px; padding: .55rem .9rem; margin-bottom: 1rem; font-weight: 600; text-align: center;
}
.resumen-cabecera { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.resumen-icono { font-size: 2rem; line-height: 1; }
.resumen-titulo {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.35rem;
  color: var(--soad-tinta); overflow-wrap: anywhere;
}
.chips-resumen { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.chips-resumen .chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: #fff; border: 1.5px solid var(--soad-borde); border-radius: 999px;
  padding: .3rem .7rem; font-size: .82rem; font-weight: 700; color: var(--soad-tinta);
}
.chips-resumen .chip-ok { border-color: var(--soad-turquesa); background: #effbfa; }
.chips-resumen .chip-tipo-n { border-color: var(--soad-turquesa); }
.chips-resumen .chip-tipo-l { border-color: var(--soad-amarillo); }
.chips-resumen .chip-tipo-xl { border-color: var(--soad-coral); }
.resumen-acts-titulo { font-weight: 800; font-size: .9rem; color: var(--soad-suave); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .03em; }
.resumen-act {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem 0; border-bottom: 1px dashed var(--soad-borde);
}
.resumen-act:last-child { border-bottom: none; }
.resumen-act .act-icono { font-size: 1.25rem; line-height: 1; flex-shrink: 0; }
.resumen-act .act-nombre { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.resumen-act .act-tema { display: block; font-size: .78rem; font-weight: 500; color: var(--soad-suave); }
.resumen-act .act-paginas {
  flex-shrink: 0; background: var(--soad-crema); border-radius: 999px;
  padding: .2rem .6rem; font-size: .78rem; font-weight: 800; color: var(--soad-coral-dark);
}
.navbar-soad .nav-link { color: var(--soad-tinta); font-weight: 600; border-radius: 12px; padding: .45rem .9rem; }
.navbar-soad .nav-link:hover { background: var(--soad-crema); color: var(--soad-coral-dark); }
.nav-link.btn-crear {
  background: var(--soad-coral);
  color: #fff !important;
}
.nav-link.btn-crear:hover { background: var(--soad-coral-dark) !important; color: #fff !important; }

/* ---------- Botones ---------- */
.btn-soad {
  background: var(--soad-coral);
  border: none;
  color: #fff;
  font-weight: 700;
  border-radius: 14px;
  padding: .65rem 1.6rem;
  transition: transform .12s ease, background .12s ease;
}
.btn-soad:hover { background: var(--soad-coral-dark); color: #fff; transform: translateY(-2px); }
.btn-soad:disabled { background: var(--soad-suave); transform: none; }
.btn-soad-sec {
  background: #fff;
  border: 2px solid var(--soad-turquesa);
  color: var(--soad-turquesa-dark);
  font-weight: 700;
  border-radius: 14px;
  padding: .6rem 1.5rem;
}
.btn-soad-sec:hover { background: var(--soad-turquesa); color: #fff; }

/* ---------- Tarjetas ---------- */
.card-soad {
  background: #fff;
  border: 1px solid var(--soad-borde);
  border-radius: 20px;
  box-shadow: 0 4px 18px rgba(45, 49, 66, 0.05);
}

/* Tarjetas seleccionables del wizard (cursos y actividades) */
.card-pick {
  background: #fff;
  border: 2.5px solid var(--soad-borde);
  border-radius: 18px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
  height: 100%;
}
.card-pick:hover { border-color: var(--soad-amarillo); transform: translateY(-3px); box-shadow: 0 6px 16px rgba(45,49,66,.08); }
.card-pick.seleccionada {
  border-color: var(--soad-coral);
  background: #fff4ec;
  box-shadow: 0 6px 18px rgba(255, 107, 53, .18);
}
.card-pick .icono { font-size: 2.3rem; line-height: 1; }
.card-pick .titulo { font-weight: 800; margin-top: .4rem; font-family: "Baloo 2", sans-serif; }
.card-pick .detalle { font-size: .82rem; color: var(--soad-suave); }
.card-pick .badge-etapa { font-size: .72rem; background: var(--soad-turquesa); color:#fff; border-radius: 8px; padding: 2px 8px; }

/* ---------- Wizard ---------- */
.wizard-pasos { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.6rem; }
.wizard-paso {
  display: flex; align-items: center; gap: .45rem;
  padding: .35rem .9rem; border-radius: 999px;
  background: #fff; border: 2px solid var(--soad-borde);
  font-size: .85rem; font-weight: 700; color: var(--soad-suave);
}
.wizard-paso.activo { border-color: var(--soad-coral); color: var(--soad-coral-dark); background: #fff4ec; }
.wizard-paso.hecho { border-color: var(--soad-turquesa); color: var(--soad-turquesa-dark); }
.wizard-paso .num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--soad-borde); color: var(--soad-tinta);
  display: inline-flex; align-items: center; justify-content: center; font-size: .75rem;
}
.wizard-paso.activo .num { background: var(--soad-coral); color: #fff; }
.wizard-paso.hecho .num { background: var(--soad-turquesa); color: #fff; }

/* Sliders de reparto de páginas */
.reparto-fila { display: flex; align-items: center; gap: 1rem; padding: .8rem 1rem; background:#fff; border-radius: 14px; border: 1px solid var(--soad-borde); }
.reparto-fila .nombre { min-width: 200px; font-weight: 700; }
.reparto-fila input[type=range] { flex: 1; accent-color: var(--soad-coral); }
.reparto-fila .valor {
  min-width: 56px; text-align: center; font-weight: 800; font-size: 1.15rem;
  background: var(--soad-crema); border-radius: 10px; padding: .25rem .4rem;
}
.contador-restante { font-size: 1.05rem; font-weight: 700; }
.contador-restante .ok { color: var(--soad-turquesa-dark); }
.contador-restante .mal { color: #cf222e; }

/* ---------- Landing ---------- */
.hero-soad {
  background: linear-gradient(135deg, #fff4ec 0%, #e9faf8 100%);
  padding: 4.5rem 0 4rem;
  text-align: center;
}
.hero-soad h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 800; }
.hero-soad h1 .resalte { color: var(--soad-coral); }
.hero-soad p.sub { font-size: 1.2rem; color: #5a5f73; max-width: 640px; margin: 1rem auto 2rem; }
.paso-circulo {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--soad-amarillo); color: var(--soad-tinta);
  font-family: "Baloo 2", sans-serif; font-size: 1.6rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: .8rem;
}
.ejemplo-tile {
  background: #fff; border: 1px solid var(--soad-borde); border-radius: 16px;
  padding: 1.1rem; text-align: center; height: 100%;
}
.ejemplo-tile .icono { font-size: 2rem; }

/* ---------- Biblioteca ---------- */
.libro-card { overflow: hidden; }
.libro-portada {
  background: linear-gradient(160deg, var(--soad-amarillo), var(--soad-coral));
  color: #fff; min-height: 130px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: "Baloo 2", sans-serif; text-align: center; padding: .8rem;
}
.libro-portada .t { font-size: 1.15rem; font-weight: 800; line-height: 1.2; }
.libro-portada .n { font-size: .85rem; opacity: .92; }
.badge-tipo { background: var(--soad-turquesa); color: #fff; border-radius: 8px; font-size: .72rem; padding: 3px 8px; }
.badge-tipo.xl { background: var(--soad-coral); }

/* Barras de límites */
.limite-barra { background: #f1ece3; border-radius: 999px; height: 14px; overflow: hidden; }
.limite-barra .relleno { height: 100%; border-radius: 999px; background: var(--soad-turquesa); transition: width .3s ease; }
.limite-barra .relleno.coral { background: var(--soad-coral); }

/* ---------- Footer ---------- */
.footer-soad {
  background: #fff; border-top: 3px solid var(--soad-amarillo);
  margin-top: 4rem; font-size: .9rem; color: var(--soad-suave);
}
.text-soft { color: var(--soad-suave); }

/* ---------- Formularios ---------- */
.form-control, .form-select { border-radius: 12px; border: 1.5px solid var(--soad-borde); padding: .6rem .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--soad-turquesa); box-shadow: 0 0 0 .2rem rgba(46, 196, 182, .15); }

/* Progreso de generación */
.progreso-generacion .progress { height: 22px; border-radius: 999px; background: #f1ece3; }
.progreso-generacion .progress-bar { background: var(--soad-turquesa); font-weight: 700; }

/* ============================================================
   Iteración 2 — mobile-first
   ============================================================ */

/* ---------- Bottom nav (móvil, tipo app) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
  background: #fff; border-top: 2px solid var(--soad-borde);
  display: flex; justify-content: space-around; align-items: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(45, 49, 66, .08);
}
body.con-bottom-nav main { scroll-margin-bottom: 80px; }
@media (max-width: 767.98px) {
  body.con-bottom-nav { padding-bottom: 78px; }
  body.con-bottom-nav .footer-soad { margin-bottom: 0; }
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  text-decoration: none; color: var(--soad-suave); font-size: .68rem; font-weight: 700;
  min-width: 64px; min-height: 48px; justify-content: center; border-radius: 12px;
}
.bn-item.activa { color: var(--soad-coral-dark); background: #fff4ec; }
.bn-icono { font-size: 1.35rem; line-height: 1.1; }
.bn-central .bn-boton {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--soad-coral); color: #fff; font-size: 2rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin-top: -26px; box-shadow: 0 6px 16px rgba(255, 107, 53, .4);
  border: 4px solid var(--soad-crema);
}

/* ---------- Footer ---------- */
.footer-link { color: var(--soad-tinta); font-weight: 600; text-decoration: none; }
.footer-link:hover { color: var(--soad-coral-dark); }

/* ---------- Targets táctiles ---------- */
@media (max-width: 767.98px) {
  .btn, .form-select, .form-control { min-height: 44px; }
  .navbar-soad .nav-link.btn-crear { min-height: 40px; display: inline-flex; align-items: center; }
}

/* ---------- Selección evidente en tarjetas del wizard ---------- */
.card-pick { position: relative; }
.card-pick .check-badge {
  position: absolute; top: -10px; right: -10px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--soad-coral); color: #fff; font-size: 1.05rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(255, 107, 53, .45);
  transform: scale(0); transition: transform .18s cubic-bezier(.34, 1.56, .64, 1);
}
.card-pick.seleccionada .check-badge { transform: scale(1); }
.badge-nivel {
  font-size: .7rem; background: #7048e8; color: #fff;
  border-radius: 8px; padding: 2px 8px; font-weight: 700;
}

/* ---------- Stepper del wizard: dots en móvil ---------- */
.wizard-dots { display: none; }
@media (max-width: 767.98px) {
  .wizard-pasos { display: none; }
  .wizard-dots {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; margin-bottom: 1.1rem;
  }
  .wizard-dots .dots { display: flex; gap: .55rem; }
  .wizard-dots .dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--soad-borde); transition: all .2s ease;
  }
  .wizard-dots .dot.activo { background: var(--soad-coral); transform: scale(1.35); }
  .wizard-dots .dot.hecho { background: var(--soad-turquesa); }
  .wizard-dots .nombre-paso { font-weight: 800; font-family: "Baloo 2", sans-serif; }
}

/* ---------- Reparto: steppers numéricos (− n +) ---------- */
.reparto-fila { flex-wrap: wrap; }
.reparto-fila .nombre { min-width: 0; flex: 1 1 100%; }
@media (min-width: 768px) {
  .reparto-fila .nombre { flex: 0 0 220px; }
}
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper button {
  width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--soad-borde);
  background: #fff; font-size: 1.4rem; font-weight: 800; color: var(--soad-coral-dark);
  display: inline-flex; align-items: center; justify-content: center;
}
.stepper button:active { background: var(--soad-crema); }
.stepper button:disabled { color: var(--soad-suave); opacity: .4; }
.stepper .valor-num {
  min-width: 52px; text-align: center; font-weight: 800; font-size: 1.25rem;
  background: var(--soad-crema); border-radius: 10px; padding: .35rem .4rem;
}
#total-paginas { min-width: 0; }

/* ---------- Biblioteca ---------- */
.miniatura-portada {
  width: 100%; border-radius: 14px; border: 1px solid var(--soad-borde);
  aspect-ratio: 210/297; object-fit: cover; background: #fff;
}
.libro-card.generando { opacity: .75; }
.libro-card.generando .libro-portada,
.libro-card.generando .miniatura-portada { animation: pulso 1.6s ease-in-out infinite; }
@keyframes pulso { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.estado-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  border-radius: 999px; padding: .25rem .8rem; font-size: .8rem; font-weight: 700;
}
.estado-pill.pendiente { background: #fff3cd; color: #8a6d00; }
.estado-pill.generando { background: #d9f7f4; color: var(--soad-turquesa-dark); }
.estado-pill.error { background: #ffe3e3; color: #cf222e; }

.chip-limites {
  display: inline-flex; align-items: center; gap: .5rem;
  background: #fff; border: 2px solid var(--soad-borde); border-radius: 999px;
  padding: .35rem .9rem; font-weight: 800; font-size: .85rem; text-decoration: none;
  color: var(--soad-tinta);
}
.chip-limites:hover { border-color: var(--soad-amarillo); color: var(--soad-tinta); }
.chip-limites .punto { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip-limites .punto.normal { background: var(--soad-turquesa); }
.chip-limites .punto.xl { background: var(--soad-coral); }

/* ---------- Landing: actividades en 2 columnas en móvil ---------- */
@media (max-width: 575.98px) {
  .hero-soad { padding: 3rem 0 2.6rem; }
  .hero-soad p.sub { font-size: 1.05rem; }
}

/* ---------- Login doble camino ---------- */
.login-opcion {
  border: 2px solid var(--soad-borde); border-radius: 18px; padding: 1.3rem;
  background: #fff; height: 100%;
}
.login-opcion h5 { font-family: "Baloo 2", sans-serif; font-weight: 800; }
.login-opcion.nuevo { background: linear-gradient(135deg, #fff4ec, #e9faf8); }

/* ============================================================
   Iteración 3
   ============================================================ */

/* ---------- Tarjetas de libro compactas (banda por tipo) ---------- */
.libro-fila {
  display: flex; background: #fff; border: 1px solid var(--soad-borde);
  border-radius: 18px; overflow: hidden; height: 100%;
  box-shadow: 0 3px 14px rgba(45, 49, 66, .05);
}
.libro-fila .banda {
  flex: 0 0 46px; display: flex; align-items: center; justify-content: center;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.05rem; color: #fff;
  writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg);
  letter-spacing: 2px;
}
.libro-fila .banda.n { background: var(--soad-turquesa); }
.libro-fila .banda.ele { background: #f5a623; }
.libro-fila .banda.xl { background: var(--soad-coral); }
.libro-fila .cuerpo { flex: 1; padding: .85rem 1rem; min-width: 0; }
.libro-fila .titulo-libro {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.18rem;
  line-height: 1.2; overflow: hidden; text-overflow: ellipsis;
}
.libro-fila .meta { color: var(--soad-suave); font-size: .82rem; margin-top: 2px; }
.libro-fila .acciones { display: flex; gap: .5rem; margin-top: .65rem; align-items: center; flex-wrap: wrap; }
.libro-fila .btn-borrar { border: 2px solid var(--soad-borde); border-radius: 12px; }
.libro-fila.generando { opacity: .8; }
.libro-fila.generando .banda { animation: pulso 1.6s ease-in-out infinite; }

/* ---------- Modal de calidades ---------- */
.opcion-calidad {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; background: #fff;
  border: 2px solid var(--soad-borde); border-radius: 16px; padding: .8rem 1rem;
  transition: all .12s ease;
}
.opcion-calidad:hover { border-color: var(--soad-turquesa); transform: translateY(-1px); }
.opcion-calidad.recomendada { border-color: var(--soad-coral); background: #fff4ec; }
.opcion-calidad .nombre { font-weight: 800; font-family: "Baloo 2", sans-serif; font-size: 1.05rem; }
.opcion-calidad .desc { color: var(--soad-suave); font-size: .85rem; }
.opcion-calidad .estado-calidad { display: block; font-size: .76rem; font-weight: 700; margin-top: .25rem; color: var(--soad-suave); }
.opcion-calidad.cacheada .estado-calidad { color: #2e7d32; }
.badge-recomendada {
  background: var(--soad-coral); color: #fff; font-size: .68rem;
  border-radius: 8px; padding: 2px 8px; vertical-align: middle; font-family: "Nunito", sans-serif;
}

/* ---------- Switch de opciones (fila pulsable, sin solapes) ---------- */
.opcion-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: #fff; border: 1px solid var(--soad-borde); border-radius: 14px;
  padding: .8rem 1rem; cursor: pointer; width: 100%;
}
.opcion-switch .texto { min-width: 0; }
.opcion-switch .form-check-input { width: 3em; height: 1.6em; cursor: pointer; }

/* ---------- Cursos "Próximamente" ---------- */
.card-pick.inactivo {
  opacity: .55; cursor: not-allowed; filter: grayscale(.7);
}
.card-pick.inactivo:hover { transform: none; border-color: var(--soad-borde); box-shadow: none; }
.badge-pronto {
  background: var(--soad-suave); color: #fff; font-size: .7rem;
  border-radius: 8px; padding: 2px 8px; font-weight: 700;
}

/* ---------- Tercer contador (L) ---------- */
.chip-limites .punto.ele { background: #f5a623; }
.limite-barra .relleno.amarillo { background: #f5a623; }

/* ============================================================
   Iteración 4
   ============================================================ */

/* ---------- Login móvil con teclado virtual ---------- */
#crear-cuenta { scroll-margin-top: 70px; }
#registro-pronto { scroll-margin-bottom: 40px; }
@media (max-width: 767.98px) {
  /* En pantallas bajas el formulario debe poder hacer scroll cómodo con el teclado abierto */
  .login-wrap { min-height: auto; padding-bottom: 40vh; }
  .login-opcion { padding: 1rem; }
}

/* ---------- Biblioteca: rejilla de metadatos con huecos fijos ---------- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .4rem;
  margin-top: .5rem;
}
.meta-grid .celda {
  background: var(--soad-crema);
  border-radius: 10px;
  padding: .35rem .5rem;
  min-width: 0;
}
.meta-grid .etiqueta {
  display: block; font-size: .62rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--soad-suave); line-height: 1.1;
}
.meta-grid .valor {
  display: block; font-size: .82rem; font-weight: 700; color: var(--soad-tinta);
  line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 380px) {
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Detalle de error de descarga (admin) ---------- */
.error-tecnico {
  background: #2d3142; color: #e8e8ea; border-radius: 12px;
  padding: .8rem 1rem; font-family: Consolas, monospace; font-size: .78rem;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto;
}

/* ---------- Páginas legales / contacto ---------- */
.doc-legal { max-width: 800px; }
.doc-legal h2 { margin-top: 1.6rem; font-size: 1.3rem; }
.doc-legal h3 { margin-top: 1.1rem; font-size: 1.08rem; }
.doc-legal .placeholder-dato {
  background: #fff3cd; color: #8a6d00; border-radius: 6px; padding: 0 .35rem; font-weight: 700;
}

/* ============================================================
   Iteración 5
   ============================================================ */

/* Distintivo "Configurable" (= admite temática). No se expone qué usa IA. */
.badge-config {
  background: linear-gradient(135deg, var(--soad-amarillo), var(--soad-coral));
  color: #fff; font-size: .68rem; font-weight: 800;
  border-radius: 8px; padding: 2px 8px; white-space: nowrap;
}

/* Metadatos de biblioteca: tamaños afinados por slot (Iteración 5) */
.meta-grid .celda.curso .valor { font-size: .76rem; }
.meta-grid .celda.paginas .valor { font-size: .76rem; }
.meta-grid .celda.fecha .valor { font-size: .9rem; }

/* ============================================================
   Iteración 6
   ============================================================ */

/* Aviso informativo de cookies (no consentimiento) */
.aviso-cookies {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 1040;
  background: #fff; border: 2px solid var(--soad-borde); border-radius: 16px;
  box-shadow: 0 6px 24px rgba(45, 49, 66, .15);
  padding: .8rem 1rem; display: flex; gap: 1rem; align-items: center;
  justify-content: space-between; flex-wrap: wrap; font-size: .9rem;
}
@media (max-width: 767.98px) {
  body.con-bottom-nav .aviso-cookies { bottom: 84px; }
}

/* ============================================================
   Iteración 7
   ============================================================ */

/* Fecha: un pelín más de ancho y fuente algo más pequeña para que quepa */
.meta-grid { grid-template-columns: 0.82fr 0.66fr 1.14fr 0.86fr; }
.meta-grid .celda.fecha .valor { font-size: .78rem; }
.meta-grid .celda.curso .valor, .meta-grid .celda.paginas .valor { font-size: .76rem; }
@media (max-width: 380px) {
  .meta-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Biblioteca como estantería de cuadernos ---------- */
.libro-card.abrible { cursor: pointer; }
.libro-3d { position: relative; width: 100%; aspect-ratio: 4 / 5; }
.cara {
  position: absolute; inset: 0;
  border-radius: 8px 16px 16px 8px;
  box-shadow: 0 4px 14px rgba(45, 49, 66, .12);
  transition: transform .2s ease, box-shadow .2s ease;
}
/* Solo en dispositivos con ratón (en táctil el :hover se queda "pegado" tras tocar) */
@media (hover: hover) {
  .libro-card.abrible:hover .cara-portada { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(45, 49, 66, .18); }
}

/* Cubierta: color por tipo + espiral de cuaderno */
.cara-portada { display: flex; }
.cara-portada.tipo-n { background: linear-gradient(160deg, #e9faf8, #d3f3ef); border: 2px solid var(--soad-turquesa); }
.cara-portada.tipo-ele { background: linear-gradient(160deg, #fff6dd, #ffecb8); border: 2px solid var(--soad-amarillo); }
.cara-portada.tipo-xl { background: linear-gradient(160deg, #ffeede, #ffd9c2); border: 2px solid var(--soad-coral); }
.espiral {
  flex: 0 0 16px; margin: 6px 0;
  background-image: radial-gradient(circle at 7px 50%, #fff 2.6px, rgba(45,49,66,.35) 3.4px, transparent 4.4px);
  background-size: 16px 16px; background-repeat: repeat-y;
}
.cubierta {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
  padding: .55rem .6rem .55rem .25rem; position: relative;
}
.tipo-sello {
  position: absolute; top: .45rem; right: .5rem;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: .72rem;
  background: #fff; border-radius: 999px; padding: .05rem .5rem;
  box-shadow: 0 1px 4px rgba(45, 49, 66, .15); color: var(--soad-tinta);
}
.titulo-cubierta {
  font-family: "Baloo 2", sans-serif; font-weight: 800; color: var(--soad-tinta);
  font-size: 1.02rem; line-height: 1.15; margin-top: 1.3rem;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
/* Ilustración IA de la portada en la cubierta del cuaderno */
.ilustracion-cubierta {
  margin-top: 1.55rem; height: 42%; flex-shrink: 0;
  border-radius: 10px; background-size: cover; background-position: center;
  box-shadow: 0 2px 8px rgba(45, 49, 66, .18); border: 2px solid rgba(255, 255, 255, .8);
}
.cubierta.con-ilustracion .titulo-cubierta { margin-top: .4rem; -webkit-line-clamp: 2; font-size: .92rem; }
.meta-cubierta {
  margin-top: auto; background: rgba(255, 255, 255, .75); border-radius: 10px;
  padding: .35rem .5rem; display: grid; grid-template-columns: 1fr 1fr; gap: .12rem .5rem;
}
/* Etiqueta y valor juntos (alineados a la izquierda): "Creado" queda en su fila
   empezando alineado con "Curso", sin valores flotando a la derecha. */
.meta-cubierta > div { display: flex; justify-content: flex-start; align-items: baseline; gap: .35rem; min-width: 0; }
.meta-cubierta .fila-creado { grid-column: 1 / -1; }
.meta-cubierta .m-et { font-size: .62rem; font-weight: 700; color: var(--soad-suave); text-transform: uppercase; letter-spacing: .02em; }
.meta-cubierta .m-val { font-size: .72rem; font-weight: 800; color: var(--soad-tinta); white-space: nowrap; }
.pista-abrir {
  margin-top: .4rem; text-align: center; font-size: .68rem; font-weight: 700;
  color: var(--soad-suave);
}
.libro-card.abrible:hover .pista-abrir { color: var(--soad-coral-dark); }
.estado-cubierta {
  margin-top: .4rem; display: flex; flex-direction: column; gap: .3rem; align-items: center;
}
.libro-card.generando .cara-portada { animation: pulso 2s ease-in-out infinite; }

/* Favorito: estrella en la esquina de la cubierta */
.btn-favorito {
  position: absolute; top: .4rem; left: .55rem; z-index: 3;
  border: none; background: rgba(255,255,255,.85); border-radius: 50%;
  width: 30px; height: 30px; font-size: 1rem; line-height: 1; cursor: pointer;
  color: #c9ccd2; box-shadow: 0 1px 4px rgba(45,49,66,.2); transition: color .15s ease, transform .15s ease;
}
.btn-favorito:hover { transform: scale(1.15); }
.libro-card.es-favorito .btn-favorito { color: #FFBF22; }
.libro-card.es-favorito .cara-portada { box-shadow: 0 0 0 2px #FFBF22, 0 4px 14px rgba(45,49,66,.12); }
.tiempo-restante { margin-top: .25rem; font-size: .7rem; font-weight: 700; color: var(--soad-suave); }
.btn-cancelar-gen {
  margin-top: .4rem; border: none; background: none; color: #c0392b; font-weight: 700;
  font-size: .76rem; cursor: pointer; border-radius: 8px; padding: .2rem .5rem;
}
.btn-cancelar-gen:hover { background: #fdecea; }

/* ---------- Libro volador: la tarjeta vuela al centro girando y llega abierta ---------- */
#telon-libro {
  position: fixed; inset: 0; z-index: 1040;
  background: rgba(45, 49, 66, .5); opacity: 0;
  transition: opacity .4s ease;
}
#telon-libro.visible { opacity: 1; }
#libro-volador {
  position: fixed; z-index: 1045; perspective: 1600px;
  transition: transform .58s cubic-bezier(.35, .65, .3, 1);
  will-change: transform;
}
#libro-volador .volador-3d {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .58s cubic-bezier(.35, .65, .3, 1);
}
#libro-volador.sin-transicion, #libro-volador.sin-transicion .volador-3d { transition: none !important; }
#libro-volador .v-cara {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
/* El clon de la cubierta (.cara-portada) ya viene con position:absolute inset:0 */
#libro-volador .v-trasera { transform: rotateY(180deg); }

/* La hoja del cuaderno abierta (cara trasera) */
.hoja-abierta {
  position: absolute; inset: 0; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 1rem 1rem 1rem 2.3rem;
  border-radius: 22px; border: 2px solid var(--soad-borde);
  box-shadow: 0 18px 50px rgba(45, 49, 66, .35);
  background:
    linear-gradient(90deg, transparent 0 24px, rgba(232, 89, 12, .25) 24px 26px, transparent 26px),
    repeating-linear-gradient(180deg, #fffdf8 0 26px, #e8eef5 26px 27px);
}
/* Botón de cerrar del libro volador: vive FUERA de .volador-3d (cuelga de #libro-volador),
   por eso recibe siempre el toque; un absolute dentro de la cara girada en 3D fallaba el
   hit-test en muchos navegadores móviles. Va en la esquina, claramente visible. */
.volador-cerrar {
  position: absolute; top: -.7rem; right: -.7rem; z-index: 6;
  width: 2.7rem; height: 2.7rem; border: none; border-radius: 50%;
  background: var(--soad-tinta); color: #fff;
  font-size: 1.7rem; line-height: 1; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(45, 49, 66, .35); cursor: pointer;
  transition: background .15s, transform .15s;
}
.volador-cerrar:hover { background: var(--soad-coral); transform: scale(1.06); }
.titulo-hoja { font-family: "Baloo 2", sans-serif; font-weight: 800; overflow-wrap: anywhere; padding-right: .3rem; }
.meta-hoja { background: rgba(255, 255, 255, .85); }

/* Acciones del libro abierto */
.acciones-hoja {
  flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center;
  gap: .7rem; padding: .5rem 0; min-height: 0;
}
.accion-principal {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; min-height: 56px; font-size: 1.1rem; font-weight: 800; border-radius: 16px;
}
.accion-principal .ico { font-size: 1.5rem; line-height: 1; }
/* Rejilla 2 columnas de acciones secundarias: tiles uniformes que no se desbordan */
.rejilla-acciones { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.tile-accion {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .22rem; padding: .6rem .35rem; min-height: 66px;
  border: 2px solid var(--soad-borde); border-radius: 15px;
  background: rgba(255, 255, 255, .92); color: var(--soad-tinta);
  font-weight: 700; font-size: .82rem; text-align: center; cursor: pointer;
  transition: border-color .15s, transform .12s, background .15s;
}
.tile-accion:hover { border-color: var(--soad-coral); background: #fff; transform: translateY(-1px); }
.tile-accion .ico { font-size: 1.45rem; line-height: 1; }
.tile-accion .lbl { line-height: 1.05; }
.tile-accion.tile-activa { border-color: var(--soad-coral); background: var(--soad-crema); color: var(--soad-coral-dark); }
.btn-eliminar-libro {
  background: none; border: none; color: #c0392b; font-weight: 700; font-size: .85rem;
  padding: .35rem .6rem; margin-top: .3rem; border-radius: 8px; cursor: pointer; align-self: center;
}
.btn-eliminar-libro:hover { background: #fdecea; }

/* Visor del libro en pantalla (PDF.js): muestra las páginas como imágenes dentro de la
   propia app, sin descargar. Indispensable en móvil (el navegador baja el PDF en vez de
   abrirlo) y permite imprimir con window.print() vía la hoja de estilos @media print. */
#visor-pdf {
  position: fixed; inset: 0; z-index: 1080; display: flex; flex-direction: column;
  background: #41465a;
}
.visor-barra {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem;
  background: var(--soad-tinta); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.visor-titulo {
  flex: 1 1 auto; font-weight: 800; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.visor-btn {
  background: rgba(255, 255, 255, .16); color: #fff; border: none; border-radius: 10px;
  padding: .45rem .75rem; font-weight: 800; font-size: 1rem; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; gap: .35rem;
}
.visor-btn:hover { background: rgba(255, 255, 255, .3); }
.visor-btn-print { background: var(--soad-coral); }
.visor-btn-print:hover { background: var(--soad-coral-dark); }
.visor-scroll { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1rem .6rem 2.5rem; }
#visor-paginas { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
#visor-paginas canvas {
  width: 100%; max-width: 820px; height: auto; background: #fff; border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
}
.visor-cargando { text-align: center; color: #fff; padding: 3rem 1rem; }

@media print {
  /* En impresión ocultamos toda la app y dejamos solo las páginas del visor. */
  body * { visibility: hidden !important; }
  #visor-pdf, #visor-pdf * { visibility: visible !important; }
  #visor-pdf { position: absolute; inset: 0; z-index: auto; background: #fff; display: block; }
  .visor-barra, #visor-cargando, #visor-error { display: none !important; }
  .visor-scroll { overflow: visible; padding: 0; }
  #visor-paginas { gap: 0; display: block; }
  #visor-paginas canvas {
    width: 100%; max-width: 100%; box-shadow: none; border-radius: 0;
    page-break-after: always; break-after: page;
  }
}

/* Selector de idioma de la interfaz (footer) */
.selector-idioma a { color: var(--soad-suave); text-decoration: none; font-weight: 700; font-size: .85rem; }
.selector-idioma a.activo { color: var(--soad-coral-dark); }
.selector-idioma .sep { color: var(--soad-borde); margin: 0 .3rem; }

/* Selector de idioma en la barra superior (ES | CA), claro y visible */
.selector-idioma-nav {
  display: inline-flex; align-items: center;
  border: 1.5px solid var(--soad-borde); border-radius: 999px;
  padding: .12rem .15rem; background: #fff; line-height: 1;
}
.selector-idioma-nav a {
  text-decoration: none; font-weight: 800; font-size: .8rem; letter-spacing: .02em;
  color: var(--soad-suave); padding: .2rem .5rem; border-radius: 999px;
  min-width: 2rem; text-align: center;
}
.selector-idioma-nav a.activo { color: #fff; background: var(--soad-coral); }
.selector-idioma-nav a:not(.activo):hover { color: var(--soad-coral-dark); background: var(--soad-crema); }
.selector-idioma-nav .sep { color: var(--soad-borde); font-size: .7rem; }
