/* Shared inbox layout for Messages and Email. Viewport and keyboard insets live in mobile-shell.css. */
#ig-inbox-root {
  --inbox-ink: #3c2735;
  --inbox-muted: #745c6a;
  --inbox-line: #eadce4;
  --inbox-tint: #f9eef4;
  --inbox-accent: #863c65;
}
body #ig-inbox-root .bm-messages-header { gap: 12px; margin-bottom: 16px; min-height: 44px; }
body #ig-inbox-root .bm-messages-header > div { flex: 1; min-width: 0; }
body #ig-inbox-root .bm-messages-header h1 { font-size: 1.875rem; line-height: 1.15; color: var(--inbox-ink); }
body #ig-inbox-root .bm-inbox-back,
body #ig-inbox-root .bm-inbox-settings {
  display: grid;
  place-items: center;
  margin: 0;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid var(--inbox-line);
  border-radius: 14px;
  background: #fffafd;
  color: var(--inbox-accent);
}
body #ig-inbox-root .bm-inbox-settings svg { width: 21px; height: 21px; }
body #ig-inbox-root.is-conversation .bm-inbox-back,
body #ig-inbox-root #ig-status-bar[hidden],
body #ig-inbox-root #ig-inbox-error:empty,
#ig-inbox-root .ig-reply-note:empty,
#ig-inbox-root .chat .ig-error:empty { display: none; }

#ig-inbox-root .ig-messages {
  grid-template-columns: minmax(19rem, 32%) minmax(0, 1fr);
  border-color: var(--inbox-line);
  box-shadow: 0 12px 36px #57244207;
}
#ig-inbox-root .bm-thread-tools {
  padding: 13px 12px 9px;
  background: #fff;
  border-color: var(--inbox-line);
}
.bm-inbox-search-row { display: flex; align-items: stretch; gap: 7px; margin-bottom: 9px; }
body #ig-inbox-root .bm-inbox-search-row .search {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 8px 9px;
  border: 1px solid var(--inbox-line);
  border-radius: 12px;
  background: #fbf7fa;
}
#ig-inbox-root .bm-inbox-search-row .search input { min-width: 0; }
.bm-channel-picker { position: relative; display: flex; min-width: 0; }
.bm-channel-picker select {
  width: 100%;
  min-height: 44px;
  appearance: none;
  padding: 7px 23px 7px 9px;
  border: 1px solid var(--inbox-line);
  border-radius: 12px;
  background: #fff;
  color: var(--inbox-ink);
  font-size: 1rem;
}
.bm-channel-picker::after {
  content: '';
  position: absolute;
  top: calc(50% - 4px);
  right: 10px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--inbox-accent);
  border-bottom: 1.5px solid var(--inbox-accent);
  transform: rotate(45deg);
  pointer-events: none;
}
#ig-inbox-root .ig-inbox-tabs { gap: 5px; padding: 0; }
#ig-inbox-root .ig-inbox-tabs > button { min-height: 44px; padding: 6px 10px; border-radius: 9px; color: var(--inbox-muted); }
#ig-inbox-root .ig-inbox-tabs > button.selected { background: #f7e4ef; color: #642745; font-weight: 700; }
#ig-inbox-root .ig-inbox-tabs .ig-count-badge { min-width: 20px; height: 20px; padding: 0 4px; font-size: .75rem; }
#ig-inbox-root #ig-thread-list { padding: 4px 6px; }
body #ig-inbox-root .ig-thread {
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 10px 9px;
  margin: 0;
  border-radius: 11px;
  text-align: left;
}
#ig-inbox-root .ig-thread.active { background: #f8e7f1; border-color: #edd6e5; }
#ig-inbox-root .ig-thread.is-unread:not(.active) { background: #fcf5fa; }
#ig-inbox-root .bm-thread-avatar {
  position: relative;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
}
#ig-inbox-root .bm-thread-avatar .avatar {
  width: 42px;
  height: 42px;
  margin: 0;
  background: #f0dae7;
  color: #703556;
  font-size: .875rem;
  font-weight: 700;
}
.bm-platform-mark {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: white;
  background: #835a74;
}
.bm-platform-mark svg { width: 15px; height: 15px; display: block; }
#ig-inbox-root .bm-thread-avatar > .bm-platform-mark {
  position: absolute;
  right: -3px;
  bottom: -2px;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
}
#ig-inbox-root .bm-thread-avatar > .bm-platform-mark svg { width: 13px; height: 13px; }
#ig-inbox-root .ig-thread .thread-copy { gap: 2px; min-width: 0; }
#ig-inbox-root .ig-thread .bm-thread-line strong { color: var(--inbox-ink); font-size: 1rem; line-height: 1.3; }
#ig-inbox-root .bm-thread-line time { color: var(--inbox-muted); font-size: .8125rem; }
#ig-inbox-root .ig-thread .bm-thread-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--inbox-muted);
}
#ig-inbox-root .ig-thread.is-unread .bm-thread-preview { color: #574052; }
#ig-inbox-root .ig-thread .bm-thread-meta { flex-wrap: nowrap; min-height: 21px; gap: 6px; line-height: 1.25; }
#ig-inbox-root .bm-thread-service,
#ig-inbox-root .bm-thread-state { font-size: .8125rem; }
#ig-inbox-root .bm-thread-state {
  padding: 2px 6px;
  border-radius: 6px;
  background: #ffedf0;
  color: #8e435c;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ig-inbox-root .bm-thread-meta > .ig-count-badge { min-width: 20px; height: 20px; font-size: .75rem; }
#ig-inbox-root .ig-list-empty { color: var(--inbox-muted); }

#ig-inbox-root .chat-head {
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--inbox-line);
  background: #fff;
  color: var(--inbox-ink);
}
#ig-inbox-root .chat-head h2 { overflow-wrap: anywhere; margin: 0; line-height: 1.25; }
#ig-inbox-root .chat-head p { margin: 0; color: var(--inbox-muted); }
#ig-inbox-root .bm-chat-channel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 5px;
  margin-top: 3px;
  color: var(--inbox-muted);
  font-size: .8125rem;
  line-height: 1.35;
}
#ig-inbox-root .bm-chat-channel .bm-platform-mark { width: 15px; height: 15px; background: transparent; }
#ig-inbox-root .bm-chat-channel svg { width: 14px; height: 14px; }
#ig-inbox-root .bm-chat-channel-detail { overflow-wrap: anywhere; }
#ig-inbox-root .bm-chat-channel-detail::before { content: '·'; margin-right: 5px; }
#ig-inbox-root .chat-head .chat-back { color: var(--inbox-accent); align-items: center; justify-content: center; }
#ig-inbox-root .chat-head .btn { min-height: 44px; max-width: 10rem; border-radius: 11px; padding: 7px 11px; font-size: .875rem; line-height: 1.25; text-align: center; }
#ig-inbox-root #ig-takeover { color: var(--inbox-accent); }
#ig-inbox-root :is(.bm-transcript, .bm-email-history) { overflow-anchor: none; }
#ig-inbox-root .bm-transcript {
  display: flex;
  flex: 1 1 0%;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  gap: 0;
  padding: 14px clamp(14px, 3vw, 30px) 16px;
  overflow-y: auto;
  background: #f8f2f7;
}
.bm-chat-day { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px 0 3px; color: #745c6a; font-size: .8125rem; font-weight: 650; }
.bm-chat-day::before, .bm-chat-day::after { content: ''; flex: 1; height: 1px; background: #e7d9e3; }
.bm-transcript-empty { margin: auto; color: var(--inbox-muted); }
.bm-message-line { display: flex; flex-direction: column; align-items: flex-start; flex: 0 0 auto; gap: 3px; margin-top: 12px; }
.bm-message-line.is-grouped { margin-top: 4px; }
.bm-message-line.outgoing,
.bm-message-line.assistant { align-items: flex-end; }
.bm-message-author { margin-inline: 5px; color: var(--inbox-muted); font-size: .75rem; font-weight: 600; }
.bm-message-bubble {
  max-width: min(87%, 38rem);
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid #ebdfe7;
  border-radius: 15px 15px 15px 5px;
  color: var(--inbox-ink);
  background: #fff;
}
.bm-message-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.52; }
.bm-message-line.outgoing .bm-message-bubble,
.bm-message-line.assistant .bm-message-bubble { border-radius: 15px 15px 5px 15px; }
.bm-message-line.outgoing .bm-message-bubble { border-color: #edcbdc; background: #f5ddea; }
.bm-message-line.assistant .bm-message-bubble { border-color: #edcede; background: #fae6f0; color: var(--inbox-ink); }
.bm-message-time { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-inline: 5px; color: #745c6a; font-size: .75rem; }
.bm-bubble-status { color: #893751; font-size: .8125rem; font-weight: 650; }
#ig-inbox-root .ig-reply-note { padding: 8px 16px 0; color: var(--inbox-muted); }
#ig-inbox-root .chat .ig-error { flex: 0 0 auto; margin: 0; padding: 4px 16px; }
#ig-inbox-root .ig-compose { padding: 9px 14px 8px; align-items: flex-end; gap: 8px; background: #fff; }
#ig-inbox-root .ig-compose textarea {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  height: 48px;
  padding: 10px 13px;
  border: 1px solid #e9d7e3;
  border-radius: 13px;
  background: #fbf7fa;
  color: var(--inbox-ink);
}
body #ig-inbox-root .ig-compose .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  height: 48px;
  min-width: 48px;
  padding: 7px 12px;
  border-radius: 12px;
  line-height: 1.2;
  color: #fff;
  background: #863c65;
}
body #ig-inbox-root .ig-compose .btn:disabled { color: #806076; background: #f1e4ed; }
.bm-send-icon { display: block; width: 19px; height: 19px; flex: 0 0 19px; }
#ig-inbox-root .bm-chat-composer {
  min-width: 0;
  align-items: flex-end;
  gap: 8px;
  padding-block: 9px;
  border-top: 1px solid var(--inbox-line);
}
#ig-inbox-root .bm-chat-composer textarea {
  min-height: 44px;
  height: 44px;
  padding: 10px 13px;
  border-radius: 18px;
}
#ig-inbox-root .bm-chat-composer textarea::placeholder { color: var(--inbox-muted); opacity: 1; }
#ig-inbox-root .bm-chat-actions-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--inbox-line);
  border-radius: 14px;
  background: #fff;
  color: var(--inbox-accent);
  cursor: pointer;
}
#ig-inbox-root .bm-chat-actions-toggle svg { width: 20px; height: 20px; }
#ig-inbox-root .bm-chat-actions-toggle:disabled { opacity: .55; }
body #ig-inbox-root .bm-chat-composer .btn {
  min-height: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 14px;
}
body #ig-inbox-root:not(.bm-email-workspace) .bm-chat-composer .btn:has(.bm-send-icon) {
  flex: 0 0 44px;
  padding: 0;
}
#ig-inbox-root:not(.bm-email-workspace) .bm-chat-composer .btn .bm-send-icon + span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body .bm-chat-actions-modal {
  max-width: min(360px, 100%);
}
.bm-chat-actions-modal .bm-modal-back { display: none; }
.bm-chat-actions-modal .modal-body { padding-block: 6px 14px; }
.bm-chat-actions-list section {
  display: grid;
  gap: 6px;
}
.bm-chat-actions-list section + section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #efdee6;
}
.bm-chat-actions-list button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--bm-action-line, #dbc2d0);
  border-radius: 10px;
  background: var(--bm-action-bg, #fff8fb);
  color: #503446;
  text-align: left;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}
.bm-chat-actions-list button:not(:disabled):is(:hover,:focus-visible) { background: #f9eaf2; border-color: #bb8ca7; }
.bm-chat-actions-list button:disabled { background: #f8f3f6; border-color: #e9dce3; color: #897681; cursor: default; }
@media (max-width: 760px) {
  body .bm-chat-actions-modal { max-width: 100%; }
}
#ig-inbox-root .bm-email-history { background: #f8f3f7; }
#ig-inbox-root .bm-email-message {
  border: 1px solid var(--inbox-line);
  border-radius: 14px;
  box-shadow: 0 2px 7px #57244208;
}
#ig-inbox-root :is(button,select,textarea,input):focus-visible { outline: 2px solid #a64c79; outline-offset: -2px; }

@media (max-width: 760px), (max-width: 1180px) and (hover: none) and (pointer: coarse) {
  body.messages-workspace.keyboard-open main > header.topbar { display: none; }
  body.messages-workspace main > .content { padding-top: 10px; padding-inline: 10px; }
  body #ig-inbox-root .bm-messages-header { margin-bottom: 9px; }
  body #ig-inbox-root .bm-messages-header h1 { font-size: 1.625rem; }
  #ig-inbox-root .bm-thread-tools { padding: 9px 8px 7px; }
  #ig-inbox-root .chat-head { padding: 8px 10px; gap: 8px; }
  #ig-inbox-root .chat-head h2 { font-size: 1rem; }
  #ig-inbox-root .bm-transcript { padding: 12px 12px 17px; }
  #ig-inbox-root .bm-message-bubble { max-width: 92%; padding: 9px 11px; }
  #ig-inbox-root .ig-reply-note { padding-inline: 10px; }
  #ig-inbox-root .ig-compose { padding-inline: 9px; }
  #ig-inbox-root.is-conversation .bm-messages-header { display: none; }
}
@media (max-width: 760px) {
  #ig-inbox-root .ig-messages { box-shadow: none; }
  #ig-inbox-root:not(.bm-email-workspace) .ig-compose .btn > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #ig-inbox-root .chat-head .btn { max-width: 7rem; }
}
