.chat-dock {
  --chat-accent: var(--brand-primary, #2646bf);
  position: fixed;
  z-index: 75;
  inset-inline-end: 24px;
  bottom: 14px;
  width: min(405px, calc(100vw - 48px));
  max-height: min(620px, calc(100dvh - 96px));
  display: flex;
  flex-direction: column;
  color: #18294a;
  background: #fff;
  border: 1px solid #dbe3f2;
  border-radius: 20px;
  box-shadow: 0 18px 56px #152b5a38, 0 3px 12px #152b5a1a;
}
.chat-dock-top { display: flex; align-items: center; gap: 5px; padding: 9px 12px; background: #eef2ff; border-radius: 19px 19px 0 0; }
.chat-dock-top h2 { flex: 1; margin: 0 4px 0 0; font-size: 16px; font-weight: 700; }
.chat-dock button, .chat-redesign button, .chat-inbox button { cursor: pointer; }
.chat-dock button:disabled, .chat-redesign button:disabled { cursor: default; }
.chat-dock-top button, .chat-dock-back, .chat-emoji-button, .chat-emoji-picker button, .chat-reactions button {
  color: #2646bf; border: 0; border-radius: 9px; background: transparent;
}
.chat-dock-top button { min-width: 32px; min-height: 32px; font-size: 19px; }
.chat-dock-top button:hover, .chat-dock-back:hover, .chat-emoji-picker button:hover, .chat-reactions button:hover { background: #e2e9ff; }
.chat-dock-content { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.chat-dock-minimised .chat-dock-content { display: none; }
.chat-dock-minimised .chat-dock-top { border-radius: 19px; }
.chat-dock-back { margin: 6px 12px; padding: 4px 6px; font-size: 12px; }
.chat-inbox { padding: 14px; }
.chat-inbox-tools { display: flex; align-items: stretch; gap: 9px; flex-wrap: wrap; }
.chat-inbox-tools input { flex: 1 1 175px; min-height: 38px; border: 1px solid #cbd7ef; border-radius: 9px; padding: 7px 10px; }
.chat-inbox-tools input[hidden], .chat-emoji-picker[hidden] { display: none; }
.chat-primary { background: #2646bf; color: #fff; border: 0; border-radius: 9px; padding: 8px 12px; font-weight: 700; }
.chat-inbox-status { margin: 9px 0; font-size: 13px; color: #53627f; }
.chat-inbox-status:empty { display: none; }
.chat-inbox-results { display: grid; gap: 4px; margin-top: 8px; }
.chat-inbox-row { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 11px; background: transparent; text-align: start; padding: 8px; color: #18294a; }
.chat-inbox-row:hover, .chat-inbox-row:focus-visible { background: #eef2ff; }
.chat-inbox-row-shell { display: flex; align-items: center; gap: 3px; min-width: 0; }
.chat-inbox-row-shell .chat-inbox-row { flex: 1; min-width: 0; }
.chat-inbox-delete, .bs-chat-delete { display: grid; place-items: center; flex: 0 0 36px; width: 36px; min-width: 36px; min-height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #6b7890; cursor: pointer; font-size: 20px; }
.chat-inbox-delete:hover, .bs-chat-delete:hover { background: #f7e9e9; color: #9f3144; }
.bs-inbox-row .bs-chat-delete { flex: 0 0 36px; width: 36px; min-width: 36px; padding: 0; text-align: center; }
.chat-dock-avatar { width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto; overflow: hidden; display: grid; place-items: center; background: #e7edff; color: #2646bf; font-weight: 700; }
.chat-dock-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-inbox-detail { min-width: 0; flex: 1; display: grid; gap: 2px; }
.chat-inbox-detail small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #53627f; }
.chat-unread { background: #2646bf; color: #fff; border-radius: 999px; padding: 3px 7px; font-size: 12px; }
.chat-dock-conversation .bs-chat { border: 0; margin: 0; border-radius: 0 0 19px 19px; height: auto; min-height: 0; }
.chat-dock-conversation .bs-chat-header { min-height: 0; padding: 8px 12px; }
.bs-chat-header { display: flex; align-items: center; gap: 10px; }
.bs-chat-header .bs-chat-contact { display: grid; min-width: 0; flex: 1; gap: 2px; }
.bs-chat-header .bs-chat-contact strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bs-chat-header .bs-chat-contact small { color: #53627f; }
.bs-chat-header .bs-chat-return { flex: 0 0 auto; white-space: nowrap; min-height: 42px; padding: 7px 10px; }
#conversation-content.chat-redesign .bs-chat-header .bs-chat-return { display: grid; place-items: center; flex: 0 0 36px; width: 36px; min-width: 36px; min-height: 36px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1; }
.chat-dock-conversation .bs-chat-history { min-height: 72px; height: clamp(110px, 28dvh, 285px); overscroll-behavior: contain; padding: 9px 12px; }
.chat-dock-conversation .bs-chat-compose { padding: 8px 12px; }
.chat-dock-conversation .bs-chat-compose textarea { min-height: 43px; max-height: 90px; }
.chat-dock-conversation .bs-chat-status { margin: 0 12px; font-size: 12px; }
.chat-redesign .bs-chat-compose { position: relative; }
.chat-redesign .bs-chat-line p { border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-redesign .bs-chat-line.mine { background: #2748bd; color: #fff; }
.chat-redesign .bs-chat-line.mine small { color: #fff; }
.chat-redesign .bs-chat-line[data-moderated] { background: #f1f4f9; color: #4e5b73; }
.chat-redesign .bs-chat-line[data-moderated] small { color: #4e5b73; }
.chat-emoji-button { min-width: 35px; min-height: 35px; font-size: 20px; }
.chat-emoji-picker { z-index: 2; position: absolute; inset-inline-start: 10px; bottom: calc(100% + 4px); width: min(255px, calc(100% - 20px)); display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 7px; border: 1px solid #dbe3f2; border-radius: 12px; background: #fff; box-shadow: 0 6px 22px #152b5a30; }
.chat-emoji-picker button { min-height: 33px; font-size: 18px; }
.chat-reactions { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 3px; }
.chat-reactions button { padding: 3px 5px; font-size: 13px; }
.chat-reactions button[hidden] { display: none; }
.bs-chat-line.mine .chat-reactions button { color: inherit; }
.bs-chat-line.mine .chat-reactions button:hover, .bs-chat-line.mine .chat-reactions button[aria-pressed="true"] { background: #ffffff38; }
.chat-reactions button[aria-pressed="true"] { background: #e2e9ff; outline: 1px solid #7893ea; }
@media (max-width: 860px) {
  .chat-dock { display: none; }
  .chat-redesign .bs-chat { margin-inline: 0; }
  .chat-inbox { padding: 10px 3px; }
  .chat-inbox-tools input { flex-basis: 100%; }
}
.chat-dock:not(.chat-dock-minimised):has(.chat-dock-conversation) { height: min(520px, calc(100dvh - 96px)); }
.chat-dock-content:has(.chat-dock-conversation) { display: flex; flex-direction: column; flex: 1; }
.chat-dock-minimised .chat-dock-content:has(.chat-dock-conversation) { display: none; }
.chat-dock-back { align-self: flex-start; flex-shrink: 0; }
.chat-dock-conversation { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-dock-conversation .bs-chat { flex: 1; min-height: 0; }
.chat-dock-conversation .bs-chat-history { flex: 1; height: auto; min-height: 36px; }
.chat-dock-conversation .bs-chat-preview img { max-width: 52px; max-height: 52px; }

@media (max-width: 860px) {
  #conversation-content.chat-redesign .bs-chat { height: max(242px, calc(100dvh - 214px)); min-height: 0; }
  #conversation-content.chat-redesign .bs-chat-history { flex: 1; min-height: 48px; }
  #conversation-content.chat-redesign .bs-chat-compose { padding: 10px 12px; gap: 7px; }
  #conversation-content.chat-redesign .bs-chat-compose textarea { min-height: 48px; max-height: 80px; }
  #conversation-content.chat-redesign .bs-chat-preview img { max-width: 52px; max-height: 52px; }
  #conversation-content.chat-redesign .bs-chat-header { gap: 8px; }
  #conversation-content.chat-redesign .bs-chat-header .bs-chat-avatar { flex-basis: 38px; width: 38px; height: 38px; }
  #conversation-content.chat-redesign .bs-chat-header .bs-chat-return { flex-basis: 34px; width: 34px; min-width: 34px; min-height: 34px; }
}

/* Full-page mobile conversation. The desktop dock has its own layout above. */
@media (max-width: 860px) {
  html[data-site-theme="v2"] .app-layout:has(#conversation-content.chat-redesign .bs-chat) > .left-sidebar { display: none !important; }
  #conversation-content.chat-redesign .bs-chat-header { min-height: 0; padding: 9px 12px; }
  #conversation-content.chat-redesign .bs-chat-older:disabled {
    margin-block: 6px 2px;
    padding: 3px 8px;
    border: 0;
    background: transparent;
    font-size: 12px;
  }
  /* Keep pagination in normal flow so it never sits on top of a message. */
  #conversation-content.chat-redesign .bs-chat-older:not([hidden]) {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    align-self: center;
    flex: 0 0 auto;
    z-index: auto;
    margin: 8px auto 12px !important;
    line-height: 1.35;
  }
  #conversation-content.chat-redesign .bs-chat-history {
    position: relative;
    flex: 1 1 0%;
    min-height: 48px;
    scroll-padding-block: 12px;
  }
  #conversation-content.chat-redesign .bs-chat-status:empty { display: none; }
  #conversation-content.chat-redesign .bs-chat-history { padding: 10px 12px; overscroll-behavior: contain; }
  #conversation-content.chat-redesign .bs-chat-line { padding: 7px 9px; }
  #conversation-content.chat-redesign .bs-chat-compose {
    grid-template-columns: minmax(0, 1fr) 44px 44px auto;
    align-items: end;
    gap: 5px;
    padding: 8px;
  }
  #conversation-content.chat-redesign .bs-chat-text { grid-column: 1; grid-row: 2; font-size: 0; gap: 0; min-width: 0; }
  #conversation-content.chat-redesign .bs-chat-compose textarea {
    width: 100%;
    min-height: 44px;
    height: 44px;
    max-height: 92px;
    padding: 10px;
    resize: vertical;
    font-size: 16px;
    line-height: 22px;
  }
  #conversation-content.chat-redesign .bs-chat-compose-actions { display: contents; }
  #conversation-content.chat-redesign .bs-chat-compose-actions > * {
    grid-row: 2;
    min-width: 44px;
    min-height: 44px;
    padding: 0 6px;
  }
  #conversation-content.chat-redesign .chat-emoji-button { grid-column: 2; }
  #conversation-content.chat-redesign .bs-chat-attach {
    grid-column: 3;
    display: grid;
    place-items: center;
    font-size: 0;
  }
  #conversation-content.chat-redesign .bs-chat-attach::before {
    content: '';
    width: 20px;
    height: 20px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='3'/%3E%3Ccircle cx='9' cy='9' r='1.3'/%3E%3Cpath d='m4 17 5-5 4 3 3-4 4 5'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  #conversation-content.chat-redesign .bs-chat-attach:focus-within { outline: 2px solid currentColor; outline-offset: 2px; }
  #conversation-content.chat-redesign .bs-chat-compose-actions > button[type='submit'] { grid-column: 4; }
  #conversation-content.chat-redesign .bs-chat-compose > .bs-chat-preview { grid-column: 1 / -1; grid-row: 1; }
  #conversation-content.chat-redesign .bs-chat-compose > progress { grid-column: 1 / -1; width: 100%; }
}

/* Some theme buttons set their own display value; preserve the hidden state. */
.bs-chat [hidden] { display: none !important; }

/* Message options live beside the bubble in both Messenger views. */
.chat-redesign .bs-chat-line {
  --chat-menu-size: 32px;
  position: relative;
  max-width: min(82%, calc(100% - var(--chat-menu-size) - 4px));
  margin-inline-end: calc(var(--chat-menu-size) + 4px);
}
.chat-redesign .bs-chat-line.mine {
  margin-inline-start: calc(var(--chat-menu-size) + 4px);
  margin-inline-end: 0;
}
.chat-redesign .bs-chat-line > small { flex-wrap: wrap; margin-top: 3px; }
.chat-redesign .bs-chat-line > .chat-reactions { margin-top: 1px; }
.chat-redesign .bs-chat-line > .bs-report-options {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: calc(100% + 4px);
  transform: translateY(-50%);
  margin: 0;
}
.chat-redesign .bs-chat-line.mine > .bs-report-options {
  inset-inline-start: auto;
  inset-inline-end: calc(100% + 4px);
}
.chat-redesign .bs-chat-line > .bs-report-options > summary {
  width: var(--chat-menu-size);
  min-width: var(--chat-menu-size);
  min-height: var(--chat-menu-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #415475;
}
.chat-redesign .bs-chat-line > .bs-report-options > summary:hover,
.chat-redesign .bs-chat-line > .bs-report-options[open] > summary {
  background: #e8edf7;
}
.chat-redesign .bs-chat-line > .bs-report-options[open] > button {
  position: absolute;
  inset: auto;
  inset-block-start: 50%;
  inset-inline-end: calc(100% + 3px);
  transform: translateY(-50%);
  margin: 0;
  width: max-content;
  min-height: 40px;
  padding: 8px 12px;
  line-height: 1.2;
  white-space: nowrap;
}
.chat-redesign .bs-chat-line.mine > .bs-report-options[open] > button {
  inset-inline-end: auto;
  inset-inline-start: calc(100% + 3px);
}
@media (hover: hover) and (pointer: fine) and (min-width: 861px) {
  .chat-redesign .bs-chat-line:not(:hover):not(:focus-within) > .bs-report-options:not([open]) { opacity: 0; }
}
@media (max-width: 860px), (pointer: coarse) {
  .chat-redesign .bs-chat-line { --chat-menu-size: 44px; }
}

/* Keep message content, delivery information and controls separate. */
.chat-redesign .bs-chat-line:has(> .bs-chat-main),
#conversation-content.chat-redesign .bs-chat-line:has(> .bs-chat-main) {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  margin-inline: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #18294a;
}
.chat-redesign .bs-chat-line.mine:has(> .bs-chat-main),
#conversation-content.chat-redesign .bs-chat-line.mine:has(> .bs-chat-main) { align-items: flex-end; }
.bs-chat-main { display: flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; }
.bs-chat-line.mine > .bs-chat-main { flex-direction: row-reverse; }
.bs-chat-bubble { min-width: 0; padding: 7px 10px; border-radius: 15px; background: #edf1f8; overflow-wrap: anywhere; }
.bs-chat-line.mine .bs-chat-bubble { background: #2748bd; color: #fff; }
.bs-chat-line[data-moderated] .bs-chat-bubble { background: #f1f4f9; color: #4e5b73; }
.chat-redesign .bs-chat-bubble > p { margin: 0; padding: 0; color: inherit; }
.bs-chat-tools { display: flex; align-items: center; flex: none; }
.bs-chat-line.mine .bs-chat-tools { flex-direction: row-reverse; }
.bs-chat-tools > .bs-report-options { margin: 0; }
.bs-chat-tools > .chat-reaction-trigger,
.bs-chat-tools > .bs-report-options > summary {
  display: grid;
  place-items: center;
  width: var(--chat-menu-size);
  min-width: var(--chat-menu-size);
  min-height: var(--chat-menu-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #415475;
  cursor: pointer;
  font-size: 16px;
}
.bs-chat-tools > .chat-reaction-trigger:hover,
.bs-chat-tools > .chat-reaction-trigger[aria-expanded='true'],
.bs-chat-tools > .bs-report-options > summary:hover,
.bs-chat-tools > .bs-report-options[open] > summary { background: #e8edf7; }
.bs-chat-tools > .bs-report-options[open] > button {
  position: absolute;
  inset: auto;
  inset-block-start: 50%;
  inset-inline-start: 0;
  transform: translateY(-50%);
  z-index: 30;
  width: max-content;
  min-height: 40px;
  margin: 0;
  padding: 8px 12px;
  white-space: nowrap;
}
.bs-chat-line.mine .bs-chat-tools > .bs-report-options[open] > button { inset-inline-start: auto; inset-inline-end: 0; }
.chat-redesign .bs-chat-line > .bs-chat-meta,
.chat-redesign .bs-chat-line.mine > .bs-chat-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 6px;
  margin: 2px 4px 0;
  color: #526381;
  font-size: 11px;
  line-height: 1.35;
}
.bs-chat-meta .bs-chat-receipt { color: inherit; }
.chat-reaction-badges { display: flex; flex-wrap: wrap; gap: 3px; margin: 3px 4px 0; }
.chat-reaction-badge { padding: 1px 5px; border-radius: 12px; background: #edf1f8; font-size: 11px; }
.chat-reaction-popover {
  position: fixed;
  z-index: 110;
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
  width: min(250px, calc(100vw - 16px));
  gap: 2px;
  padding: 4px;
  border: 1px solid #dbe3f2;
  border-radius: 24px;
  background: white;
  box-shadow: 0 6px 22px #152b5a30;
}
.chat-reaction-popover[hidden], .chat-reaction-badges[hidden] { display: none; }
.chat-reaction-popover > button {
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}
.chat-reaction-popover > button:hover,
.chat-reaction-popover > button[aria-pressed='true'] { background: #e2e9ff; }
@media (hover: hover) and (pointer: fine) and (min-width: 861px) {
  .bs-chat-line:not(:hover):not(:focus-within) .bs-chat-tools:not(:has([open], [aria-expanded='true'])) { opacity: 0; }
}




.chat-dock-conversation .bs-chat-header .bs-chat-return { display: none; }

/* Keep chat actions discoverable on desktop, touch screens and Android WebView. */
.chat-redesign .bs-chat-line .bs-chat-tools,
.chat-redesign .bs-chat-line > .bs-report-options {
  opacity: 1 !important;
  visibility: visible !important;
}
.chat-redesign .bs-chat-tools > .chat-reaction-trigger,
.chat-redesign .bs-chat-tools > .bs-report-options > summary,
.chat-emoji-button {
  opacity: 1 !important;
  visibility: visible !important;
}
.chat-emoji-button { display: inline-grid !important; place-items: center; flex: 0 0 40px; width: 40px; min-width: 40px; min-height: 40px; padding: 0; font-size: 20px; }
