/* Shared responsive contract. Loaded after page and identity styles. */
.app .principal, .app .lienzo, .app .aula-barra { min-width: 0; max-width: 100%; }
.app .lienzo { overflow-wrap: anywhere; }
.app :where(.panel, .ficha, .curso, .metrica, .campo, .formulario, .lugar-main, .comunidad-main) { min-width: 0; }
.app :where(img, video, iframe), .ingreso img { max-width: 100%; }
.app :where(input, select, textarea) { max-width: 100%; min-width: 0; }
.app :where(.tabla-caja, .tabla-envoltura, .tabla-envoltorio, .cal) { position: relative; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.app :where(.tabla-caja, .tabla-envoltura, .tabla-envoltorio, .cal):focus-visible { outline: 3px solid var(--or-500); outline-offset: 3px; }
.app .lateral { height: 100dvh; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.app .lateral .nav { min-height: 0; overscroll-behavior-y: contain; }
.menu-cerrar { display: none; }
.app :where(.pestanias, .acciones, .filtros-barra, .barra-busqueda, .banda-admin) { max-width: 100%; }
.app .pestanias { overflow-x: auto; overscroll-behavior-x: contain; }
.app .pestanias a { flex-shrink: 0; }
.app :where(.btn, .nav__it, .salir) { white-space: normal; }
.app .dlg { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }
.app :where(button, a, input, select, textarea):focus-visible { outline: 3px solid var(--or-500); outline-offset: 3px; }

@media screen and (max-width: 1100px) {
    .app .sidebar-toggle { display: none; }
    .app .lateral { margin-left: 0; pointer-events: auto; }
    .app .menu-cerrar { display: grid; place-items: center; align-self: flex-end; flex: none; width: 44px; height: 44px; border: 1px solid #ffffff40; border-radius: 10px; background: transparent; color: white; font-size: 26px; cursor: pointer; }
    .app .cabecera { height: auto; min-height: 68px; padding: 10px 20px; gap: 12px; }
    .app .cabecera__der { gap: 8px; flex-shrink: 0; }
    .app .cabecera__der > .chapa { display: none; }
    .app .yo__btn-txt { display: none; }
    .app .lienzo { padding: 24px 20px max(32px, env(safe-area-inset-bottom)); }
    .app .lugar-grid, .app .comunidad-grid { grid-template-columns: minmax(0, 1fr); }
    .app .lugar-rail { position: static; }
    .app .aula-barra { padding: 18px 20px 0; }
    .app .pestanias { flex-wrap: nowrap; }
    .app .pestanias a { min-height: 44px; white-space: nowrap; }
    .app :where(.menu-movil, .ui-icon-btn, .hb__btn, .yo__btn, .nav__it, .salir) { min-height: 44px; }
    .app :where(.menu-movil, .ui-icon-btn, .hb__btn, .yo__btn) { min-width: 44px; }
    .app .banda-admin { flex-wrap: wrap; }
}

@media screen and (max-width: 600px) {
    .app .cabecera { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
    .app .cabecera__t { flex: 1 1 100%; order: 3; white-space: normal; overflow-wrap: anywhere; font-size: 1rem; }
    .app .cabecera__der { margin-left: auto; }
    .app .cabecera__ruta { display: none; }
    .app .lienzo { padding: 20px 16px max(28px, env(safe-area-inset-bottom)); }
    .app .aula-barra { padding: 16px 16px 0; }
    .app :where(.tipos-eval, .rejilla-datos, .cols-2, .cursos) { grid-template-columns: minmax(0, 1fr); }
    .app :where(.filtros-barra, .barra-busqueda) { flex-wrap: wrap; }
    .app :where(.filtros-barra, .barra-busqueda) .ctrl { flex: 1 1 100%; width: 100%; min-width: 0; }
    .app :where(.perfil__ident, .res__txt, .grupo-curso__txt, .aula-item__cab .fila__txt, .eval-resumen__dato) { min-width: 0; }
    .app :where(.btn, .ctrl), .ingreso :where(input, select, textarea), .acceso-body :where(input, select, textarea) { min-height: 44px; }
    /* 16px avoids automatic iOS zoom when focusing form controls. */
    .app :where(input, select, textarea), .ingreso :where(input, select, textarea), .acceso-body :where(input, select, textarea) { font-size: 16px; }
    .app .chat { height: min(72dvh, 540px); bottom: max(8px, env(safe-area-inset-bottom)); }
    .app .chat__escribir textarea { min-width: 0; }
    .app :where(.pop, .yo__pop) { position: fixed; top: 116px; left: 8px; right: 8px; width: auto; max-height: calc(100dvh - 128px); overflow-y: auto; }
    .app .pop__lista { max-height: calc(100dvh - 220px); }
    .ingreso .escena--comercial { min-height: 310px; height: 42svh; max-height: 390px; }
    .escena--comercial .escena__marca { top: 18px; left: 20px; }
    .escena--comercial .escena__pie { left: 20px; right: 20px; bottom: 62px; }
    .escena--comercial .escena__texto h2 { font-size: clamp(26px, 7vw, 38px); margin-top: 10px; }
    .escena--comercial .escena__texto p { display: none; }
    .escena--comercial .escena__barras { left: 20px; bottom: 18px; }
    .ingreso .ingreso__panel { padding: 28px 20px max(32px, env(safe-area-inset-bottom)); }
}

@media screen and (max-width: 360px) {
    .app .atajos-campus { grid-template-columns: minmax(0, 1fr); }
    .app .cabecera__der { gap: 3px; }
    .app .hero__acciones { align-items: stretch; flex-direction: column; }
    .app .hero__acciones .btn { width: 100%; }
}

@media screen and (max-height: 500px) and (max-width: 1100px) {
    .app .lateral__yo, .app .ayuda-campus { display: none; }
    .app .lateral__marca { padding-bottom: 8px; }
    .app .cabecera { position: relative; }
}

/* The cinematic banner must not derive its width from its height/aspect ratio. */
.ingreso { grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); }
.ingreso .escena--comercial { width: 100%; min-width: 0; aspect-ratio: auto; }
.ingreso .ingreso__panel { min-width: 0; }
@media screen and (max-width: 860px) {
    .ingreso .soporte-whatsapp { position: static; width: fit-content; margin: 0 auto max(24px, env(safe-area-inset-bottom)); }
}

/* ═══ Arreglos 19-sep-2026 ═════════════════════════════════════════════ */

/* Tarjetas de curso: las píldoras NUNCA se parten letra por letra
   («Onlin e», «estudiant e»). El `overflow-wrap:anywhere` del lienzo es para
   textos largos, no para etiquetas cortas: aquí se anula y la fila se envuelve. */
.app .curso__pie { flex-wrap: wrap; row-gap: 8px; }
.app .pildora { white-space: nowrap; overflow-wrap: normal; word-break: normal; flex: none; max-width: 100%; }
.app .pildora { line-height: 1.35; }
/* La franja de color de la tarjeta: barra lateral de alto completo (antes
   quedaba un cuadradito de 6×6 en la esquina). */
.app .curso__spine { width: 6px; height: auto; align-self: stretch; }
.app .curso h4 { overflow-wrap: break-word; }

/* Estado de la fecha en Formación (admin › Aulas) */
.pildora--fecha-activa { background: #E7F6EC; color: #1E7A3F; }
:root[data-theme="oscuro"] .pildora--fecha-activa { background: rgba(52,168,94,.16); color: #7FD6A0; }

/* Diálogo «Cerrar y eliminar» con la fecha todavía activa */
.modal-cierre__aviso--fecha { margin-top: 14px; border-color: #F3B8AB; background: #FFF1EE; color: #8F2A16; }
.modal-cierre__aviso--fecha strong { color: #7A1F0E; }
.modal-cierre__check { display: flex; align-items: flex-start; gap: 9px; margin-top: 10px; font-weight: 700; cursor: pointer; }
.modal-cierre__check input { width: 18px; height: 18px; min-height: 0; flex: none; margin-top: 1px; accent-color: #C0391B; }
.modal-cierre__aviso + .modal-cierre__aviso { margin-top: 10px; }
.modal-cierre .btn:disabled { opacity: .45; cursor: not-allowed; }
:root[data-theme="oscuro"] .modal-cierre__aviso--fecha { background: rgba(214,69,40,.14); border-color: rgba(255,141,120,.35); color: #FFC2B5; }
:root[data-theme="oscuro"] .modal-cierre__aviso--fecha strong { color: #FFD9D0; }

/* Enlaces (URL) de las publicaciones: docente y estudiante */
.enlace-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.enlace-form__titulo { margin: 0 0 4px; font-family: var(--display); font-weight: 700; font-size: .92rem; color: var(--ink); }
.enlace-form__ayuda { margin: 0 0 12px; font-size: .8rem; color: var(--muted); line-height: 1.5; }
.enlace-form__servicios { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 14px; }
.enlace-form__servicios span { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px;
    background: var(--soft); border: 1px solid var(--line); font-size: .72rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.enlace-form__servicios i { width: 8px; height: 8px; border-radius: 50%; background: var(--marca, #42588A); flex: none; }
.enlace-form .btn { width: 100%; justify-content: center; margin-top: 4px; }
.adjunto__ico--servicio { background: var(--marca, var(--nv-700)); color: #fff; font-size: .72rem; font-weight: 800; font-family: var(--display); }
.adjunto__txt a { color: inherit; }
.adjunto__txt strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adjunto__abrir { flex: none; font-size: .75rem; font-weight: 700; color: var(--or-600); white-space: nowrap; }

/* Tableta: Editar/Ocultar a la izquierda y Eliminar a la derecha, en una fila */
@media screen and (min-width: 601px) and (max-width: 860px) {
    .app .acciones--barra { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; }
}
/* Móvil: botones de acción de alto cómodo, sin inflarse */
@media screen and (max-width: 600px) {
    .app .acciones--barra .btn { min-height: 46px; padding-top: 10px; padding-bottom: 10px; }
}

/* Tableta: la ficha de la publicación en dos columnas solo si hay espacio */
@media screen and (max-width: 1100px) {
    .app .cols-2--pub { grid-template-columns: minmax(0, 1fr); }
    .app .portada--pub h2 { font-size: clamp(1.4rem, 4.2vw, 2rem); overflow-wrap: anywhere; }
}
@media screen and (max-width: 600px) {
    .app .acciones--barra { flex-direction: column; align-items: stretch; gap: 10px; }
    .app .acciones--barra > div { display: flex; gap: 8px; }
    .app .acciones--barra > div > * { flex: 1 1 0; }
    .app .acciones--barra > div .btn, .app .acciones--barra > .btn { width: 100%; justify-content: center; }
    .app .acciones--barra .en-linea { display: flex; }
    .app .adjunto { padding: 10px 12px; gap: 10px; }
    .app .adjunto__abrir { display: none; }
    .app .modal-cierre__form { padding: 22px 18px; }
    .app .modal-cierre__acciones .btn { flex: 1 1 auto; justify-content: center; }
    .app .celda-acciones { flex-wrap: wrap; }
}

/* Admin › Aulas: en celular y tableta la fila del aula baja a varias líneas
   (antes las píldoras y el botón «Cerrar y eliminar» se salían por la derecha). */
@media screen and (max-width: 1100px) {
    .app .aula-item__cab { align-items: flex-start; }
    .app .aula-item__cab .fila__txt { flex: 1 1 0; min-width: 0; }
    .app .aula-item__cab .fila__spine { align-self: stretch; }
    .app .aula-item__cab .fila__der { flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-start; min-width: 0; }
    .app .aula-item__cab .celda-acciones { white-space: normal; }
}
@media screen and (max-width: 600px) {
    .app .aula-item__cab .celda-acciones > * { flex: 1 1 calc(50% - 6px); }
    .app .aula-item__cab .celda-acciones .btn { width: 100%; justify-content: center; }
    .app .aula-item__cab .celda-acciones .en-linea { display: flex; }
}

/* ═══ Biblioteca docente · fila de plantilla ═══════════════════════════
   Una fila = un recurso reutilizable. En escritorio cabe todo en línea;
   al estrecharse, el grupo de acciones baja entero y en el teléfono se
   convierte en bloques a lo ancho. El botón «Asignar» nunca se estrecha:
   antes se partía letra por letra en una columna de 32px. */

/* Tableta: el grupo de acciones ocupa su propio renglón, alineado a la
   derecha, para que el título no quede exprimido contra los botones. */
@media screen and (max-width: 900px) {
    .app .plantilla-fila { align-items: flex-start; }
    .app .plantilla-fila .fila__ico { margin-top: 2px; }
    /* base 100% = el grupo de acciones se lleva un renglón entero para
       él; el icono y el título siguen juntos en el de arriba. */
    .app .plantilla-acciones { flex: 1 1 100%; padding-left: 48px; }
    .app .clonar-form { flex: 0 1 340px; }
}

/* Teléfono: primero los dos botones secundarios a mitad de ancho cada
   uno y debajo el asignador a lo ancho, que es la acción principal.
   Se respeta el orden del DOM, así el tabulador sigue el orden visual. */
@media screen and (max-width: 600px) {
    .app .plantilla-fila { padding: 14px; gap: 10px 12px; }
    .app .plantilla-acciones { justify-content: flex-start; padding-left: 0; gap: 8px; }
    .app .plantilla-acciones > .btn { flex: 1 1 0; min-width: 116px; }
    .app .clonar-form { flex: 1 1 100%; }
    /* 16px: por debajo de eso iOS hace zoom al enfocar el selector. */
    .app :where(.clonar-form, .asignar-inline) .ctrl,
    .app :where(.clonar-form, .asignar-inline) .ctrl:focus { font-size: 16px; padding-top: 10px; padding-bottom: 10px; }
    .app :where(.clonar-form, .asignar-inline) .btn { padding-left: 16px; padding-right: 16px; }
    /* «Asignar a aula» es una etiqueta larga: en el teléfono el selector y
       el botón se apilan dentro del mismo marco en vez de disputarse el
       ancho (el selector quedaba reducido a la flechita). */
    .app .asignar-inline { width: 100%; flex-direction: column; align-items: stretch; }
    .app .asignar-inline .ctrl { flex: none; }
    /* El contador de la sección se queda al lado del título; en columna
       caía solo a un renglón vacío. */
    .app .tipo-bloque__cab { flex-direction: row; align-items: flex-start; gap: 12px; }
    .app .tipo-bloque__acciones { width: auto; flex: none; }
    /* El selector de «crear plantilla»: siete tarjetas altas en columna
       obligaban a recorrer media pantalla. En el teléfono se leen como
       una lista, icono al lado del texto. */
    .app .crear-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .app .crear-card { flex-direction: row; align-items: center; gap: 12px; min-height: 0; padding: 12px 14px; }
    .app .crear-card__ico { flex: none; }
    .app .crear-card__txt { min-width: 0; }
}

/* Adaptación integral · septiembre 2026.
   Mantener las tablas dentro de su región desplazable, sin ocultar columnas
   ni aplicar overflow:hidden a la página para disimular desbordamientos. */
.app :where(fieldset, .aula-barra__id > div, .tipo-eval__cuerpo, .riel) { min-width: 0; }
.app :where(.cal-tabla-caja) { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.app :where(.tabla-caja, .tabla-envoltura, .tabla-envoltorio, .cal-tabla-caja, .pestanias) { scrollbar-width: thin; }
.app .cursos { grid-template-columns: repeat(auto-fill, minmax(min(100%, 292px), 1fr)); }
.app .cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); }
.app .tipos-eval { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.app .pildora { white-space: normal; overflow-wrap: break-word; }
.app .lienzo pre { max-width: 100%; overflow-x: auto; }

@media screen and (max-width: 1100px) {
    /* La identidad define un selector más específico para los enlaces. */
    .app .lateral .nav__it { min-height: 44px; font-size: .82rem; }
    .app .lateral { padding-top: max(12px, env(safe-area-inset-top)); }
    .app :where(.btn, .ctrl) { min-height: 44px; }
    .app :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea),
    .ingreso :where(input, select, textarea),
    .acceso-body :where(input, select, textarea) { font-size: 16px; }
    .app :where(.chat__volver, .chat__cerrar, .chat__enviar) { min-width: 44px; min-height: 44px; }
    .app .aula-barra__id { align-items: flex-start; }
    .app .aula-barra__id h2 { overflow-wrap: anywhere; }
}

/* La tableta usa una sola columna: conserva una anchura útil para escribir
   incluso entre los antiguos puntos de corte de 860 y 1024px. */
@media screen and (max-width: 1024px) {
    .ingreso { display: flex; flex-direction: column; min-height: 100svh; }
    .ingreso .escena--comercial { flex: none; min-height: 260px; height: 32svh; max-height: 360px; }
    .ingreso .ingreso__panel { width: 100%; flex: 1; padding: 32px 24px; }
    .ingreso .acceso2 { width: 100%; max-width: 480px; margin-top: 0; }
    .ingreso .acceso2__logo { display: none; }
    .ingreso .soporte-whatsapp { position: static; max-width: calc(100% - 32px); width: fit-content; margin: 0 auto max(24px, env(safe-area-inset-bottom)); }
    .ingreso .escena__marca { top: 18px; left: 20px; right: 20px; }
    .ingreso .escena__marca-txt { min-width: 0; overflow-wrap: break-word; }
    .ingreso .escena__marca-txt > span { letter-spacing: .1em; }
    .ingreso .escena__barras { left: 20px; bottom: 12px; align-items: center; }
    .ingreso .escena-pausa { width: 44px; height: 44px; }
    /* Aumentar el área de toque sin engrosar las barras de progreso. */
    .ingreso .escena__barra { position: relative; overflow: visible; }
    .ingreso .escena__barra::after { content: ''; position: absolute; inset: -19px 0; }
}

@media screen and (max-width: 600px) {
    .app :where(.cols-2, .cursos, .tipos-eval, .rejilla-2, .rejilla-3) { grid-template-columns: minmax(0, 1fr); }
    .app .lienzo { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
    .app .cabecera { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    .app .cabecera__t:empty { display: none; }
    .app .cabecera--consola .cabecera__der { display: flex; }
    .app .cabecera--consola .avatar--sm { width: 44px; height: 44px; }
    .app .pestanias { scroll-padding-inline: 12px; }
    .app .pestanias a { padding-inline: 14px; }
    .app .filtro { width: 100%; min-width: 0; }
    .app .filtro .ctrl { width: 100%; }
    .app .acciones--barra > div { flex-wrap: wrap; }
    .app .acciones--barra > div > * { flex-basis: 120px; }
    .app :where(.galeria--portadas, .crear-grid) { grid-template-columns: minmax(0, 1fr); }
    .app .chat { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
    .ingreso .escena--comercial { min-height: 200px; height: 28svh; max-height: 260px; }
    .ingreso .ingreso__panel { padding: 28px 20px 24px; }
    .ingreso .acceso2__encabezado h1 { font-size: clamp(1.6rem, 6.5vw, 2rem); line-height: 1.2; }
    .ingreso .escena__marca img { width: 44px; height: 44px; }
    .ingreso .escena__marca-txt strong { font-size: 12px; }
    .ingreso .escena__marca-txt > span { font-size: 8px; line-height: 1.6; }
    /* Los controles de selección conservan su tamaño nativo. La etiqueta
       es la zona táctil; el input no debe heredar 44px de alto. */
    .app input:is([type="checkbox"], [type="radio"]) { min-height: 0; }
    .app .campo--check label { min-height: 44px; }
}

@media screen and (max-height: 500px) and (max-width: 1100px) {
    .app :where(.pop, .yo__pop) { position: fixed; top: 8px; left: 8px; right: 8px; width: auto; max-height: calc(100dvh - 16px); overflow-y: auto; }
    .app .pop__lista { max-height: calc(100dvh - 110px); }
    .ingreso .escena--comercial { min-height: 160px; height: 160px; }
}

/* El icono del menú debe seguir siendo legible con el tema oscuro. */
:root[data-theme="oscuro"] .app .menu-movil {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}
