/* Private messages are a fixed application workspace, not a scrolling page.
   Only the conversation list and message history own scrollbars. */
body #messagesView.section-page:not(.hidden) {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%; min-height: 0; max-height: 100%;
  gap: 12px; padding: 0 !important;
  overflow: hidden !important; background: transparent !important;
  --dm-line: var(--skin-frame, #29445f);
  --dm-ink: var(--skin-text, #e4efff);
  --dm-muted: var(--skin-muted, #96afce);
  --dm-deep: var(--skin-deep, #071320);
  --dm-accent: var(--skin-accent, #55b8ff);
  color: var(--dm-ink); font-family: "Segoe UI", system-ui, sans-serif !important;
}
body #messagesView.section-page :is(h1,h2,h3,strong,b,p,time,span,button,input,select,textarea) {
  font-family: "Segoe UI", system-ui, sans-serif !important;
}
body[data-view="messages"] .app-notification {
  top: calc(var(--shell-top, 78px) + 12px); bottom: auto;
  /* Incoming messages must not cover the composer while the user types. */
}
body #messagesView > .hub-header {
  min-height: 82px !important; padding: 14px 22px !important;
  display: flex !important; align-items: center; gap: 18px;
}
body #messagesView > .hub-header h1 { margin: 3px 0 0 !important; font-size: 25px !important; line-height: 1.15; }
body #messagesView > .hub-header p { margin: 5px 0 0; font-size: 12px; }
body #messagesView > .hub-header .settings-select { width: min(290px, 42%) !important; height: 38px; flex: none; }
body #messagesView .messages-layout {
  display: grid !important; grid-template-columns: minmax(220px, 285px) minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr); gap: 12px !important;
  min-height: 0 !important; height: 100%; margin: 0 !important; overflow: hidden;
}
body #messagesView .messages-layout > .hub-panel {
  box-sizing: border-box; min-height: 0 !important; max-height: none !important; height: 100%;
  overflow: hidden; position: relative;
  padding: max(14px, var(--atlas-edge-top, var(--dm-native-edge, 0px)))
           max(14px, var(--atlas-edge-right, var(--dm-native-edge, 0px)))
           max(14px, var(--atlas-edge-bottom, var(--dm-native-edge, 0px)))
           max(14px, var(--atlas-edge-left, var(--dm-native-edge, 0px))) !important;
}
body[data-skin-renderer="native"] #messagesView .messages-layout > .hub-panel { --dm-native-edge: 18px; }
body #messagesView .dm-sidebar-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); }
body #messagesView .dm-sidebar-head { min-height: 38px; display: flex; align-items: center; padding: 0 5px 10px; }
body #messagesView .dm-sidebar-head h2 { font-size: 14px; }
body #messagesView .dm-conversation-list {
  display: flex; flex-direction: column; gap: 7px; min-height: 0;
  overflow-y: auto; padding: 3px; background: transparent !important;
  border: 0 !important; box-shadow: none !important;
}
body #messagesView .dm-thread-button {
  grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px;
  min-height: 66px; padding: 10px; flex: none; margin: 0;
  color: var(--dm-ink); background: var(--dm-deep); border: 1px solid var(--dm-line);
  border-radius: 8px; transform: none !important; box-shadow: none !important;
}
body #messagesView .dm-thread-button.active {
  border-color: var(--dm-accent); background: color-mix(in srgb, var(--dm-accent) 12%, var(--dm-deep));
  box-shadow: inset 3px 0 var(--dm-accent) !important;
}
body #messagesView .dm-thread-button strong { font-size: 13px; font-weight: 650; }
body #messagesView .dm-thread-button :is(span.status-label, small) { color: var(--dm-muted); font-size: 11px; }
body #messagesView .dm-thread-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto !important; }
body #messagesView .dm-thread-head {
  min-height: 57px !important; padding: 7px 11px 12px;
  border-bottom: 1px solid var(--dm-line); background: transparent !important;
}
body #messagesView .dm-thread-head span { color: var(--dm-muted); font-size: 9px; letter-spacing: .1em; }
body #messagesView .dm-thread-head strong { margin-top: 4px; color: var(--dm-ink); font-size: 16px; }
body #messagesView .dm-history {
  min-height: 0 !important; min-width: 0; overflow: auto;
  padding: 16px 10px; margin: 0; border: 0 !important;
  border-radius: 0 !important; box-shadow: none !important; background: transparent !important;
  scrollbar-width: thin; scrollbar-color: var(--dm-line) transparent;
  overscroll-behavior: contain; scroll-padding-bottom: 14px;
}
/* A frame belongs to the fixed thread panel, never to its scrolling history. */
body #messagesView .dm-history::before, body #messagesView .dm-history::after {
  content: none !important; display: none !important; border-image: none !important;
}
body #messagesView .dm-bubble {
  box-sizing: border-box; width: fit-content; max-width: min(82%, 680px); min-width: 145px;
  margin: 0 auto 12px 0; padding: 10px 13px;
  border: 1px solid var(--dm-line); border-radius: 10px 10px 10px 3px;
  background: var(--dm-deep) !important; box-shadow: none !important;
  font-family: "Segoe UI", system-ui, sans-serif !important;
}
body #messagesView .dm-bubble.mine {
  margin-left: auto; margin-right: 0; border-radius: 10px 10px 3px 10px;
  background: color-mix(in srgb, var(--dm-accent) 10%, var(--dm-deep)) !important;
}
body #messagesView .dm-bubble p { color: var(--dm-ink); font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
body #messagesView .dm-bubble :is(strong, time) { color: var(--dm-muted); font-family: inherit !important; font-size: 11px; }
body #messagesView .dm-bubble time { font-size: 10px; }
body #messagesView .dm-bubble .message-delete { padding: 2px 5px; font-size: 10px; min-height: 0; }
body #messagesView .dm-form {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 44px !important;
  position: relative !important; inset: auto; align-items: center; gap: 8px;
  padding: 12px 6px 0 !important; margin: 0;
  border: 0 !important; border-top: 1px solid var(--dm-line) !important;
  border-radius: 0 !important; background: transparent !important; box-shadow: none !important;
}
body #messagesView .dm-form input {
  box-sizing: border-box; width: 100%; min-width: 0 !important; height: 44px !important;
  padding: 0 13px; font-size: 13px; font-family: "Segoe UI", system-ui, sans-serif;
  border: 1px solid var(--dm-line); border-radius: 7px;
  color: var(--dm-ink); background: var(--dm-deep) !important;
}
body #messagesView .dm-form #dmEncryptionButton {
  grid-column: auto !important; grid-row: auto !important; min-width: 70px;
  height: 44px !important; padding: 0 9px; font-size: 11px;
}
body #messagesView .dm-form .send-button { width: 44px !important; height: 44px !important; min-height: 44px; padding: 10px; }
body #messagesView :is(.dm-conversation-list,.dm-history) > .empty-state {
  min-height: 100%; display: grid; place-content: center; padding: 20px;
  color: var(--dm-muted); text-align: center; font-size: 13px;
}
@media (max-width: 1050px) {
  body #messagesView .messages-layout { grid-template-columns: minmax(185px, 225px) minmax(0, 1fr) !important; gap: 9px !important; }
}
@media (max-width: 767px) {
  body #messagesView.section-page:not(.hidden) { gap: 8px; }
  body #messagesView > .hub-header { min-height: 76px !important; padding: 11px 16px !important; gap: 10px; }
  body #messagesView > .hub-header h1 { font-size: 22px !important; }
  body #messagesView > .hub-header p { display: none; }
  body #messagesView > .hub-header .settings-select { width: 47% !important; font-size: 11px; }
  body #messagesView .messages-layout { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: 83px minmax(0, 1fr); gap: 8px !important; }
  body #messagesView .dm-sidebar-panel { display: block; }
  body #messagesView .dm-sidebar-head { display: none; }
  body #messagesView .dm-conversation-list { height: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  body #messagesView .dm-thread-button { width: 190px; min-height: 54px; padding: 6px; gap: 8px; }
  body #messagesView .dm-thread-head { min-height: 46px !important; padding: 2px 8px 8px; }
  body #messagesView .dm-history { padding: 10px 4px; }
  body #messagesView .dm-bubble { max-width: 92%; }
  body #messagesView .dm-form { padding: 9px 0 0 !important; gap: 5px; grid-template-columns: minmax(0, 1fr) 40px 40px !important; }
  body #messagesView .dm-form #dmEncryptionButton { min-width: 40px; width: 40px; padding: 0; font-size: 0; }
  body #messagesView .dm-form .send-button { width: 40px !important; height: 44px !important; }
}
