:root{--chat-blue:#0866ff;--chat-bg:#fff;--chat-soft:#f0f2f5;--chat-text:#1c1e21;--chat-muted:#65676b}
.chat-launcher{position:fixed;right:18px;bottom:18px;width:56px;height:56px;border:0;border-radius:50%;background:var(--chat-blue);color:#fff;z-index:9990;box-shadow:0 5px 22px #0003;font-size:25px;cursor:pointer}.chat-launcher .chat-badge,.chat-bubble .chat-badge{position:absolute;right:-3px;top:-4px;background:#e41e3f;color:#fff;border:2px solid #fff;border-radius:999px;min-width:20px;height:20px;padding:0 5px;font:700 11px/16px Arial;display:grid;place-items:center}.chat-bubble-stack{position:fixed;right:22px;bottom:86px;z-index:9989;display:flex;flex-direction:column-reverse;gap:10px}.chat-bubble{position:relative;width:48px;height:48px;border:2px solid #fff;border-radius:50%;background:#ddd;box-shadow:0 3px 14px #0003;overflow:visible;cursor:pointer;padding:0}.chat-bubble img{width:100%;height:100%;object-fit:cover;border-radius:50%}.chat-bubble .initials{display:grid;place-items:center;width:100%;height:100%;border-radius:50%;font-weight:800}.chat-panel{position:fixed;right:18px;bottom:82px;width:min(390px,calc(100vw - 24px));height:min(620px,calc(100vh - 110px));z-index:9992;background:var(--chat-bg);border-radius:16px;box-shadow:0 12px 45px #0004;overflow:hidden;display:flex;flex-direction:column;color:var(--chat-text);font-family:Arial,sans-serif}.chat-panel[hidden]{display:none}.chat-head{padding:12px 14px;display:flex;align-items:center;gap:10px;border-bottom:1px solid #ddd}.chat-head strong{font-size:18px;flex:1}.chat-icon-btn{border:0;background:transparent;border-radius:50%;width:34px;height:34px;cursor:pointer;font-size:18px}.chat-icon-btn:hover{background:var(--chat-soft)}.chat-tabs{display:flex;padding:8px;gap:5px}.chat-tabs button{flex:1;border:0;border-radius:10px;padding:8px;background:transparent;font-weight:700;cursor:pointer}.chat-tabs button.active{background:#e7f3ff;color:var(--chat-blue)}.chat-search{padding:0 10px 8px}.chat-search input{width:100%;box-sizing:border-box;border:0;background:var(--chat-soft);padding:10px 13px;border-radius:18px;outline:none}.chat-list{overflow:auto;flex:1;padding:4px 8px 12px}.chat-person{display:flex;align-items:center;gap:10px;padding:9px;border-radius:10px;cursor:pointer}.chat-person:hover{background:var(--chat-soft)}.chat-avatar{width:42px;height:42px;border-radius:50%;background:#ddd;object-fit:cover;display:grid;place-items:center;font-weight:800;flex:0 0 auto}.chat-person-main{min-width:0;flex:1}.chat-person-main strong,.chat-person-main small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chat-person-main small{color:var(--chat-muted);margin-top:3px}.chat-count{background:#e41e3f;color:#fff;border-radius:999px;min-width:20px;height:20px;display:grid;place-items:center;font-size:11px;font-weight:800}.chat-action{border:0;background:#e7f3ff;color:var(--chat-blue);padding:7px 9px;border-radius:8px;font-weight:700;cursor:pointer}.chat-room{display:flex;flex-direction:column;height:100%}.chat-room-head{display:flex;align-items:center;gap:9px;padding:10px;border-bottom:1px solid #ddd}.chat-room-head strong{flex:1}.chat-messages{flex:1;overflow:auto;padding:12px;display:flex;flex-direction:column;gap:5px}.chat-msg{max-width:78%;padding:8px 11px;border-radius:16px;background:var(--chat-soft);white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px}.chat-msg.mine{align-self:flex-end;background:var(--chat-blue);color:#fff}.chat-compose{display:flex;gap:7px;padding:9px;border-top:1px solid #ddd}.chat-compose textarea{flex:1;resize:none;max-height:90px;border:0;background:var(--chat-soft);border-radius:18px;padding:9px 12px;outline:none}.chat-send{border:0;background:var(--chat-blue);color:#fff;border-radius:50%;width:38px;height:38px;cursor:pointer}.chat-empty{text-align:center;color:var(--chat-muted);padding:30px 15px}.chat-pending-title{font-size:12px;color:var(--chat-muted);font-weight:800;text-transform:uppercase;padding:10px 9px 4px}.chat-blocked{opacity:.72}.chat-login-note{padding:28px 20px;text-align:center}.chat-login-note a{color:var(--chat-blue);font-weight:700}.portal-chat-friends{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:10px}.portal-chat-friend{border:1px solid #ddd;border-radius:12px;padding:12px;display:flex;gap:10px;align-items:center}.portal-chat-friend .chat-person-main{flex:1}
@media(max-width:600px){.chat-panel{right:6px;bottom:6px;width:calc(100vw - 12px);height:calc(100dvh - 12px);border-radius:14px}.chat-launcher{right:12px;bottom:12px}.chat-bubble-stack{right:16px;bottom:78px}}

/* v2: integración visual con el portal FCK */
.chat-launcher{left:18px!important;right:auto!important}
.chat-bubble-stack{left:22px!important;right:auto!important}
.chat-panel{left:18px!important;right:auto!important}
.chat-panel,.chat-panel *{box-sizing:border-box}
.chat-panel{background:#fff!important;color:#1c1e21!important}
.chat-panel .chat-head,.chat-panel .chat-room-head{background:#fff!important;color:#1c1e21!important}
.chat-panel .chat-head strong,.chat-panel .chat-room-head strong,.chat-panel .chat-person-main strong{color:#1c1e21!important}
.chat-panel .chat-person-main small,.chat-panel .chat-empty,.chat-panel .chat-pending-title{color:#65676b!important}
.chat-panel .chat-tabs button{background:transparent!important;color:#4b4f56!important;border:0!important;box-shadow:none!important}
.chat-panel .chat-tabs button.active{background:#e7f3ff!important;color:#0866ff!important}
.chat-panel .chat-search input,.chat-panel .chat-compose textarea{background:#f0f2f5!important;color:#1c1e21!important;border:0!important}
.chat-panel .chat-search input::placeholder,.chat-panel .chat-compose textarea::placeholder{color:#65676b!important;opacity:1}
.chat-panel .chat-icon-btn{color:#1c1e21!important;background:transparent!important;border:0!important}
.chat-panel .chat-icon-btn:hover,.chat-panel .chat-person:hover{background:#f0f2f5!important}
.chat-panel .chat-action{background:#e7f3ff!important;color:#0866ff!important;border:0!important}
.chat-panel .chat-msg:not(.mine){background:#f0f2f5!important;color:#1c1e21!important}
.chat-panel .chat-msg.mine{background:#0866ff!important;color:#fff!important}
.chat-panel .chat-send{background:#0866ff!important;color:#fff!important;border:0!important}
.chat-profile-icon-with-count{position:relative;display:inline-flex;flex:0 0 auto;line-height:1;overflow:visible}
.chat-profile-icon-with-count>.chat-avatar{width:42px;height:42px;border-radius:50%!important;border:2px solid #9238ed!important;object-fit:cover;background:#090d2a!important;color:#fff!important;box-sizing:border-box;display:grid;place-items:center;font-weight:800}
.chat-achievement-count{position:absolute;right:-5px;bottom:-3px;z-index:2;display:inline-flex;align-items:center;justify-content:center;min-width:21px;height:21px;padding:0 4px;border:1px solid #934aff;border-radius:50%;background:#301178;color:#fff;font:800 10px/1 Arial,sans-serif;box-shadow:0 0 0 2px #fff}
.chat-bubble{overflow:visible;background:#090d2a;border-color:#9238ed}
.chat-bubble .chat-profile-icon-with-count{width:100%;height:100%}
.chat-bubble .chat-profile-icon-with-count>.chat-avatar{width:100%;height:100%;border:0!important}
.chat-bubble .chat-achievement-count{right:-5px;bottom:-5px;box-shadow:0 0 0 2px #040920}
.portal-chat-friend{color:#fff}
.portal-chat-friend .chat-person-main strong{color:#fff!important}
.portal-chat-friend .chat-person-main small{color:#8196ba!important}
.portal-chat-friend .chat-achievement-count{box-shadow:0 0 0 2px #040920}
@media(max-width:600px){.chat-panel{left:6px!important;right:auto!important}.chat-launcher{left:12px!important;right:auto!important}.chat-bubble-stack{left:16px!important;right:auto!important}}

/* v3: zumbido + corrección buscador portal */
#portal-friend-search{background:#f0f2f5!important;color:#1c1e21!important;-webkit-text-fill-color:#1c1e21!important;caret-color:#1c1e21!important;border:1px solid #d8dbe0!important}
#portal-friend-search::placeholder{color:#65676b!important;-webkit-text-fill-color:#65676b!important;opacity:1!important}
#portal-friend-search:focus{background:#fff!important;color:#1c1e21!important;border-color:#9238ed!important;outline:2px solid rgba(146,56,237,.16)!important}
.chat-buzz{border:0;background:#f0e7ff;color:#6f1bd1;border-radius:50%;width:38px;height:38px;flex:0 0 38px;cursor:pointer;font-weight:900;font-size:17px}.chat-buzz:hover{background:#e3d1ff}.chat-buzz:disabled{cursor:not-allowed;opacity:.58}.chat-msg-buzz{font-weight:800;text-align:center;background:#f0e7ff!important;color:#6f1bd1!important}.chat-msg-buzz.mine{background:#6f1bd1!important;color:#fff!important}

/* v6: el Messenger debe quedar por encima del botón flotante de WhatsApp */
.chat-bubble-stack{z-index:10018!important}
.chat-launcher{z-index:10019!important}
.chat-panel{z-index:10020!important}

/* Menú de opciones de la conversación */
.chat-room-actions{position:relative;margin-left:auto;flex-shrink:0}
.chat-options-menu{position:absolute;right:0;top:calc(100% + 6px);z-index:30;min-width:165px;padding:5px;background:#fff;color:#222;border:1px solid #ddd;border-radius:10px;box-shadow:0 8px 22px #0003}
.chat-options-menu[hidden]{display:none!important}
.chat-options-menu button{display:block;width:100%;text-align:left;padding:10px 12px;border:0;border-radius:7px;background:transparent;color:#252238;cursor:pointer;font-size:14px}
.chat-options-menu button:hover{background:#f1ecff;color:#4b269a}

/* v8: botón cerrar independiente junto al menú de opciones */
.chat-panel .chat-room-actions{display:flex;align-items:center;gap:3px}
.chat-panel .chat-direct-close{font-size:25px;line-height:1;color:#343a40!important;flex:0 0 34px}

/* Presencia y escritura */
.chat-profile-icon-with-count{position:relative}.chat-online-dot{position:absolute;right:0;bottom:2px;width:11px;height:11px;border-radius:50%;background:#24bd65;border:2px solid #fff;z-index:3}.chat-room-presence{font-size:11px;color:#31b875;margin-left:4px;white-space:nowrap}.chat-typing-indicator{padding:5px 15px;font-size:12px;color:#888}.chat-typing-indicator[hidden]{display:none!important}

.chat-away-dot{position:absolute;right:0;bottom:2px;width:11px;height:11px;border-radius:50%;background:#f3b23e;border:2px solid #fff;z-index:3}
