.mail-nav-badge,
.mail-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 .38rem;
  margin-left: auto;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
  flex: 0 0 auto;
}

.mail-shell { max-width: 1040px; margin: 0 auto; min-width: 0; }
.mail-shell--narrow { max-width: 760px; }
.mail-shell--thread { max-width: 920px; }
.mail-shell button,
.mail-shell .btn-avi,
.mail-shell .btn-avi-outline,
[data-mail-profile-action] { min-height: 44px; }
.mail-page-header,
.mail-thread-header,
.mail-thread-identity,
.mail-row-topline,
.mail-form-actions,
.mail-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.mail-page-header h1,
.mail-thread-header h1 { margin: .25rem 0 0; overflow-wrap: anywhere; }
.mail-kicker { color: var(--accent, #38bdf8); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.mail-back-link { color: var(--muted, #94a3b8); text-decoration: none; font-size: .9rem; }
.mail-tabs { display: flex; gap: .45rem; overflow-x: auto; padding: 1rem 0; }
.mail-tabs a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; white-space: nowrap; padding: .65rem .9rem; border-radius: .65rem; color: inherit; text-decoration: none; border: 1px solid rgba(148,163,184,.25); }
.mail-tabs a.active { border-color: var(--accent, #38bdf8); background: rgba(56,189,248,.12); }
.mail-list { display: grid; gap: .65rem; }
.mail-row { border: 1px solid rgba(148,163,184,.2); border-radius: .85rem; background: rgba(15,23,42,.58); overflow: hidden; }
.mail-row--unread { border-color: rgba(56,189,248,.55); background: rgba(14,116,144,.13); }
.mail-row-main { display: flex; align-items: center; gap: .85rem; min-width: 0; padding: .9rem; color: inherit; text-decoration: none; }
.mail-row-copy { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.mail-row-topline strong,
.mail-row-subject,
.mail-row-preview { overflow-wrap: anywhere; }
.mail-row-topline time,
.mail-message time { color: var(--muted, #94a3b8); font-size: .78rem; white-space: nowrap; }
.mail-row-identity { color: var(--muted, #94a3b8); font-size: .78rem; }
.mail-row-subject { margin-top: .2rem; font-weight: 700; }
.mail-row-preview { color: var(--muted, #94a3b8); font-size: .9rem; }
.mail-row-action { padding: 0 .9rem .9rem 4.8rem; }
.mail-empty { padding: 2rem; text-align: center; color: var(--muted, #94a3b8); }
.mail-pagination { margin-top: 1rem; justify-content: center; flex-wrap: wrap; }
.mail-feedback { margin: .7rem 0; padding: .75rem .9rem; border-radius: .65rem; }
.mail-feedback--ok { background: rgba(34,197,94,.13); border: 1px solid rgba(34,197,94,.35); }
.mail-feedback--error { background: rgba(239,68,68,.13); border: 1px solid rgba(239,68,68,.35); }
.mail-form { display: grid; gap: 1rem; padding: 1rem; }
.mail-field { display: grid; gap: .45rem; min-width: 0; }
.mail-field label { font-weight: 700; }
.mail-textarea { width: 100%; max-width: 100%; min-width: 0; resize: vertical; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-selected-recipient { display: flex; align-items: center; gap: .7rem; padding: .65rem; border-radius: .65rem; background: rgba(56,189,248,.08); }
.mail-selected-recipient-copy { display: grid; min-width: 0; }
.mail-selected-recipient strong,
.mail-selected-recipient small { overflow-wrap: anywhere; }
.mail-recipient-results { display: grid; gap: .35rem; }
.mail-recipient-result { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .65rem; text-align: left; border: 1px solid rgba(148,163,184,.25); border-radius: .65rem; background: transparent; color: inherit; cursor: pointer; }
.mail-recipient-result-copy { display: grid; min-width: 0; }
.mail-thread-header { align-items: flex-start; margin-bottom: 1rem; }
.mail-thread-identity { justify-content: flex-start; min-width: 0; }
.mail-thread-identity > div { min-width: 0; }
.mail-thread-person,
.mail-private-note { color: var(--muted, #94a3b8); }
.mail-private-note { font-size: .86rem; }
.mail-older { text-align: center; margin: .7rem 0; }
.mail-messages { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.mail-message { width: 100%; max-width: none; box-sizing: border-box; justify-self: stretch; padding: .85rem; border: 1px solid rgba(148,163,184,.23); border-radius: .55rem; background: rgba(15,23,42,.62); min-width: 0; }
.mail-message--self { background: rgba(14,116,144,.12); border-color: rgba(56,189,248,.3); }
.mail-message--other { background: rgba(15,23,42,.62); border-color: rgba(148,163,184,.23); }
.mail-message header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .45rem; }
.mail-message-body { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.mail-reply-form { margin-top: 1rem; }

@media (max-width: 640px) {
  .mail-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .mail-tabs a { min-width: 0; white-space: normal; text-align: center; }
  .mail-page-header,
  .mail-thread-header { align-items: stretch; flex-direction: column; }
  .mail-row-main { align-items: flex-start; }
  .mail-row-topline { align-items: flex-start; flex-direction: column; gap: .15rem; }
  .mail-row-topline time { white-space: normal; }
  .mail-row-action { padding-left: .9rem; }
  .mail-message header { flex-direction: column; gap: .15rem; }
  .mail-form-actions { align-items: stretch; flex-direction: column; }
  .mail-form-actions .btn-avi,
  .mail-form-actions .btn-avi-outline,
  .mail-thread-header button,
  .mail-row-action button { min-height: 44px; width: 100%; }
}
