/* ══ LucIA, EL CHAT DE LA WEB (en todas las páginas públicas, t543, 29-oct-2026) ═══════════════════════
   Un botón flotante abajo a la derecha y un panel encima. En móvil el panel ocupa el ancho entero y sale de abajo. Todo
   con clases: la CSP no admite estilos en línea. Por encima de la cabecera (20).

   SU PROPIA HOJA, Y PEQUEÑA. Hasta el 29-oct el chat vivía dentro de biango.css (la hoja de las páginas de dentro) y su JS
   dentro de biango.js (45 KB con la agenda de la demo y la asistencia remota): la portada, /precios/ y el blog no cargan
   ninguno de los dos, así que allí no podía salir, y donde salía, con una conexión lenta el botón se pintaba y no hacía nada
   hasta que llegaba el JS entero. Ahora el chat trae su hoja (esta) y su JS (estatico/js/chat.js), y los carga TODA página
   que lo lleva (plantillas/circuito.js). Lo que el chat usaba de la hoja de dentro (los campos del formulario, el botón
   primario, que `hidden` gane siempre) va aquí abajo con :where(), sin peso: en las páginas de dentro manda lo de siempre. */
:where(.chatweb) [hidden] { display: none !important; }
:where(.chatweb) :where(button, input) { font: inherit; color: inherit; }
:where(.leadweb) .campo { display: grid; gap: .4rem; }
:where(.leadweb) .campo label { font-weight: 700; font-stretch: 90%; font-size: .92rem; color: var(--tinta); }
:where(.leadweb) .campo label small { margin-inline-start: .35em; font-weight: 500; font-stretch: 100%; color: var(--tinta-3); }
:where(.leadweb) .campo input {
  width: 100%; min-height: 2.9rem; padding: .7em .95em; border-radius: 12px; border: 1.5px solid #C5CDD9; background: var(--papel); color: var(--tinta);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
:where(.leadweb) .campo input:focus { outline: 0; border-color: var(--azul-boton); box-shadow: 0 0 0 4px color-mix(in srgb, var(--l-recepcion) 22%, transparent); }
:where(.leadweb) .boton--primario { background: var(--azul-boton); color: #fff; }
@media (hover: hover) and (pointer: fine) { :where(.leadweb) .boton--primario:hover { background: #125AAB; } }

.chatweb { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 60; }
.chatweb__abrir {
  display: inline-flex; align-items: center; gap: .55em; min-height: 2.9rem; padding: .3rem 1.15rem .3rem .3rem; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--tinta); color: #fff; font-weight: 650; font-size: .98rem; line-height: 1.2;
  box-shadow: 0 18px 40px -18px rgba(27, 33, 48, .6); transition: transform 160ms var(--sale), background-color 180ms ease;
}
.chatweb__abrir:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .chatweb__abrir:hover { background: var(--azul-boton); } }
/* La cara de LucIA (estatico/img/lucia/lucia-cara-96.webp, 96×96 y 4 KB: el robot de dentro del programa, recortado a la
   cabeza). Su tamaño va también en el HTML (width y height): el botón no salta cuando llega la imagen. */
.chatweb__cara { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: #fff; object-fit: cover; }
.chatweb--abierto .chatweb__abrir { display: none; }
.chatweb__panel {
  position: absolute; right: 0; bottom: 0; width: min(26rem, calc(100vw - 2rem)); max-height: min(38rem, calc(100vh - 2rem));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--papel); color: var(--tinta); border: 1px solid var(--borde); border-top: 8px solid var(--l-recepcion); border-radius: var(--radio);
  box-shadow: 0 30px 70px -28px rgba(27, 33, 48, .55);
}
.chatweb__cab { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; border-bottom: 1px solid var(--borde); background: var(--suelo); }
.chatweb__avatar { flex: none; display: block; width: 2.75rem; height: 2.75rem; border-radius: 50%; overflow: hidden; background: var(--azul-claro); border: 2px solid var(--l-recepcion); }
.chatweb__avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chatweb__quien { min-width: 0; flex: 1; display: grid; gap: .1rem; }
.chatweb__quien strong { font-weight: 750; font-stretch: 92%; font-size: .98rem; }
.chatweb__quien small { font-size: .78rem; color: var(--tinta-3); line-height: 1.3; }
.chatweb__cerrar { flex: none; width: 2.25rem; height: 2.25rem; border: 0; border-radius: 50%; background: transparent; color: var(--tinta-2); cursor: pointer; display: grid; place-items: center; }
@media (hover: hover) and (pointer: fine) { .chatweb__cerrar:hover { background: color-mix(in srgb, var(--tinta) 8%, transparent); } }
.chatweb__cerrar .ico { width: 1rem; height: 1rem; }
.chatweb__hilo { flex: 1; min-height: 12rem; overflow-y: auto; padding: 1rem; display: grid; gap: .6rem; align-content: start; overscroll-behavior: contain; }
.chatweb__msg { max-width: 88%; padding: .65rem .9rem; border-radius: 16px; font-size: .96rem; line-height: 1.5; }
.chatweb__msg p { margin: 0; white-space: pre-line; }
.chatweb__msg--bot { justify-self: start; background: var(--suelo); border: 1px solid var(--borde); border-bottom-left-radius: 6px; }
.chatweb__msg--yo { justify-self: end; background: var(--azul-boton); color: #fff; border-bottom-right-radius: 6px; }
.chatweb__fuentes { padding: .5rem 0 0; margin: .5rem 0 0; border-top: 1px solid var(--borde); display: grid; gap: .3rem; font-size: .86rem; }
.chatweb__fuentes a { color: var(--azul-texto); text-decoration: underline; text-underline-offset: 2px; }
.chatweb__msg--pensando { display: inline-flex; gap: .3rem; padding: .8rem 1rem; }
.chatweb__msg--pensando span { width: .45rem; height: .45rem; border-radius: 50%; background: var(--tinta-3); animation: chatweb-punto 1.1s ease-in-out infinite; }
.chatweb__msg--pensando span:nth-child(2) { animation-delay: .18s; }
.chatweb__msg--pensando span:nth-child(3) { animation-delay: .36s; }
@keyframes chatweb-punto { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chatweb__form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--borde); }
.chatweb__form input[name="texto"] { flex: 1; min-width: 0; padding: .7rem .95rem; border: 1.5px solid var(--borde); border-radius: 999px; font-size: .96rem; background: var(--papel); color: var(--tinta); }
.chatweb__form input[name="texto"]:focus { outline: 3px solid color-mix(in srgb, var(--l-recepcion) 45%, transparent); outline-offset: 1px; border-color: var(--azul-boton); }
.chatweb__enviar { flex: none; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%; background: var(--azul-boton); color: #fff; cursor: pointer; display: grid; place-items: center; }
.chatweb__enviar:disabled { opacity: .5; cursor: default; }
.chatweb__enviar .ico { width: 1.05rem; height: 1.05rem; }
.chatweb__miel { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.chatweb__oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chatweb__pie { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem; padding: .55rem .95rem .75rem; font-size: .84rem; color: var(--tinta-3); }
.chatweb__pie a { color: inherit; }
/* Las dos formas de hablar con una persona (B-1743): escribir por WhatsApp y «Que me contacten». Se parten en dos líneas
   si el panel es estrecho, sin empujar «Privacidad» fuera. */
.chatweb__vias { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
.chatweb__pie > a { margin-left: auto; }
.chatweb__numero { white-space: nowrap; }
.chatweb__pie .chatweb__whatsapp { display: inline-flex; align-items: center; gap: .35em; font-weight: 650; color: var(--azul-texto); text-decoration: underline; text-underline-offset: 2px; }
.chatweb__whatsapp .ico { flex: none; width: 1.1em; height: 1.1em; }
.chatweb__lead-abrir { border: 0; background: transparent; padding: 0; font: inherit; font-weight: 650; color: var(--azul-texto); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 36em) {
  .chatweb { right: 0; bottom: 0; left: 0; }
  .chatweb__abrir { position: absolute; right: 1rem; bottom: 1rem; }
  .chatweb__panel { width: 100%; max-height: 92vh; border-radius: var(--radio) var(--radio) 0 0; border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { .chatweb__msg--pensando span { animation: none; opacity: .7; } }

/* ══ «QUE ME CONTACTEN», EN SU VENTANA (B-2286, 28-oct-2026) ════════════════
   Antes se desplegaba dentro del panel del chat, en una caja pequeña con su propia barra. Ahora es un <dialog> modal
   (estatico/js/chat.js lo abre con showModal()): centrado encima de la página en el ordenador, entero y sin desplazarse
   desde 1366×768, y a pantalla completa en el móvil. La cabecera va en el azul de Biango (--azul-boton, #1668C4: el
   blanco encima llega a 5,5:1). Mientras está abierta, la página de detrás no se desplaza (html.leadweb-abierta).
   Ojo: a `.leadweb` NO se le pone `display`; cerrado, el navegador lo esconde con el suyo. */
/* Al quitar la barra de desplazamiento (Windows), lo de detrás no salta: ocupa su hueco un relleno del mismo ancho, que mide
   chat.js al abrir (--leadweb-barra, puesta por CSSOM: en el HTML no hay ningún `style=`). Con `scrollbar-gutter` el hueco
   se quedaba SIN oscurecer: una franja clara a la derecha del fondo. */
html.leadweb-abierta { overflow: hidden; padding-inline-end: var(--leadweb-barra, 0px); }
html.leadweb-abierta .chatweb { right: calc(max(1rem, env(safe-area-inset-right)) + var(--leadweb-barra, 0px)); }
.leadweb {
  width: min(40rem, 100% - 2rem); max-width: none; max-height: calc(100dvh - 2rem);
  margin: auto; padding: 0; border: 0; background: transparent; color: var(--tinta); overflow: visible;
}
.leadweb::backdrop { background: rgba(27, 33, 48, .6); }
@supports (backdrop-filter: blur(1px)) { .leadweb::backdrop { backdrop-filter: blur(3px); } }
.leadweb__caja {
  display: flex; flex-direction: column; max-height: calc(100dvh - 2rem); overflow: hidden auto; overscroll-behavior: contain;
  background: var(--papel); border-radius: 20px; box-shadow: 0 40px 90px -30px rgba(15, 19, 26, .65);
}
.leadweb__cab { position: relative; flex: none; display: flex; align-items: flex-start; gap: 1rem; padding: 1.6rem 1.6rem 1.45rem; background: var(--azul-boton); color: #fff; }
.leadweb__ico { flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; background: #fff; color: var(--azul-boton); }
.leadweb__ico .ico { width: 1.35rem; height: 1.35rem; }
.leadweb__textos { flex: 1; min-width: 0; display: grid; gap: .4rem; padding-inline-end: 2.75rem; }
.leadweb__titulo { font-weight: 800; font-size: clamp(1.45rem, 1.2rem + .8vw, 1.8rem); line-height: 1.1; letter-spacing: -.02em; color: #fff; text-wrap: balance; }
.leadweb .chatweb__lead-intro { margin: 0; font-size: 1rem; line-height: 1.45; color: var(--azul-claro); }
.leadweb__cerrar {
  position: absolute; top: .9rem; right: .9rem; width: 2.75rem; height: 2.75rem; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; transition: background-color 160ms ease;
}
@media (hover: hover) and (pointer: fine) { .leadweb__cerrar:hover { background: rgba(255, 255, 255, .28); } }
.leadweb__cerrar:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.leadweb__cerrar .ico { width: 1.2rem; height: 1.2rem; }
/* El formulario de siempre, con aire: dos columnas en el ordenador, una en el móvil. */
.chatweb__lead { padding: 1.6rem; }
.chatweb__lead > * + * { margin-top: 1.15rem; }
.chatweb__lead > .chatweb__estado:empty { margin-top: 0; }
.leadweb__campos { display: grid; gap: 1rem 1.15rem; }
@media (min-width: 36.01em) { .leadweb__campos { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.chatweb__consent { display: flex; gap: .65rem; align-items: flex-start; font-size: .92rem; color: var(--tinta-2); line-height: 1.45; cursor: pointer; }
.chatweb__consent input { flex: none; width: 1.2rem; height: 1.2rem; margin: .12rem 0 0; accent-color: var(--azul-boton); cursor: pointer; }
.chatweb__lead .botonera { margin-top: 1.4rem; }
.chatweb__lead .botonera .boton, .leadweb__listo .boton { min-width: 11rem; }
.chatweb__estado { margin: 0; font-size: .95rem; }
.chatweb__estado[data-tipo="error"] { padding: .8rem 1rem; border-radius: 12px; background: #FDE7E7; color: #8F1D21; border: 1px solid color-mix(in srgb, var(--l-clinica) 40%, var(--borde)); }
/* Enviado: el aviso grande, en la misma ventana, y el botón para volver. */
.chatweb__estado[data-tipo="ok"] { padding: 1.1rem 1.25rem; border-radius: 14px; background: #E3F4EA; color: #145232; border-inline-start: 6px solid var(--l-contabilidad); font-size: 1.08rem; font-weight: 650; line-height: 1.45; }
@media (max-width: 36em) {
  .leadweb { width: 100%; height: 100%; max-height: 100%; margin: 0; }
  .leadweb__caja { height: 100%; max-height: none; border-radius: 0; box-shadow: none; }
  .leadweb__cab { padding: max(1.35rem, env(safe-area-inset-top)) 1.25rem 1.3rem; }
  .leadweb__ico { display: none; }   /* en el ancho del móvil, el título cabe en una línea */
  .chatweb__lead { padding: 1.35rem 1.25rem max(1.35rem, env(safe-area-inset-bottom)); }
  .chatweb__lead .botonera .boton, .leadweb__listo .boton { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .leadweb[open] .leadweb__caja { animation: leadweb-entra 220ms var(--sale); }
  .leadweb[open]::backdrop { animation: leadweb-fondo 220ms ease; }
}
@keyframes leadweb-entra { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes leadweb-fondo { from { opacity: 0; } }
