/* Recepta · Chat interno (chat.js). Solo tokens. En la computadora, la lista a la izquierda y la conversación a la
   derecha; en el celular, una cosa por vez (la lista o la conversación, con «‹» para volver). */
.ch { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: var(--esp-4); height: calc(100dvh - 140px); min-height: 460px; }
.ch-lista, .ch-conv { background: var(--hoja); border: 1px solid var(--perla); border-radius: var(--radio-grande); box-shadow: var(--sombra); min-width: 0; min-height: 0; }
.ch-lista { display: flex; flex-direction: column; overflow: hidden; }
.ch-lista-cab { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-2); padding: var(--esp-4) var(--esp-4) var(--esp-2); flex-wrap: wrap; }
.ch-lista-cab h1 { margin: 0; font-size: var(--texto-grande); }
.ch-cab-acciones { display: inline-flex; gap: var(--esp-2); flex-wrap: wrap; }
.ch-buscar { margin: 0 var(--esp-4) var(--esp-2); width: auto; }
.ch-canales { overflow-y: auto; padding: 0 var(--esp-2) var(--esp-4); flex: 1; }
.ch-canales h2 { font-size: var(--texto-mini); text-transform: uppercase; letter-spacing: 0.06em; color: var(--pizarra); margin: var(--esp-4) var(--esp-2) var(--esp-1); }
.ch-item { display: flex; align-items: center; gap: var(--esp-3); width: 100%; padding: var(--esp-2); border-radius: var(--radio); color: var(--tinta); text-decoration: none; border: 0; background: none; text-align: left; cursor: pointer; min-height: 52px; }
.ch-item:hover { background: var(--niebla); }
.ch-item.activo { background: var(--cobalto-suave); }
.ch-item-txt { flex: 1; min-width: 0; display: grid; }
.ch-item-txt b, .ch-item-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-item-txt small { color: var(--pizarra); font-size: var(--texto-chico); }
.ch-item.sin-leer .ch-item-txt b, .ch-item.sin-leer .ch-item-txt small { color: var(--tinta); font-weight: var(--peso-fuerte); }
.ch-item-lado { display: grid; justify-items: end; gap: 2px; flex: none; }
.ch-item-lado small { color: var(--pizarra); font-size: var(--texto-mini); }
.ch .contador, .ch-item .contador { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radio-pildora); background: var(--cobalto); color: var(--hoja); font-size: var(--texto-mini); font-weight: var(--peso-fuerte); }
.ch-sumar, .ch-persona { opacity: 0.85; }

.ch-avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: var(--peso-fuerte); font-size: var(--texto-chico); color: var(--hoja); background: var(--cobalto); }
.ch-avatar.chico { width: 30px; height: 30px; font-size: 0.62rem; letter-spacing: -0.02em; overflow: hidden; }
.ch-avatar.canal { background: var(--perla-suave); color: var(--pizarra); border-radius: var(--radio); font-size: var(--texto-grande); }
.ch-avatar.t1 { background: var(--menta-texto); } .ch-avatar.t2 { background: var(--ambar-texto); } .ch-avatar.t3 { background: var(--error); }
.ch-avatar.t4 { background: var(--cobalto-hondo); } .ch-avatar.t5 { background: var(--pizarra); }

.ch-conv { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.ch-conv.ch-soltar { box-shadow: inset 0 0 0 3px var(--cobalto); }
.ch-vacio { display: grid; place-items: center; height: 100%; padding: var(--esp-4); }
.ch-conv-cab { display: flex; align-items: center; gap: var(--esp-3); padding: var(--esp-3) var(--esp-4); border-bottom: 1px solid var(--perla); }
.ch-conv-titulo { flex: 1; min-width: 0; }
.ch-conv-titulo h2 { margin: 0; font-size: var(--texto-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-conv-titulo small { color: var(--pizarra); font-size: var(--texto-chico); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-volver { display: none; font-size: var(--titulo); line-height: 1; text-decoration: none; color: var(--cobalto); padding: 0 var(--esp-2); min-width: 44px; min-height: 44px; place-items: center; }
.ch-mas { position: relative; }
.ch-mas summary { list-style: none; cursor: pointer; padding: var(--esp-2) var(--esp-3); border-radius: var(--radio); font-size: var(--texto-grande); min-height: 44px; display: grid; place-items: center; }
.ch-mas summary::-webkit-details-marker { display: none; }
.ch-mas-menu { position: absolute; right: 0; top: 100%; z-index: 5; display: grid; min-width: 200px; background: var(--hoja); border: 1px solid var(--perla); border-radius: var(--radio); box-shadow: var(--sombra-flotante); padding: var(--esp-1); }
.ch-mas-menu button { border: 0; background: none; text-align: left; padding: var(--esp-2) var(--esp-3); border-radius: var(--radio-chico); min-height: 40px; }
.ch-mas-menu button:hover { background: var(--niebla); }

.ch-mensajes { flex: 1; overflow-y: auto; padding: var(--esp-4); display: flex; flex-direction: column; gap: var(--esp-1); }
.ch-dia { text-align: center; margin: var(--esp-3) 0; }
.ch-dia span { font-size: var(--texto-mini); color: var(--pizarra); background: var(--niebla); padding: 2px var(--esp-3); border-radius: var(--radio-pildora); }
.ch-primero { margin: auto; color: var(--pizarra); text-align: center; }
.ch-msj { display: flex; gap: var(--esp-2); align-items: flex-end; max-width: 100%; margin-top: var(--esp-2); }
.ch-msj.seguido { margin-top: 0; }
.ch-msj.mio { flex-direction: row-reverse; }
.ch-hueco { width: 30px; flex: none; }
.ch-msj.mio .ch-hueco { display: none; }
.ch-burbuja { max-width: min(560px, 78%); min-width: 0; background: var(--niebla); border-radius: var(--radio-grande) var(--radio-grande) var(--radio-grande) var(--radio-chico); padding: var(--esp-2) var(--esp-3); overflow-wrap: anywhere; }
.ch-msj.mio .ch-burbuja { background: var(--cobalto-suave); border-radius: var(--radio-grande) var(--radio-grande) var(--radio-chico) var(--radio-grande); }
.ch-burbuja p { margin: 0; }
.ch-burbuja mark { background: var(--ambar-suave); color: var(--ambar-texto); border-radius: var(--radio-chico); padding: 0 2px; }
.ch-autor { display: block; font-size: var(--texto-chico); color: var(--cobalto); margin-bottom: 2px; }
.ch-hora { display: flex; gap: var(--esp-2); justify-content: flex-end; align-items: center; font-size: var(--texto-mini); color: var(--pizarra); margin-top: 2px; }
.ch-borrar { border: 0; background: none; padding: 0; min-height: 0; color: var(--pizarra); font-size: var(--texto-mini); text-decoration: underline; opacity: 0; cursor: pointer; }
.ch-msj:hover .ch-borrar, .ch-borrar:focus-visible { opacity: 1; }
@media (pointer: coarse) { .ch-borrar { opacity: 0.7; } }
.ch-error { color: var(--error); font-weight: var(--peso-fuerte); }
.ch-sistema { align-self: center; max-width: min(560px, 100%); text-align: center; background: var(--menta-suave); color: var(--menta-texto); border-radius: var(--radio-grande); padding: var(--esp-2) var(--esp-4); margin: var(--esp-3) 0; display: grid; gap: var(--esp-2); justify-items: center; overflow-wrap: anywhere; }
.ch-sistema small { color: var(--pizarra); font-size: var(--texto-mini); }

.ch-tarjeta { display: flex; align-items: center; gap: var(--esp-3); margin-top: var(--esp-1); padding: var(--esp-2) var(--esp-3); background: var(--hoja); border: 1px solid var(--perla); border-radius: var(--radio); color: var(--tinta); text-decoration: none; text-align: left; max-width: 100%; }
.ch-tarjeta:hover { border-color: var(--cobalto); }
.ch-tarjeta > span:first-child { font-size: var(--texto-grande); flex: none; }
.ch-tarjeta > span:last-child { display: grid; min-width: 0; }
.ch-tarjeta b { overflow-wrap: anywhere; }
.ch-tarjeta small { color: var(--cobalto); font-size: var(--texto-chico); }
.ch-tarjeta-previa { margin-bottom: var(--esp-3); }
.ch-archivo { display: flex; align-items: center; gap: var(--esp-3); margin-top: var(--esp-1); padding: var(--esp-2) var(--esp-3); background: var(--hoja); border: 1px solid var(--perla); border-radius: var(--radio); text-align: left; max-width: 100%; min-height: 48px; cursor: pointer; }
.ch-archivo > span:last-child { display: grid; min-width: 0; }
.ch-archivo b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-archivo small { color: var(--pizarra); font-size: var(--texto-chico); }
.ch-foto { max-width: 100%; border-radius: var(--radio); }

.ch-escribir { display: flex; align-items: flex-end; gap: var(--esp-2); padding: var(--esp-3); border-top: 1px solid var(--perla); }
.ch-caja { flex: 1; min-width: 0; position: relative; }
.ch-caja textarea { width: 100%; resize: none; min-height: 44px; max-height: 160px; line-height: 1.4; }
.ch-adjuntar, .ch-mandar { flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: var(--texto-grande); }
.ch-adjuntar { border: 1px solid var(--perla); background: var(--hoja); }
.ch-sugerencias { position: absolute; bottom: calc(100% + 4px); left: 0; right: 0; background: var(--hoja); border: 1px solid var(--perla); border-radius: var(--radio); box-shadow: var(--sombra-flotante); display: grid; padding: var(--esp-1); z-index: 5; }
.ch-sugerencias button { border: 0; background: none; text-align: left; padding: var(--esp-2) var(--esp-3); border-radius: var(--radio-chico); min-height: 40px; }
.ch-sugerencias button[aria-selected='true'], .ch-sugerencias button:hover { background: var(--cobalto-suave); }
.ch-sugerencias small { color: var(--pizarra); }
.ch-sumate { padding: var(--esp-4); border-top: 1px solid var(--perla); display: flex; gap: var(--esp-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ch-sumate p { margin: 0; flex: 1; min-width: 200px; }

.ch-tipo { display: flex; margin-bottom: var(--esp-4); }
.ch-tipo button { flex: 1; min-height: 44px; }
.ch-elegir { list-style: none; margin: 0 0 var(--esp-3); padding: 0; display: grid; gap: var(--esp-1); }
.ch-elegir button { display: flex; align-items: center; gap: var(--esp-3); width: 100%; border: 1px solid var(--perla); background: var(--hoja); border-radius: var(--radio); padding: var(--esp-2) var(--esp-3); text-align: left; min-height: 52px; }
.ch-elegir button > span:last-child { display: grid; min-width: 0; }
.ch-elegir button small { color: var(--pizarra); overflow: hidden; text-overflow: ellipsis; }
.ch-elegir button.activo { border-color: var(--cobalto); background: var(--cobalto-suave); }

@media (max-width: 760px) {
  .ch { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 120px); min-height: 400px; }
  .ch.ch-con-conversacion .ch-lista { display: none; }
  .ch:not(.ch-con-conversacion) .ch-conv { display: none; }
  .ch-volver { display: grid; }
  .ch-burbuja { max-width: 86%; }
  .ch-mensajes { padding: var(--esp-3); }
}
/* El reloj de Proyectos (flota abajo a la derecha) no tapa la caja para escribir */
@media (max-width: 760px) { body:has(.ch-escribir) .pr-reloj { bottom: 92px; } }
