@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;800;900&family=DM+Sans:wght@400;500;600;700&display=swap');

/* ─── THEME TOKENS ───────────────────────────────────────────────────────── */
:root {
  --black: #000000;
  --white: #FFFFFF;
  --grey-light: #f2f2f2;
  --grey-mid: #888888;
  --border: 1px solid #000000;
  --border-thick: 2px solid #000000;
  --font-display: 'Playfair Display', serif;
  --font-ui: 'DM Sans', sans-serif;
  --transition: 0.15s ease;

  /* Semantic tokens — light mode */
  --bg:           #ffffff;
  --bg-subtle:    #f2f2f2;
  --fg:           #000000;
  --fg-muted:     #888888;
  --border-color: #000000;
  --input-bg:     #ffffff;
  --overlay-bg:   rgba(0,0,0,0.6);
  --danger:       #c0392b;
  --danger-hover: #96281b;
}

[data-theme="dark"] {
  --bg:           #111111;
  --bg-subtle:    #1e1e1e;
  --fg:           #f0f0f0;
  --fg-muted:     #777777;
  --border-color: #444444;
  --input-bg:     #1a1a1a;
  --overlay-bg:   rgba(0,0,0,0.8);
  --black:        #f0f0f0;
  --white:        #111111;
  --grey-light:   #1e1e1e;
  --grey-mid:     #777777;
  --border:       1px solid #444444;
  --border-thick: 2px solid #444444;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.2s ease, color 0.2s ease;
}

.site-header {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--white); border-bottom: var(--border); z-index: 100;
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.site-logo {
  font-family: var(--font-display); font-size: 1.2rem; color: var(--fg);
  text-decoration: none; letter-spacing: 0.01em;
  display: inline-flex; align-items: center; gap: 10px;
}
.site-logo:hover { opacity: 0.7; }
.site-logo-img {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
  /* Logo is dark on transparent — invert to white in dark mode */
  filter: none;
  transition: filter var(--transition);
}
[data-theme="dark"] .site-logo-img {
  filter: invert(1);
}
.site-nav { display: flex; gap: 24px; align-items: center; }
.nav-link {
  font-family: var(--font-ui); font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--black);
  text-decoration: none; transition: opacity var(--transition);
}
.nav-link:hover { opacity: 0.5; }
.nav-link.disabled { opacity: 0.3; pointer-events: none; cursor: default; }

.page-content { padding-top: 56px; min-height: 100vh; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; border-radius: 0;
  cursor: pointer; padding: 14px 28px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  border: none; outline: none; text-decoration: none; white-space: nowrap;
}
.btn:focus-visible { outline: 3px solid var(--black); outline-offset: 2px; }
.btn-primary { background: var(--black); color: var(--white); border: var(--border-thick); border-color: var(--black); }
.btn-primary:hover { background: var(--white); color: var(--black); }
.btn-secondary { background: var(--white); color: var(--black); border: var(--border-thick); }
.btn-secondary:hover { background: var(--black); color: var(--white); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
  font-family: var(--font-ui); font-size: 1rem; color: var(--black);
  background: var(--white); border: var(--border); border-radius: 0;
  padding: 12px 14px; width: 100%; outline: none;
  transition: border var(--transition); appearance: none; -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus { border: var(--border-thick); }
/* Hide number input spinners — design uses plain styled inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { appearance: textfield; }
input::placeholder, textarea::placeholder { color: var(--grey-mid); }
textarea { resize: vertical; min-height: 160px; }

.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px; color: var(--black);
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--black); color: var(--white);
  font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 10px 5px 12px; border: 2px solid var(--black);
}
.pill-remove {
  background: none; border: none; color: var(--white); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0;
  display: flex; align-items: center; opacity: 0.7; transition: opacity var(--transition);
}
.pill-remove:hover { opacity: 1; }
.pill-static { background: var(--grey-light); color: var(--black); border-color: var(--black); }
.pill-static .pill-type { color: var(--grey-mid); text-transform: uppercase; font-size: 0.65rem; }
.pills-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border: var(--border-thick); padding: 32px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  transform: translateY(-16px); transition: transform 0.2s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-family: var(--font-display); font-size: 1.7rem; margin-bottom: 20px; letter-spacing: 0; line-height: 1.15; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; min-width: 120px; }

.home-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - 56px); padding: 40px 24px; text-align: center;
}
.human-count {
  font-family: var(--font-display); font-size: clamp(4rem, 18vw, 10rem);
  line-height: 1.05; letter-spacing: -0.02em; margin-bottom: 8px;
}
.human-label {
  font-family: var(--font-ui); font-size: 0.85rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--grey-mid); margin-bottom: 20px;
}

/* ─── QUOTA METER ────────────────────────────────────────────────────────── */
.quota-meter-wrap {
  width: 100%; max-width: 320px;
  margin-bottom: 24px;
}
.quota-bar-track {
  position: relative; width: 100%; height: 4px;
  background: var(--bg-subtle); border: 1px solid var(--border-color);
  overflow: visible;
}
.quota-bar-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 0%; max-width: 100%;
  background: var(--quota-color, #2ecc71);
  transition: background 0.4s ease;
  transform-origin: left;
}
/* The free-limit tick mark at the 100-user position */
.quota-free-line {
  position: absolute; top: -4px; bottom: -4px;
  width: 2px; background: var(--fg); opacity: 0.25;
  left: calc(50 / 150 * 100%); /* assuming 300 max visual range */
  pointer-events: none;
}
.quota-legend {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}
.quota-status {
  font-family: var(--font-ui); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 3px 8px; border: 1.5px solid currentColor;
  transition: color 0.4s ease, border-color 0.4s ease, background 0.4s ease;
}
.quota-free   { color: #1a8a4a; background: rgba(26,138,74,0.08); }
.quota-over   { color: var(--fg-muted); background: transparent; }
[data-theme="dark"] .quota-free { color: #4cd98a; background: rgba(76,217,138,0.1); }
[data-theme="dark"] .quota-over { color: var(--fg-muted); background: transparent; }
.quota-limit-label {
  font-size: 0.65rem; color: var(--fg-muted); letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Count colour shifts */
.human-count { transition: color 0.4s ease; }
.human-count--free { color: #1a8a4a; }
[data-theme="dark"] .human-count--free { color: #4cd98a; }
.home-actions {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 320px; margin-top: 8px;
}
#active-filters { min-height: 0; transition: min-height 0.2s; }

.filter-categories { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filter-cat-btn {
  font-family: var(--font-ui); font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; padding: 8px 16px;
  border: var(--border-thick); background: var(--white); color: var(--black); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.filter-cat-btn:hover, .filter-cat-btn.active { background: var(--black); color: var(--white); }
[data-theme="dark"] .filter-cat-btn:hover,
[data-theme="dark"] .filter-cat-btn.active { background: #ffffff; color: #111111; }

.compose-page { padding: 40px 24px 80px; max-width: 640px; margin: 0 auto; }
.page-title { font-family: var(--font-display); font-size: clamp(1.9rem, 7vw, 3rem); letter-spacing: -0.01em; margin-bottom: 8px; line-height: 1.1; }
.page-subtitle { font-size: 0.85rem; color: var(--grey-mid); letter-spacing: 0.05em; margin-bottom: 40px; }

.info-panel { background: var(--grey-light); border: var(--border); padding: 20px; margin: 24px 0; }
.info-panel-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; font-size: 0.85rem; }
.info-panel-row:last-child { margin-bottom: 0; }
.info-label { font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; font-size: 0.72rem; color: var(--grey-mid); flex-shrink: 0; }
.info-value { font-size: 0.9rem; text-align: right; }
code { font-family: 'Courier New', monospace; font-size: 0.8rem; background: var(--white); border: var(--border); padding: 2px 6px; word-break: break-all; }

.payment-section { border: var(--border-thick); padding: 24px; margin: 24px 0; }
.payment-section-title { font-family: var(--font-display); font-size: 1.35rem; margin-bottom: 8px; line-height: 1.2; }
.payment-amount { font-size: 0.9rem; color: var(--grey-mid); margin-bottom: 20px; }

.messages-page { padding: 40px 24px 80px; max-width: 800px; margin: 0 auto; }
.messages-list { margin-top: 24px; border-top: var(--border-thick); }
.message-row {
  border-bottom: var(--border); padding: 16px 0; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  gap: 4px 12px; transition: background var(--transition);
}
.message-row:hover { background: var(--grey-light); margin: 0 -8px; padding: 16px 8px; }
.message-sender { font-size: 0.8rem; color: var(--grey-mid); letter-spacing: 0.05em; text-transform: uppercase; }
.message-subject { font-size: 1rem; font-weight: 400; color: var(--black); }
.message-row.unread .message-subject { font-weight: 800; }
.message-meta { font-size: 0.75rem; color: var(--grey-mid); text-align: right; white-space: nowrap; }
.expiry-soon { font-weight: 700; color: var(--black); }
.reported-flag { font-size: 1rem; line-height: 1; margin-left: 4px; }
.empty-state { text-align: center; padding: 80px 20px; color: var(--grey-mid); }
.empty-state-title { font-family: var(--font-display); font-size: 1.8rem; margin-bottom: 12px; color: var(--fg); line-height: 1.15; }

.message-detail-from { font-size: 0.75rem; color: var(--grey-mid); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
.message-detail-from a { color: inherit; text-decoration: none; }
.message-detail-subject { font-family: var(--font-display); font-size: 1.7rem; line-height: 1.2; margin-bottom: 12px; }
.message-detail-body { font-size: 0.95rem; line-height: 1.75; white-space: pre-wrap; margin: 20px 0; }
.message-detail-footer { font-size: 0.75rem; color: var(--grey-mid); border-top: var(--border); padding-top: 16px; margin-top: 20px; }
.detail-meta-row { display: flex; justify-content: space-between; margin-bottom: 6px; }

.report-options { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.report-option-btn {
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.05em; padding: 12px 16px; border: var(--border);
  background: var(--white); color: var(--black); cursor: pointer; text-align: left;
  transition: background var(--transition), color var(--transition);
}
.report-option-btn:hover, .report-option-btn.selected { background: var(--fg); color: var(--bg); }

/* ─── SORT POPUP OPTIONS ─────────────────────────────────────────────────── */
.sort-options { display: flex; flex-direction: column; gap: 0; margin: 16px 0; border: var(--border-thick); }
.sort-option-btn {
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 500;
  letter-spacing: 0.03em; padding: 13px 16px;
  border: none; border-bottom: var(--border);
  background: var(--bg); color: var(--fg);
  cursor: pointer; text-align: left; width: 100%;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sort-option-btn:last-child { border-bottom: none; }
.sort-option-btn:hover { background: var(--fg); color: var(--bg); }
.sort-option-btn.selected {
  background: var(--fg); color: var(--bg);
  font-weight: 700;
}
.sort-option-btn.selected::after {
  content: '✓';
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 0.85rem; opacity: 0.8;
}
[data-theme="dark"] .sort-option-btn { background: var(--bg); color: var(--fg); }
[data-theme="dark"] .sort-option-btn:hover { background: var(--fg); color: var(--bg); }
[data-theme="dark"] .sort-option-btn.selected { background: var(--fg); color: var(--bg); }

.profile-page { padding: 40px 24px 80px; max-width: 640px; margin: 0 auto; }
.profile-section { margin-bottom: 40px; }
.profile-section-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--grey-mid); margin-bottom: 16px; }
.filter-add-row { display: flex; gap: 8px; margin-top: 12px; }
.filter-add-row input { flex: 1; }
.filter-add-row .btn { flex-shrink: 0; padding: 12px 20px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; min-height: 36px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--white);
  color: var(--black); font-family: var(--font-ui); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.03em; padding: 6px 10px 6px 14px; border: var(--border-thick);
}
.chip-remove {
  background: none; border: none; cursor: pointer; color: var(--black);
  font-size: 1rem; line-height: 1; padding: 0; opacity: 0.5;
  transition: opacity var(--transition); display: flex; align-items: center;
}
.chip-remove:hover { opacity: 1; }

.account-actions { border-top: var(--border-thick); padding-top: 32px; margin-top: 40px; display: flex; flex-direction: column; gap: 12px; }
.account-actions-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--grey-mid); margin-bottom: 8px; }
input.max-recipients-input { width: 130px; }

/* Email notifications toggle row */
.notification-pref-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: var(--border); }
.notification-pref-label { display: flex; flex-direction: column; gap: 4px; }
.notification-pref-title { font-size: 0.9rem; font-weight: 600; }
.notification-pref-desc { font-size: 0.78rem; color: var(--grey-mid); line-height: 1.4; max-width: 340px; }

.toggle-btn {
  position: relative; flex-shrink: 0;
  width: 44px; height: 24px;
  background: var(--grey-light); border: 1px solid var(--grey-mid);
  border-radius: 999px; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}
.toggle-btn[aria-checked="true"] { background: var(--fg); border-color: var(--fg); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  transition: transform 0.2s;
  display: block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-btn[aria-checked="true"] .toggle-knob { transform: translateX(20px); }
[data-theme="dark"] .toggle-btn { background: var(--grey-mid); border-color: var(--grey-mid); }
[data-theme="dark"] .toggle-btn[aria-checked="true"] { background: var(--fg); border-color: var(--fg); }
[data-theme="dark"] .toggle-knob { background: var(--bg); }

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
  border-width: 2px;
}
.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.login-box { max-width: 480px; margin: 0 auto; }
.login-intro { margin-bottom: 32px; }
.login-intro p { font-size: 0.9rem; color: var(--grey-mid); margin-top: 8px; line-height: 1.6; }
.login-response { margin-top: 16px; font-size: 0.85rem; font-weight: 600; border: var(--border); padding: 12px 16px; background: var(--grey-light); }

.warning-text { font-size: 0.85rem; color: var(--grey-mid); line-height: 1.6; margin-bottom: 16px; }
.confirm-delete-input { margin-top: 16px; }

#toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; width: calc(100vw - 48px); max-width: 400px;
}
.toast {
  background: var(--white); border: var(--border-thick); padding: 14px 40px 14px 16px;
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  position: relative; overflow: hidden; pointer-events: all; width: 100%;
  animation: toastIn 0.2s ease forwards;
}
.toast.dismissing { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(8px); opacity: 0; } }
.toast-close {
  position: absolute; top: 10px; right: 10px; background: none; border: none;
  cursor: pointer; font-size: 1rem; line-height: 1; color: var(--black);
  opacity: 0.5; transition: opacity var(--transition);
}
.toast-close:hover { opacity: 1; }
.toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--black); animation: toastProgress 4s linear forwards; }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }
.toast.success { border-left: 4px solid var(--black); }
.toast.error { border-left: 4px solid var(--black); background: var(--black); color: var(--white); }
.toast.error .toast-close { color: var(--white); }
.toast.error .toast-progress { background: var(--white); }
.toast.info { border-left: 4px solid var(--grey-mid); }

.divider { border: none; border-top: var(--border); margin: 32px 0; }
.loading { text-align: center; padding: 60px 20px; color: var(--grey-mid); font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase; }

@media (min-width: 640px) {
  .home-actions { flex-direction: row; max-width: none; justify-content: center; }
  .home-actions .btn { max-width: 240px; }
}
@media (max-width: 375px) {
  .site-header { padding: 0 16px; }
  .compose-page, .messages-page, .profile-page { padding-left: 16px; padding-right: 16px; }
  .modal { padding: 24px 20px; }
}

/* ─── THEME TOGGLE BUTTON — desktop ─────────────────────────────────────── */
#theme-toggle {
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;           /* kill any stray text/emoji on ALL screen sizes */
  flex-shrink: 0;
  transition: opacity var(--transition);
  padding: 0;
  position: relative;
}
#theme-toggle:hover { opacity: 0.5; }
 
/* SVG icon via ::before — moon in light mode, sun in dark mode.
   Applies on EVERY screen size; the media-query block below just
   widens the tap target on mobile without redefining the icon. */
#theme-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  background-color: var(--fg);
  /* Moon — light mode */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-position: center;
          mask-position: center;
  pointer-events: none;
  transition: opacity var(--transition);
}
 
/* Sun — dark mode */
[data-theme="dark"] #theme-toggle::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/svg%3E");
}

/* ─── MOBILE HEADER — icon nav ───────────────────────────────────────────── */
@media (max-width: 820px) {
  /* ── Full-width 4-column grid — each slot is exactly 25vw ── */
  .site-header {
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 equal columns = 25vw each */
    align-items: stretch;
    width: 100%;
  }
 
  /* logo occupies column 1; nav (which holds 2 links + button) spans columns 2-4 */
  .site-logo {
    grid-column: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 56px;
    width: 100%;
    font-size: 0; /* hide wordmark, show only logo image */
    gap: 0;
    padding: 0;
  }
  .site-logo-img { height: 28px; }
 
  /* Nav: 3 items in a 3-column sub-grid that fills the remaining 3 slots */
  .site-nav {
    grid-column: 2 / 5;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: stretch;
    gap: 0;
    height: 56px;
  }
 
  /* Every nav child (links + button) becomes a full-height centred tap target */
  .site-nav > * {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 56px;
  }
 
  /* Nav links: collapse text, keep the icon pseudo-element */
  .nav-link {
    font-size: 0;
    letter-spacing: 0;
    padding: 0;
  }
 
  /* ── Messages icon ── */
  #nav-messages::before,
  .site-nav a[href="/messages"]::before {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-size: contain;
            mask-size: contain;
    -webkit-mask-position: center;
            mask-position: center;
    transition: opacity var(--transition);
    flex-shrink: 0;
  }
 
  /* ── Profile icon ── */
  .site-nav a[href="/profile"]::before {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 20c0-4 3.6-7 8-7s8 3 8 7'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 20c0-4 3.6-7 8-7s8 3 8 7'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-size: contain;
            mask-size: contain;
    -webkit-mask-position: center;
            mask-position: center;
    transition: opacity var(--transition);
    flex-shrink: 0;
  }
 
  /* ── Theme toggle — widen tap target only; icon already defined above ── */
  #theme-toggle {
    width: 100%;
    height: 56px;
  }
  /* ::before icon size bump for mobile */
  #theme-toggle::before {
    width: 22px;
    height: 22px;
  }
 
  .nav-link:hover::before,
  .nav-link.disabled::before { opacity: 0.4; }
}

/* ─── EMAIL VERIFY STEP ──────────────────────────────────────────────────── */
.verify-box {
  max-width: 480px;
  margin-top: 32px;
}

.verify-intro {
  font-size: 0.9rem;
  color: var(--grey-mid);
  line-height: 1.6;
  margin-bottom: 28px;
  border-left: 3px solid var(--black);
  padding-left: 16px;
}

.verify-sent-notice {
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--grey-light);
  border: var(--border);
  padding: 12px 16px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ─── VERIFIED BADGE ─────────────────────────────────────────────────────── */
.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: var(--border-thick);
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 28px;
  background: var(--grey-light);
}

.verified-icon {
  font-size: 1rem;
  line-height: 1;
}

.verified-label {
  color: var(--grey-mid);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Submit button disabled state (compose page) */
#submit-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: all; /* allow hover to show it's disabled */
}

/* ─── DARK MODE — header/modal/input/chip overrides ─────────────────────── */
[data-theme="dark"] .site-header,
[data-theme="dark"] .site-footer { background: var(--bg); }

[data-theme="dark"] .modal { background: var(--bg); }
[data-theme="dark"] .modal-overlay { background: var(--overlay-bg); }

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--input-bg);
  color: var(--fg);
  border-color: var(--border-color);
}

[data-theme="dark"] .info-panel { background: var(--bg-subtle); }
[data-theme="dark"] code { background: var(--bg-subtle); }
[data-theme="dark"] .verified-badge { background: var(--bg-subtle); }
[data-theme="dark"] .login-response { background: var(--bg-subtle); }
[data-theme="dark"] .filter-cat-btn { background: var(--bg); color: var(--fg); }
[data-theme="dark"] .report-option-btn { background: var(--bg); color: var(--fg); }
[data-theme="dark"] .report-option-btn:hover { background: var(--fg); color: var(--bg); }
[data-theme="dark"] .report-option-btn.selected { background: var(--fg); color: var(--bg); }
[data-theme="dark"] .chip { background: var(--bg); }
[data-theme="dark"] .chip-remove { color: var(--fg); }
[data-theme="dark"] .pill-static { background: var(--bg-subtle); }
[data-theme="dark"] .detail-filter-chip { background: var(--bg-subtle); border-color: var(--border-color); }
[data-theme="dark"] .toast { background: var(--bg); color: var(--fg); }
[data-theme="dark"] .toast.error { background: var(--fg); color: var(--bg); }
[data-theme="dark"] .message-row:hover { background: var(--bg-subtle); }

/* ─── SITE FOOTER — fixed, stacks on mobile ──────────────────────────────── */
/* ─── FOOTER — desktop ───────────────────────────────────────────────────── */
.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: var(--border);
  z-index: 100;
  padding: 0 24px;
  display: flex;
  align-items: center;
  min-height: 48px;
}
.site-footer-inner {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 10px 0;
}
.site-footer-logo {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  white-space: nowrap;
}
.site-footer-logo:hover { opacity: 0.6; }
.site-footer-nav {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
}
.footer-link {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 4px 10px;
  transition: color var(--transition);
  white-space: nowrap;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
}
.footer-link:last-child { border-right: none; }
.footer-link:hover { color: var(--fg); }

/* ─── FOOTER — mobile bottom tray ───────────────────────────────────────── */
/* The trigger button — hidden on desktop */
.footer-tray-btn {
  display: none;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  transition: color var(--transition);
}
.footer-tray-btn:hover { color: var(--fg); }
.footer-tray-btn-icon {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 14px;
}
.footer-tray-btn-icon span {
  display: block;
  height: 1.5px;
  background: currentColor;
  border-radius: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Backdrop */
.footer-tray-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.footer-tray-backdrop.open { opacity: 1; }

/* The tray itself */
.footer-tray {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 151;
  background: var(--bg);
  border-top: var(--border-thick);
  padding: 0 env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}
.footer-tray.open { transform: translateY(0); }

/* Drag handle */
.footer-tray-handle {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}
.footer-tray-handle-bar {
  width: 36px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
}

/* Tray header row */
.footer-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px 15px;
  border-bottom: var(--border);
}
.footer-tray-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0;
}
.footer-tray-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--fg-muted);
  padding: 4px;
  transition: color var(--transition);
}
.footer-tray-close:hover { color: var(--fg); }

/* Link list inside tray */
.footer-tray-links {
  display: flex;
  flex-direction: column;
}
.footer-tray-link {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  padding: 17px 20px;
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition);
  /* Large tap target */
  min-height: 56px;
}
.footer-tray-link:last-child { border-bottom: none; }
.footer-tray-link:active { background: var(--bg-subtle); }
.footer-tray-link-arrow {
  font-size: 0.9rem;
  color: var(--fg-muted);
}

@media (max-width: 820px) {
  /* Hide the desktop nav links */
  .site-footer-nav { display: none; }

  /* Show the tray trigger button */
  .footer-tray-btn { 
    display: flex; 
    padding: 0px 25px;
  }

  /* Show backdrop and tray (JS toggles .open) */
  .footer-tray-backdrop { display: block; pointer-events: none; }
  .footer-tray-backdrop.open { pointer-events: all; }
  .footer-tray { display: block; }
}

/* Page padding to clear fixed footer — desktop 48px, mobile ~80px when stacked */
.page-content { padding-bottom: 48px; }
.home-page { min-height: calc(100vh - 56px - 48px); }
@media (max-width: 820px) {
  .page-content { padding-bottom: 88px; }
  .home-page { min-height: calc(100vh - 56px - 88px); }
}

/* ─── EMAIL VERIFY STEP ──────────────────────────────────────────────────── */
.verify-box { max-width: 480px; margin-top: 32px; }
.verify-intro {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.6;
  margin-bottom: 28px;
  border-left: 3px solid var(--fg);
  padding-left: 16px;
}
.verify-sent-notice {
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-subtle);
  border: var(--border);
  padding: 12px 16px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ─── VERIFIED BADGE ─────────────────────────────────────────────────────── */
.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: var(--border-thick);
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 28px;
  background: var(--bg-subtle);
}
.verified-icon { font-size: 1rem; line-height: 1; }
.verified-label { color: var(--fg-muted); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; }

/* Submit button disabled state */
#submit-btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: all; }

/* ─── CHAR COUNTER ───────────────────────────────────────────────────────── */
.char-counter {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  text-align: right;
  transition: color var(--transition);
}
.char-counter--near { color: #b07d00; }
.char-counter--limit { color: var(--danger); font-weight: 700; }

/* ─── STATIC PAGES ───────────────────────────────────────────────────────── */
.static-page { padding: 60px 24px 100px; max-width: 720px; margin: 0 auto; }
.static-page-eyebrow {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--fg-muted); margin-bottom: 12px;
}
.static-page h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 4rem);
  letter-spacing: -0.02em; line-height: 1.05;
  margin-bottom: 40px; border-bottom: var(--border-thick); padding-bottom: 24px;
}
.static-page h2 {
  font-family: var(--font-display);
  font-size: 1.5rem; letter-spacing: -0.01em; line-height: 1.2; margin: 40px 0 12px;
}
.static-page p { font-size: 0.95rem; line-height: 1.75; color: var(--fg); margin-bottom: 20px; }
.static-page ul { padding-left: 20px; margin-bottom: 20px; }
.static-page ul li { font-size: 0.95rem; line-height: 1.75; color: var(--fg); margin-bottom: 8px; }
.static-page a { color: var(--fg); font-weight: 700; }
.static-page a:hover { opacity: 0.6; }
.static-page-updated { font-size: 0.75rem; color: var(--fg-muted); letter-spacing: 0.08em; margin-bottom: 40px; display: block; }

.contact-form-wrap { margin-top: 40px; border-top: var(--border-thick); padding-top: 40px; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 520px) { .contact-grid { grid-template-columns: 1fr; } }

.job-list { margin-top: 8px; }
.job-item {
  border: var(--border-thick); padding: 24px; margin-bottom: 16px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.job-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 4px; }
.job-meta { font-size: 0.75rem; color: var(--fg-muted); letter-spacing: 0.08em; text-transform: uppercase; }
.job-apply-btn { flex-shrink: 0; padding: 10px 20px; font-size: 0.75rem; }

/* ─── MESSAGE DETAIL FILTER CHIPS ────────────────────────────────────────── */
.detail-meta-row--filters { align-items: flex-start; }
.detail-meta-row--filters > span:first-child { padding-top: 3px; }
#detail-filters { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 320px; }
.detail-filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-subtle); border: 1px solid var(--border-color);
  padding: 2px 7px; font-size: 0.7rem; font-family: 'Courier New', monospace; white-space: nowrap;
}
.detail-filter-type { color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.65rem; margin-right: 2px; }
.detail-filter-type::after { content: ':'; }
.detail-filters-none { font-size: 0.8rem; color: var(--fg-muted); }

/* ─── TYPEAHEAD / AUTOCOMPLETE ───────────────────────────────────────────── */

/* Wrapper — must be relative so the dropdown can be positioned absolutely */
.typeahead-wrapper {
  position: relative;
  width: 100%;
}

/* The dropdown list */
.typeahead-dropdown {
  position: absolute;
  top: calc(100% - 1px); /* overlap the input border by 1 px */
  left: 0;
  right: 0;
  z-index: 300;
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--bg);
  border: var(--border-thick);
  border-top: 1px solid var(--border-color); /* softer top join with input */
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 4px 4px 0 var(--fg); /* sharp editorial shadow */
}

/* Each suggestion row */
.typeahead-item {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--fg);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
}
.typeahead-item:last-child { border-bottom: none; }

/* Label text — grows to fill remaining space, truncates if needed */
.typeahead-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* User count badge — right-aligned, muted, tabular numbers */
.typeahead-item-count {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  transition: color var(--transition);
}

/* On hover/active rows the count should lighten to stay readable */
.typeahead-item--active .typeahead-item-count,
.typeahead-item:hover .typeahead-item-count {
  color: var(--bg);
  opacity: 0.65;
}

/* Hover / keyboard-active state */
.typeahead-item--active,
.typeahead-item:hover {
  background: var(--fg);
  color: var(--bg);
}
.typeahead-item--active mark,
.typeahead-item:hover mark {
  background: transparent;
  color: var(--bg);
  opacity: 0.65;
}

/* Highlighted match characters */
.typeahead-item mark {
  background: transparent;
  color: var(--fg);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Dark-mode adjustments are handled by CSS variable inheritance — no extras needed */

/* filter-add-row: make sure the input stretches inside .typeahead-wrapper */
.filter-add-row .typeahead-wrapper { flex: 1; }
.filter-add-row .typeahead-wrapper input { width: 100%; }

/* ─── PROFILE SECTION HEADER (title + counter) ───────────────────────────── */
.profile-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.profile-section-header .profile-section-title {
  margin-bottom: 0; /* override standalone bottom margin when inside header */
}

/* Item counter badge: "12 / 100" */
.filter-counter {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  white-space: nowrap;
  transition: color var(--transition);
}
.filter-counter--near  { color: #b07d00; }
.filter-counter--limit { color: var(--danger); font-weight: 700; }

/* ─── MESSAGES PAGE HEADER + BULK ACTIONS ────────────────────────────────── */
.messages-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  /* page-title already has margin-bottom: 8px; this sits above messages-list */
}

.messages-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  /* shrink below the title on narrow screens */
  min-width: 0;
}

.messages-sort {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort-label {
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--grey-mid);
  white-space: nowrap;
}

.sort-select {
  font-size: 0.72rem;
  padding: 7px 10px;
  border: var(--border-thick);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  height: auto;
  max-width: 160px;
}

.messages-bulk-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.message-audience {
  font-size: 0.72rem;
  color: var(--grey-mid);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .sort-select {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--border-color);
}

/* Compact button variant — same border/colour logic as btn-secondary but tighter */
.btn-sm {
  padding: 7px 14px;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
}

/* ─── SELECT MODE — row highlight ────────────────────────────────────────── */

/* In select mode, suppress the normal hover shift so the cursor stays clean */
.message-row.select-mode:hover {
  background: transparent;
  margin: 0;
  padding: 16px 0;
}

/* Selected state: invert background, keep existing grid layout intact */
.message-row.selected {
  background: var(--fg) !important;
  margin: 0 !important;
  padding: 16px 0 !important;
}

/* Flip text colours on selected rows so they stay legible on the dark bg */
.message-row.selected .message-sender,
.message-row.selected .message-subject,
.message-row.selected .message-meta,
.message-row.selected .expiry-soon {
  color: var(--bg);
}

/* Dark mode: invert is bg→fg, so flip accordingly */
[data-theme="dark"] .message-row.selected {
  background: var(--fg) !important;
}
[data-theme="dark"] .message-row.selected .message-sender,
[data-theme="dark"] .message-row.selected .message-subject,
[data-theme="dark"] .message-row.selected .message-meta,
[data-theme="dark"] .message-row.selected .expiry-soon {
  color: var(--bg);
}

/* Unread bold stays visible on selected rows */
.message-row.selected.unread .message-subject {
  font-weight: 800;
}

/* Modal body text helper (used by the confirm modals) */
.modal-body-text {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.6;
  margin: 0 0 8px;
}
/* No-filters hint */
.no-filters-hint {
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-align: center;
  margin: 4px 0 0;
  transition: opacity 0.2s ease;
}
.no-filters-hint.hidden {
  display: none;
}
/* ─── UNREAD MESSAGE DOT ─────────────────────────────────────────────────── */

/* Desktop: wrapper sits inline next to the link text */
.nav-messages-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* The dot itself */
.nav-unread-dot {
  position: absolute;
  top: -3px;
  right: -8px;
  width: 7px;
  height: 7px;
  background: #e74c3c;
  border-radius: 50%;
  border: 1.5px solid var(--bg);
  pointer-events: none;
  display: none; /* hidden until JS adds .has-unread */
}

/* Show when JS adds the class */
.nav-messages-wrap.has-unread .nav-unread-dot {
  display: block;
}

/* ── Mobile overrides ────────────────────────────────────────────────────── */
/* On mobile the .site-nav is a 3-column grid and `.site-nav > *` makes every
   direct child a full 56px cell. The wrapper span is that direct child, so
   it must behave identically to how the bare <a> did before. The inner <a>
   then fills the wrapper and shows its icon via ::before. */
@media (max-width: 820px) {
  /* Wrapper takes the full grid cell */
  .nav-messages-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 56px;
  }

  /* Inner link fills the wrapper so its tap target is the full cell */
  .nav-messages-wrap .nav-link {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
  }

  /* Dot: position relative to the 22×22 icon centred in the cell.
     Shift right by half the icon width (11px) minus a small margin. */
  .nav-unread-dot {
    top: 12px;
    right: calc(50% - 19px);
  }
}