.messenger-shell [hidden],
.messenger-dialog[hidden],
.messenger-toast[hidden] {
  display: none !important;
}

.messenger-main {
  min-width: 0;
}

.messenger-intro {
  margin-bottom: 14px;
}

.messenger-shell {
  position: relative;
  min-height: min(760px, calc(100dvh - 150px));
  height: min(820px, calc(100dvh - 130px));
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  border-radius: 24px;
}

.conversation-sidebar {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.conversation-sidebar-head {
  min-height: 80px;
  padding: 17px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.conversation-sidebar-head h2 {
  margin: 2px 0 0;
  font-size: 25px;
}

.messenger-icon-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text);
  font-size: 21px;
  cursor: pointer;
}

.messenger-icon-btn:hover,
.messenger-icon-btn:focus-visible {
  border-color: rgba(189, 31, 37, .25);
  background: var(--red-50);
  color: var(--red-800);
}

.conversation-search {
  min-height: 48px;
  margin: 0 14px 10px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-2);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.conversation-search > span {
  color: var(--muted);
  font-size: 20px;
}

.conversation-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.conversation-search button {
  width: 29px;
  height: 29px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
}

.conversation-filter-tabs {
  display: flex;
  gap: 6px;
  padding: 0 14px 11px;
  overflow-x: auto;
  scrollbar-width: none;
}

.conversation-filter-tabs::-webkit-scrollbar {
  display: none;
}

.conversation-filter-tabs button {
  min-height: 34px;
  padding: 0 10px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.conversation-filter-tabs button.is-active {
  background: var(--red-50);
  border-color: rgba(189, 31, 37, .20);
  color: var(--red-800);
}

.conversation-list {
  min-height: 0;
  flex: 1;
  padding: 0 9px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.conversation-item {
  position: relative;
  width: 100%;
  min-height: 78px;
  margin-bottom: 5px;
  padding: 10px 9px;
  border: 1px solid transparent;
  border-radius: 17px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: transparent;
  color: var(--text);
  text-align: right;
  cursor: pointer;
}

.conversation-item:hover {
  background: var(--surface-2);
}

.conversation-item.is-active {
  background: var(--red-50);
  border-color: rgba(189, 31, 37, .16);
}

.conversation-item.is-unread .conversation-name {
  font-weight: 950;
}

.conversation-item.is-archived {
  opacity: .72;
}

.conversation-avatar-wrap {
  position: relative;
}

.conversation-avatar {
  width: 50px;
  height: 50px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 19px;
  font-weight: 950;
}

.avatar-red { background: linear-gradient(135deg, var(--red-700), var(--red-950)); }
.avatar-blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.avatar-gold { background: linear-gradient(135deg, #f59e0b, #b45309); }
.avatar-mint { background: linear-gradient(135deg, #10b981, #047857); }
.avatar-purple { background: linear-gradient(135deg, #8b5cf6, #5b21b6); }
.avatar-slate { background: linear-gradient(135deg, #64748b, #334155); }

.conversation-online-dot {
  position: absolute;
  left: -1px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: #22c55e;
}

.conversation-copy {
  min-width: 0;
}

.conversation-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conversation-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.conversation-pin {
  color: var(--red-700);
  font-size: 13px;
}

.conversation-preview {
  margin: 4px 0 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.conversation-item.is-unread .conversation-preview {
  color: var(--text);
}

.conversation-meta {
  align-self: stretch;
  display: grid;
  justify-items: end;
  align-content: space-between;
  gap: 5px;
  color: var(--muted-2);
  font-size: 11px;
  white-space: nowrap;
}

.conversation-unread {
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--red-700);
  color: #fff;
  font-size: 11px;
  font-weight: 950;
}

.conversation-empty {
  padding: 36px 18px;
  text-align: center;
  color: var(--muted);
}

.conversation-empty span,
.conversation-empty strong,
.conversation-empty small {
  display: block;
}

.conversation-empty span {
  margin-bottom: 8px;
  font-size: 44px;
}

.conversation-panel {
  position: relative;
  min-width: 0;
  background:
    radial-gradient(circle at 90% 10%, rgba(189, 31, 37, .035), transparent 25%),
    var(--surface-2);
}

.conversation-placeholder {
  min-height: 100%;
  padding: 40px 20px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.placeholder-illustration {
  width: 120px;
  height: 120px;
  border-radius: 40px;
  display: grid;
  place-items: center;
  background: var(--red-50);
  border: 1px solid rgba(189, 31, 37, .15);
  font-size: 58px;
}

.conversation-placeholder h2 {
  margin: 18px 0 3px;
}

.conversation-placeholder p {
  max-width: 460px;
  margin: 0 0 16px;
  color: var(--muted);
}

.active-conversation {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
}

.active-chat-header {
  position: relative;
  min-height: 76px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  display: flex;
  align-items: center;
  gap: 11px;
  backdrop-filter: blur(10px);
}

.messenger-back-btn {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 27px;
}

.active-chat-user {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.active-chat-user .chat-avatar {
  flex: 0 0 auto;
}

.active-chat-user > div {
  min-width: 0;
}

.active-chat-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.active-chat-name-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.online-indicator {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #22c55e;
}

.online-indicator.is-offline {
  background: #94a3b8;
}

.active-chat-user small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-chat-actions {
  display: flex;
  gap: 5px;
}

.chat-actions-menu {
  position: absolute;
  z-index: 40;
  top: 62px;
  left: 13px;
  width: min(240px, calc(100vw - 30px));
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-actions-menu button {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: right;
}

.chat-actions-menu button:hover {
  background: var(--surface-2);
}

.message-search-bar {
  min-height: 48px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  background: var(--surface);
}

.message-search-bar input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.message-search-bar span:last-of-type {
  color: var(--muted);
  font-size: 12px;
}

.message-search-bar button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
}

.linked-ad-card {
  min-height: 62px;
  margin: 9px 12px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.linked-ad-icon {
  width: 45px;
  height: 45px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--red-50);
  font-size: 24px;
}

.linked-ad-card span,
.linked-ad-card strong,
.linked-ad-card small {
  display: block;
}

.linked-ad-card span {
  color: var(--muted);
  font-size: 11px;
}

.linked-ad-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-ad-card small {
  color: var(--red-800);
}

.linked-ad-card a {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  color: var(--red-800);
  font-size: 12px;
  font-weight: 900;
}

.messenger-thread {
  min-height: 0;
  padding: 15px 18px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

.message-day-separator {
  margin: 13px 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}

.message-day-separator::before,
.message-day-separator::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.message-row {
  display: flex;
  margin: 6px 0;
}

.message-row.is-outgoing {
  justify-content: flex-start;
}

.message-row.is-incoming {
  justify-content: flex-end;
}

.message-bubble {
  position: relative;
  max-width: min(76%, 620px);
  padding: 9px 11px 7px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(15, 23, 42, .035);
}

.message-row.is-outgoing .message-bubble {
  border-top-left-radius: 6px;
  border-color: rgba(189, 31, 37, .14);
  background: var(--red-50);
}

.message-row.is-incoming .message-bubble {
  border-top-right-radius: 6px;
}

.message-bubble.is-highlighted {
  animation: messageHighlight 1.2s ease;
}

@keyframes messageHighlight {
  0%, 100% { box-shadow: 0 4px 14px rgba(15,23,42,.035); }
  45% { box-shadow: 0 0 0 5px rgba(245, 158, 11, .22); }
}

.message-text {
  margin: 0;
  color: var(--text);
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-text mark {
  border-radius: 3px;
  background: #fde68a;
  color: #78350f;
  padding-inline: 1px;
}

.message-footer {
  min-height: 18px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted-2);
  font-size: 10px;
}

.message-status {
  color: #2563eb;
  letter-spacing: -2px;
}

.message-attachments {
  display: grid;
  gap: 6px;
  margin-bottom: 7px;
}

.message-image-attachment {
  position: relative;
  width: min(320px, 100%);
  min-height: 140px;
  max-height: 260px;
  border: 0;
  border-radius: 13px;
  overflow: hidden;
  background: var(--surface-3);
  cursor: pointer;
}

.message-image-attachment img {
  width: 100%;
  height: 100%;
  min-height: 140px;
  max-height: 260px;
  display: block;
  object-fit: cover;
}

.message-file-attachment {
  min-width: min(280px, 100%);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  color: var(--text);
}

.file-type-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  font-size: 19px;
}

.message-file-attachment strong,
.message-file-attachment small {
  display: block;
}

.message-file-attachment strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.message-file-attachment small {
  color: var(--muted);
  font-size: 10px;
}

.message-file-attachment b {
  color: var(--red-800);
  font-size: 12px;
}

.typing-indicator {
  min-height: 32px;
  padding: 0 18px 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-indicator > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingDot .9s infinite alternate;
}

.typing-indicator > span:nth-child(2) { animation-delay: .15s; }
.typing-indicator > span:nth-child(3) { animation-delay: .3s; }

.typing-indicator small {
  margin-right: 5px;
  color: var(--muted);
}

@keyframes typingDot {
  to { transform: translateY(-4px); opacity: .45; }
}

.pending-attachments {
  padding: 8px 13px 0;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pending-file {
  position: relative;
  flex: 0 0 132px;
  min-height: 68px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.pending-file.is-image {
  min-height: 100px;
  padding-top: 43px;
  background-size: cover;
  background-position: center;
  color: #fff;
}

.pending-file.is-image::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(transparent, rgba(15,23,42,.78));
}

.pending-file > * {
  position: relative;
  z-index: 2;
}

.pending-file strong,
.pending-file small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-file strong { font-size: 11px; }
.pending-file small { color: var(--muted); font-size: 9px; }
.pending-file.is-image small { color: rgba(255,255,255,.8); }

.pending-file-remove {
  position: absolute;
  z-index: 4;
  top: 5px;
  left: 5px;
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 50%;
  background: rgba(15,23,42,.75);
  color: #fff;
}

.drop-zone-overlay {
  position: absolute;
  z-index: 80;
  inset: 0;
  padding: 25px;
  background: rgba(15,23,42,.72);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
}

.drop-zone-overlay > div {
  width: min(440px, 100%);
  min-height: 210px;
  border: 2px dashed rgba(255,255,255,.65);
  border-radius: 25px;
  display: grid;
  place-items: center;
  align-content: center;
  color: #fff;
  text-align: center;
}

.drop-zone-overlay span,
.drop-zone-overlay strong,
.drop-zone-overlay small {
  display: block;
}

.drop-zone-overlay span {
  margin-bottom: 8px;
  font-size: 53px;
}

.drop-zone-overlay small {
  color: rgba(255,255,255,.74);
}

.messenger-composer {
  position: relative;
  margin: 0 12px;
  padding: 7px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px;
}

.composer-tools {
  position: relative;
  display: flex;
  gap: 3px;
}

.composer-tool-btn {
  width: 39px;
  height: 39px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.composer-tool-btn:hover {
  background: var(--surface-2);
  color: var(--red-800);
}

.emoji-picker {
  position: absolute;
  z-index: 50;
  right: 0;
  bottom: 48px;
  width: 228px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

.emoji-picker button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 18px;
}

.emoji-picker button:hover {
  background: var(--surface-2);
}

.messenger-composer textarea {
  min-height: 39px;
  max-height: 145px;
  padding: 9px 5px 5px;
  border: 0;
  outline: 0;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.65;
}

.composer-send-btn {
  min-width: 86px;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--red-700), var(--red-900));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 900;
  box-shadow: var(--shadow-red);
}

.composer-send-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.composer-send-btn b {
  transform: rotate(180deg);
}

.composer-hint {
  min-height: 27px;
  padding: 4px 15px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted-2);
  font-size: 10px;
}

.messenger-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: min(88dvh, 750px);
  padding: 0;
  border: 0;
  border-radius: 23px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 75px rgba(15,23,42,.25);
}

.messenger-dialog::backdrop {
  background: rgba(15,23,42,.62);
  backdrop-filter: blur(4px);
}

.messenger-dialog-card {
  padding: 19px;
  display: grid;
  gap: 13px;
}

.messenger-dialog-card > header,
.messenger-dialog-card > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.messenger-dialog-card header h2 {
  margin: 3px 0 0;
}

.messenger-dialog-card header > button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
}

.new-chat-search {
  min-height: 48px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.new-chat-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.new-contact-list {
  max-height: 430px;
  overflow-y: auto;
  display: grid;
  gap: 7px;
}

.new-contact-item {
  min-height: 66px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  color: var(--text);
  text-align: right;
}

.new-contact-item:hover {
  border-color: rgba(189,31,37,.25);
  background: var(--red-50);
}

.new-contact-item span:first-child {
  width: 45px;
  height: 45px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--red-700);
  color: #fff;
  font-weight: 950;
}

.new-contact-item strong,
.new-contact-item small {
  display: block;
}

.new-contact-item small {
  color: var(--muted);
}

.new-contact-item b {
  color: var(--red-800);
  font-size: 12px;
}

.file-preview-body {
  min-height: 240px;
  max-height: 60dvh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}

.file-preview-body img {
  max-width: 100%;
  max-height: 58dvh;
  display: block;
  object-fit: contain;
}

.file-preview-generic {
  padding: 30px;
  text-align: center;
}

.file-preview-generic span,
.file-preview-generic strong,
.file-preview-generic small {
  display: block;
}

.file-preview-generic span {
  margin-bottom: 9px;
  font-size: 62px;
}

.file-preview-generic small {
  color: var(--muted);
}

.danger-btn {
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: #b91c1c;
  color: #fff;
  font-weight: 900;
}

.messenger-toast {
  position: fixed;
  z-index: 500;
  left: 50%;
  bottom: 28px;
  min-width: min(370px, calc(100% - 24px));
  padding: 12px 15px;
  border-radius: 14px;
  background: #111827;
  color: #fff;
  box-shadow: 0 18px 50px rgba(15,23,42,.25);
  transform: translateX(-50%);
  text-align: center;
  font-weight: 900;
}

body.dark-mode .conversation-sidebar,
body.dark-mode .active-chat-header,
body.dark-mode .linked-ad-card,
body.dark-mode .messenger-composer,
body.dark-mode .message-bubble,
body.dark-mode .messenger-dialog,
body.dark-mode .pending-file {
  background: var(--surface);
}

body.dark-mode .message-row.is-outgoing .message-bubble {
  background: rgba(189,31,37,.14);
}

@media (max-width: 1240px) {
  .messenger-shell {
    grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  }

  .messenger-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .messenger-intro,
  .messenger-stats {
    display: none;
  }

  .messenger-main {
    padding-bottom: 0;
  }

  .messenger-shell {
    height: calc(100dvh - var(--header-h) - 28px);
    min-height: 620px;
    grid-template-columns: 1fr;
    border-radius: 20px;
  }

  .conversation-sidebar {
    border-left: 0;
  }

  .conversation-panel {
    position: absolute;
    z-index: 20;
    inset: 0;
    transform: translateX(-105%);
    transition: transform .22s ease;
  }

  .messenger-shell.chat-open .conversation-panel {
    transform: translateX(0);
  }

  .messenger-back-btn {
    display: inline-grid;
    place-items: center;
  }

  .active-chat-header {
    min-height: 68px;
  }

  .linked-ad-card {
    margin-top: 7px;
  }
}

@media (max-width: 620px) {
  .container.layout-shell {
    width: 100%;
  }

  .dashboard-main.messenger-main {
    width: 100%;
    max-width: none;
  }

  .messenger-shell {
    min-height: 540px;
    height: calc(100dvh - var(--header-h));
    border-radius: 0;
    border-inline: 0;
  }

  .conversation-sidebar-head {
    min-height: 69px;
  }

  .active-chat-actions .messenger-icon-btn:nth-child(2) {
    display: none;
  }

  .active-chat-user .chat-avatar {
    width: 43px;
    height: 43px;
    border-radius: 14px;
  }

  .active-chat-name-row strong {
    font-size: 16px;
  }

  .active-chat-user small {
    max-width: 170px;
    font-size: 11px;
  }

  .linked-ad-card {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .linked-ad-card a {
    display: none;
  }

  .linked-ad-icon {
    width: 40px;
    height: 40px;
  }

  .messenger-thread {
    padding: 12px 9px 18px;
  }

  .message-bubble {
    max-width: 88%;
  }

  .message-image-attachment {
    width: min(260px, 100%);
  }

  .messenger-composer {
    margin-inline: 7px;
    grid-template-columns: auto minmax(0, 1fr) 44px;
  }

  .composer-tools {
    gap: 0;
  }

  .composer-tool-btn {
    width: 34px;
  }

  .composer-send-btn {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .composer-send-btn span {
    display: none;
  }

  .composer-hint span:first-child {
    display: none;
  }

  .composer-hint {
    justify-content: flex-end;
  }

  .emoji-picker {
    right: -5px;
    width: 208px;
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 380px) {
  .conversation-item {
    grid-template-columns: 45px minmax(0, 1fr) auto;
  }

  .conversation-avatar {
    width: 45px;
    height: 45px;
  }

  .message-bubble {
    max-width: 94%;
  }

  .active-chat-actions {
    gap: 2px;
  }

  .messenger-icon-btn {
    width: 37px;
    height: 37px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


/* V44 — reliable long-conversation scrolling */
.messenger-shell,
.conversation-panel,
.active-conversation {
  min-height: 0;
}

.conversation-panel {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.active-conversation {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.messenger-thread {
  position: relative;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: scroll !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(100, 116, 139, .55) transparent;
  scrollbar-width: thin;
}

.messenger-thread::-webkit-scrollbar {
  width: 8px;
}

.messenger-thread::-webkit-scrollbar-track {
  background: transparent;
}

.messenger-thread::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(100, 116, 139, .48);
  background-clip: padding-box;
}

.messenger-thread::-webkit-scrollbar-thumb:hover {
  background: rgba(71, 85, 105, .72);
  background-clip: padding-box;
}

.message-day-separator {
  position: sticky;
  z-index: 4;
  top: 0;
  width: max-content;
  max-width: 100%;
  margin: 13px auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .05);
  backdrop-filter: blur(8px);
}

.message-day-separator::before,
.message-day-separator::after {
  display: none;
}

.scroll-to-bottom-btn {
  position: absolute;
  z-index: 35;
  left: 18px;
  bottom: 91px;
  min-height: 43px;
  padding: 0 10px 0 13px;
  border: 1px solid rgba(189, 31, 37, .18);
  border-radius: 999px;
  background: var(--surface);
  color: var(--red-800);
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  animation: scrollButtonIn .18s ease;
}

.scroll-to-bottom-btn[hidden] {
  display: none !important;
}

.scroll-to-bottom-btn span {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--red-700);
  color: #fff;
  font-size: 17px;
  line-height: 1;
}

.scroll-to-bottom-btn:hover,
.scroll-to-bottom-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 15px 36px rgba(15, 23, 42, .20);
}

@keyframes scrollButtonIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

body.dark-mode .scroll-to-bottom-btn {
  background: var(--surface);
  border-color: rgba(248, 113, 113, .22);
}

@media (max-width: 980px) {
  .messenger-shell {
    min-height: 0;
    max-height: calc(100dvh - var(--header-h) - 28px);
  }

  .conversation-panel,
  .active-conversation {
    height: 100%;
    max-height: 100%;
  }

  .messenger-thread {
    min-height: 0;
    height: auto;
  }

  .scroll-to-bottom-btn {
    left: 13px;
    bottom: 83px;
  }
}

@media (max-width: 620px) {
  body:has(.messenger-shell.chat-open) {
    overflow: hidden;
  }

  .messenger-shell {
    min-height: 0;
    height: calc(100dvh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
  }

  .messenger-thread {
    padding-bottom: 30px;
  }

  .scroll-to-bottom-btn {
    left: 9px;
    bottom: 78px;
    min-width: 43px;
    padding: 0;
    justify-content: center;
  }

  .scroll-to-bottom-btn b {
    display: none;
  }

  .scroll-to-bottom-btn span {
    width: 31px;
    height: 31px;
  }
}


/* V45 — dynamic conversation list and reliable sidebar scrolling */
.conversation-sidebar {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.conversation-sidebar-head,
.conversation-search,
.conversation-filter-tabs {
  flex: 0 0 auto;
}

.conversation-list {
  position: relative;
  flex: 1 1 auto;
  height: 0;
  min-height: 0;
  max-height: 100%;
  overflow-y: scroll !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, .55) transparent;
}

.conversation-list::-webkit-scrollbar {
  width: 8px;
}

.conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(100, 116, 139, .48);
  background-clip: padding-box;
}

.conversation-list::-webkit-scrollbar-thumb:hover {
  background: rgba(71, 85, 105, .72);
  background-clip: padding-box;
}

.conversation-item.is-newly-added {
  animation: newConversationFlash 1.15s ease;
}

@keyframes newConversationFlash {
  0% {
    opacity: .45;
    transform: translateY(-8px);
    box-shadow: 0 0 0 5px rgba(189, 31, 37, .12);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    box-shadow: none;
  }
}


@media (max-width: 980px) {
  .conversation-sidebar {
    height: 100%;
    max-height: 100%;
  }

  .conversation-list {
    height: 0;
    min-height: 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 620px) {
  .new-contact-list { max-height: 35dvh; }
}


/* V46 — clean production-ready messenger */
.real-contact-empty {
  min-height: 150px;
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.real-contact-empty span,
.real-contact-empty strong,
.real-contact-empty small {
  display: block;
}

.real-contact-empty span {
  margin-bottom: 8px;
  font-size: 40px;
}

.real-contact-empty strong {
  color: var(--text);
}

.real-contact-empty small {
  max-width: 390px;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.8;
}
