.chat-media-image,.chat-media-video{display:block;width:min(360px,100%);max-height:420px;object-fit:contain;border-radius:9px;background:#e8ecea}
.chat-media-image.sticker{width:min(190px,100%);background:transparent}
.chat-media-audio{display:block;width:min(330px,100%);height:42px}
.chat-message-body{margin-top:7px}
.chat-message-body:first-child{margin-top:0}
.chat-document{display:flex;align-items:center;gap:9px;padding:10px;border-radius:9px;background:#eef3f1;font-weight:700}
.chat-media-download{display:inline-block;margin-top:7px;color:var(--green);font-size:11px;font-weight:750}
.bubble.outbound .chat-document{background:#cceec7}
.inbox-admin-actions{display:flex;align-items:center;margin-left:auto;margin-right:10px}
.topbar .inbox-admin-actions+.notification-menu{margin-left:0}
.inbox-admin-actions form{margin:0}
@media(max-width:600px){.inbox-admin-actions{margin-left:8px}.inbox-admin-actions .btn{padding:8px 10px;font-size:11px}}
.chat-layout{height:calc(100vh - 190px);min-height:520px;max-height:850px;overflow:hidden}
.chat-list{min-height:0;overflow-y:auto;overscroll-behavior:contain}
.chat-panel{min-height:0;overflow:hidden}
.messages{min-height:0;overflow-y:auto;overscroll-behavior:contain}
.chat-form{align-items:flex-end;position:relative}.chat-compose-tools{display:flex;align-items:center;gap:6px}.chat-tool-button{width:40px;height:40px;border:1px solid var(--line);border-radius:10px;background:#fff;display:grid;place-items:center;cursor:pointer;font-size:18px;padding:0}.chat-compose-status{position:absolute;left:14px;bottom:58px;max-width:70%;padding:4px 8px;border-radius:7px;background:#fff;color:var(--muted);font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-compose-status:empty{display:none}
.chat-message-actions{display:flex;justify-content:flex-end;gap:3px;margin:-5px -7px 4px}.chat-message-actions button{border:0;background:transparent;color:var(--muted);cursor:pointer;padding:2px 5px;border-radius:5px}.chat-message-actions button:hover{background:#edf2f0;color:var(--ink)}
@media(max-width:800px){.chat-layout{height:calc(100vh - 155px);min-height:560px;max-height:none}.chat-list{max-height:220px;flex:0 0 220px}.chat-panel{min-height:0}}
.ui-icon{display:inline-block;width:20px;height:20px;vertical-align:middle;flex:0 0 auto}
.sidebar .ui-icon{width:19px;height:19px}.menu-toggle .ui-icon,.notification-menu summary .ui-icon{width:22px;height:22px}.chat-tool-button .ui-icon{width:20px;height:20px}.chat-message-actions .ui-icon{width:15px;height:15px}.chat-document .ui-icon{width:20px;height:20px}.user-avatar-preview>.ui-icon{width:34px;height:34px}
.bubble small.chat-message-meta{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.bubble small.chat-message-meta span+span:before{content:"·";margin-right:8px;color:#8b9894}
.bubble small.chat-message-meta b{color:#38564e;font-weight:750}
.chat-whisper-toggle{width:auto;min-width:68px;padding:0 10px;font-size:11px;font-weight:800;color:#805600;background:#fffaf0;border-color:#e6c873}
.chat-whisper-toggle.active{color:#fff;background:#ad7200;border-color:#ad7200}
.chat-form.whisper-mode{background:#fff9e8;border-top-color:#e5c36b}
.chat-form.whisper-mode textarea{border-color:#d8aa35;background:#fffdf7}
.bubble.whisper{align-self:center;width:min(82%,680px);max-width:82%;background:#fff4c7;border:1px solid #e4c25d;color:#614600;box-shadow:0 2px 8px rgba(125,85,0,.1)}
.chat-whisper-label{margin-bottom:6px;font-size:10px;font-weight:850;letter-spacing:.45px;text-transform:uppercase;color:#946200}
.bubble.whisper small.chat-message-meta b{color:#6f4d00}
@media(max-width:520px){.bubble.whisper{width:94%;max-width:94%}}
.chat-form[data-service-window="closed"] .chat-tool-button:not(.chat-whisper-toggle){display:none}
.whisper-window-alert{margin:14px 14px 10px!important;border-radius:10px}
.whisper-window-alert+.chat-form{padding-top:17px;border-top:1px solid #ead8a7}
.chat-form .chat-whisper-toggle{height:48px;min-height:48px;align-self:flex-end}
.chat-form textarea,.chat-form>.btn{height:48px;min-height:48px}
.chat-form .chat-compose-tools{align-items:flex-end}
.chat-form{align-items:center}
.chat-form .chat-compose-tools{height:48px;min-height:48px;align-items:center}
.chat-form .chat-whisper-toggle,.chat-form textarea,.chat-form>.btn{height:48px;min-height:48px;max-height:48px;margin-top:0;margin-bottom:0;align-self:center}
/* WhatsApp shared contact/vCard display — preserve existing chat layout. */
.shared-contact-list{display:grid;gap:9px;min-width:0;max-width:100%}
.shared-contact-card{display:flex;flex-direction:column;align-items:flex-start;gap:6px;min-width:0;padding:12px 14px;border:1px solid rgba(17,89,77,.16);border-radius:12px;background:#f6fbf9;color:#183f36}
.shared-contact-card strong{font-size:14px;line-height:1.35;overflow-wrap:anywhere}
.shared-contact-card small{font-size:11px;line-height:1.4;overflow-wrap:anywhere}
.shared-contact-type{font-size:10px!important;font-weight:800;letter-spacing:.09em;color:#3a7768}
.shared-contact-phone{display:block;font-size:13px;font-weight:650;color:#116a58;overflow-wrap:anywhere;text-decoration:none}
a.shared-contact-phone:hover{text-decoration:underline}
@media(max-width:520px){.shared-contact-card{padding:11px 12px}.shared-contact-list{width:100%}}

/* Structured WhatsApp messages: location, replies, reactions, system and order. */
.wa-rich-card{display:flex;flex-direction:column;align-items:flex-start;gap:7px;max-width:100%;min-width:0;padding:12px 14px;background:#f6fbf9;border:1px solid rgba(17,89,77,.16);border-radius:12px;color:#183f36;overflow-wrap:anywhere}
.wa-rich-card strong{font-size:14px;line-height:1.4;font-weight:750}
.wa-rich-card span{font-size:13px;line-height:1.4}
.wa-rich-card small{font-size:11px;line-height:1.45}
.wa-rich-type{font-weight:800;letter-spacing:.08em;font-size:10px!important;color:#3a7768}
.wa-rich-coordinate{font-variant-numeric:tabular-nums;color:#647c74}
.wa-rich-action{display:inline-flex;align-items:center;max-width:100%;border-radius:8px;padding:7px 10px;background:#e4f4eb;color:#0b665a;font-size:12px;font-weight:750;text-decoration:none}
.wa-rich-action:hover{text-decoration:underline}
.wa-rich-notice{background:#faf9f4;border-color:#e8e1cf;color:#625438}
@media(max-width:520px){.wa-rich-card{padding:11px 12px}.wa-rich-action{font-size:11px}}

/* Inbox: precisely fill the available viewport below the 92px topbar.
   Keep the message list scrollable without extending the page itself. */
.page:has(> .chat-layout){
  display:flex;
  flex-direction:column;
  height:calc(100vh - 92px);
  height:calc(100dvh - 92px);
  min-height:0;
  max-height:calc(100dvh - 92px);
  overflow:hidden;
  padding-bottom:16px;
}
.page:has(> .chat-layout) > .chat-layout{
  flex:1 1 0;
  height:100%!important;
  min-height:0!important;
  max-height:100%!important;
  min-width:0;
  grid-template-rows:minmax(0,1fr);
  overflow:hidden;
}
.page:has(> .chat-layout) .chat-list{
  height:100%;
  min-height:0;
  max-height:100%;
  overflow-y:auto;
}
.page:has(> .chat-layout) .chat-panel{
  height:100%;
  min-height:0;
  max-height:100%;
  overflow:hidden;
}
.page:has(> .chat-layout) .messages{
  flex:1 1 0;
  min-height:0;
  overflow-y:auto;
}
.page:has(> .chat-layout) .chat-panel > .chat-header,
.page:has(> .chat-layout) .chat-panel > .whisper-window-alert,
.page:has(> .chat-layout) .chat-panel > .chat-form{flex-shrink:0}
/* The native Inbox back link is mobile-only; desktop remains two panes. */
.inbox-mobile-back{display:none!important}
/* Mobile inbox: list view OR conversation view, never both stacked.
   A flex-bounded page avoids guessing the real topbar height. */
@media(max-width:800px){
  .page:has(> .chat-layout) .chat-header{position:relative;display:flex;flex-direction:column;align-items:flex-start;gap:9px;padding:14px 62px 14px 14px;min-width:0}
  .page:has(> .chat-layout) .chat-header .inbox-mobile-back{display:inline-flex!important;position:absolute;top:12px;right:12px;align-items:center;justify-content:center;width:40px;height:40px;min-width:40px;min-height:40px;flex:0 0 40px;padding:0;margin:0;border-radius:10px;font-size:0;line-height:1}
  .page:has(> .chat-layout) .chat-header .inbox-mobile-back svg{display:block;width:20px;height:20px;flex-shrink:0}
  .page:has(> .chat-layout) .chat-header>.help,.page:has(> .chat-layout) .chat-header>.inbox-contact-meta,.page:has(> .chat-layout) .chat-header>.inbox-mobile-meta{width:100%;max-width:100%;min-width:0}
  .main:has(.page > .chat-layout){
    display:flex;
    flex-direction:column;
    height:100vh;
    height:100dvh;
    min-height:0;
    overflow:hidden;
  }
  .main:has(.page > .chat-layout) > .topbar{flex:0 0 auto}
  .main .page:has(> .chat-layout){
    flex:1 1 0;
    height:auto;
    max-height:none;
    min-height:0;
    padding-bottom:12px;
    overflow:hidden;
  }
  .page:has(> .chat-layout) > .chat-layout{
    flex:1 1 0;
    width:100%;
    max-width:100%;
    min-width:0;
    height:100%!important;
    max-height:100%!important;
    min-height:0!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:minmax(0,1fr)!important;
    overflow:hidden;
  }
  .page:has(> .chat-layout) .chat-list{
    height:100%;
    min-height:0;
    max-height:none;
    min-width:0;
    overflow-y:auto;
    overflow-x:hidden;
    border-right:0;
    border-bottom:0;
    overscroll-behavior:contain;
  }
  .page:has(> .chat-layout) .chat-panel{
    display:none!important;
    min-width:0;
  }
  .page:has(> .chat-layout) .chat-layout:has(.chat-header) .chat-list{
    display:none!important;
  }
  .page:has(> .chat-layout) .chat-layout:has(.chat-header) .chat-panel{
    display:flex!important;
    flex-direction:column;
    width:100%;
    height:100%;
    min-height:0;
    min-width:0;
  }
  .page:has(> .chat-layout) .chat-item,
  .page:has(> .chat-layout) .inbox-list-filter{
    max-width:100%;
    min-width:0;
    overflow-wrap:anywhere;
  }
  .page:has(> .chat-layout) .chat-item small{
    max-width:100%;
    overflow-wrap:anywhere;
  }
  .page:has(> .chat-layout) .messages,
  .page:has(> .chat-layout) .chat-form{
    min-width:0;
  }
}
@media(max-width:480px){
  .main .page:has(> .chat-layout){padding:12px}
  .page:has(> .chat-layout) > .chat-layout{border-radius:12px}
}

