.communications-inbox-summary {
  min-width: 0;
}

.communications-inbox-toolbar {
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 410px);
}

.communications-inbox-filters {
  display: block;
  min-width: 0;
}

.communications-inbox-filters > summary {
  display: none;
}

.communications-inbox-filter-fields {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(160px, 210px);
  gap: 10px;
  align-items: end;
}

.communications-inbox-refresh-icon,
.communications-thread-back {
  display: none;
}

@media (max-width: 980px) {
  .communications-inbox-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .communications-inbox-filter-fields {
    grid-column: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .content #panel-communications-inbox > .card {
    padding-inline: 0;
    padding-top: 8px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .content #panel-communications-inbox .ops-page-head {
    min-height: 44px;
    margin-bottom: 4px;
  }

  .content #panel-communications-inbox .ops-page-actions {
    flex: 0 0 auto;
    width: auto;
    justify-content: flex-end;
  }

  .content #panel-communications-inbox .ops-page-copy {
    min-width: 0;
  }

  .content #panel-communications-inbox .ops-page-copy h2 {
    font-size: 17px;
    line-height: 1.2;
  }

  .content #panel-communications-inbox .ops-page-actions > .communications-inbox-refresh {
    flex: 0 0 44px;
    width: 44px !important;
    max-width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
  }

  .content #panel-communications-inbox button,
  .content #panel-communications-inbox a.btn-ghost,
  .content #panel-communications-inbox select,
  .content #panel-communications-inbox input,
  .content #panel-communications-inbox summary {
    min-width: 44px;
    min-height: 44px;
  }

  .communications-inbox-refresh-icon {
    display: inline;
    font-size: 22px;
    line-height: 1;
  }

  .communications-inbox-refresh-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .communications-inbox-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    margin: 4px 0 8px;
  }

  .communications-inbox-summary {
    display: grid;
    gap: 2px;
    min-height: 24px;
  }

  .communications-inbox-summary .ops-summary-status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .communications-inbox-summary .ops-helper {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 24px;
  }

  .communications-inbox-filters {
    display: block;
    min-width: 0;
  }

  .communications-inbox-filters:not([data-mobile-shell-ready]) .communications-inbox-filter-fields {
    display: none;
  }

  .communications-inbox-filters > summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    list-style: none;
  }

  .communications-inbox-filters > summary::-webkit-details-marker {
    display: none;
  }

  .communications-inbox-filters > summary::after {
    content: "+";
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1;
  }

  .communications-inbox-filters[open] > summary::after {
    content: "−";
  }

  .communications-inbox-filter-summary {
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .communications-inbox-filter-fields {
    grid-column: auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px 0 0;
  }

  .communications-inbox-filter-fields select {
    min-height: 44px;
  }

  .content #panel-communications-inbox .admin-mobile-section-tabs {
    position: sticky;
    top: calc(116px + env(safe-area-inset-top, 0px));
    z-index: 8;
    min-height: 44px;
    margin: 0;
    padding-top: 4px;
    background: #ffffff;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.06);
  }

  .content #panel-communications-inbox .admin-mobile-section-tabs button {
    min-height: 44px;
  }

  .communications-thread-back {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 10px;
    border: 0;
    border-radius: 9px;
    background: #eef2ff;
    color: #1e3a8a;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
  }

  .communications-mailbox,
  .communications-unmatched-panel {
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .communications-mailbox-pane-head,
  .communications-conversation-head {
    padding-inline: 8px;
    background: #ffffff;
  }

  .communications-mailbox-list,
  .communications-mailbox-detail,
  .communications-unmatched-panel,
  .communications-unmatched-list {
    min-width: 0;
    width: 100%;
  }

  .communications-thread-row {
    min-height: 64px;
    padding: 10px 8px 10px 11px;
  }

  .communications-thread-row-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .content #panel-communications-inbox button.communications-thread-name {
    width: auto;
    min-width: 0;
    min-height: 0;
    border-radius: 0;
  }

  .content #panel-communications-inbox .communications-thread-select {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .communications-thread-head-meta {
    max-width: 62%;
    flex-wrap: wrap;
    gap: 4px;
  }

  .communications-thread-badges {
    gap: 4px;
  }

  .communications-thread-preview {
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
  }

  .communications-mailbox-detail {
    height: calc(100dvh - 164px - env(safe-area-inset-bottom, 0px));
    min-height: 0;
    max-height: calc(100dvh - 164px - env(safe-area-inset-bottom, 0px));
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    overflow: hidden;
    overscroll-behavior: contain;
  }

  .communications-conversation-head {
    min-width: 0;
    align-items: center;
    padding: 8px 10px;
  }

  .communications-conversation-head .ops-surface-copy {
    min-width: 0;
  }

  .communications-conversation-head .ops-surface-title,
  .communications-conversation-head .ops-helper {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .communications-thread-settings summary {
    min-height: 44px;
    padding: 8px 10px;
  }

  .communications-message-list {
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    padding: 8px;
  }

  .communications-message {
    width: min(100%, 760px);
    min-width: 0;
    border: 0;
    border-radius: 10px;
    box-shadow: none;
  }

  .communications-message-body,
  .communications-message-subject,
  .communications-message-meta {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .communications-message-details {
    border-top: 1px solid rgba(100, 116, 139, 0.2);
  }

  .communications-message-details > summary {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    list-style-position: inside;
  }

  .communications-message-details > .communications-message-meta {
    padding-bottom: 4px;
  }

  .communications-reply-box {
    position: relative;
    z-index: 3;
    gap: 6px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 18px rgba(15, 23, 42, 0.08);
  }

  .communications-reply-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 8px;
  }

  .communications-reply-grid > .ops-field,
  .communications-reply-box > .ops-field {
    min-width: 0;
  }

  .communications-reply-grid .ops-field-label,
  .communications-reply-box > .ops-field > .ops-field-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .communications-reply-box textarea {
    min-height: 44px;
    max-height: 120px;
    resize: none;
    overflow-wrap: anywhere;
  }

  .communications-reply-box > .row {
    min-width: 0;
    margin-top: 0 !important;
  }

  .communications-reply-box .ops-summary-status {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .communications-mailbox-detail.is-composer-focused .communications-conversation-head,
  .communications-mailbox-detail.is-composer-focused .communications-thread-settings,
  .communications-mailbox-detail.is-composer-focused .communications-reply-grid {
    display: none;
  }

  .communications-unmatched-list {
    padding: 0;
  }

  .communications-unmatched-card {
    gap: 8px;
    margin: 0;
    padding: 10px 8px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
  }

  .communications-unmatched-card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .communications-unmatched-card-head .muted {
    grid-column: 1 / -1;
  }

  .content #panel-communications-inbox .communications-unmatched-card-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 8px;
  }

  .content #panel-communications-inbox .communications-unmatched-card-actions > .ops-field {
    grid-column: 1 / -1;
  }

  .content #panel-communications-inbox .communications-unmatched-card-actions button {
    width: 100%;
  }
}
