/* =============================================================
 *  screens/chat.css
 *  Extraído automaticamente de index.php.
 *  NÃO editar manualmente até remover o script de split.
 * ============================================================= */

    /* ── CHAT ── */
    #panel-chat { display: flex; flex-direction: column; background: var(--bg); height: 100%; overflow: hidden; }

    .chat-header {
      height: var(--header); padding: 0 18px;
      display: flex; align-items: center; gap: 12px;
      background: var(--panel); border-bottom: 1px solid var(--border);
      flex-shrink: 0; box-shadow: var(--sh-sm);
    }

    /* Voltar: visível em mobile (carrega depois de responsive.css; evitar display:none global). */
    .btn-back {
      display: flex; width: 36px; height: 36px;
      align-items: center; justify-content: center;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-sm); font-size: 18px;
      cursor: pointer; color: var(--text-2); flex-shrink: 0;
      transition: all .15s;
    }
    .btn-back:hover { background: var(--accent-soft); color: var(--accent); }
    @media (min-width: 768px) {
      .btn-back { display: none; }
    }

    /* Ações no canto superior direito do cabeçalho — chamadas de voz e vídeo (DM e grupo). */
    .chat-hdr-acoes {
      display: inline-flex; align-items: center; gap: 6px;
      flex-shrink: 0; margin-left: auto;
    }
    .chat-hdr-acoes button {
      width: 38px; height: 38px;
      display: inline-flex; align-items: center; justify-content: center;
      background: transparent; border: 1px solid transparent;
      border-radius: 999px; color: var(--text-2);
      cursor: pointer; transition: background .15s, color .15s, border-color .15s;
    }
    .chat-hdr-acoes button:hover {
      background: var(--accent-soft); color: var(--accent);
      border-color: var(--border);
    }
    .chat-hdr-acoes button:focus-visible {
      outline: 2px solid var(--accent); outline-offset: 2px;
    }
    .chat-hdr-acoes button[disabled] { opacity: .45; pointer-events: none; }
    .chat-hdr-acoes svg { display: block; }
    @media (max-width: 460px) {
      .chat-hdr-acoes button { width: 36px; height: 36px; }
    }

    .chat-hdr-info { flex: 1; min-width: 0; cursor: pointer; border-radius: var(--radius-sm); padding: 4px 6px; margin: -4px -6px; transition: background .15s; }
    .chat-hdr-info:hover { background: var(--surface-2); }
    .chat-hdr-info:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .chat-hdr-name { font-size: 15px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .online-status {
      display: flex; align-items: flex-start; gap: 6px; font-size: 11px; font-weight: 600;
      color: var(--green); line-height: 1.35; max-width: 100%;
    }
    .online-status.offline { color: var(--text-3); }
    .online-status.offline .presence-dot { display: none; }
    .presence-dot.dot-online {
      width: 7px; height: 7px; margin-top: 3px; flex-shrink: 0; border-radius: 50%;
      background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2.5s infinite;
    }
    #hdr-presence-text { min-width: 0; word-break: break-word; }

    .empty-state {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-start;
      gap: 0;
      padding: 0;
      position: relative;
      background: var(--bg);
    }
    /* Imagem em «cobertura»: preenche a área disponível ao redimensionar sem esticar; recorta bordas.
       object-position topo: zona superior da arte sempre alinhada à área útil sob o cabeçalho. */
    .empty-icon {
      flex: 1;
      min-height: 0;
      width: 100%;
      position: relative;
      overflow: hidden;
    }
    .empty-icon img {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      display: block;
      object-fit: cover;
      object-position: top center;
    }

    /* Ajuda: texto completo + imagens (lista de resumos fica no iframe da sidebar) */
    .ajuda-detalhe-painel {
      flex: 1;
      min-height: 0;
      flex-direction: column;
      background: var(--bg);
      overflow: hidden;
    }
    .ajuda-detalhe-painel:not(.d-none) {
      display: flex;
    }
    .ajuda-detalhe-scroll {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      padding: 12px 16px 28px;
      width: 100%;
      max-width: none;
      margin: 0;
      box-sizing: border-box;
    }
    .ajuda-detalhe-cat {
      margin: 0 0 8px;
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.07em;
      text-transform: uppercase;
      color: var(--accent);
    }
    .ajuda-detalhe-titulo {
      margin: 0 0 16px;
      font-size: 1.35rem;
      font-weight: 900;
      letter-spacing: -0.03em;
      color: var(--text-1);
      line-height: 1.25;
    }
    .ajuda-detalhe-imagens {
      margin-bottom: 16px;
      text-align: left;
    }
    .ajuda-detalhe-fig {
      margin: 0 0 14px;
      max-width: 100%;
    }
    .ajuda-detalhe-img {
      display: block;
      width: auto;
      max-width: 100%;
      max-height: min(240px, 40vh);
      height: auto;
      margin: 0 auto;
      object-fit: contain;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: var(--surface);
    }
    .ajuda-detalhe-cap {
      margin-top: 8px;
      font-size: 13px;
      font-weight: 600;
      color: var(--text-2);
      line-height: 1.4;
    }
    .ajuda-detalhe-html {
      font-size: 15px;
      line-height: 1.6;
      color: var(--text-2);
    }
    .ajuda-detalhe-html p { margin: 0 0 12px; }
    .ajuda-detalhe-html p:last-child { margin-bottom: 0; }
    .ajuda-detalhe-html code {
      font-size: 0.9em;
      padding: 2px 6px;
      border-radius: 4px;
      background: var(--surface-2);
    }
    .ajuda-detalhe-html kbd {
      font-size: 0.85em;
      padding: 2px 7px;
      border-radius: 4px;
      border: 1px solid var(--border);
      background: var(--surface);
    }

    /* Área de scroll + botão flutuante “ir ao fim” */
    .messages-wrap {
      flex: 1;
      min-height: 0;
      position: relative;
      display: none;
      flex-direction: column;
    }
    /* scroll-behavior: smooth atrapalha scrollTop ao abrir conversa (histórico + imagens); instantâneo no JS */
    #messages-box  { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 3px; scroll-behavior: auto; min-height: 0; }

    .btn-scroll-chat-bottom {
      position: absolute;
      right: 12px;
      bottom: 12px;
      z-index: 8;
      width: 44px;
      height: 44px;
      padding: 0;
      border-radius: 50%;
      border: 1px solid var(--border);
      background: var(--panel);
      box-shadow: 0 4px 16px rgba(0, 0, 0, .14);
      color: var(--accent);
      cursor: pointer;
      align-items: center;
      justify-content: center;
      transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
    }
    .btn-scroll-chat-bottom:not(.d-none) { display: flex; }
    .btn-scroll-chat-bottom:hover {
      background: var(--accent-soft);
      box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
    }
    .btn-scroll-chat-bottom:active { transform: scale(0.96); }

    .msg-row       { display: flex; align-items: flex-end; gap: 7px; width: 100%; animation: fadeUp .18s ease; }
    /* row-reverse + flex-start: grupo [ferramentas][bolha][avatar] encostado à direita */
    .msg-row.me    { flex-direction: row-reverse; justify-content: flex-start; }
    .msg-row.msg-row--system {
      justify-content: center;
      align-items: center;
      flex-wrap: wrap;
    }
    .msg-row.msg-row--system .bubble-system {
      display: block;
      max-width: 92%;
      padding: 8px 12px;
      border-radius: 12px;
      font-size: 12.5px;
      font-weight: 700;
      line-height: 1.45;
      color: var(--text-2);
      background: rgba(17, 24, 39, .07);
      text-align: center;
    }
    .msg-row.msg-row--system .bubble-meta--system {
      width: 100%;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      margin-top: 2px;
      font-size: 11px;
      color: var(--text-3);
      font-weight: 600;
    }

    .msg-row.msg-row--call-log .bubble-call-log {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      max-width: 92%;
      padding: 10px 16px;
      border-radius: 999px;
      background: rgba(17, 24, 39, .08);
      border: 1px solid rgba(17, 24, 39, .08);
      text-align: left;
      box-sizing: border-box;
    }
    .msg-row.msg-row--call-log .bubble-call-log-ico {
      flex-shrink: 0;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: rgba(59, 130, 246, .15);
      position: relative;
    }
    .msg-row.msg-row--call-log .bubble-call-log-ico::before {
      content: '';
      position: absolute;
      inset: 0;
      margin: auto;
      width: 12px;
      height: 12px;
      background-repeat: no-repeat;
      background-position: center;
      background-size: contain;
      opacity: .9;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231d4ed8'%3E%3Cpath d='M6.6 11.9c2 3.9 5.7 7.7 11.9 11.9l4-4c.5-.5 1.3-.7 2-.5 1.1.3 2.3.5 3.6.5.6 0 1 .5 1 1.2V21c0 .6-.4 1-1 1C9.9 22 2 14.3 2 4.9 2 4.4 2.5 4 3 4h3.8c.6 0 1.1.5 1.1 1.1 0 1.3.3 2.5.8 3.7.3.8.1 1.5-.4 2l-3.9 4.1z'/%3E%3C/svg%3E");
    }
    .msg-row.msg-row--call-log .bubble-call-log-title {
      font-size: 13px;
      font-weight: 800;
      color: var(--text-2);
      line-height: 1.3;
    }
    .msg-row.msg-row--call-log .bubble-call-log-sub {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-3);
      line-height: 1.35;
      margin-top: 2px;
    }

    .chat-gravacao-wrap {
      margin-top: 8px;
    }
    .chat-gravacao-link {
      display: inline-block;
      font-size: 12px;
      font-weight: 700;
      color: var(--accent);
      text-decoration: none;
      padding: 2px 0;
      border-bottom: 1px solid transparent;
    }
    .chat-gravacao-link:hover {
      border-bottom-color: rgba(59, 130, 246, .45);
    }

    .bubble        { max-width: 68%; padding: 9px 13px 7px; border-radius: 16px; font-size: 14px; font-weight: 500; line-height: 1.55; word-break: break-word; white-space: pre-wrap; }
    .bubble.them   { background: var(--bub-them); color: var(--bub-them-t); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
    .bubble.me     { background: var(--bub-me);   color: var(--bub-me-t);   border-bottom-right-radius: 4px; box-shadow: 0 2px 8px var(--accent-glow); }
    .bubble.them .bubble-meta { align-items: flex-start; }
    .bubble-meta   { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; margin-top: 4px; width: 100%; min-width: 0; }
    .bubble-meta-line {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: flex-end;
      align-items: baseline;
      gap: 4px 6px;
      width: 100%;
      min-width: 0;
    }
    .bubble.them .bubble-meta-line { justify-content: flex-start; }
    /* Nome do remetente em cima da bolha (só em grupo, bolhas "them") — <button> sem estilo de botão nativo */
    .bubble-sender {
      display: block; max-width: 100%;
      font-size: 12px; font-weight: 800; line-height: 1.2;
      font-family: inherit;
      color: var(--accent); text-decoration: none;
      margin: 0 0 4px; padding: 0;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      cursor: pointer;
      border: none;
      background: transparent;
      box-shadow: none;
      -webkit-appearance: none;
      appearance: none;
      text-align: left;
    }
    .bubble-sender:hover { text-decoration: underline; }
    .bubble-sender:focus { outline: none; }
    .bubble-sender:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
      border-radius: 4px;
    }
    .bubble.me .bubble-sender { display: none; }
    /* Lista de transmissão: linha própria abaixo do horário/estado */
    .bubble.me .bubble-meta-line--lista {
      justify-content: flex-end;
      margin-top: 1px;
    }
    .bubble.me .msg-broadcast-footer {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      max-width: 100%;
      font-size: 9px;
      font-weight: 600;
      line-height: 1.25;
      letter-spacing: 0.01em;
      color: rgba(255, 255, 255, 0.88);
      opacity: 0.98;
    }
    .bubble.me .msg-broadcast-footer .msg-broadcast-nome {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
    }
    .bubble.me .msg-broadcast-ic {
      flex-shrink: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      line-height: 0;
      color: rgba(255, 255, 255, 0.98);
    }
    .bubble.me .msg-broadcast-ic .msg-broadcast-svg {
      display: block;
      flex-shrink: 0;
    }
    .btime         { font-size: 10px; font-weight: 600; opacity: .6; }
    .msg-status    { font-size: 10px; font-weight: 700; opacity: .85; letter-spacing: .02em; }

    /* API de integração: botões sob o texto (mensagem interactiva). */
    .msg-integration-bar {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
      padding-top: 8px;
      border-top: 1px solid rgba(0, 0, 0, 0.08);
    }
    .bubble.me .msg-integration-bar {
      border-top-color: rgba(255, 255, 255, 0.2);
    }
    .msg-integration-btn {
      flex: 1 1 calc(33.33% - 6px);
      min-width: 88px;
      padding: 8px 11px;
      font-size: 13px;
      font-weight: 600;
      font-family: inherit;
      line-height: 1.35;
      cursor: pointer;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface-2);
      color: var(--text);
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }
    .msg-integration-btn:hover {
      background: var(--accent-soft);
      border-color: var(--accent);
      color: var(--accent);
    }
    .msg-integration-btn:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
    .bubble.me .msg-integration-btn {
      background: rgba(255, 255, 255, 0.12);
      border-color: rgba(255, 255, 255, 0.28);
      color: var(--bub-me-t);
    }
    .bubble.me .msg-integration-btn:hover {
      background: rgba(255, 255, 255, 0.22);
      border-color: rgba(255, 255, 255, 0.42);
      color: #fff;
    }
    .msg-integration-done {
      margin-top: 8px;
      padding-top: 6px;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-3);
      border-top: 1px dashed var(--border);
    }
    .bubble.me .msg-integration-done {
      color: rgba(255, 255, 255, 0.75);
      border-top-color: rgba(255, 255, 255, 0.22);
    }

    /* Texto + blocos de código (Markdown ```lang … ```) */
    .msg-text-wrap { display: block; width: 100%; min-width: 0; }
    .msg-mention {
      font-weight: 700;
      color: var(--accent-h);
      background: rgba(37, 99, 235, 0.1);
      border-radius: 4px;
      padding: 0 3px;
      text-decoration: none;
      cursor: pointer;
    }
    .bubble.me .msg-mention {
      color: rgba(255, 255, 255, 0.96);
      background: rgba(255, 255, 255, 0.22);
    }
    .mention-popover {
      position: fixed;
      z-index: 1300;
      min-width: 200px;
      max-width: min(320px, 92vw);
      max-height: 220px;
      overflow-y: auto;
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: 0 8px 32px rgba(15, 23, 42, 0.14);
      padding: 4px 0;
    }
    .mention-popover-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      cursor: pointer;
      font-size: 14px;
      border: none;
      background: transparent;
      width: 100%;
      text-align: left;
      font-family: inherit;
      color: var(--text);
    }
    .mention-popover-item[data-active="1"] {
      background: var(--accent-soft);
    }
    .msg-code-block {
      margin: 8px 0 2px;
      border-radius: 10px;
      overflow: hidden;
      max-width: 100%;
      font-size: 12px;
      line-height: 1.48;
      font-weight: 500;
    }
    .msg-code-lang {
      font-family: var(--font);
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0.05em;
      padding: 5px 10px;
      text-transform: uppercase;
    }
    .bubble.them .msg-code-lang {
      background: #dde1f0;
      color: var(--accent-h);
    }
    .bubble.me .msg-code-lang {
      background: rgba(0, 0, 0, 0.28);
      color: rgba(255, 255, 255, 0.92);
    }
    .msg-pre {
      margin: 0;
      padding: 10px 12px;
      overflow-x: auto;
      max-width: 100%;
      white-space: pre;
      word-break: normal;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    }
    .msg-pre code.hljs { font-size: 12px; font-weight: 500; }

    /* Reações 😊: canal ao lado da bolha. Menu ▾: canto superior direito dentro da bolha (.bubble-menu-wrap) */
    .msg-row-tools {
      position: relative;
      flex-shrink: 0;
      display: flex;
      flex-direction: row;
      align-items: center;
      gap: 4px;
      align-self: center;
      z-index: 6;
    }
    .bubble.bubble--has-menu {
      position: relative;
      padding-top: 22px;
    }
    .bubble.photo-msg.bubble--has-menu {
      padding-top: 22px;
    }
    .bubble-menu-wrap {
      position: absolute;
      top: 4px;
      right: 6px;
      z-index: 8;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
    }
    .bubble-menu-wrap .msg-menu-btn {
      opacity: 0;
      pointer-events: none;
      transition: opacity .15s ease, color .12s ease, transform .12s ease, box-shadow .12s ease;
    }
    .msg-row:hover .bubble-menu-wrap .msg-menu-btn,
    .bubble:focus-within .bubble-menu-wrap .msg-menu-btn,
    .msg-row:focus-within .bubble-menu-wrap .msg-menu-btn {
      opacity: 1;
      pointer-events: auto;
      transform: translateX(0);
    }
    .msg-menu-btn {
      width: 28px;
      height: 24px;
      border: none;
      border-radius: 8px;
      background: rgba(255,255,255,.92);
      box-shadow: 0 4px 14px rgba(0,0,0,.12);
      color: var(--text-2);
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      padding: 0;
    }
    .bubble.them .msg-menu-btn {
      color: var(--text);
      border: 1px solid rgba(0,0,0,.08);
    }
    .bubble.me .msg-menu-btn {
      color: rgba(255,255,255,.96);
      background: rgba(0,0,0,.20);
      border: 1px solid rgba(255,255,255,.22);
      box-shadow: 0 6px 16px rgba(0,0,0,.22);
    }
    .msg-menu-btn:hover {
      box-shadow: 0 8px 18px rgba(0,0,0,.16);
    }
    .msg-menu-btn:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    /* Reações (WhatsApp-like) */
    .msg-row-tools .msg-react-btn {
      width: 28px;
      height: 24px;
      border: none;
      border-radius: 999px;
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      padding: 0;
      margin: 0;
      opacity: 0;
      pointer-events: none;
      transition: opacity .15s ease, transform .12s ease, box-shadow .12s ease, background .12s ease;
      background: rgba(255,255,255,.92);
      box-shadow: 0 4px 14px rgba(0,0,0,.12);
      color: var(--text);
      border: 1px solid rgba(0,0,0,.08);
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .msg-row.me .msg-row-tools .msg-react-btn {
      color: rgba(255,255,255,.98);
      background: rgba(0,0,0,.20);
      border: 1px solid rgba(255,255,255,.22);
      box-shadow: 0 6px 16px rgba(0,0,0,.22);
    }
    .msg-row:hover .msg-row-tools .msg-react-btn,
    .msg-row:focus-within .msg-row-tools .msg-react-btn {
      opacity: 1;
      pointer-events: auto;
      transform: translateX(0);
    }
    .msg-row-tools .msg-react-btn:active { transform: scale(0.96); }

    /* Telemóvel: sem hover — menu ▾ e 😊 sempre acessíveis (sem depender de long-press). */
    @media (hover: none) {
      .bubble-menu-wrap .msg-menu-btn {
        opacity: 0.92;
        pointer-events: auto;
      }
      .msg-row-tools .msg-react-btn {
        opacity: 0.92;
        pointer-events: auto;
        transform: translateX(0);
      }
    }

    .msg-reactions {
      display: flex;
      justify-content: flex-end;
      gap: 6px;
      margin-top: 6px;
      flex-wrap: wrap;
    }
    .bubble.them .msg-reactions { justify-content: flex-start; }
    .react-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 3px 8px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 800;
      background: rgba(255,255,255,.92);
      border: 1px solid rgba(0,0,0,.08);
      color: var(--text);
      box-shadow: 0 6px 18px rgba(0,0,0,.08);
      user-select: none;
      cursor: pointer;
    }
    .bubble.me .react-pill {
      background: rgba(0,0,0,.18);
      border-color: rgba(255,255,255,.22);
      color: rgba(255,255,255,.98);
      box-shadow: 0 10px 22px rgba(0,0,0,.18);
    }
    .react-pill.mine {
      outline: 2px solid rgba(99,102,241,.35);
      outline-offset: 1px;
    }
    .bubble.me .react-pill.mine {
      outline: 2px solid rgba(255,255,255,.32);
    }
    .react-count { opacity: .82; font-weight: 900; }

    #reaction-popover {
      position: fixed;
      z-index: 10060;
      pointer-events: none;
    }
    #reaction-popover.open { pointer-events: auto; }
    .react-bar {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border-radius: 999px;
      background: rgba(24,24,27,.92);
      border: 1px solid rgba(255,255,255,.14);
      box-shadow: 0 20px 40px rgba(0,0,0,.35);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      transform: translateY(0);
    }
    .react-bar button {
      width: 34px;
      height: 34px;
      border-radius: 999px;
      border: none;
      background: rgba(255,255,255,.10);
      color: #fff;
      font-size: 18px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: transform .12s ease, background .12s ease;
    }
    .react-bar button:hover { background: rgba(255,255,255,.16); }
    .react-bar button:active { transform: scale(.96); }
    .react-bar button.sel {
      background: rgba(99,102,241,.35);
      outline: 2px solid rgba(255,255,255,.22);
      outline-offset: 1px;
    }
    .msg-dropdown {
      position: absolute; top: 100%; right: 0; margin-top: 4px;
      min-width: 190px; background: var(--panel); border: 1px solid var(--border);
      border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.18); z-index: 80;
      max-height: calc(100vh - 16px);
      overflow-x: hidden;
      overflow-y: auto;
    }
    .msg-dropdown-item {
      display: block; width: 100%; text-align: left; padding: 12px 16px;
      border: none; background: transparent; font-size: 14px; font-weight: 700;
      cursor: pointer; color: var(--text); font-family: inherit;
    }
    .msg-dropdown-item:hover { background: var(--surface-2); }
    .msg-quote {
      display: flex; gap: 8px; margin: 0 0 8px 0; max-width: 100%;
      padding: 6px 8px; border-radius: 8px;
      background: rgba(0,0,0,.08); font-size: 12px; line-height: 1.35;
    }
    .msg-link {
      color: var(--accent);
      font-weight: 800;
      text-decoration: underline;
      text-underline-offset: 2px;
      word-break: break-word;
    }
    .bubble.me .msg-link { color: rgba(255,255,255,.98); text-decoration-color: rgba(255,255,255,.75); }
    .msg-link:active { opacity: .85; }
    .msg-link-preview {
      margin-top: 8px;
      border-radius: 12px;
      border: 1px solid rgba(17,24,39,.12);
      background: rgba(255,255,255,.92);
      overflow: hidden;
      box-shadow: 0 8px 20px rgba(0,0,0,.12);
      padding: 10px 12px;
      max-width: min(100%, 360px);
    }
    .bubble.me .msg-link-preview {
      background: rgba(0,0,0,.2);
      border-color: rgba(255,255,255,.22);
      box-shadow: 0 10px 22px rgba(0,0,0,.2);
    }
    .msg-link-preview.is-loading { opacity: 0.9; }
    .msg-link-preview-img {
      width: calc(100% + 24px);
      margin: -10px -12px 8px -12px;
      max-height: 180px;
      object-fit: cover;
      display: block;
      background: #dbe2f5;
    }
    .msg-link-preview-head {
      font-size: 13px;
      font-weight: 800;
      color: var(--text);
      line-height: 1.35;
    }
    .msg-link-preview-desc {
      margin-top: 4px;
      font-size: 12px;
      color: var(--text-2);
      line-height: 1.4;
    }
    .msg-link-preview-site {
      margin-top: 6px;
      font-size: 11px;
      font-weight: 700;
      color: var(--text-3);
      text-transform: uppercase;
      letter-spacing: .02em;
    }
    .msg-link-preview-url {
      display: block;
      margin-top: 6px;
      font-size: 12px;
      font-weight: 700;
      color: var(--accent);
      text-decoration: underline;
      text-underline-offset: 2px;
      word-break: break-word;
    }
    .bubble.me .msg-link-preview-url {
      color: rgba(255,255,255,.96);
      text-decoration-color: rgba(255,255,255,.75);
    }
    .msg-youtube-wrap {
      margin-top: 8px;
      width: min(100%, 360px);
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid rgba(0,0,0,.08);
      background: #000;
      box-shadow: 0 8px 20px rgba(0,0,0,.16);
    }
    .bubble.me .msg-youtube-wrap {
      border-color: rgba(255,255,255,.26);
      box-shadow: 0 10px 24px rgba(0,0,0,.24);
    }
    .msg-youtube-iframe {
      width: 100%;
      aspect-ratio: 16 / 9;
      border: 0;
      display: block;
      background: #000;
      max-width: 100%;
    }
    .msg-youtube-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px;
      background: rgba(0, 0, 0, 0.88);
    }
    .msg-youtube-btn {
      border: 1px solid rgba(255,255,255,.28);
      background: rgba(255,255,255,.12);
      color: #fff;
      border-radius: 8px;
      padding: 5px 10px;
      font-size: 12px;
      font-weight: 700;
      line-height: 1;
      cursor: pointer;
    }
    .msg-youtube-btn:active { transform: scale(0.98); }
    .msg-youtube-open {
      margin-left: auto;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 5px 8px;
      border-radius: 8px;
      font-size: 11px;
      font-weight: 800;
      color: #fff;
      text-decoration: none;
      border: 1px solid rgba(255,255,255,.3);
      background: rgba(255,255,255,.14);
      white-space: nowrap;
    }
    .msg-youtube-open:active { transform: scale(0.98); }
    .msg-caption {
      margin-top: 6px;
      font-size: 13px;
      line-height: 1.45;
      font-weight: 650;
      color: var(--text);
      white-space: pre-wrap;
      word-break: break-word;
    }
    .bubble.them .msg-caption { color: var(--text); opacity: .92; }
    .bubble.me .msg-caption { color: rgba(255,255,255,.96); }
    /* Mesma família visual da citação em bolha recebida: azul muito suave + barra verde —
       evita o «cartão branco» destacado dentro da bolha enviada. */
    .bubble.me .msg-quote {
      background: rgba(219, 234, 254, 0.58);
      border: 1px solid rgba(67, 97, 238, 0.22);
      box-shadow: none;
    }
    .bubble.me .msg-quote-name {
      color: var(--accent-h);
    }
    .bubble.me .msg-quote-prev {
      color: var(--text);
      opacity: 0.92;
    }
    .msg-quote-accent {
      width: 3px; flex-shrink: 0; border-radius: 2px;
      background: var(--accent);
    }
    /* Bolha cinza recebida: citação um pouco mais definida */
    .bubble.them .msg-quote {
      background: rgba(67, 97, 238, 0.09);
      border: 1px solid rgba(67, 97, 238, 0.14);
    }
    .bubble.them .msg-quote-name { color: var(--accent-h); }
    .bubble.them .msg-quote-prev { color: var(--text); opacity: 0.92; }
    /* Legenda de encaminhamento (estilo WhatsApp) */
    .msg-forward-tag {
      display: flex;
      align-items: flex-start;
      gap: 6px;
      margin: 0 0 6px 0;
      font-size: 12px;
      font-weight: 700;
      line-height: 1.3;
      color: var(--text-3);
    }
    .bubble.me .msg-forward-tag {
      color: rgba(255, 255, 255, 0.78);
    }
    .msg-forward-icon {
      font-size: 13px;
      opacity: 0.9;
      flex-shrink: 0;
    }
    .msg-forward-txt {
      word-break: break-word;
      display: block;
    }
    .msg-forward-user {
      display: block;
    }
    .msg-forward-group {
      display: block;
      margin-top: 2px;
    }
    .msg-quote-name { font-weight: 800; color: var(--accent); margin-bottom: 2px; font-size: 12px; }
    .msg-quote-source-group { font-size: 11px; font-weight: 700; color: var(--text-2); opacity: .85; margin-bottom: 2px; }
    .bubble.me .msg-quote-source-group { color: rgba(255, 255, 255, 0.85); }
    .msg-quote-prev { color: var(--text-2); opacity: .92; word-break: break-word; white-space: pre-wrap; }
    .msg-quote--jump {
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      transition: opacity .12s ease, filter .12s ease;
    }
    .bubble.them .msg-quote--jump:hover { filter: brightness(0.97); }
    .bubble.me .msg-quote--jump:hover { filter: brightness(0.98); }
    .msg-quote--jump:focus { outline: none; }
    .msg-quote--jump:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
    @keyframes msgRowScrollFlash {
      0%   { box-shadow: 0 0 0 0 rgba(67, 97, 238, 0); }
      25%  { box-shadow: 0 0 0 3px var(--accent-glow); }
      100% { box-shadow: 0 0 0 0 rgba(67, 97, 238, 0); }
    }
    .msg-row.msg-row--scroll-flash {
      animation: msgRowScrollFlash 1.4s ease;
      border-radius: 18px;
    }

    /* Compositor: citação + texto no mesmo cartão (evita faixa larga desligada do campo) */
    .composer-surface {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      background: var(--surface);
      border: 1.5px solid var(--border);
      border-radius: 22px;
      transition: border-color .2s, box-shadow .2s, background .2s;
      overflow: hidden;
    }
    .composer-surface:focus-within {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-glow);
      background: var(--panel);
    }

    #reply-preview-bar {
      flex-shrink: 0;
      padding: 5px 8px 6px 10px;
      border-bottom: 1px solid var(--border);
      background: var(--surface-2);
    }
    #reply-preview-bar.d-none { display: none !important; }
    .reply-preview-inner {
      display: flex;
      align-items: center;
      gap: 8px;
      max-width: 100%;
      min-height: 0;
    }
    .reply-preview-bar-accent {
      width: 3px;
      align-self: stretch;
      min-height: 28px;
      flex-shrink: 0;
      border-radius: 2px;
      background: var(--accent);
    }
    .reply-preview-text { flex: 1; min-width: 0; }
    .reply-preview-kicker {
      font-size: 10px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--text-3);
      margin-bottom: 1px;
    }
    .reply-preview-name { font-size: 12px; font-weight: 800; color: var(--accent); line-height: 1.2; }
    .reply-preview-snippet {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-2);
      margin-top: 1px;
      line-height: 1.3;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    #reply-preview-cancel {
      flex-shrink: 0;
      width: 30px;
      height: 30px;
      border: 1px solid var(--border);
      border-radius: 50%;
      background: var(--surface);
      color: var(--text-2);
      font-size: 18px;
      line-height: 1;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background .15s, color .15s, border-color .15s;
    }
    #reply-preview-cancel:hover {
      background: var(--panel);
      color: var(--text);
      border-color: var(--border-2);
    }

    .composer-input-row {
      display: flex;
      gap: 8px;
      align-items: flex-end;
      padding: 2px 6px 6px 10px;
      min-width: 0;
    }
    .composer-input-row #msg-input {
      border: none;
      box-shadow: none;
      background: transparent;
      border-radius: 16px;
      padding: 8px 6px 8px 2px;
    }
    .composer-input-row #msg-input:focus {
      border: none;
      box-shadow: none;
      background: transparent;
    }

    #forward-modal {
      display: none; position: fixed; inset: 0; z-index: 10060;
      background: rgba(15,18,40,.55); align-items: center; justify-content: center;
      padding: 16px;
    }
    #forward-modal.open { display: flex; }
    #msg-info-modal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 1400;
      background: rgba(15, 23, 42, 0.45);
      align-items: flex-end;
      justify-content: center;
      padding: 12px;
    }
    #msg-info-modal.open { display: flex; }
    @media (min-width: 720px) {
      #msg-info-modal { align-items: center; }
    }
    .msg-info-modal-box {
      width: 100%;
      max-width: 420px;
      max-height: min(82vh, 560px);
      background: var(--panel);
      border-radius: 16px;
      border: 1px solid var(--border);
      box-shadow: 0 16px 48px rgba(0,0,0,.2);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .msg-info-head {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 14px;
      border-bottom: 1px solid var(--border);
    }
    .msg-info-head h3 { flex: 1; font-size: 16px; font-weight: 800; margin: 0; color: var(--text); }
    .msg-info-head button {
      border: none;
      background: transparent;
      font-size: 22px;
      line-height: 1;
      cursor: pointer;
      color: var(--text-2);
      padding: 4px 8px;
      border-radius: 8px;
    }
    .msg-info-head button:active { background: var(--surface-2); }
    .msg-info-body {
      padding: 12px 14px 18px;
      overflow-y: auto;
      font-size: 14px;
      -webkit-overflow-scrolling: touch;
    }
    .msg-info-list { display: flex; flex-direction: column; gap: 12px; }
    .msg-info-row {
      display: flex;
      gap: 10px;
      align-items: flex-start;
      padding: 10px 12px;
      border-radius: 12px;
      background: var(--surface-2);
      border: 1px solid var(--border);
    }
    .msg-info-av {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      object-fit: cover;
      flex-shrink: 0;
      border: 1px solid rgba(17,24,39,.08);
    }
    .msg-info-who { font-weight: 800; color: var(--text); margin: 0 0 6px 0; font-size: 14px; }
    .msg-info-meta { min-width: 0; flex: 1; }
    .msg-info-line {
      display: grid;
      grid-template-columns: 88px minmax(0, 1fr);
      column-gap: 8px;
      align-items: start;
      font-size: 12.5px;
      color: var(--text-2);
      margin: 4px 0;
      line-height: 1.45;
    }
    .msg-info-label { color: var(--text-3); font-weight: 700; }
    .msg-info-value { min-width: 0; overflow-wrap: anywhere; }
    .msg-info-tabs {
      display: flex;
      gap: 4px;
      padding: 4px;
      margin: 0 0 12px 0;
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: 12px;
    }
    .msg-info-tab {
      flex: 1;
      appearance: none;
      border: none;
      background: transparent;
      color: var(--text-2);
      font-weight: 700;
      font-size: 13px;
      padding: 8px 10px;
      border-radius: 9px;
      cursor: pointer;
      transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }
    .msg-info-tab:hover { color: var(--text); }
    .msg-info-tab.is-active {
      background: var(--panel);
      color: var(--text);
      box-shadow: 0 1px 3px rgba(0,0,0,.08);
    }
    .msg-info-tab-count {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 18px;
      height: 18px;
      padding: 0 6px;
      border-radius: 999px;
      background: var(--accent, #2563eb);
      color: #fff;
      font-size: 11px;
      font-weight: 800;
      line-height: 1;
    }
    .msg-info-pane[hidden] { display: none; }
    .msg-info-reaction-emoji {
      font-size: 18px;
      line-height: 1.2;
    }
    .forward-modal-box {
      width: 100%; max-width: 420px; max-height: 85dvh;
      background: var(--panel); border-radius: 16px; border: 1px solid var(--border);
      box-shadow: 0 16px 48px rgba(0,0,0,.2);
      display: flex; flex-direction: column; overflow: hidden;
    }
    .forward-modal-head {
      display: flex; align-items: center; gap: 10px; padding: 14px 16px;
      border-bottom: 1px solid var(--border);
    }
    .forward-modal-head button {
      border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--text-2);
      padding: 4px 8px; line-height: 1;
    }
    .forward-modal-head h3 { flex: 1; font-size: 16px; font-weight: 800; margin: 0; }
    .forward-modal-search {
      padding: 10px 14px; border-bottom: 1px solid var(--border);
    }
    .forward-modal-search input {
      width: 100%; padding: 10px 12px 10px 36px; border-radius: 12px;
      border: 1.5px solid var(--border); background: var(--surface); font-size: 14px;
    }
    .forward-search-wrap { position: relative; }
    .forward-search-wrap span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); opacity: .5; }
    #forward-contact-list {
      overflow-y: auto; flex: 1; min-height: 0; padding: 8px 0;
    }
    .forward-row {
      display: flex; align-items: center; gap: 12px; padding: 10px 16px;
      cursor: pointer; border: none; background: transparent; width: 100%; text-align: left;
      font-family: inherit;
    }
    .forward-row:hover { background: var(--surface-2); }
    .forward-row input { width: 18px; height: 18px; flex-shrink: 0; }
    .forward-row-name { font-weight: 800; font-size: 14px; color: var(--text); }
    .forward-modal-foot {
      padding: 12px 16px; border-top: 1px solid var(--border);
      display: flex; justify-content: flex-end; gap: 10px;
    }
    .btn-forward-send {
      padding: 10px 20px; border-radius: 12px; border: none;
      background: var(--accent); color: #fff; font-weight: 800; font-size: 14px; cursor: pointer;
    }
    .btn-forward-send:disabled { opacity: .45; cursor: not-allowed; }

    #group-info-modal {
      display: none; position: fixed; inset: 0; z-index: 10070;
      background: rgba(15,18,40,.55); align-items: center; justify-content: center;
      padding: 16px;
    }
    #group-info-modal.open { display: flex; }
    .gi-box {
      width: 100%; max-width: 440px; max-height: 85dvh;
      background: var(--panel); border-radius: 16px; border: 1px solid var(--border);
      box-shadow: 0 16px 48px rgba(0,0,0,.2);
      display: flex; flex-direction: column; overflow: hidden;
    }
    .gi-head {
      display: flex; align-items: center; gap: 10px; padding: 14px 16px;
      border-bottom: 1px solid var(--border);
    }
    .gi-head button {
      border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--text-2);
      padding: 4px 8px; line-height: 1;
    }
    .gi-head h3 { flex: 1; font-size: 16px; font-weight: 800; margin: 0; }
    .gi-body { overflow-y: auto; padding: 0; }
    .gi-hero {
      position: relative;
      display: flex; flex-direction: column; align-items: center; gap: 8px;
      padding: 0 16px 16px;
      background: var(--surface);
    }
    .gi-cover {
      position: relative;
      width: calc(100% + 32px); margin: 0 -16px -44px; height: 128px;
      background: linear-gradient(135deg, var(--accent) 0%, #6750A4 100%);
      background-size: cover; background-position: center;
    }
    .gi-cover-btn {
      position: absolute; top: 8px; right: 8px;
      width: 34px; height: 34px; border-radius: 50%;
      background: rgba(0,0,0,.45); color: #fff; border: none;
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      backdrop-filter: blur(4px);
      transition: background .15s;
    }
    .gi-cover-btn:hover { background: rgba(0,0,0,.65); }
    .gi-cover-btn svg { width: 16px; height: 16px; fill: currentColor; }
    .gi-avatar-wrap {
      position: relative; width: 88px; height: 88px; flex-shrink: 0;
      z-index: 1;
    }
    .gi-hero-avatar {
      width: 88px; height: 88px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 30px; font-weight: 800;
      border: 3px solid var(--panel); object-fit: cover;
      background: var(--surface);
      box-shadow: 0 4px 14px rgba(0,0,0,.15);
    }
    .gi-avatar-edit {
      position: absolute; right: -2px; bottom: -2px;
      width: 30px; height: 30px; border-radius: 50%;
      background: var(--accent); color: #fff; border: 2px solid var(--panel);
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      box-shadow: 0 2px 8px rgba(0,0,0,.2);
      transition: transform .12s, background .15s;
    }
    .gi-avatar-edit:hover { background: var(--accent-h); transform: scale(1.06); }
    .gi-avatar-edit svg { width: 14px; height: 14px; fill: currentColor; }


    /* Um único layer (máscara) evita artefato de “dois ícones” em alguns browsers */
    .btn-mic .mic-graphic {
      display: block;
      width: 22px;
      height: 22px;
      background-color: currentColor;
      -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2s-2 .9-2 2v6c0 1.1.9 2 2 2zm5-3c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z'/%3E%3C/svg%3E");
      mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2s-2 .9-2 2v6c0 1.1.9 2 2 2zm5-3c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z'/%3E%3C/svg%3E");
      -webkit-mask-size: contain;
      mask-size: contain;
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-position: center;
      mask-position: center;
      pointer-events: none;
    }
    .btn-mic:hover  { background: var(--accent-soft); border-color: #c7d2fe; }
    .btn-mic:active { transform: scale(.88); }
    .btn-photo {
      width: 44px; height: 44px; border-radius: 50%;
      padding: 0;
      background: var(--surface); border: 1.5px solid var(--border);
      color: var(--accent);
      cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
      transition: background .15s, transform .15s, border-color .15s;
      touch-action: manipulation; flex-shrink: 0;
      -webkit-tap-highlight-color: transparent;
    }
    .btn-photo .cam-graphic {
      display: block; width: 22px; height: 22px;
      background-color: currentColor;
      /* Ícone: clipe (anexo) */
      -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M16.5 6.5v9.25a4.25 4.25 0 1 1-8.5 0V6.75a2.75 2.75 0 1 1 5.5 0v8.75a1.25 1.25 0 1 1-2.5 0V7.25h-1.5V15.5a2.75 2.75 0 1 0 5.5 0V6.75a4.25 4.25 0 1 0-8.5 0v9a5.75 5.75 0 0 0 11.5 0V6.5h-1.5z'/%3E%3C/svg%3E");
      mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M16.5 6.5v9.25a4.25 4.25 0 1 1-8.5 0V6.75a2.75 2.75 0 1 1 5.5 0v8.75a1.25 1.25 0 1 1-2.5 0V7.25h-1.5V15.5a2.75 2.75 0 1 0 5.5 0V6.75a4.25 4.25 0 1 0-8.5 0v9a5.75 5.75 0 0 0 11.5 0V6.5h-1.5z'/%3E%3C/svg%3E");
      -webkit-mask-size: contain; mask-size: contain;
      -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
      pointer-events: none;
    }
    .btn-photo:hover  { background: var(--accent-soft); border-color: #c7d2fe; }
    .btn-photo:active { transform: scale(.88); }
    .btn-mic.recording {
      background: var(--red-soft); border-color: #fca5a5; color: var(--red);
      box-shadow: 0 0 0 2px rgba(239, 68, 68, .15);
    }

    .normal-input-wrap {
      display: flex;
      flex: 1;
      min-width: 0;
      align-items: stretch;
    }
    .composer-input-row #msg-input { flex: 1; min-width: 0; }
    .voice-record-wrap {
      flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: 16px; padding: 10px 12px;
    }
    .voice-rec-top {
      display: flex; align-items: center; gap: 10px;
    }
    #rec-time {
      font-variant-numeric: tabular-nums; font-weight: 800; font-size: 14px;
      color: var(--text); min-width: 44px;
    }
    .voice-meter-bars {
      flex: 1; display: flex; align-items: center; justify-content: space-between;
      gap: 3px; height: 28px;
    }
    .voice-meter-bar {
      flex: 1; min-width: 3px; max-width: 8px; height: 100%;
      background: var(--accent);
      border-radius: 3px; transform-origin: center bottom;
      transform: scaleY(0.2); opacity: .85;
      transition: transform .08s ease-out;
    }
    .voice-rec-actions {
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
    }
    .btn-voice-cancel {
      width: 44px; height: 44px; border-radius: 50%;
      border: 1.5px solid var(--border); background: var(--panel);
      color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; transition: background .15s, border-color .15s;
    }
    .btn-voice-cancel:hover { background: var(--red-soft); border-color: #fca5a5; color: var(--red); }
    .btn-voice-send {
      width: 44px; height: 44px; border-radius: 50%;
      border: none; background: var(--accent); color: #fff;
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; box-shadow: 0 3px 10px var(--accent-glow);
    }
    .btn-voice-send svg { width: 20px; height: 20px; display: block; }
    .avatar-img {
      width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
      flex-shrink: 0; border: 1px solid var(--border);
    }
    .bubble.photo-msg { padding: 6px; overflow: visible; }
    .bubble.photo-msg .chat-photo-img {
    display: block;
    max-width: min(280px, 78vw);
    max-height: 360px;
    width: auto;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    }


    /* Download-to-device (offline cache) */
    .media-dl-btn {
      flex-shrink: 0;
      width: 34px;
      height: 34px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--accent);
      font-weight: 900;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: background .15s, border-color .15s, transform .15s, opacity .15s;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
    }
    .media-dl-btn:hover { background: var(--accent-soft); border-color: #c7d2fe; }
    .media-dl-btn:active { transform: scale(.96); }
    .media-dl-btn.d-none { display: none !important; }
    .bubble.me .media-dl-btn {
      background: rgba(255,255,255,.16);
      border-color: rgba(255,255,255,.22);
      color: rgba(255,255,255,.92);
    }
    .bubble.me .media-dl-btn:hover { background: rgba(255,255,255,.24); }

    /* Player de áudio custom (layout do exemplo) */
    .audio-player {
      display: flex;
      align-items: center;
      gap: 10px;
      max-width: min(420px, 78vw);
      min-width: min(260px, 78vw);
    }
    .audio-player audio { display: none; }

    .audio-play {
      flex-shrink: 0;
      width: 40px;
      height: 40px;
      border-radius: 999px;
      border: 1px solid rgba(0,0,0,.10);
      background: rgba(255,255,255,.92);
      color: var(--text);
      cursor: pointer;
      font-size: 16px;
      font-weight: 900;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: transform .12s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
      box-shadow: 0 6px 18px rgba(0,0,0,.10);
      user-select: none;
      -webkit-tap-highlight-color: transparent;
    }
    .audio-play:active { transform: scale(.96); }
    .audio-play:hover { background: var(--surface-2); }
    .audio-play.audio-play--wait[aria-disabled="true"] {
      opacity: 0.65;
      cursor: pointer; /* não mostrar “rodando/espera” */
    }

    .audio-mid { flex: 1; min-width: 0; }
    .audio-wave {
      position: relative;
      width: 100%;
      height: 20px;
      border-radius: 999px;
      cursor: pointer;
      outline: none;
    }
    .audio-wave-track {
      position: absolute;
      inset: 50% 0 auto 0;
      height: 6px;
      transform: translateY(-50%);
      border-radius: 999px;
      background: rgba(15,23,42,.22);
    }
    .bubble.me .audio-wave-track { background: rgba(255,255,255,.26); }

    .audio-wave-fill {
      position: absolute;
      inset: 50% auto auto 0;
      height: 6px;
      transform: translateY(-50%);
      border-radius: 999px;
      background: var(--accent);
      width: 0%;
    }
    .bubble.me .audio-wave-fill { background: rgba(255,255,255,.92); }

    .audio-wave-knob {
      position: absolute;
      top: 50%;
      width: 12px;
      height: 12px;
      border-radius: 999px;
      transform: translate(-50%, -50%);
      background: var(--accent);
      box-shadow: 0 6px 18px rgba(0,0,0,.18);
      left: 0%;
    }
    .bubble.me .audio-wave-knob { background: rgba(255,255,255,.98); }
    .audio-wave:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    .audio-times {
      margin-top: 2px;
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      font-weight: 900;
      letter-spacing: 0.01em;
      font-variant-numeric: tabular-nums;
      color: var(--text-2);
      opacity: 0.95;
    }
    .bubble.me .audio-times { color: rgba(255,255,255,.92); opacity: 0.92; }

    .audio-dl {
      flex-shrink: 0;
      width: 34px;
      height: 34px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--accent);
      font-weight: 900;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: background .15s, transform .12s, opacity .15s;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
    }
    .audio-dl:hover { background: var(--accent-soft); }
    .audio-dl:active { transform: scale(.96); }
    .bubble.me .audio-dl {
      background: rgba(255,255,255,.16);
      border-color: rgba(255,255,255,.22);
      color: rgba(255,255,255,.92);
    }
    .bubble.me .audio-dl:hover { background: rgba(255,255,255,.24); }

    @keyframes spin360 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
    .audio-dl.loading {
      position: relative;
      pointer-events: none;
      opacity: 0.72;
      color: transparent; /* esconde a setinha enquanto roda */
    }
    .audio-dl.loading::after {
      content: '';
      position: absolute;
      width: 16px;
      height: 16px;
      border-radius: 999px;
      border: 2px solid rgba(0,0,0,.18);
      border-top-color: var(--accent);
      animation: spin360 .8s linear infinite;
      inset: 0;
      margin: auto;
    }
    .bubble.me .audio-dl.loading::after {
      border-color: rgba(255,255,255,.22);
      border-top-color: rgba(255,255,255,.92);
    }

    .audio-speed-btn {
      flex-shrink: 0;
      min-width: 44px;
      height: 34px;
      padding: 0 10px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      font-weight: 900;
      font-size: 12px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: background .15s, border-color .15s, transform .15s, opacity .15s;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
    }
    .audio-speed-btn:hover { background: var(--surface-2); }
    .audio-speed-btn:active { transform: scale(.96); }
    .bubble.me .audio-speed-btn {
      background: rgba(255,255,255,.16);
      border-color: rgba(255,255,255,.22);
      color: rgba(255,255,255,.92);
    }
    .bubble.me .audio-speed-btn:hover { background: rgba(255,255,255,.24); }
    /* Legenda com a mesma largura da imagem (não alarga a bolha) */
    .photo-with-caption {
      display: block;
      max-width: min(280px, 78vw);
      box-sizing: border-box;
    }
    .photo-with-caption .photo-wrap { position: relative; display: block; }
    .photo-with-caption .msg-caption {
      margin-top: 6px;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      min-width: 0;
      overflow-wrap: anywhere;
      word-break: break-word;
    }

    .photo-wrap { position: relative; display: inline-block; }
    .photo-wrap .media-dl-btn {
      position: absolute;
      right: 10px;
      bottom: 10px;
      box-shadow: 0 6px 16px rgba(0,0,0,.18);
    }

    .file-bubble-inner {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .file-ico { font-size: 18px; opacity: .85; }
    .file-txt { flex: 1; min-width: 0; }
    .file-name { font-weight: 800; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .file-sub { margin-top: 2px; font-size: 11px; font-weight: 700; opacity: .8; }
    .file-open {
      flex-shrink: 0;
      padding: 7px 10px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--accent);
      font-weight: 800;
      font-size: 12px;
      text-decoration: none;
      transition: background .15s, border-color .15s, transform .15s;
    }
    .file-open:hover { background: var(--accent-soft); border-color: #c7d2fe; }
    .file-open:active { transform: scale(.97); }
    .file-open.secondary { color: var(--text-2); }

    .file-upload-progress {
      margin-top: 8px;
      width: 100%;
    }
    .file-prog-bar {
      height: 8px;
      border-radius: 999px;
      background: rgba(31, 41, 55, 0.12);
      overflow: hidden;
    }
    .bubble.me .file-prog-bar { background: rgba(255, 255, 255, 0.22); }
    .file-prog-fill {
      height: 100%;
      width: 0%;
      background: var(--accent);
      border-radius: 999px;
      transition: width .12s linear;
    }
    .bubble.me .file-prog-fill { background: rgba(255,255,255,0.88); }
    .file-prog-meta {
      margin-top: 6px;
      display: flex;
      justify-content: space-between;
      gap: 10px;
      font-size: 11px;
      font-weight: 800;
      opacity: 0.85;
    }
    .bubble.me .file-prog-meta { opacity: 0.78; }

    /* Vídeo no chat (controlo próprio + descarregar) */
    .bubble.video-msg {
      padding: 8px;
      max-width: min(320px, 92vw);
      overflow: hidden;
    }
    .bubble.me.video-msg {
      overflow: hidden;
    }
    .video-with-caption {
      display: block;
      max-width: min(320px, 92vw);
      box-sizing: border-box;
    }
    .video-with-caption .msg-caption {
      margin-top: 8px;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      min-width: 0;
      overflow-wrap: anywhere;
      word-break: break-word;
    }
    .chat-video-wrap { width: 100%; min-width: 0; position: relative; }
    .chat-video-el {
      display: block;
      width: 100%;
      max-height: min(50dvh, 420px);
      border-radius: 10px;
      background: #0f172a;
    }
    .chat-video-el.chat-video-err { opacity: 0.5; }
    .chat-video-controls {
      margin-top: 8px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      width: 100%;
      max-width: 100%;
      min-width: 0;
      box-sizing: border-box;
    }
    .chat-video-row1 {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .chat-video-play {
      flex-shrink: 0;
      width: 38px;
      height: 38px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--accent);
      font-size: 16px;
      font-weight: 800;
      line-height: 1;
      cursor: pointer;
      transition: background .15s, transform .12s;
    }
    .chat-video-play:hover { background: var(--surface-2); }
    .chat-video-play:active { transform: scale(0.96); }
    /* Não usar disabled no botão play: em vários browsers o clique não dispara ou “passa”
       para o elemento de baixo — o utilizador vê seek a funcionar mas play “não faz nada”. */
    .chat-video-play.chat-video-play--wait[aria-disabled="true"] {
      opacity: 0.5;
      cursor: wait;
    }
    .chat-video-load-msg {
      font-size: 11px;
      font-weight: 800;
      opacity: 0.85;
      margin-top: 2px;
      letter-spacing: 0.02em;
    }
    .bubble.me .chat-video-load-msg { opacity: 0.78; }
    .chat-video-buffer-prog {
      margin-top: 4px;
      height: 5px;
      border-radius: 999px;
      background: rgba(31, 41, 55, 0.18);
      overflow: hidden;
    }
    .bubble.me .chat-video-buffer-prog {
      background: rgba(255, 255, 255, 0.22);
    }
    .chat-video-buffer-prog-fill {
      height: 100%;
      width: 0%;
      border-radius: inherit;
      background: var(--accent);
      transition: width 0.12s linear;
    }
    .bubble.me .chat-video-buffer-prog-fill {
      background: rgba(255, 255, 255, 0.88);
    }
    .bubble.me .chat-video-play {
      background: rgba(255,255,255,.14);
      border-color: rgba(255,255,255,.28);
      color: #fff;
    }
    .bubble.me .chat-video-play:hover { background: rgba(255,255,255,.22); }
    .chat-video-time {
      font-size: 12px;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      opacity: 0.9;
      flex: 1;
      min-width: 0;
    }
    .chat-video-acoes {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }
    .chat-video-wrap .media-dl-btn {
      position: static;
      box-shadow: none;
    }
    .chat-video-wrap:fullscreen,
    .chat-video-wrap:-webkit-full-screen {
      width: 100%;
      height: 100%;
      max-width: none;
      background: #0f172a;
      padding: 12px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
    }
    .chat-video-wrap:fullscreen .chat-video-el,
    .chat-video-wrap:-webkit-full-screen .chat-video-el {
      max-height: none;
      flex: 1 1 auto;
      min-height: 0;
      width: 100%;
      object-fit: contain;
    }
    .chat-video-wrap:fullscreen .chat-video-controls,
    .chat-video-wrap:-webkit-full-screen .chat-video-controls {
      flex-shrink: 0;
      transform: none;
    }
    .chat-video-progress-wrap {
      width: 100%;
    }
    .chat-video-seek {
      width: 100%;
      height: 8px;
      cursor: pointer;
      accent-color: var(--accent);
    }
    .bubble.me .chat-video-seek { accent-color: rgba(255,255,255,.92); }
    .chat-video-speeds {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
    }
    .chat-video-rate {
      padding: 5px 8px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface);
      font-size: 11px;
      font-weight: 800;
      cursor: pointer;
      line-height: 1.2;
      transition: background .15s, transform .12s;
    }
    .chat-video-rate:hover { background: var(--surface-2); }
    .chat-video-rate:active { transform: scale(0.96); }
    .chat-video-rate.sel {
      background: var(--accent-soft);
      border-color: #c7d2fe;
      color: var(--accent);
    }
    .bubble.me .chat-video-rate {
      background: rgba(255,255,255,.12);
      border-color: rgba(255,255,255,.22);
      color: rgba(255,255,255,.95);
    }
    .bubble.me .chat-video-rate.sel {
      background: rgba(255,255,255,.28);
      border-color: rgba(255,255,255,.4);
      color: #fff;
    }
    .chat-video-fallback {
      margin-top: 6px;
      font-size: 12px;
      font-weight: 700;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }
    .btn-video-retry {
      padding: 5px 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface);
      font-weight: 800;
      font-size: 11px;
      cursor: pointer;
    }

