.native-message-console { min-height: 0; }
.native-messages-page .native-contact-list { display: flex; flex-direction: column; gap: 0; }
.native-messages-page .inbox-contact-row { flex: 0 0 auto; }
.native-messages-page .inbox-contact-row .native-contact-item { padding: 10px 8px; min-height: 70px; }
/* The bounded 80-row rail keeps actual heights through selection and read updates. */
.native-messages-page .native-contact-item { content-visibility: visible; }
.native-messages-page .native-contact-item p { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-weight: 450; line-height: 1.35; margin: 4px 0; }
.native-messages-page .native-contact-item strong { font-weight: 650; font-size: 14px; }
.native-messages-page .native-contact-item > span { border-radius: 50%; }
.inbox-contact-row { display: flex; align-items: center; min-width: 0; border-bottom: 1px solid #e9ebef; }
.inbox-contact-row .native-contact-item { flex: 1; min-width: 0; border: 0; border-radius: 0; }
.inbox-row-select { display: grid; place-items: center; flex: 0 0 32px; align-self: stretch; cursor: pointer; }
.inbox-row-select input, .inbox-select-all input { width: 17px; height: 17px; accent-color: #007aff; }
.inbox-contact-row:has(input:checked) { background: #eaf3ff; }
.inbox-organization-tools { position: relative; padding: 8px 12px; font-size: 12px; border-bottom: 1px solid #e9ebef; }
.inbox-select-all { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.inbox-selection-hint { margin: 6px 0 0; font-size: 11px; line-height: 1.4; color: inherit; }
.inbox-bulk:not([hidden]) { position: absolute; bottom: calc(100% + 4px); left: 8px; right: 8px; z-index: 5; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px; background: #fff; color: #17212b; border: 1px solid #cad4df; border-radius: 14px; box-shadow: 0 6px 24px #173b4526; }
.inbox-bulk strong { flex-basis: 100%; }
.inbox-bulk button { min-height: 36px; border: 1px solid #cad4df; border-radius: 16px; background: #fff; color: #0757a6; padding: 5px 10px; }
.native-messages-page .native-inbox-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.native-messages-page .native-inbox-filters a { border-radius: 16px; padding: 7px 10px; }
.native-messages-page .native-inbox-filters a.active { background: #e5efff; color: #005fc7; }
.native-messages-page .native-thread-title h3 { letter-spacing: -.025em; }
.native-messages-page .native-conversation-row.outbound .native-conversation-card { background: #087bf5; border-color: #087bf5; color: #fff; border-radius: 20px 20px 5px 20px; }
.native-messages-page .native-conversation-row.inbound .native-conversation-card { background: #e9e9eb; border-color: #e9e9eb; color: #17212b; border-radius: 20px 20px 20px 5px; }
.native-messages-page .native-conversation-row.outbound .native-conversation-card a { color: #fff; text-decoration: underline; }
.native-messages-page .native-conversation-row.outbound .native-mobile-message-meta { color: #e5efff; }
.native-messages-page .native-message-bubble-list { background: #fff; }
.native-customer-composer textarea,
.native-customer-composer:focus-within textarea { min-height: 52px; height: 52px; max-height: 96px; padding: 5px 10px; line-height: 20px; overflow-y: auto; border-radius: 22px; background: #f5f5f7; }
@media (max-width: 760px) {
  .inbox-row-select, .inbox-select-all, .inbox-selection-hint, .inbox-bulk:not([hidden]) { display: none; }
  .inbox-organization-tools:not(:has([role="status"]:not(:empty), a)) { display: none; }
}
html[data-app-theme="dark"] .inbox-contact-row { border-color: #34414e; }
html[data-app-theme="dark"] .inbox-contact-row:has(input:checked) { background: #17385e; }
html[data-app-theme="dark"] .inbox-bulk { background: #17212b; color: #f5f7fa; border-color: #526878; }
.native-message-thread-panel {
  display: flex;
  flex-direction: column;
  background: #f7f9fb;
}

.native-thread-head {
  min-height: 66px;
  border-bottom: 1px solid #dbe4ea;
  padding: 10px 14px;
  background: #fff;
}

.native-message-bubble-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 18px 24px;
  background: linear-gradient(180deg, #fbfdfe 0%, #f6fafb 100%);
}

.native-thread-head, .native-customer-composer { flex-shrink: 0; }
.native-message-bubble-list { overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; overflow-anchor: none; }
.native-message-bubble-list > * { flex-shrink: 0; }
.native-thread-menu { position: relative; }
.native-thread-menu summary { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; list-style: none; border-radius: 8px; }
.native-thread-menu summary::-webkit-details-marker { display: none; }
.native-thread-menu summary svg { width: 20px; height: 20px; }
.native-thread-menu-content { position: absolute; right: 0; top: 44px; z-index: 10; width: min(280px, calc(100vw - 24px)); max-height: min(440px, 65dvh); overflow: auto; overscroll-behavior: contain; padding: 12px; background: #fff; border: 1px solid #dbe4ea; border-radius: 12px; box-shadow: 0 12px 32px #173b4526; overflow-wrap: anywhere; }
.native-thread-menu-content > p { margin: 4px 0 8px; }
.native-customer-thread-head .native-thread-actions .native-thread-menu-content .button { display: flex; width: 100%; height: 40px; justify-content: flex-start; gap: 10px; padding: 8px; margin-top: 4px; }
.native-thread-actions .native-thread-menu-content .button span { display: inline; color: inherit; text-transform: none; font-size: 13px; }
.native-customer-thread-head .native-mobile-thread-back.has-return-origin { display: inline-grid; place-items: center; }
@media (max-width: 760px) {
  html:has(.native-messages-page.is-native-thread-open),
  body:has(.native-messages-page.is-native-thread-open) { overflow: hidden; overscroll-behavior: none; }
  body:has(.native-messages-page.is-native-thread-open) .mobile-tabbar { display: none; }
  #app > .native-messages-page.is-native-thread-open { position: fixed; top: var(--inbox-top, 0px); left: 0; right: 0; height: var(--inbox-height, 100dvh); min-height: 0; z-index: 900; margin: 0; padding: 0; border: 0; border-radius: 0; display: block; background: #fff; overflow: hidden; }
  .native-messages-page.is-native-thread-open .section-body,
  .native-messages-page.is-native-thread-open [data-native-message-results],
  .native-messages-page.is-native-thread-open .native-message-console.has-native-explicit-contact { height: 100%; min-height: 0; overflow: hidden; padding: 0; }
  .native-messages-page.is-native-thread-open .native-message-thread-panel { display: flex; height: 100%; min-height: 0; }
  .native-customer-thread-head { position: relative; padding-top: max(8px, env(safe-area-inset-top)); }
  .native-thread-title h3 { font-size: 16px; overflow-wrap: anywhere; }
  .native-thread-avatar { display: none; }
  .native-message-bubble-list { padding: 14px 12px; background: #fff; }
  .native-customer-composer { position: relative; bottom: auto; max-height: 48%; overflow-y: auto; overscroll-behavior: contain; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .native-customer-composer:not(:focus-within) .native-compose-bar { display: grid; }
}

.native-inbox-recovery-back { display: none; }
@media (max-width: 760px) {
  .native-messages-page.is-native-thread-open:not(:has(.native-customer-thread-head)) .native-inbox-recovery-back { display: block; position: absolute; top: max(8px, env(safe-area-inset-top)); left: 12px; z-index: 5; padding: 10px; background: #fff; border-radius: 8px; }
}
@media (max-width: 760px) {
  .native-message-console.has-native-explicit-contact { grid-template-columns: minmax(0, 1fr); }
  .native-thread-title h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .native-thread-head .native-thread-mobile-subtitle { display: none; }
  .native-thread-head .native-thread-contact-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; text-transform: none; }
  .native-customer-composer:focus-within[data-channel] .native-compose-fields-text,
  .native-customer-composer .native-compose-fields-text { display: none; }
}

/* One clear sending choice and a persistent sender label for each message. */
.native-message-bubble-list .native-mobile-message-meta {
  display: block;
  margin-bottom: 7px;
  color: #48616f;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
}
.native-message-bubble-list .native-mobile-message-time { display: none; }
.native-customer-composer .native-compose-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
}
.native-customer-composer .native-compose-channel-row { flex-wrap: nowrap; gap: 4px; }
.native-customer-composer :is(.native-compose-channel-button, .native-compose-internal-toggle) {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  font-size: 12px;
}
.native-customer-composer :is(.native-compose-channel-button, .native-compose-internal-toggle) svg { width: 18px; height: 18px; }
.native-customer-composer .native-compose-sender-email { margin-left: auto; min-width: 0; width: min(180px, 40%); }
.native-compose-sender-email select { width: 100%; min-width: 0; min-height: 44px; padding: 0 8px; text-overflow: ellipsis; }
.native-customer-composer:not([data-channel="email"]) .native-compose-sender-email { display: none; }
.native-customer-composer :is(.native-compose-destination, .native-compose-sender-email > span) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.native-customer-composer[data-channel="email"] .native-compose-fields-email { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.native-compose-email-options { grid-column: 1 / -1; min-width: 0; }
.native-compose-email-options > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--ink); font-size: 12px; }
.native-compose-email-extra { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.native-customer-composer .native-compose-fields input { min-height: 44px; }
.native-customer-composer:has(.customer-phone-assignment details[open]) { overflow: visible; z-index: 5; }
.native-customer-composer .native-compose-body { grid-template-columns: minmax(0, 1fr) auto; }
.native-customer-composer .native-compose-body .button {
  width: auto;
  min-width: 108px;
  padding: 0 12px;
  gap: 6px;
}
.native-customer-composer .native-compose-body .button span { display: inline; }
@media (max-width: 760px) {
  .native-customer-thread-head { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 6px; padding-left: 10px; padding-right: 10px; }
  .native-customer-thread-head .native-mobile-thread-back { width: 44px; height: 44px; border: 1px solid #9abadd; background: #e8f2ff; color: #0757a6; }
  .native-mobile-thread-back svg { width: 28px; height: 28px; stroke-width: 2.75; }
  .native-customer-thread-head .native-thread-actions { gap: 2px; }
  .native-customer-thread-head .native-thread-actions > .button { display: inline-flex; min-width: 44px; min-height: 44px; width: 44px; padding: 0; }
  .native-customer-composer .native-compose-bar { gap: 3px; }
  .native-customer-composer :is([data-native-channel], [data-native-internal-toggle]) { min-width: 44px; padding: 0 6px; }
  .native-customer-composer .customer-phone-assignment, .native-customer-composer .customer-phone-assignment summary { min-width: 44px; }
  .native-customer-composer :is([data-native-channel], [data-native-internal-toggle]) svg { display: none; }
  .native-customer-composer .native-compose-email-extra { grid-template-columns: minmax(0, 1fr); }
  .native-message-bubble-list .native-mobile-message-time { display: inline; }
  .native-customer-composer:not(:focus-within) .native-compose-bar { display: flex; }
  .native-customer-composer .native-compose-body .button { min-width: 44px; padding: 0 9px; }
  .native-customer-composer .native-compose-body .button span { display: none; }
}

.native-inbox-scopes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 8px 12px; border-bottom: 1px solid #dbe4ea; }
.native-inbox-scopes a { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 8px; border: 1px solid #c5d5e5; border-radius: 9px; color: #244b70; background: #fff; text-decoration: none; font-weight: 750; }
.native-inbox-scopes a:is(.active, [aria-current="page"]) { color: #0757a6; background: #e8f2ff; border-color: #9abadd; }
html[data-app-theme="dark"] .native-inbox-scopes { border-color: #34414e; }
html[data-app-theme="dark"] .native-inbox-scopes a { color: #d9eaff; background: #1c2c3c; border-color: #526878; }
html[data-app-theme="dark"] :is(.native-inbox-scopes a:is(.active, [aria-current="page"]), .native-customer-thread-head .native-mobile-thread-back) { color: #e4f1ff; background: #17385e; border-color: #698bac; }
html[data-app-theme="dark"] .native-customer-composer :is(.native-compose-channel-button, .native-compose-sender-email select, .native-compose-fields) { color: #e4f1ff; background: #1c2c3c; border-color: #526878; }
html[data-app-theme="dark"] .native-customer-composer .native-compose-fields span { color: inherit; }
html[data-app-theme="dark"] .native-customer-composer .native-compose-channel-button.active { color: #e4f1ff; background: #17385e; border-color: #698bac; }
html[data-app-theme="dark"] .native-compose-email-options > summary { color: #e4f1ff; }

/* Global inbox entry uses the shell's existing access and active-route rules. */
.topbar-actions .global-messages-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--teal-dark);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.global-messages-shortcut svg { width: 19px; height: 19px; }
.topbar-actions .global-messages-shortcut:is(:hover, :focus-visible, .active) {
  background: var(--soft);
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
}
.topbar-actions .global-messages-shortcut[hidden] { display: none; }
@media (max-width: 760px) {
  .topbar-actions .global-messages-shortcut { display: none; }
}

/* Conversation context remains usable at desktop and phone widths. */
.native-side-pane form[data-inbox-note] { display: grid; gap: 10px; margin-bottom: 18px; }
[data-inbox-note] label { display: grid; gap: 6px; font-weight: 700; }
[data-inbox-note] textarea { width: 100%; min-height: 110px; resize: vertical; box-sizing: border-box; }
[data-inbox-note] button, [data-inbox-older-media] { min-height: 44px; }
.native-side-pane .native-message-media-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.native-side-pane .native-message-media-thumb img, .native-side-pane video { width: 100%; max-height: 240px; object-fit: contain; }
.native-side-pane .native-side-list article { overflow-wrap: anywhere; }
.native-side-pane [role="status"] { white-space: normal; }
.native-contact-drawer-icons button { min-width: 44px; min-height: 44px; }
@media (max-width: 760px) {
  .native-message-console.is-context-open.has-native-explicit-contact .native-contact-drawer {
    display: grid; position: fixed; inset: var(--inbox-top, 0px) 0 auto; height: var(--inbox-height, 100dvh);
    z-index: 65; grid-template-columns: minmax(0, 1fr) 52px;
    border-left: 0; box-shadow: 0 4px 24px #0003;
  }
  .native-contact-drawer-body { padding: 12px; }
}
.native-thread-actions .button[data-inbox-context-open] { display: none; min-width: 44px; min-height: 44px; }
@media (max-width: 760px) { .native-thread-actions .button[data-inbox-context-open] { display: inline-flex; } }
.native-customer-thread-head .native-thread-actions > .button { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }
.native-messages-page .native-customer-thread-head .native-thread-actions > .button[data-native-thread-refresh] { display: inline-flex; min-width: 44px; min-height: 44px; }
.native-customer-thread-head [data-native-dial-focus] { order: 0; }
.native-customer-thread-head [data-native-thread-refresh] { order: 1; }
.native-customer-thread-head [data-inbox-context-open] { order: 2; }
.native-customer-thread-head .native-thread-menu { order: 3; }
.native-thread-refresh-status { grid-column: 1 / -1; flex-basis: 100%; margin: 0; color: #a22727; font-size: 12px; }
.native-customer-thread-head:has(.native-thread-refresh-status) { flex-wrap: wrap; }
html[data-app-theme="dark"] .native-thread-refresh-status { color: #ffb4b4; }

html[data-app-theme="dark"] .native-messages-page .native-message-bubble-list { background: #15212d; }
html[data-app-theme="dark"] .inbox-bulk button { background: #233342; color: #b8d7ff; border-color: #4a5b6b; }
