/* Chat de PROMPTINA: se suma a la identidad azul de la v35 (css/v35.css) sin cambiarla.
   Reglas: objetivos táctiles de 44 px o más, contraste AA, tamaños en rem, movimiento reducido respetado. */

[hidden] { display: none !important; }

/* ───── Accesibilidad general ───── */
.salto { position: absolute; left: 12px; top: -80px; z-index: 100; background: #0b3d6e; color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.salto:focus { top: 12px; }
button, select, .btn, a.btn { min-height: 44px; }
a.btn, .btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
:focus-visible { outline: 3px solid #2a7fc4; outline-offset: 3px; }
.bluehero :focus-visible, .attention-clock :focus-visible { outline-color: #8ed9ff; }
button:disabled { opacity: 1; cursor: not-allowed; color: #5a6f85; background: #e4ebf3; border-color: #c6d3e1; box-shadow: none; }
.nav { min-height: 44px; }
header a { min-height: 44px; display: inline-flex; align-items: center; color: #134f91; font-weight: 600; }
header .enlace-herramientas { padding: 0 4px; text-decoration: underline; text-underline-offset: 3px; }

/* ───── Panel de sesiones ───── */
.session-panel .estado-texto { margin: 0 0 6px; font-size: 1.0625rem; color: #123e68; }
.sessbar { margin: 20px 0 8px; }
.sessbar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 1rem; font-weight: 700; color: #0b3d6e; margin-bottom: 8px; }
.sessbar-top .pct { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.sessbar-pista { position: relative; height: 18px; border-radius: 999px; background: #d3e6f6; border: 1px solid #9ec3e4; overflow: hidden; }
.sessbar-relleno { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #0a5fa5, #2a9fdc); transition: width .6s ease, background .3s; }
.sessbar.aviso-20 .sessbar-relleno { background: linear-gradient(90deg, #8a5200, #d68a00); }
.sessbar.aviso-10 .sessbar-relleno { background: linear-gradient(90deg, #8f1229, #d1324d); }
.sessbar-nota { font-size: .9375rem; color: #35546f; margin: 6px 0 0; }
.sessbar.sin-sesion .sessbar-relleno { width: 0 !important; }
.session-actions { flex-wrap: wrap; }
.btn-cierre { background: #fff; color: #0b567d; border: 2px solid #0b6aa8; border-radius: 12px; padding: 12px 20px; font-size: 1.0625rem; font-weight: 700; }
.btn-cierre:hover:not(:disabled) { background: #e5f1ff; }
.btn-secundario { background: #fff; color: #0b567d; border: 1px solid #6fa6d1; border-radius: 10px; padding: 10px 18px; font-size: 1rem; font-weight: 600; }
.btn-secundario:hover:not(:disabled) { background: #e5f1ff; }
.start-session:disabled { background: #e4ebf3; color: #4e6a85; box-shadow: none; }

/* ───── Avisos ───── */
.avisos { margin: 14px 0; display: grid; gap: 10px; }
.aviso { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-radius: 12px; padding: 14px 16px; font-size: 1.0625rem; line-height: 1.5; border: 1px solid #bbd5ef; background: #e9f3ff; color: #12385d; }
.aviso p { margin: 0; flex: 1 1 240px; }
.aviso strong { font-weight: 800; }
.aviso.aviso-20 { background: #fff4d9; border-color: #e0b04a; color: #4a3000; }
.aviso.aviso-10 { background: #ffe4e8; border-color: #e08797; color: #650b1d; }
.aviso.aviso-error { background: #ffe9ec; border-color: #d8707f; color: #650b1d; }
.aviso .btn-secundario { flex: 0 0 auto; }

/* ───── Chat ───── */
.chat-session { margin-top: 26px; }
.bienvenida { padding: 22px 24px; margin: 0 0 18px; }
.bienvenida h2 { font-size: 1.5rem; margin: 0 0 10px; }
.bienvenida p { font-size: 1.0625rem; line-height: 1.7; margin: 0 0 10px; white-space: normal; }
.chat-log { display: flex; flex-direction: column; gap: 16px; margin: 0 0 18px; padding: 0; list-style: none; }
.msg { max-width: 100%; }
.msg-usuario { align-self: flex-end; max-width: min(92%, 640px); background: #dcecff; border: 1px solid #a9c9ea; color: #0f2f4d; border-radius: 16px 16px 4px 16px; padding: 14px 18px; font-size: 1.0625rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-usuario .quien, .msg-bot .quien { display: block; font-size: .8125rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #2c557c; margin-bottom: 6px; }
.msg-bot { align-self: stretch; background: #fff; border: 1px solid #b9d3ea; border-radius: 16px 16px 16px 4px; padding: 18px 20px; box-shadow: 0 4px 14px #0e4b8310; }
.msg-bot .message-markdown { font-size: 1.0625rem; }
.msg-bot.error { border-color: #d8707f; background: #fff7f8; }
.msg-bot .reintentar { margin-top: 12px; }

.escribiendo { display: inline-flex; align-items: center; gap: 10px; color: #234e77; font-size: 1rem; padding: 4px 0; }
.escribiendo .puntos { display: inline-flex; gap: 5px; }
.escribiendo .puntos i { width: 9px; height: 9px; border-radius: 50%; background: #1a73b8; animation: salto 1.1s infinite ease-in-out; }
.escribiendo .puntos i:nth-child(2) { animation-delay: .18s; }
.escribiendo .puntos i:nth-child(3) { animation-delay: .36s; }
@keyframes salto { 0%, 70%, 100% { transform: translateY(0); opacity: .45; } 35% { transform: translateY(-6px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .escribiendo .puntos i { animation: none; opacity: .8; } .sessbar-relleno { transition: none; } }

/* Prompts entregados: bloque con botón «Copiar» */
.prompt-block { margin: 16px 0; border: 1px solid #8fbbe0; border-radius: 12px; overflow: hidden; background: #f1f8ff; }
.prompt-block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 6px 14px; background: #dcecff; border-bottom: 1px solid #b6d3ec; font-size: .9375rem; font-weight: 700; color: #0b3d6e; }
.prompt-block .copiar { background: #0b5ea3; color: #fff; border: 0; border-radius: 9px; padding: 8px 18px; font-size: 1rem; font-weight: 700; min-width: 96px; }
.prompt-block .copiar:hover { background: #084a82; }
.prompt-block .copiar.copiado { background: #0a6b46; }
.message-markdown .prompt-block pre { margin: 0; border: 0; border-radius: 0; background: transparent; white-space: pre-wrap; overflow-wrap: anywhere; padding: 16px; font-size: .9688rem; line-height: 1.65; color: #11283f; font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace; }

/* Citas como etiqueta al pie de la respuesta */
.citas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #d3e3f1; }
.citas-titulo { font-size: .8125rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #2c557c; align-self: center; margin-right: 2px; }
.cita { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #8fbbe0; background: #eaf4fe; color: #0b3d6e; border-radius: 999px; padding: 6px 12px; font-size: .9375rem; font-weight: 600; }
.cita::before { content: "\1F4D6"; font-size: .95em; }

/* Compositor */
.composer-form { margin-top: 8px; }
.composer-fila { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 10px; }
.composer-fila label { font-size: .9375rem; color: #234e77; font-weight: 600; }
.composer-fila select { min-height: 44px; font-size: 1rem; max-width: 100%; }
.composer-fila .acciones { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.composer textarea { min-height: 96px; max-height: 40vh; }
.send { min-width: 120px; min-height: 48px; border-radius: 10px; }
.send:disabled { background: #e4ebf3; color: #4e6a85; }
.contador { font-size: .875rem; color: #44627e; }
.contador.excedido { color: #8f1229; font-weight: 700; }

/* Chips con preguntas típicas por capítulo */
.concepts .chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.concepts .chip { min-height: 44px; border: 1px solid #8fb5d9; border-radius: 10px; padding: 10px 14px; background: #fff; color: #174f84; font-size: .9688rem; font-weight: 600; text-align: left; }
.concepts .chip:hover { background: #e5f1ff; border-color: #2a7fc4; }
.concepts-titulo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.concepts-titulo strong { font-size: 1.0625rem; font-weight: 700; color: #0b3d6e; }

/* Enlaces fijos puestos por la interfaz */
.enlaces-fijos { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.enlaces-fijos .btn-secundario { text-decoration: none; }

/* Diálogo «Guía rápida» */
dialog.guia { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; border: 1px solid #8fbbe0; border-radius: 20px; padding: 26px; color: #12385d; background: #fff; box-shadow: 0 20px 60px #0a2a4a55; }
dialog.guia::backdrop { background: #061a2ab0; }
dialog.guia h2 { margin: 0 0 12px; font-size: 1.5rem; color: #06456c; }
dialog.guia ol { padding-left: 22px; font-size: 1.0625rem; line-height: 1.7; }
dialog.guia .cerrar-guia { margin-top: 16px; }

/* Anuncios para lectores de pantalla y avisos breves */
.anuncios { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #0b3d6e; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 1rem; font-weight: 600; z-index: 50; box-shadow: 0 8px 24px #0a2a4a55; }

/* Pie con atribución */
footer.pie { display: block; margin: 22px 3px 14px; font-size: .875rem; line-height: 1.7; color: #3f5d79; }
footer.pie p { margin: 0 0 8px; }
footer.pie a { color: #0b5ea3; font-weight: 600; text-underline-offset: 3px; }
footer.pie .atribucion { padding-top: 10px; border-top: 1px solid #cddcec; }

/* Contraste y tamaños corregidos sobre la v35 (misma identidad visual) */
.attention-note, .attention-legend > span, .attention-time > small { color: #cfe3f1; }
.keyhint { color: #3f5d79; }
.little, .label { color: #3b5878; }
.sidecard .restantes { display: block; margin-top: 12px; font-size: 1rem; color: #123e68; }

/* Móvil */
@media (max-width: 650px) {
  header > span { display: none; }
  header { justify-content: space-between; height: auto; min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
  .msg-usuario { max-width: 100%; }
  .composer-fila .acciones { width: 100%; }
  .composer-fila .acciones .send { flex: 1; }
  .prompt-block-head { padding-left: 12px; }
  .session-actions .btn-cierre, .session-actions .start-session { width: 100%; }
  .bluehero { padding: 24px 18px; }
  .photolabel { position: static; margin-top: 12px; }
}

/* Tablas dentro de las respuestas: no cortar palabras; si no entran, se desplazan */
.message-markdown th, .message-markdown td { overflow-wrap: normal; word-break: normal; min-width: 7rem; }

/* Selector de capítulo (también fija el ámbito de la consulta) */
.selector-capitulo { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; }
.selector-capitulo label { font-size: .9375rem; color: #234e77; font-weight: 600; }
.selector-capitulo select { width: 100%; max-width: 100%; min-height: 44px; font-size: 1rem; }
@media (max-width: 650px) { .selector-capitulo { width: 100%; } .composer-fila { justify-content: flex-end; } }
