/* =====================================================================
   Chat de la comunidad (js/chat.js) y avisos en el celular (js/notif.js)
   Un solo desplazamiento: los mensajes van en el flujo del panel y el cuadro de escribir queda pegado abajo.
   ===================================================================== */
#p-chat { padding-bottom: 0; }
@media (max-width: 900px) { #p-chat { overflow: visible; } }      /* en el celular desplaza la página, no una caja interna */
.chx { display: flex; flex-direction: column; min-height: 100%; }

/* ---------------------------------------------------------------- cabecera de la sala */
.chx-cab { margin: 0 0 6px; }
.chx-top { display: flex; align-items: center; gap: 12px; }
.chx-ico { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--paper-3); font-size: 22px; }
.chx-ico.est { background: var(--lc, var(--ink)); color: #fff; font: 800 20px var(--f-cond); box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.chx-tit { flex: 1; min-width: 0; }
.chx-tit h2 { margin: 0; font: 800 22px/1.1 var(--f-cond); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chx-tit p { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; margin: 4px 0 0; font-size: 12.5px; color: var(--ink-3); }
.chx-caras { display: inline-flex; padding-left: 6px; }
.chx-caras .ch-av { margin-left: -6px; box-shadow: 0 0 0 2px var(--paper-2), inset 0 0 0 1.5px var(--ac); }
.chx-dura { white-space: nowrap; }
.chx-campana { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1.5px solid var(--rule-2); background: var(--white); font-size: 19px; filter: grayscale(1); opacity: .8; }
.chx-campana:hover { opacity: 1; }
.chx-campana.on { filter: none; opacity: 1; border-color: var(--ink); background: #fff4cc; }
.chx-campana[aria-expanded="true"] { border-color: var(--ink); }

.chx-salas { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.chx-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 12px; border: 1.5px solid var(--rule-2); border-radius: 999px; background: var(--white); font: 700 14px var(--f-cond); color: var(--ink); }
.chx-chip i, .chx-res i { width: 10px; height: 10px; border-radius: 50%; background: var(--lc, var(--ink)); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--lc, var(--ink)); }
.chx-chip small { min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font: 700 11px/18px var(--f-cond); text-align: center; }
.chx-chip.on { background: var(--ink); border-color: var(--ink); color: var(--white); }
.chx-chip.sec { border-style: dashed; color: var(--ink-2); font-weight: 600; }
.chx-buscar { margin-top: 10px; padding: 10px; border: 1.5px solid var(--ink); border-radius: 14px; background: var(--white); }
.chx-buscar[hidden] { display: none; }
.chx-buscar input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--rule-2); border-radius: 10px; font: 16px var(--f-ui); }
#ch-res { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.chx-res { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: left; font: 600 15px var(--f-cond); }
.chx-res:hover { background: var(--paper-2); }
.chx-res b { flex: 1; font-weight: 700; }
.chx-res small { color: var(--ink-3); font-weight: 600; }
.chx-notif { margin-top: 10px; }
.chx-notif[hidden] { display: none; }
.chx-seguir { margin-bottom: 8px; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 12px; background: #fff4cc; }

.chx-normas { margin: 10px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--ink); color: #e9eaee; font-size: 13.5px; line-height: 1.45; }
.chx-normas p { margin: 0; color: #fff; }
.chx-normas ul { margin: 8px 0 10px; padding-left: 18px; }
.chx-normas li { margin: 0 0 2px; }
.chx-normas a { color: #fff; }
.chx-normas-acc { display: flex; align-items: center; gap: 14px; }
.chx-normas .nt-b { background: #fff; color: var(--ink); border-color: #fff; }

/* ---------------------------------------------------------------- hilo */
.chx-hilo { flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 6px 0 14px; }
.chx-sep { align-self: center; margin: 12px 0 6px; padding: 3px 12px; border-radius: 999px; background: var(--paper-3); font: 700 12px var(--f-cond); letter-spacing: .02em; color: var(--ink-2); }
.chm { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; align-items: start; margin-top: 8px; animation: chEntra .32s var(--ease) both; }
.chm > .ch-av { margin-top: 20px; }
.chm.bot > .ch-av { margin-top: 22px; }
.chm.cont { margin-top: 0; }
.chm.cont > .ch-av { visibility: hidden; height: 0; }
.chm.cont .chm-quien { display: none; }
.chm-col { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.chm-quien { display: flex; align-items: baseline; gap: 6px; margin: 0 0 3px 6px; }
.chm-quien b { font: 700 13px var(--f-cond); color: var(--ink-2); }
.chm-quien small { font: 700 11px var(--f-cond); padding: 0 6px; border-radius: 999px; background: var(--ink); color: #fff; }
.chm-burbuja { position: relative; max-width: min(100%, 460px); padding: 8px 12px 6px; border-radius: 18px 18px 18px 6px; background: var(--white); border: 1px solid var(--rule); box-shadow: 0 1px 1px rgba(22,24,29,.05); cursor: pointer; outline-offset: 2px; transition: transform .12s, box-shadow .12s; }
.chm.cont .chm-burbuja { border-top-left-radius: 6px; }
.chm-burbuja:active { transform: scale(.985); }
.chm.activo .chm-burbuja { box-shadow: 0 0 0 2px var(--ink); }
.chm-t { margin: 0; font-size: 15.5px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.chm-h { display: block; margin-top: 2px; text-align: right; font: 600 11px var(--f-cond); color: var(--ink-3); }
/* los míos: a la derecha, en tinta */
.chm.yo { grid-template-columns: minmax(0, 1fr); }
.chm.yo > .ch-av, .chm.yo .chm-quien { display: none; }
.chm.yo .chm-col { align-items: flex-end; }
.chm.yo .chm-burbuja { background: var(--ink); border-color: var(--ink); color: #fff; border-radius: 18px 18px 6px 18px; }
.chm.yo.cont .chm-burbuja { border-top-right-radius: 6px; }
.chm.yo .chm-h { color: #b9bcc6; }
.chm.yo .chm-cita { background: rgba(255,255,255,.12); border-left-color: rgba(255,255,255,.5); color: #e2e4ea; }
.chm.yo.activo .chm-burbuja { box-shadow: 0 0 0 2px var(--red); }
/* asistente */
.chm.bot .chm-burbuja { background: var(--paper-2); border: 1.5px solid var(--ink); }
.chm.brilla .chm-burbuja { box-shadow: 0 0 0 3px #f5c400; }
.chm.oculto { display: block; text-align: center; }
.chm.oculto p { display: inline-block; margin: 4px 0; padding: 4px 12px; border-radius: 999px; border: 1px dashed var(--rule-2); color: var(--ink-3); font-size: 12.5px; font-style: italic; }
.chm-cita { display: block; width: 100%; margin: 0 0 5px; padding: 5px 9px; border: 0; border-left: 3px solid var(--ink-3); border-radius: 4px 10px 10px 4px; background: rgba(22,24,29,.06); text-align: left; font: 500 12.5px/1.35 var(--f-ui); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chm-cita b { display: block; font: 700 12px var(--f-cond); }
.chm-ayuda { margin: 8px 0 2px; padding: 7px 10px; border-radius: 10px; background: #fde8ea; color: var(--ink); font-size: 13px; line-height: 1.45; }
.chm-ayuda a, .chm-link { font-weight: 700; color: var(--red-ink); }
.chm-link { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; text-decoration: underline; }
.chm-reac { display: flex; flex-wrap: wrap; gap: 4px; margin: -6px 0 0 10px; position: relative; }
.chm.yo .chm-reac { margin: -6px 10px 0 0; }
.chm-r { display: inline-flex; align-items: center; gap: 3px; min-height: 26px; padding: 1px 8px; border: 1.5px solid var(--paper-2); border-radius: 999px; background: var(--white); box-shadow: 0 1px 3px rgba(22,24,29,.15); font: 700 13px var(--f-cond); }
.chm-r span { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.chm-r.on { background: #fff4cc; border-color: #f5c400; }
.chm-acc { margin-top: 6px; padding: 8px; border-radius: 16px; background: var(--white); border: 1.5px solid var(--ink); box-shadow: var(--shadow); animation: chEntra .18s var(--ease) both; max-width: 100%; }
.chm-acc[hidden] { display: none; }
.chm-emojis { display: flex; gap: 2px; }
.chm-e { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: none; font-size: 22px; transition: transform .12s; }
.chm-e:hover, .chm-e:focus-visible { transform: scale(1.18); background: var(--paper-2); }
.chm-e.on { background: #fff4cc; }
.chm-btns { display: flex; gap: 6px; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--rule); }
.chm-btns button, .chm-mini button { min-height: 34px; padding: 4px 12px; border: 1.5px solid var(--rule-2); border-radius: 999px; background: var(--paper-2); font: 700 13px var(--f-cond); }
.chm-mini { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chm-mini[hidden] { display: none; }
.chm-mini p { width: 100%; margin: 0; font-size: 13px; color: var(--ink-2); }
@keyframes chEntra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* tarjeta de viaje del asistente */
.chm-viaje { margin: 8px 0 2px; padding: 10px; border-radius: 12px; background: var(--white); border: 1px solid var(--rule); }
.chm-v-cab b { display: block; font: 800 15px/1.2 var(--f-cond); }
.chm-v-cab span { font-size: 12.5px; color: var(--ink-2); }
.chm-viaje ol { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; position: relative; }
.chm-viaje li { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; line-height: 1.3; }
.chm-viaje li .plate { flex: none; min-width: 44px; height: 24px; font-size: 14px; border-radius: 5px; }
.chm-viaje li b { display: block; font: 700 14px var(--f-cond); }
.chm-viaje li small { color: var(--ink-3); font-size: 12px; }
.chm-viaje li.pie { color: var(--ink-2); font-size: 13px; }
.chm-v-pie { flex: none; width: 44px; text-align: center; }
.chm-v-ver { width: 100%; }
.chm-v-nota { display: block; margin-top: 6px; color: var(--ink-3); font-size: 11.5px; }

.chx-vacio { margin: 18px 0 8px; padding: 22px 16px; border: 1.5px dashed var(--rule-2); border-radius: 18px; text-align: center; color: var(--ink-2); }
.chx-vacio-i { font-size: 34px; }
.chx-vacio b { display: block; margin: 6px 0 4px; font: 800 17px var(--f-cond); color: var(--ink); }
.chx-vacio p { margin: 0 0 10px; font-size: 14px; }
.chx-sug { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chx-sug button { min-height: 38px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--white); font: 700 13.5px var(--f-cond); }

/* ---------------------------------------------------------------- escribir: pegado abajo del panel (o de la pantalla en el celular) */
.chx-pie { position: sticky; bottom: 0; z-index: 3; margin: 0 -18px; padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(251,250,247,0) 0, var(--paper-2) 14px); }
.chx-nuevos { display: block; margin: 0 auto 8px; padding: 6px 14px; border: 0; border-radius: 999px; background: var(--red); color: #fff; font: 700 13px var(--f-cond); box-shadow: var(--shadow); }
.chx-nuevos[hidden] { display: none; }
.chx-resp { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 6px 10px; border-left: 3px solid var(--ink); border-radius: 4px 12px 12px 4px; background: var(--white); font-size: 13px; box-shadow: var(--shadow); }
.chx-resp[hidden] { display: none; }
.chx-resp span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chx-x { flex: none; width: 30px; height: 30px; padding: 0; border-radius: 50%; }
.chx-atajos { display: flex; gap: 6px; margin: 0 0 7px; overflow: hidden; flex-wrap: wrap; max-height: 36px; }
.chx-atajos[hidden] { display: none; }
.chx-atajos button { flex: none; min-height: 32px; padding: 3px 11px; border-radius: 999px; border: 1.5px solid var(--rule-2); background: var(--white); font: 700 13px var(--f-cond); white-space: nowrap; }
.chx-atajos .chx-albot { border-color: var(--ink); }
.chx-atajos .chx-albot.on { background: var(--ink); color: #fff; }
.chx-form.albot { border-color: var(--ink); box-shadow: 0 0 0 3px #fff4cc, 0 6px 22px rgba(22,24,29,.12); background: #fffdf3; }
.chx-pensando { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font: 600 13.5px var(--f-cond); color: var(--ink-2); }
.chx-pensando i { display: inline-block; width: 5px; height: 5px; margin-left: 3px; border-radius: 50%; background: var(--ink-2); animation: chPunto 1.2s infinite ease-in-out; }
.chx-pensando i:nth-child(2) { animation-delay: .15s; }
.chx-pensando i:nth-child(3) { animation-delay: .3s; }
@keyframes chPunto { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chx-form { display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 6px; border: 1.5px solid var(--ink); border-radius: 26px; background: var(--white); box-shadow: 0 6px 22px rgba(22,24,29,.12); }
.chx-form:focus-within { box-shadow: 0 0 0 3px rgba(15,111,209,.25), 0 6px 22px rgba(22,24,29,.12); }
.chx-yo { flex: none; width: 38px; height: 38px; margin-bottom: 1px; font-size: 20px; }
.chx-form textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 132px; resize: none; padding: 9px 4px; border: 0; background: none; font: 16px/1.35 var(--f-ui); outline: none; }
.chx-enviar { flex: none; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: var(--red); color: #fff; transition: transform .12s, background .12s; }
.chx-enviar:hover { background: var(--red-ink); }
.chx-enviar:active { transform: scale(.92); }
.chx-enviar svg { width: 20px; height: 20px; margin: 0 0 0 2px; }
.chx-enviar:disabled { opacity: .5; }
.chx-pie .ch-err { margin: 6px 4px 0; padding: 7px 10px; border-radius: 10px; background: #fde8ea; color: var(--ink); font-size: 13.5px; line-height: 1.4; }
.ch-err[hidden] { display: none; }
.chx-bloq { padding: 12px; border: 1.5px solid var(--ink); border-radius: 16px; background: var(--paper-3); font-size: 14px; }
.chx-bloq p { margin: 0 0 8px; }
.chx-bloq form { display: grid; gap: 8px; margin-top: 8px; }
.chx-bloq textarea { min-height: 70px; padding: 8px 10px; border: 1.5px solid var(--rule-2); border-radius: 10px; font: 15px var(--f-ui); }

/* avatares */
.ch-av { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--ac, #888) 16%, #fff); box-shadow: inset 0 0 0 2px var(--ac, #888); font-size: 18px; line-height: 1; }
.ch-av.xs { width: 22px; height: 22px; font-size: 12px; }
.ch-entrar { display: block; margin: 12px 0 4px; min-height: 40px; }
@media (prefers-reduced-motion: reduce) { .chm, .chm-acc { animation: none; } }

/* ---------------------------------------------------------------- avisos en el celular (js/notif.js) */
.nt { margin: 0 0 14px; padding: 14px; border: 1.5px solid var(--ink); border-radius: 16px; background: var(--white); }
.nt.on { border-color: var(--good); }
.nt-cab { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.nt-cab div { flex: 1; display: flex; flex-direction: column; }
.nt-cab b { font: 800 16px var(--f-cond); }
.nt-cab small { color: var(--ink-3); font-size: 12.5px; }
.nt-ico { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #fff4cc; font-size: 19px; }
.nt-x { flex: none; width: 34px; height: 34px; padding: 0; border-radius: 50%; }
.nt-op { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; padding: 8px 0; cursor: pointer; }
.nt-op input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ink); }
.nt-op b { display: block; font: 700 14.5px/1.25 var(--f-cond); }
.nt-op small { display: block; color: var(--ink-3); font-size: 12.5px; line-height: 1.35; }
.nt-amb { display: flex; flex-direction: column; gap: 4px; margin: -2px 0 6px 32px; font-size: 14px; }
.nt-amb[hidden] { display: none; }
.nt-amb label { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.nt-amb small { color: var(--ink-3); }
.nt-salas { margin: 4px 0 6px; font-size: 13px; }
.nt-salas small { color: var(--ink-3); }
.nt-salas div { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.nt-chip { min-height: 32px; padding: 3px 10px; border-radius: 999px; background: var(--paper-2); font: 700 13px var(--f-cond); }
.nt-pista { margin: 2px 0 6px; font-size: 12.5px; color: var(--ink-3); }
.nt-acc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.nt-b { min-height: 40px; padding: 7px 16px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--ink); color: var(--white); font: 800 14px var(--f-cond); }
.nt-b.sec { background: var(--white); color: var(--ink); border-color: var(--rule-2); }
.nt-b:disabled { opacity: .55; }
.nt-info { margin: 0 0 6px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.nt-msj { margin: 10px 0 0; padding: 7px 10px; border-radius: 10px; background: var(--paper-3); font-size: 13.5px; }
.nt-pie { margin: 10px 0 0; font-size: 12px; color: var(--ink-3); }
.nt-pie a { color: inherit; }
.nt-mini { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.nt-mini p { flex: 1; margin: 0; font-size: 13px; line-height: 1.35; color: var(--ink-2); }
.nt-mini p b { color: var(--ink); }
.nt-mini .nt-b { flex: none; min-height: 36px; padding: 5px 12px; font-size: 13px; }
@media (max-width: 420px) { .nt-mini { flex-wrap: wrap; } .nt-mini .nt-b { margin-left: 48px; } }
