/* =====================================================================
   Chat público de Turing (19 nov 2026). Todo bajo .ct para no tocar el resto del sitio.
   - Una columna tipo mensajería, con tarjetas dentro de la conversación; pestañas Chat y Buzón.
   - Arreglo de la maqueta (Daniel, 19 nov): el encabezado, la botonera y la caja de envío NO se encogen
     (flex-shrink:0) y el historial tiene min-height:0; así el texto de la botonera ya no se recorta.
   - Claro y oscuro (prefers-color-scheme + data-theme), foco visible, movimiento reducido, celular primero.
   ===================================================================== */
.ct {
  --ct-bg: #F4F6FB; --ct-surface: #FFFFFF; --ct-surface2: #EAEEF8; --ct-fg: #16192B; --ct-muted: #566080; --ct-line: #D5DBEB;
  --ct-turing: #1F5FD6; --ct-turing-ink: #FFFFFF; --ct-turing-soft: #DDE8FF;
  --ct-morado: #5E3CB8; --ct-morado-soft: #E9E2FA;
  --ct-vela: #F3C45A; --ct-vela-soft: #FFF1CC;
  --ct-ok: #1B7F5C; --ct-warn: #8F5208; --ct-bad: #B3261E;
  max-width: 920px; margin: 0 auto; color: var(--ct-fg);
  /* Fondo propio: el contraste del título y las pestañas no depende de que la página también sea oscura. */
  background: var(--ct-bg); border-radius: 22px; padding: 14px 18px 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ct {
    --ct-bg: #0E1220; --ct-surface: #171C30; --ct-surface2: #1F2640; --ct-fg: #EDF0FA; --ct-muted: #A3AACB; --ct-line: #2C3557;
    --ct-turing: #6E9BFF; --ct-turing-ink: #0B1530; --ct-turing-soft: #1B2A52;
    --ct-morado: #B39CFF; --ct-morado-soft: #2A2250; --ct-vela-soft: #3A3014;
    --ct-ok: #52D1A0; --ct-warn: #F0B35A; --ct-bad: #FF8E85;
  }
}
:root[data-theme="dark"] .ct {
  --ct-bg: #0E1220; --ct-surface: #171C30; --ct-surface2: #1F2640; --ct-fg: #EDF0FA; --ct-muted: #A3AACB; --ct-line: #2C3557;
  --ct-turing: #6E9BFF; --ct-turing-ink: #0B1530; --ct-turing-soft: #1B2A52;
  --ct-morado: #B39CFF; --ct-morado-soft: #2A2250; --ct-vela-soft: #3A3014;
  --ct-ok: #52D1A0; --ct-warn: #F0B35A; --ct-bad: #FF8E85;
}
.ct *, .ct *::before, .ct *::after { box-sizing: border-box; }
.ct [hidden] { display: none !important; }
.ct-vista-previa { color: #16192B; background: #FFF1CC; border: 1px solid #F3C45A; border-radius: 12px; padding: 8px 14px; margin: 0 0 14px; font-size: .92rem; }
.ct-visible-lector { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ct-top { display: flex; gap: 14px; align-items: center; padding: 4px 0 8px; }
.ct-top h1 { color: var(--ct-fg); }
.ct-logo { flex: 0 0 44px; height: 44px; border-radius: 50%; }
.ct-top h1 { font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.15; margin: 0; text-wrap: balance; }
.ct-sub { color: var(--ct-muted); margin: 2px 0 0; font-size: .95rem; }

.ct-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; border-bottom: 1px solid var(--ct-line); }
.ct-tabs button { font: inherit; background: none; border: 0; color: var(--ct-muted); padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; margin-bottom: -1px; min-height: 44px; }
.ct-tabs button[aria-selected="true"] { color: var(--ct-fg); border-bottom-color: var(--ct-turing); font-weight: 700; }
.ct button:focus-visible, .ct input:focus-visible, .ct textarea:focus-visible, .ct a:focus-visible, .ct select:focus-visible, .ct-log:focus-visible { outline: 3px solid var(--ct-morado); outline-offset: 2px; }

.ct-btn { font: inherit; border: 1px solid var(--ct-line); background: var(--ct-surface); color: var(--ct-fg); border-radius: 999px; padding: 8px 16px; cursor: pointer; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.ct-btn:hover { filter: brightness(.97); }
.ct-primario { background: var(--ct-turing); color: var(--ct-turing-ink); border-color: var(--ct-turing); font-weight: 700; }
.ct-peligro { color: var(--ct-bad); border-color: var(--ct-bad); }
.ct-btn[disabled] { opacity: .6; cursor: default; }

/* ---- el chat ---- */
.ct-chat { background: var(--ct-surface); border: 1px solid var(--ct-line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; height: clamp(480px, 74vh, 780px); }
.ct-cabeza { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--ct-turing); color: var(--ct-turing-ink); }
.ct-cabeza img { flex: 0 0 34px; height: 34px; border-radius: 50%; background: #fff; }
.ct-cabeza b { display: block; line-height: 1.1; }
.ct-cabeza small { opacity: .9; }
.ct-cuota { margin-left: auto; background: rgba(255,255,255,.2); border-radius: 999px; padding: 4px 10px; font-size: .82rem; text-align: center; white-space: nowrap; flex: 0 0 auto; }
.ct-cuota:empty { display: none; }
.ct-nuevo { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ct-turing-ink); background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.45); border-radius: 999px; padding: 4px 11px; min-height: 30px; }
.ct-nuevo:hover { background: rgba(255,255,255,.34); }
.ct-nuevo:focus-visible { outline: 3px solid #FFD36B; outline-offset: 2px; }
.ct-cuota:not(:empty) + .ct-nuevo { margin-left: 0; }
.ct-cuota:empty + .ct-nuevo { margin-left: auto; }
.ct-cabeza > div { min-width: 0; }
/* Lo que no debe encogerse (arreglo de la botonera): */
.ct-cabeza, .ct-rapidos, .ct-envio, .ct-pie { flex-shrink: 0; }
.ct-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--ct-bg); }

.ct-msg { display: flex; gap: 8px; max-width: 100%; }
.ct-msg.yo { justify-content: flex-end; }
.ct-av { flex: 0 0 28px; height: 28px; border-radius: 50%; margin-top: 2px; }
.ct-burbuja { background: var(--ct-surface); border: 1px solid var(--ct-line); border-radius: 4px 16px 16px 16px; padding: 10px 14px; min-width: 0; max-width: min(100%, 560px); overflow-wrap: anywhere; }
.yo .ct-burbuja { background: var(--ct-turing); color: var(--ct-turing-ink); border-color: var(--ct-turing); border-radius: 16px 4px 16px 16px; }
.ct-burbuja p { margin: 0 0 8px; }
.ct-burbuja p:last-child { margin: 0; }
.ct-origen { display: block; font-size: .78rem; color: var(--ct-muted); margin-top: 8px; }
.ct-origen::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--ct-turing); }
.ct-origen[data-origen="tarjeta"]::before, .ct-origen[data-origen="contacto"]::before { background: var(--ct-morado); }
.ct-origen[data-origen="enlaces"]::before { background: var(--ct-warn); }
.ct-origen[data-origen="guardada"]::before { background: var(--ct-ok); }
.ct-pensando { display: inline-flex; gap: 4px; padding: 4px 0; }
.ct-pensando i { width: 7px; height: 7px; border-radius: 50%; background: var(--ct-muted); animation: ct-b 1s infinite; }
.ct-pensando i:nth-child(2) { animation-delay: .15s; } .ct-pensando i:nth-child(3) { animation-delay: .3s; }
@keyframes ct-b { 50% { transform: translateY(-4px); opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .ct-pensando i { animation: none; } }

/* ---- tarjetas dentro de la conversación ---- */
.ct-tarjeta { border: 1px solid var(--ct-line); border-radius: 12px; background: var(--ct-surface2); padding: 12px; margin-top: 8px; }
.ct-tarjeta h3 { margin: 0 0 6px; font-size: 1.05rem; }
.ct-tarjeta.ct-ayuda { background: var(--ct-vela-soft); border-color: var(--ct-vela); }
.ct-tarjeta.ct-cuenta { background: var(--ct-morado-soft); border-color: var(--ct-morado); }
.ct-ficha { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.ct-ficha .ct-mini { flex: 0 0 56px; height: 56px; border-radius: 50%; }
.ct-ficha b { display: block; font-size: 1.05rem; }
.ct-ficha small { color: var(--ct-muted); display: block; }
.ct-mini { background: linear-gradient(135deg, var(--ct-turing), var(--ct-morado)); display: grid; place-items: center; color: #fff; font-weight: 700; overflow: hidden; object-fit: cover; border-radius: 8px; flex: 0 0 40px; height: 40px; }
.ct-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ct-lista a { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; background: var(--ct-surface); border: 1px solid var(--ct-line); border-radius: 10px; padding: 8px; min-height: 52px; }
.ct-lista a:hover { border-color: var(--ct-turing); }
.ct-lista .ct-t { min-width: 0; }
.ct-lista b { display: block; line-height: 1.25; overflow-wrap: anywhere; }
.ct-lista small { color: var(--ct-muted); display: block; overflow-wrap: anywhere; }
.ct-cal { margin-left: auto; flex: 0 0 auto; min-width: 34px; text-align: center; font-weight: 700; border-radius: 8px; padding: 2px 6px; background: var(--ct-turing-soft); }
.ct-fuentes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ct-fuente { display: inline-flex; gap: 6px; align-items: center; background: var(--ct-surface2); border-radius: 10px; padding: 5px 10px; font-size: .84rem; text-decoration: none; color: var(--ct-fg); max-width: 100%; border: 1px solid var(--ct-line); }
.ct-fuente b { color: var(--ct-turing); white-space: nowrap; }
.ct-botones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ct-chip { font: inherit; font-size: .9rem; line-height: 1.3; border: 1px solid var(--ct-turing); color: var(--ct-fg); background: var(--ct-surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-block; min-height: 36px; }
.ct-chip:hover { background: var(--ct-turing-soft); }
.ct-lineas { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.ct-lineas li { background: var(--ct-surface); border: 1px solid var(--ct-line); border-radius: 10px; padding: 8px 12px; }
.ct-lineas a { font-weight: 700; font-size: 1.15rem; color: var(--ct-fg); }
.ct-lineas small { display: block; color: var(--ct-muted); }
.ct-form label { display: block; font-weight: 700; font-size: .86rem; margin: 10px 0 3px; }
.ct-form input, .ct-form textarea { width: 100%; font: inherit; border: 1px solid var(--ct-line); border-radius: 10px; padding: 8px 10px; background: var(--ct-bg); color: var(--ct-fg); }
.ct-form textarea { min-height: 96px; resize: vertical; }
.ct-error { color: var(--ct-bad); font-size: .88rem; margin: 6px 0 0; }
.ct-nota { font-size: .85rem; color: var(--ct-muted); }

/* ---- botonera y caja de envío ---- */
.ct-rapidos { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; background: var(--ct-surface); border-top: 1px solid var(--ct-line); -webkit-overflow-scrolling: touch; }
.ct-rapidos .ct-chip { white-space: nowrap; flex: 0 0 auto; }
.ct-rapidos:empty { display: none; }
.ct-envio { display: flex; gap: 8px; padding: 10px 16px 8px; background: var(--ct-surface); }
.ct-envio input { flex: 1; min-width: 0; font: inherit; border: 1px solid var(--ct-line); border-radius: 999px; padding: 10px 16px; background: var(--ct-bg); color: var(--ct-fg); min-height: 44px; }
.ct-pie { font-size: .78rem; color: var(--ct-muted); margin: 0; padding: 0 16px 12px; background: var(--ct-surface); }
.ct-pie a { color: inherit; }

/* ---- Buzón ---- */
.ct-buzon { background: var(--ct-surface); border: 1px solid var(--ct-line); border-radius: 18px; padding: 16px; }
.ct-buzon h2 { font-size: 1.15rem; margin: 18px 0 8px; } .ct-buzon h2:first-child { margin-top: 0; }
.ct-tema { margin: 0 0 14px; }
.ct-tema h3 { font-size: .95rem; margin: 0 0 6px; color: var(--ct-muted); text-transform: none; }
.ct-hilos { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ct-hilo { width: 100%; text-align: left; font: inherit; background: var(--ct-surface2); border: 1px solid var(--ct-line); border-radius: 10px; padding: 8px 12px; cursor: pointer; color: var(--ct-fg); display: grid; gap: 2px; min-height: 48px; }
.ct-hilo small { color: var(--ct-muted); }
.ct-hmsg { border-radius: 10px; padding: 8px 12px; margin: 8px 0; background: var(--ct-surface2); max-width: 92%; overflow-wrap: anywhere; }
.ct-hmsg.yo { background: var(--ct-turing-soft); margin-left: auto; }
.ct-estado { display: inline-block; font-size: .78rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; background: var(--ct-surface2); }
.ct-estado[data-tono="ambar"] { background: var(--ct-vela-soft); } .ct-estado[data-tono="verde"] { background: var(--ct-turing-soft); color: var(--ct-ok); }
.ct-contacto { border: 1px solid var(--ct-line); border-radius: 12px; padding: 12px; margin: 8px 0; background: var(--ct-surface2); }
.ct-contacto h4 { margin: 0 0 4px; font-size: 1rem; }
.ct-acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

@media (max-width: 520px) {
  .ct { border-radius: 16px; padding: 10px 10px 12px; }
  .ct-log { padding: 12px; }
  .ct-cabeza, .ct-rapidos, .ct-envio, .ct-pie { padding-left: 12px; padding-right: 12px; }
  .ct-cuota { font-size: .75rem; padding: 3px 8px; }
  .ct-cabeza small { display: none; }
  .ct-chat { height: max(440px, calc(100vh - 210px)); height: max(440px, calc(100dvh - 210px)); }
  .ct-sub { display: none; }
  .ct-top { padding-bottom: 0; }
  .ct-top h1 { font-size: 1.35rem; }
  .ct-tabs { margin: 6px 0 10px; }
}

/* ---- Dentro de la ventana flotante (iframe, ?marco=1): ocupa todo el marco, sin título grande ni bordes redondos ---- */
body.ct-marco { margin: 0; background: #F4F6FB; }
.ct-seccion-marco, .ct-seccion-marco .contenedor { padding: 0 !important; margin: 0 !important; max-width: none !important; width: 100% !important; }
.ct--marco { max-width: none; margin: 0; border-radius: 0; padding: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.ct--marco .ct-vista-previa { margin: 0; border-radius: 0; }
.ct--marco .ct-tabs { margin: 0; padding: 0 8px; flex: 0 0 auto; background: var(--ct-surface); }
.ct--marco .ct-chat { flex: 1 1 auto; min-height: 0; height: auto; border: 0; border-radius: 0; }
.ct--marco .ct-buzon { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body.ct-marco { background: #0E1220; } }
/* ---- Ventana flotante: menos amontonado (19 nov 2026, Daniel: «se ve muy amontonado» y «el botón de ES se ve encima de Turing») ----
   - La barra azul («Se guarda en tu Buzón» + «Chat nuevo») desaparece: «Chat nuevo» queda en la misma fila de las pestañas.
   - El contador de preguntas libres pasa a una línea chica arriba de la caja de envío (a quien tiene cuenta no se le muestra: la pestaña Buzón ya lo dice).
   - Letra, botones y aviso legal más chicos y con aire; el botón flotante de idioma «ES» (que Idioma.php mete en toda página) y otros avisos fijos se esconden dentro del marco. */
body.ct-marco .idioma-flotante, body.ct-marco .aviso-az, body.ct-marco .om-aviso-vivo, body.ct-marco .eval-avance-aviso, body.ct-marco .obs-flota,
body.ct-marco .mr-act-pastilla, body.ct-marco .mr-nov, body.ct-marco [data-flotante], body.ct-marco .chat-flota { display: none !important; }
.ct--marco { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr) auto auto auto auto; background: var(--ct-surface); }
.ct--marco .ct-vista-previa { grid-row: 1; grid-column: 1 / -1; }
.ct--marco .ct-tabs { grid-row: 2; grid-column: 1 / -1; padding: 0 6px; }
.ct--marco .ct-tabs button { min-height: 40px; padding: 6px 12px; font-size: .93rem; }
.ct--marco .ct-chat { display: contents; }
.ct--marco .ct-cabeza { display: contents; }
.ct--marco .ct-cabeza > img, .ct--marco .ct-cabeza > div { display: none; }
.ct--marco .ct-nuevo { grid-row: 2; grid-column: 2; align-self: center; justify-self: end; margin: 0 10px 2px 0; z-index: 1; min-height: 30px; padding: 3px 11px; font-size: .8rem;
  color: var(--ct-turing); background: var(--ct-surface); border-color: var(--ct-turing); }
.ct--marco .ct-nuevo:hover { background: var(--ct-turing-soft); }
.ct--marco .ct-log { grid-row: 3; grid-column: 1 / -1; padding: 12px; gap: 10px; font-size: .93rem; line-height: 1.45; }
.ct--marco .ct-cuota { grid-row: 4; grid-column: 1 / -1; margin: 0; padding: 4px 14px 0; background: var(--ct-surface); border-radius: 0; font-size: .74rem; text-align: left; color: var(--ct-muted); }
.ct--marco .ct-rapidos { grid-row: 5; grid-column: 1 / -1; padding: 6px 12px; gap: 6px; border-top: 0; }
.ct--marco .ct-envio { grid-row: 6; grid-column: 1 / -1; padding: 6px 12px 2px; }
.ct--marco .ct-envio input { min-height: 40px; padding: 8px 14px; font-size: .93rem; }
.ct--marco .ct-envio .ct-btn { min-height: 40px; padding: 6px 16px; }
.ct--marco .ct-pie { grid-row: 7; grid-column: 1 / -1; font-size: .7rem; line-height: 1.3; padding: 2px 14px 8px; }
.ct--marco .ct-buzon { grid-row: 3 / 8; grid-column: 1 / -1; min-height: 0; overflow-y: auto; padding: 12px; border: 0; border-radius: 0; background: var(--ct-bg); }
.ct--marco .ct-burbuja { padding: 8px 12px; }
.ct--marco .ct-burbuja p { margin: 0 0 6px; }
.ct--marco .ct-botones { gap: 6px; margin-top: 6px; }
.ct--marco .ct-chip { font-size: .84rem; line-height: 1.25; padding: 4px 11px; min-height: 32px; }
.ct--marco .ct-rapidos .ct-chip { font-size: .8rem; padding: 3px 10px; min-height: 30px; }
.ct--marco .ct-tarjeta { padding: 10px; }
.ct--marco .ct-origen { margin-top: 6px; }

/* ---- Gráfica de barras (cifras del sitio): barras de HTML, sin librerías; el texto de cada fila ya dice el dato ---- */
.ct-grafica h3{margin:0 0 .5rem;font-size:.95rem}
.ct-barras{list-style:none;margin:0;padding:0;display:grid;gap:.35rem}
.ct-barras li{display:grid;grid-template-columns:minmax(4.5rem,9.5rem) 1fr auto;align-items:center;gap:.5rem;font-size:.85rem}
.ct-b-etq{overflow-wrap:anywhere;line-height:1.2}
.ct-b-pista{display:block;height:.7rem;border-radius:999px;background:color-mix(in srgb,var(--ct-line) 80%,transparent);overflow:hidden}
.ct-b-pista i{display:block;height:100%;border-radius:999px;background:var(--ct-turing)}
.ct-b-val{font-variant-numeric:tabular-nums}

/* ---- Proponer a una persona (formulario y borrador) y botón de PDF ---- */
.ct-memorial label,.ct-borrador label{display:block;margin:.6rem 0 .2rem;font-size:.85rem;font-weight:600}
.ct-memorial input,.ct-memorial select,.ct-memorial textarea,.ct-borrador input{width:100%;box-sizing:border-box;font:inherit;padding:.5rem .6rem;border:1px solid var(--ct-line);border-radius:10px;background:var(--ct-surface);color:var(--ct-fg)}
.ct-borrador h4{margin:.8rem 0 .15rem;font-size:.85rem;text-transform:uppercase;letter-spacing:.04em;color:var(--ct-muted)}
.ct-borrador p{margin:.1rem 0}
.ct-clip{flex:none;min-width:44px;min-height:44px;border:1px solid var(--ct-line);background:var(--ct-surface);border-radius:12px;font-size:1.15rem;cursor:pointer;color:var(--ct-fg)}
.ct-clip:focus-visible{outline:3px solid var(--ct-turing);outline-offset:2px}
