/* BBBS messenger: a WeChat-PC-inspired master/detail workspace.
   Scoped to private messages; all existing APIs and composer behaviors are preserved. */
/* Keep the site's existing three-column desktop layout, including the right sidebar.
   Only the central column becomes the two-pane messenger. */
body:is([data-view="messages"],[data-view="conversation"]) #app-shell > .col-main {
  min-width: 0;
  max-width: none;
}
body:is([data-view="messages"],[data-view="conversation"]) #app-shell .dm-workspace {
  --dm-divider: #e3e0dc;
  --dm-heading: #272c36;
  --dm-muted: #92949b;
  display: grid;
  grid-template-columns: clamp(245px, 27%, 325px) minmax(0, 1fr);
  height: min(820px, calc(100dvh - 110px));
  min-height: 540px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dedbd7;
  border-radius: 13px;
  background: #f5f5f4;
  box-shadow: 0 8px 25px #2a2e3d10;
  position: relative;
  color: var(--dm-heading);
  font-size: 14px;
}
#app-shell .dm-workspace :is(button,input,textarea) { font-family: inherit; }
#app-shell .dm-workspace .dm-workspace-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: #f5f3f1;
  border-right: 1px solid var(--dm-divider);
}
#app-shell .dm-workspace .dm-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 23px 19px 13px;
}
#app-shell .dm-sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .01em;
  margin: 0;
}
#app-shell .dm-sidebar-count {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #a0a0a3;
}
#app-shell .dm-icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 7px;
  background: #e9e7e4;
  border: 0;
  border-radius: 8px;
  color: #5c5f65;
  cursor: pointer;
}
#app-shell .dm-icon-button:hover { background: #dddad7; }
#app-shell .dm-icon-button svg { width: 19px; height: 19px; }
#app-shell .dm-sidebar-search {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  margin: 0 13px 11px;
  padding: 0 10px;
  border: 1px solid #ebe8e5;
  border-radius: 8px;
  background: #eae8e6;
}
#app-shell .dm-sidebar-search svg {
  flex: none;
  width: 17px;
  height: 17px;
  color: #989a9d;
}
#app-shell .dm-sidebar-search input {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 7px 7px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: #30333b;
}
#app-shell .dm-sidebar-search:focus-within {
  border-color: #b8cdb2;
  background: #f4f5f3;
}
#app-shell .dm-sidebar-search input::placeholder { color: #a3a3a5; }
#app-shell .dm-sidebar-search input::-webkit-search-cancel-button { cursor: pointer; }
#app-shell .dm-workspace .dm-workspace-threads {
  min-height: 0;
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-top: 1px solid #eeece8;
}
#app-shell .dm-list-status {
  margin: 0;
  padding: 22px 17px;
  color: #8d8f96;
  font-size: 13px;
  line-height: 1.6;
}
#app-shell .dm-list-error,
#app-shell .dm-compose-error,
#app-shell .dm-invite-error { color: #a43d3d; }
#app-shell .dm-workspace-thread {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 80px;
  padding: 14px 15px;
  border: 0;
  border-bottom: 1px solid #eeece9;
  background: transparent;
  color: #35363b;
  text-decoration: none;
}
#app-shell .dm-workspace-thread:hover,
#app-shell .dm-workspace-thread:focus-visible {
  background: #e9e6e2;
  text-decoration: none;
}
#app-shell .dm-workspace-thread.is-active {
  background: #dedbd6;
}
#app-shell .dm-workspace-thread .dm-thread-avatar {
  flex: 0 0 46px;
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  image-rendering: pixelated;
  background: #dadfe1;
}
#app-shell .dm-thread-content {
  min-width: 0;
  flex: 1;
  display: block;
}
#app-shell .dm-thread-head,
#app-shell .dm-thread-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
#app-shell .dm-thread-head strong {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: #33353a;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#app-shell .dm-thread-head .dm-thread-time {
  flex: none;
  margin: 0;
  font-size: 11px;
  white-space: nowrap;
  color: #a1a1a3;
  font-variant-numeric: tabular-nums;
}
#app-shell .dm-thread-bottom { margin-top: 6px; }
#app-shell .dm-thread-preview {
  display: block;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 0;
  color: #99999c;
  font-size: 12px;
  line-height: 1.4;
}
#app-shell .dm-workspace-thread.is-unread .dm-thread-preview { color: #666e74; font-weight: 600; }
#app-shell .dm-unread-count {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  line-height: 18px;
  border-radius: 10px;
  background: #e44f4f;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}
#app-shell .dm-sidebar-invitations,
#app-shell .dm-conversation-invitations {
  min-width: 0;
  max-height: 38dvh;
  overflow-y: auto;
  border-top: 1px solid var(--dm-divider);
  background: #fffdf8;
  color: #52565c;
}
#app-shell .dm-sidebar-invitations summary,
#app-shell .dm-conversation-invitations summary {
  cursor: pointer;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 700;
  list-style-position: inside;
}
#app-shell .dm-sidebar-invitations summary span,
#app-shell .dm-conversation-invitations summary span { color: #66865e; }
#app-shell .dm-invite-item {
  padding: 10px 15px;
  border-top: 1px solid #f1eee8;
  font-size: 12px;
}
#app-shell .dm-invite-item > :is(span,strong) { display: block; margin-top: 4px; }
#app-shell .dm-invite-item p { margin: 5px 0; }
#app-shell .dm-invite-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
#app-shell .dm-invite-actions :is(button,a),
#app-shell .dm-invite-refresh {
  border: 1px solid #d9dbd1;
  border-radius: 5px;
  background: #fff;
  padding: 4px 7px;
  font-size: 11px;
  color: #4a5a42;
  cursor: pointer;
}
#app-shell .dm-invite-refresh { margin: 5px 15px 12px; }
#app-shell .dm-workspace-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #f5f5f5;
}
#app-shell .dm-workspace-placeholder {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-width: 0;
  padding: 25px;
  color: #aaa;
  text-align: center;
}
#app-shell .dm-placeholder-icon {
  width: 80px;
  height: 80px;
  color: #d0d1d0;
}
#app-shell .dm-placeholder-icon svg { display: block; width: 100%; height: 100%; }
#app-shell .dm-workspace-placeholder strong { margin-top: 14px; color: #76797d; font-size: 17px; }
#app-shell .dm-workspace-placeholder p { color: #a1a1a4; margin: 5px 0 20px; font-size: 13px; }
#app-shell .dm-workspace-placeholder button {
  border: 1px solid #d5d6d1;
  border-radius: 7px;
  background: #fff;
  padding: 8px 16px;
  color: #6d706f;
  font-size: 13px;
  cursor: pointer;
}
#app-shell .dm-workspace .dm-chat-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
}
#app-shell .dm-workspace .dm-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 71px;
  padding: 12px 25px;
  border: 0;
  border-bottom: 1px solid var(--dm-divider);
  background: #f5f5f5;
}
#app-shell .dm-workspace .dm-chat-peer {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
#app-shell .dm-workspace .dm-chat-peer img,
#app-shell .dm-workspace .dm-chat-avatar {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  image-rendering: pixelated;
  background: #dce0dd;
}
#app-shell .dm-workspace .dm-chat-peer-text { display: grid; gap: 2px; min-width: 0; }
#app-shell .dm-workspace .dm-chat-peer-text strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #303337;
  font-size: 15px;
}
#app-shell .dm-workspace .dm-chat-peer-text span { margin: 0; color: #a0a2a5; font-size: 11px; }
#app-shell .dm-peer-profile {
  margin-left: auto;
  color: #8c8e94;
  font-size: 12px;
  white-space: nowrap;
}
#app-shell .dm-peer-profile:hover { color: #455a46; }
#app-shell .dm-workspace .dm-mobile-back { display: none; }
#app-shell .dm-workspace .dm-conversation-status {
  padding: 20px 25px;
  color: #8b8e92;
}
#app-shell .dm-workspace .dm-chat-content {
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
body[data-view="conversation"] #app-shell .dm-workspace .message-list.dm-chat-history {
  display: flex;
  flex-direction: column;
  gap: 17px;
  height: auto;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 24px clamp(16px, 3vw, 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f5f5f5;
  scrollbar-width: thin;
}
#app-shell .dm-chat-empty {
  margin: auto;
  padding: 30px 10px;
  color: #a5a6a8;
  font-size: 13px;
  text-align: center;
}
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-message {
  align-items: flex-start;
  gap: 11px;
}
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-message.mine {
  flex-direction: row-reverse;
  justify-content: flex-start;
}
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-avatar-link { flex: 0 0 40px; }
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-stack {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  max-width: min(76%, 600px);
  min-width: 0;
}
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-message.mine .dm-chat-stack { align-items: flex-end; }
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-time {
  order: 0;
  display: block;
  margin: 0 0 5px;
  color: #a1a4a6;
  font-size: 11px;
  line-height: 1.3;
}
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-bubble {
  order: 1;
  width: fit-content;
  max-width: 100%;
  padding: 10px 14px;
  margin: 0;
  border-radius: 4px 12px 12px 12px;
  border: 1px solid #e4e4e4;
  background: #fff;
  box-shadow: none;
  color: #30343a;
  font-size: 14px;
  line-height: 1.65;
}
body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-message.mine .dm-chat-bubble {
  border-color: #c8e9b7;
  border-radius: 12px 4px 12px 12px;
  background: #d8f5c6;
}
#app-shell .dm-workspace .dm-chat-bubble .msg-body { min-width: 0; overflow-wrap: anywhere; }
#app-shell .dm-workspace .dm-chat-bubble img,
#app-shell .dm-workspace .dm-chat-bubble video { max-width: 100%; height: auto; }
#app-shell .dm-workspace .dm-chat-bubble pre { max-width: 100%; overflow-x: auto; }
#app-shell .dm-workspace .dm-chat-composer {
  min-width: 0;
  padding: 6px 20px 15px;
  margin: 0;
  border: 0;
  border-top: 1px solid #dedede;
  background: #fff;
}
#app-shell .dm-workspace .dm-chat-composer .bbbs-rich-editor {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
}
#app-shell .dm-workspace .dm-chat-composer .bbbs-rich-toolbar {
  padding: 7px 0 5px;
  border: 0;
  background: #fff;
}
#app-shell .dm-workspace .dm-chat-composer .bbbs-rich-toolbar button,
#app-shell .dm-workspace .dm-chat-composer .bbbs-rich-toolbar select {
  min-height: 28px;
  padding: 4px 7px;
  font-size: 12px;
}
#app-shell .dm-workspace .dm-chat-composer .bbbs-rich-surface {
  min-height: 72px;
  max-height: 130px;
  padding: 10px 4px;
  color: #333;
  font-size: 14px;
  box-shadow: none;
}
#app-shell .dm-workspace .dm-chat-composer .bbbs-rich-footer {
  padding: 3px 4px;
  border: 0;
  background: #fff;
}
#app-shell .dm-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 3px;
}
#app-shell .dm-composer-actions span {
  margin-right: auto;
  color: #a3a4a6;
  font-size: 11px;
}
#app-shell .dm-send-button {
  min-height: 32px;
  padding: 6px 21px;
  border: 1px solid #b6ddbd;
  border-radius: 5px;
  background: #e1f3e2;
  color: #315d39;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#app-shell .dm-send-button:hover:not(:disabled) { background: #d1edce; }
#app-shell .dm-send-button:disabled { opacity: .45; cursor: not-allowed; }
#app-shell .dm-compose-error { margin: 4px 0; font-size: 12px; }

/* Compose: centered, accessible entry instead of a full-page form. */
#app-shell .dm-compose-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #181d2d99;
}
#app-shell .dm-compose-dialog {
  width: min(540px, 100%);
  max-height: min(90dvh, 760px);
  overflow-y: auto;
  border: 1px solid #d9d7d2;
  border-radius: 12px;
  background: #fffdfb;
  box-shadow: 0 20px 70px #1e223d44;
}
#app-shell .dm-compose-dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid #ebe7e0;
}
#app-shell .dm-compose-dialog h2 { margin: 0; color: #343639; font-size: 17px; }
#app-shell .dm-compose-form { padding: 14px 20px 20px; }
#app-shell .dm-compose-form .field-label { color: #60636b; font-size: 12px; }
#app-shell .dm-compose-form .input { border-radius: 7px; }
#app-shell .dm-compose-form .dm-recipient-results { top: calc(100% - 12px); }
#app-shell .dm-compose-form .dm-help {
  margin: 6px 0 16px;
  font-size: 11px;
  color: #999ba0;
}
#app-shell .dm-compose-form .bbbs-rich-editor { border-radius: 8px; margin-bottom: 8px; }
#app-shell .dm-compose-form .bbbs-rich-surface { min-height: 95px; max-height: 210px; }
#app-shell .dm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 12px;
}
#app-shell .dm-dialog-cancel {
  padding: 7px 16px;
  border: 1px solid #e1dfdc;
  border-radius: 5px;
  background: #fff;
  color: #6e7177;
  font-size: 13px;
  cursor: pointer;
}

@media (max-width: 760px) {
  body:is([data-view="messages"],[data-view="conversation"]) #app-shell.shell {
    display: block;
  }
  body:is([data-view="messages"],[data-view="conversation"]) #app-shell .dm-workspace {
    grid-template-columns: minmax(0,1fr);
    height: calc(100dvh - 120px);
    min-height: 430px;
    border-radius: 10px;
  }
  body[data-view="messages"] #app-shell .dm-workspace .dm-workspace-main { display: none; }
  body[data-view="conversation"] #app-shell .dm-workspace .dm-workspace-sidebar { display: none; }
  body[data-view="conversation"] #app-shell .dm-workspace .dm-workspace-main { display: flex; }
  #app-shell .dm-workspace .dm-sidebar-header { padding: 17px 17px 12px; }
  #app-shell .dm-workspace .dm-workspace-thread { min-height: 75px; }
  #app-shell .dm-workspace .dm-mobile-back {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    color: #666970;
  }
  #app-shell .dm-workspace .dm-mobile-back svg { width: 23px; height: 23px; }
  #app-shell .dm-workspace .dm-chat-header { padding: 10px 12px; min-height: 60px; gap: 7px; }
  #app-shell .dm-workspace .dm-chat-peer img { width: 34px; height: 34px; }
  #app-shell .dm-workspace .dm-peer-profile { font-size: 11px; }
  body[data-view="conversation"] #app-shell .dm-workspace .message-list.dm-chat-history { padding: 16px 12px; gap: 14px; }
  body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-stack { max-width: calc(100% - 46px); }
  body[data-view="conversation"] #app-shell .dm-workspace .dm-chat-bubble { padding: 9px 11px; font-size: 13px; }
  #app-shell .dm-workspace .dm-chat-composer { padding: 3px 10px 10px; }
  #app-shell .dm-workspace .dm-chat-composer .bbbs-rich-surface { min-height: 56px; max-height: 95px; }
  #app-shell .dm-composer-actions span { display: none; }
  #app-shell .dm-compose-dialog { max-height: 88dvh; }
  #app-shell .dm-compose-dialog > header { padding: 11px 13px; }
  #app-shell .dm-compose-form { padding: 10px 13px 15px; }
}
@media (max-height: 650px) and (min-width: 761px) {
  body:is([data-view="messages"],[data-view="conversation"]) #app-shell .dm-workspace { height: 550px; min-height: 550px; }
  #app-shell .dm-workspace .dm-chat-composer .bbbs-rich-surface { min-height: 56px; max-height: 85px; }
}
