/* global-communication-hub-20260807-v1: inbox and unified read/reply overlay */
.global-communication-hub {
  position: fixed;
  right: 18px;
  bottom: 82px;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(330px, calc(100vw - 36px));
  max-height: min(360px, calc(100vh - 150px));
  overflow: hidden;
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 97%, transparent);
  box-shadow: 0 14px 34px rgb(16 38 56 / 16%);
}

.global-communication-hub[hidden] {
  display: none;
}

.global-communication-hub > header,
.global-message-compose > header,
.global-message-original > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.global-communication-hub > header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--rule);
}

.global-communication-hub h2,
.global-message-overlay h2,
.global-message-overlay h3,
.global-message-overlay h4 {
  margin: 0;
}

.global-communication-hub h2 {
  font-size: 16px;
}

.global-communication-hub h2 span {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  place-items: center;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
}

.global-communication-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.global-communication-header-actions button,
.global-communication-hub > header a {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}

.global-communication-feed {
  display: grid;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--ink) 42%, transparent) var(--surface-subtle, #f7f8f9);
  scrollbar-gutter: stable;
}

.global-communication-feed::-webkit-scrollbar,
.global-message-overlay-body::-webkit-scrollbar {
  width: 10px;
}

.global-communication-feed::-webkit-scrollbar-track,
.global-message-overlay-body::-webkit-scrollbar-track {
  background: var(--surface-subtle, #f7f8f9);
}

.global-communication-feed::-webkit-scrollbar-thumb,
.global-message-overlay-body::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface-subtle, #f7f8f9);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
}

.global-communication-feed-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.global-communication-feed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: start;
  border-bottom: 1px solid var(--rule);
}

.global-communication-feed-dismiss {
  display: inline-grid;
  width: var(--bona-button-height, 36px);
  height: var(--bona-button-height, 36px);
  place-items: center;
  margin: 6px 4px 0 0;
  padding: 0;
  border: 0;
  border-radius: var(--bona-radius-control, 8px);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  line-height: 1;
}

.global-communication-feed-dismiss:hover,
.global-communication-feed-dismiss:focus-visible {
  background: var(--surface-raised, #f2f5f7);
  color: var(--ink);
}

.global-communication-feed-dismiss:focus-visible {
  outline: none;
  box-shadow: var(--bona-focus-ring, 0 0 0 2px var(--accent));
}

.global-communication-feed-item:hover,
.global-communication-feed-item:focus-visible,
.global-communication-feed-item[aria-current="true"] {
  background: var(--surface-raised, #f2f5f7);
}

.global-communication-feed-item.is-unread {
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.global-communication-feed-top,
.global-communication-feed-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.global-communication-feed-top strong,
.global-communication-feed-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-communication-feed-top small,
.global-communication-feed-preview,
.global-communication-feed-meta,
.global-communication-status {
  color: var(--muted);
  font-size: 10px;
}

.global-communication-feed-preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.global-communication-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 14px;
  background: var(--surface-subtle, #f7f8f9);
}

.global-communication-status {
  min-width: 0;
  flex: 1;
  margin: 0;
}

.global-communication-status-bar button {
  flex: none;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  text-decoration: underline;
}

.global-communication-hub-restore {
  right: 18px;
  bottom: 82px;
  z-index: 40;
  width: min(230px, calc(100vw - 36px));
}

.global-communication-hub-restore strong span {
  display: inline-grid;
  min-width: 20px;
  min-height: 20px;
  place-items: center;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
}

.global-message-overlay {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 60;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  width: min(760px, calc(100vw - 56px));
  height: min(850px, calc(100vh - 56px));
  overflow: hidden;
  resize: both;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 22px 60px rgb(16 38 56 / 24%);
}

.global-message-overlay[hidden] {
  display: none;
}

.global-message-overlay [hidden] {
  display: none;
}

.global-message-overlay-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-raised, #f2f5f7);
  cursor: move;
}

.global-message-overlay-header h2 {
  max-width: 560px;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-message-overlay-header small {
  color: var(--muted);
}

.global-message-window-actions,
.global-message-compose-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.global-message-overlay-body {
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--ink) 42%, transparent) var(--surface-subtle, #f7f8f9);
  scrollbar-gutter: stable;
}

.global-message-loading {
  min-height: 240px;
  place-content: center;
  grid-template-columns: auto minmax(0, 360px);
  align-items: center;
  gap: 14px;
  padding: 32px;
  color: var(--ink);
}

.global-message-loading:not([hidden]) {
  display: grid;
}

.global-message-loading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.global-message-loading button {
  grid-column: 2;
  justify-self: start;
}

.global-message-loading-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: global-message-loading-spin 800ms linear infinite;
}

@keyframes global-message-loading-spin {
  to { transform: rotate(360deg); }
}

.global-message-loading button:not([hidden]) ~ .global-message-loading-spinner,
.global-message-loading:has([data-global-message-retry]:not([hidden])) .global-message-loading-spinner {
  animation: none;
  border-color: var(--critical, #9d2b2b);
}

@media (prefers-reduced-motion: reduce) {
  .global-message-loading-spinner { animation: none; }
}

.global-message-compose,
.global-message-original {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.global-message-compose {
  border-bottom: 3px solid var(--ink);
  background: var(--paper);
}

.global-message-compose h3,
.global-message-original h3 {
  font-size: 18px;
}

.global-message-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 10px;
}

.global-message-fields label,
.global-message-copy-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.global-message-fields input,
.global-message-copy-fields input {
  min-height: 36px;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
}

.global-message-copy-fields > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
}

.global-message-copy-fields[open] {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.global-message-copy-fields[open] > summary {
  grid-column: 1 / -1;
}

.global-message-signature .reply-signature-preview {
  max-height: 250px;
  overflow: auto;
}

.reply-signature-preview {
  line-height: 1.62;
}

.reply-signature-preview-disclaimer {
  line-height: 1.875;
}

.global-message-original {
  background: var(--surface-subtle, #f7f8f9);
}

.global-message-original > header span {
  color: var(--muted);
  font-size: 11px;
}

.global-message-original-meta {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  background: var(--paper);
}

.global-message-original-meta div {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
}

.global-message-original-meta dt {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.global-message-original-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.global-message-original-body {
  min-width: 0;
  min-height: 160px;
  overflow-wrap: anywhere;
  padding: 16px;
  border: 1px solid var(--rule);
  background: #fff;
}

.global-message-original-attachments {
  display: grid;
  gap: 8px;
}

.global-message-attachment {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
}

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

.global-message-minimized-tab {
  right: 18px;
  bottom: 18px;
  z-index: 60;
}

@media (max-width: 768px) {
  .global-communication-hub {
    right: 10px;
    bottom: 70px;
    width: calc(100vw - 20px);
    max-height: 230px;
  }

  .global-communication-hub-restore {
    right: 10px;
    bottom: 70px;
    width: min(230px, calc(100vw - 20px));
  }

  .global-message-overlay {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    resize: none;
    border: 0;
  }

  .global-message-overlay-header {
    flex-direction: column;
    cursor: default;
  }

  .global-message-overlay-header > div:first-child,
  .global-message-window-actions {
    width: 100%;
    min-width: 0;
  }

  .global-message-overlay-header h2 {
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .global-message-window-actions {
    justify-content: flex-end;
  }

  .global-message-fields,
  .global-message-copy-fields[open] {
    grid-template-columns: 1fr;
  }

  .global-message-copy-fields[open] > summary {
    grid-column: auto;
  }

  .global-message-compose,
  .global-message-original {
    padding: 14px;
  }
}
