/* Shared viewport geometry; loaded after the existing messenger styles. */
body.atlas-messenger-active {
  --atlas-chat-inset: 16px;
  --atlas-chat-gap: 12px;
  --atlas-chat-nav-width: clamp(220px, 20vw, 260px);
  height: var(--atlas-chat-height, 100dvh);
  overflow: hidden;
}
html:has(body.atlas-messenger-active) { overflow: hidden; }

body.atlas-messenger-active .atlas-messenger-nav,
body.atlas-messenger-active .neo-chat.chat-panel,
body.atlas-messenger-active .atlas-direct-view {
  box-sizing: border-box;
  position: fixed;
  top: calc(var(--atlas-chat-top, 0px) + var(--atlas-chat-inset)) !important;
  bottom: auto !important;
  height: calc(var(--atlas-chat-height, 100dvh) - 2 * var(--atlas-chat-inset)) !important;
  min-height: 0 !important;
  max-height: none;
  margin: 0;
  overflow: hidden;
}
body.atlas-messenger-active .atlas-messenger-nav {
  display: flex;
  flex-direction: column;
  left: calc(var(--atlas-sidebar-width, 250px) + var(--atlas-chat-gap));
  right: auto;
  width: var(--atlas-chat-nav-width);
  padding: 12px;
}
body.atlas-messenger-active .atlas-messenger-header { display: grid; gap: 7px; margin-bottom: 9px; }
body.atlas-messenger-active .atlas-messenger-header-actions { flex-wrap: wrap; }
body.atlas-messenger-active .atlas-messenger-nav > :not(.atlas-conversation-items):not(.atlas-contact-picker) { flex-shrink: 0; }
body.atlas-messenger-active .atlas-conversation-items { flex: 1 1 0; height: auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

body.atlas-messenger-active .neo-chat.chat-panel,
body.atlas-messenger-active .atlas-direct-view {
  display: flex;
  flex-direction: column;
  left: calc(var(--atlas-sidebar-width, 250px) + var(--atlas-chat-nav-width) + 2 * var(--atlas-chat-gap));
  right: var(--atlas-chat-inset);
  width: auto;
  max-width: none;
  border-radius: 19px;
  z-index: 121;
}
body.atlas-messenger-direct .neo-chat.chat-panel { visibility: hidden; }
body.atlas-messenger-active .neo-chat .neo-chat-cover,
body.atlas-messenger-active .atlas-direct-header {
  box-sizing: border-box;
  flex: 0 0 72px;
  height: 72px;
  min-height: 0;
  gap: 10px;
  padding: 9px 12px;
  overflow: hidden;
}
body.atlas-messenger-active .neo-chat-cover > div:not(.neo-cover-avatar) { flex: 1 1 auto; min-width: 0; }
body.atlas-messenger-active .neo-chat-cover .neo-cover-avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px; }
body.atlas-messenger-active .neo-chat-cover h2 { font-size: 16px; line-height: 1.25; margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.atlas-messenger-active .neo-chat-cover p { display: none; }
body.atlas-messenger-active .neo-chat-cover span:not(.status-flower) { font-size: 10px; }
body.atlas-messenger-active .neo-chat-cover > div:not(.neo-cover-avatar) > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.atlas-messenger-active .neo-chat .neo-chat-layout,
body.atlas-messenger-active .neo-chat .neo-chat-main {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow: hidden;
}
body.atlas-messenger-active .neo-chat .neo-chat-layout { position: relative; }
body.atlas-messenger-active .neo-chat .neo-chat-main { flex-direction: column; width: 100%; }
body.atlas-messenger-active .neo-chat .chat-messages,
body.atlas-messenger-active .atlas-direct-messages {
  flex: 1 1 0;
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
}
body.atlas-messenger-active .chat-messages > *,
body.atlas-messenger-active .atlas-direct-messages > * { flex-shrink: 0; }
body.atlas-messenger-active .neo-chat .chat-compose,
body.atlas-messenger-active .atlas-direct-compose {
  position: relative;
  bottom: auto;
  flex: 0 0 auto;
  min-width: 0;
  max-height: 45%;
  overflow-y: auto;
  padding: 8px 10px;
}
body.atlas-messenger-active .neo-chat .compose-tools.atlas-unified-tools { gap: 7px; margin-bottom: 6px; }
body.atlas-messenger-active .neo-chat .compose-tools:not(.atlas-tools-expanded) :is(.atlas-icon-emoji,.atlas-icon-poll,.atlas-icon-video) { display: none !important; }
body.atlas-messenger-active .neo-chat .compose-tools { flex-wrap: wrap; }
body.atlas-messenger-active .neo-chat .atlas-tools-toggle {
  min-height: 40px; padding: 6px 12px; border: 1px solid #60efff50;
  border-radius: 12px; background: #1b2b40; color: #dffbff; cursor: pointer;
}
body.atlas-messenger-active .neo-chat .atlas-tools-toggle:focus-visible { outline: 3px solid #60efff; }
body.atlas-messenger-active .neo-chat .compose-tools .emoji-picker {
  position: static !important; flex: 0 0 100%; order: 10;
  width: 100%; max-width: 100%; max-height: 150px; overflow-y: auto;
  margin: 0; transform: none !important;
}
body.atlas-messenger-active .neo-chat .compose-row { gap: 8px; }
body.atlas-messenger-active .neo-chat .compose-row textarea { min-height: 44px; max-height: 96px; padding: 10px 12px; }

body.atlas-messenger-active .neo-chat .neo-chat-members { display: none !important; }
body.atlas-messenger-active .neo-chat.atlas-members-open .neo-chat-members {
  display: block !important;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: min(280px, calc(100% - 20px));
  max-width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border-left: 1px solid rgba(96, 239, 255, .3);
  background: #181b26;
  box-shadow: -8px 0 24px #0005;
  z-index: 10;
}
.neo-chat .atlas-members-toggle,
.neo-chat .atlas-members-close {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid rgba(96, 239, 255, .3);
  border-radius: 10px;
  background: #1b2b40;
  color: #dffbff;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.neo-chat .atlas-members-close { display: block; margin: 0 0 12px auto; }
.neo-chat .atlas-members-toggle:focus-visible,
.neo-chat .atlas-members-close:focus-visible { outline: 3px solid #60efff; outline-offset: 2px; }
body.atlas-messenger-active .atlas-personal-messenger-stage {
  position: fixed;
  top: calc(var(--atlas-chat-top, 0px) + var(--atlas-chat-inset));
  left: calc(var(--atlas-sidebar-width, 250px) + var(--atlas-chat-nav-width) + 2 * var(--atlas-chat-gap));
  right: var(--atlas-chat-inset);
  height: calc(var(--atlas-chat-height, 100dvh) - 2 * var(--atlas-chat-inset));
  min-height: 0;
  margin: 0;
  padding: 0;
}
body.atlas-messenger-active .atlas-personal-messenger-empty { box-sizing: border-box; min-height: 0; height: 100%; }

@media (max-width: 760px) {
  body.atlas-messenger-active { --atlas-chat-inset: 0px; }
  body.atlas-messenger-active .atlas-messenger-nav,
  body.atlas-messenger-active .neo-chat.chat-panel,
  body.atlas-messenger-active .atlas-direct-view {
    left: 0;
    right: 0;
    width: 100%;
    border: 0;
    border-radius: 0;
  }
  body.atlas-messenger-active .atlas-messenger-nav { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); z-index: 2000; }
  body.atlas-messenger-active.atlas-messenger-thread-open > .atlas-messenger-nav { display: none; }
  body.atlas-messenger-active:not(.atlas-messenger-thread-open) .neo-chat.chat-panel,
  body.atlas-messenger-active:not(.atlas-messenger-thread-open) .atlas-direct-view { visibility: hidden; }
  body.atlas-messenger-active .neo-chat.chat-panel,
  body.atlas-messenger-active .atlas-direct-view { padding-top: calc(44px + env(safe-area-inset-top)); background: #0f111a; z-index: 2001; }
  body.atlas-messenger-active .neo-chat .neo-chat-cover,
  body.atlas-messenger-active .atlas-direct-header { flex-basis: 64px; height: 64px; min-height: 0; padding: 7px 10px; }
  body.atlas-messenger-active .neo-chat-cover h2 { font-size: 14px; }
  body.atlas-messenger-active .neo-chat .chat-compose,
  body.atlas-messenger-active .atlas-direct-compose { padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); }
  body.atlas-messenger-active > .atlas-group-back,
  body.atlas-messenger-active > .atlas-thread-atlas-exit { top: calc(var(--atlas-chat-top, 0px) + env(safe-area-inset-top)); z-index: 2006; }
  body.atlas-messenger-active .atlas-personal-messenger-stage { display: none; }
}
