:root {
  --bg: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --border: #dbe1ea;
  --text: #0e1726;
  --text-muted: #5b6678;
  --accent: #2457d6;
  --accent-hover: #1a44b0;
  --accent-soft: #e6edfd;
  --danger: #c8312f;
  --danger-hover: #a52422;
  --live: #e5383b;
  --ok: #1f9d6b;
  --avatar-l: 40%;
}

:root.dark {
  --bg: #090e15;
  --surface: #111823;
  --surface-2: #182131;
  --border: #243044;
  --text: #e6ebf2;
  --text-muted: #8f9bb0;
  --accent: #6c9bff;
  --accent-hover: #8fb2ff;
  --accent-soft: #16264a;
  --danger: #ff7b72;
  --danger-hover: #ff9a93;
  --live: #ff5a5f;
  --ok: #3ccf91;
  --avatar-l: 74%;
}

html, body {
  height: 100%;
}

body {
  overflow-x: clip;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.font-timestamp {
  font-family: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

#detail-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Sender avatar: hue comes from the address, so the same sender is always the same colour. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 9999px;
  font-weight: 600;
  background: hsl(var(--h, 215) 70% 50% / 0.16);
  color: hsl(var(--h, 215) 65% var(--avatar-l));
}

/* Unread marker, borrowed from the REC lamp on a camera. */
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--live);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent);
  animation: rec-pulse 2.2s ease-out infinite;
}
.rec-dot.is-read {
  background: transparent;
  box-shadow: none;
  animation: none;
}

@keyframes rec-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Header "Live" chip, driven by the auto-refresh. */
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--ok);
}
.live-dot.is-stale { background: var(--live); }
.live-dot.is-syncing { animation: live-blink 0.9s ease-in-out infinite; }

@keyframes live-blink {
  50% { opacity: 0.25; }
}

/* Rows that arrive through auto-refresh flash once so the change is noticed. */
.row-new {
  animation: row-flash 2.4s ease-out;
}
@keyframes row-flash {
  0%, 35% { background-color: var(--accent-soft); }
  100% { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .rec-dot, .live-dot.is-syncing, .row-new { animation: none; }
}

/* Mobile browsers zoom the page when a focused field is under 16px. Keep
   fields at 16px on touch-size screens so focusing them never shifts the page. */
@media (max-width: 767px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}
