:root {
  color-scheme: light;
  --ink: #0d1117;
  --ink-soft: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --canvas: #f1f5f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --field: #ffffff;
  --rail: #0f172a;
  --rail-soft: #1e293b;
  --nav: #f4f6f9;
  --accent: #004a87;
  --accent-dark: #003765;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red-soft: #fff1f2;
  --official: #0f172a;
  --official-soft: #1e293b;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.14);
  --shadow-xl: 0 28px 64px rgba(15, 23, 42, 0.20);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

a,
button,
input,
textarea,
.message-row,
.status-tile,
.compose-panel,
.auth-panel,
.visual-mail-card {
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

button:active,
.message-row:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.message-row:focus-visible {
  outline: 2.5px solid rgba(37, 99, 235, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}

/* ── Loading ── */
.loading-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 28px;
  padding: 28px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.loading-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.loading-brand img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  padding: 5px;
  border-radius: 12px;
  background: #ffffff;
}

.loading-brand strong,
.loading-brand span {
  display: block;
}

.loading-brand strong {
  font-size: 26px;
  font-weight: 850;
  letter-spacing: 0;
  color: #fff;
}

.loading-brand span {
  color: rgba(255,255,255,0.55);
  overflow-wrap: anywhere;
  font-size: 13px;
  margin-top: 3px;
}

.loading-line {
  width: 280px;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  position: relative;
}

.loading-line::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  animation: load-slide 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes load-slide {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(280%); }
}

/* ── Auth ── */
.auth-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(320px, 420px);
  align-items: center;
  justify-content: center;
  gap: 60px;
  padding: 48px;
  background:
    linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.auth-view:not(.hidden),
.mail-view:not(.hidden) {
  animation: view-enter 240ms ease both;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-intro {
  display: grid;
  gap: 28px;
}

.auth-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.brand-mark img {
  width: 84%;
  height: 84%;
  object-fit: contain;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
}

.brand-name {
  min-width: 0;
  font-weight: 850;
  font-size: 24px;
  letter-spacing: 0;
  line-height: 1.05;
  color: #fff;
}

.brand-domain {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  overflow-wrap: anywhere;
  margin-top: 2px;
}

.auth-visual {
  display: grid;
  gap: 8px;
  width: min(100%, 520px);
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  box-shadow: 0 20px 48px rgba(0,0,0,0.32);
  backdrop-filter: blur(8px);
}

.visual-topline,
.visual-mail-card,
.visual-metrics {
  display: grid;
  align-items: center;
}

.visual-topline {
  grid-template-columns: 1fr auto;
  min-height: 38px;
  padding: 0 6px;
  color: rgba(255,255,255,0.5);
}

.visual-topline strong {
  color: #60a5fa;
  font-size: 24px;
  font-weight: 850;
}

.visual-mail-card {
  grid-template-columns: 38px 1fr 64px;
  gap: 12px;
  min-height: 70px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
}

.visual-mail-card.active {
  border-left: 3px solid #2563eb;
  background: rgba(37,99,235,0.1);
}

.visual-mail-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.visual-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: rgba(255,255,255,0.15);
  font-weight: 850;
  font-size: 15px;
}

.visual-avatar.blue {
  background: #2563eb;
}

.visual-lines {
  display: grid;
  gap: 9px;
}

.visual-lines span {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
}

.visual-lines span:last-child {
  width: 72%;
}

.visual-pill {
  display: grid;
  place-items: center;
  min-height: 28px;
  border-radius: 999px;
  color: #f87171;
  background: rgba(239,68,68,0.15);
  font-size: 12px;
  font-weight: 850;
  border: 1px solid rgba(239,68,68,0.2);
}

.visual-pill.gold {
  color: #fbbf24;
  background: rgba(251,191,36,0.12);
  border-color: rgba(251,191,36,0.2);
}

.visual-metrics {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.visual-metrics div {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}

.visual-metrics strong,
.visual-metrics span {
  overflow-wrap: anywhere;
}

.visual-metrics strong {
  color: #fff;
  font-size: 18px;
  font-weight: 850;
}

.visual-metrics span {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
}

.auth-panel {
  display: grid;
  gap: 18px;
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid rgba(255,255,255,0.12);
  border-top: 3px solid #2563eb;
  border-radius: 12px;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 24px 60px rgba(0,0,0,0.36);
}

.auth-panel:hover {
  box-shadow: 0 28px 72px rgba(0,0,0,0.42);
}

.auth-panel h1,
.title-block h1,
.compose-header h2,
.empty-reader h2,
.message-reader h1 {
  margin: 0;
  letter-spacing: 0;
}

.auth-panel h1 {
  font-size: 28px;
  font-weight: 850;
  color: var(--ink);
  line-height: 1.1;
}

.auth-panel p,
.title-block p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  padding: 10px 13px;
  font-weight: 500;
}

textarea {
  resize: vertical;
  line-height: 1.52;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.auth-panel button[type="submit"],
.compose-primary,
.compose-actions button {
  min-height: 42px;
  border-radius: 7px;
  background: #2563eb;
  color: #fff;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.auth-panel button[type="submit"]:hover,
.compose-primary:hover,
.compose-actions button:hover {
  background: #1d4ed8;
  box-shadow: 0 6px 18px rgba(37,99,235,0.32);
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.button-icon svg,
.folder-icon svg,
.suite-icon svg,
.icon-button svg,
.right-rail svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.folder-icon svg {
  width: 16px;
  height: 16px;
}

.suite-icon svg,
.icon-button svg,
.right-rail svg {
  width: 18px;
  height: 18px;
}

.link-button,
.ghost-button {
  color: var(--blue);
  background: transparent;
  font-weight: 800;
}

.form-message {
  min-height: 19px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.form-message.error {
  color: var(--accent-dark);
}

.form-message.success {
  color: var(--green);
}

/* ── Mail layout ── */
.mail-view {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  display: grid;
  grid-template-columns: 64px 292px minmax(0, 1fr);
  background: var(--canvas);
}

/* ── Suite rail ── */
.suite-rail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 58px repeat(4, 68px) 1fr auto;
  gap: 6px;
  padding: 9px 7px;
  border-right: 1px solid rgba(0,0,0,0.3);
  background: linear-gradient(180deg, #0a1120 0%, #0f172a 40%, #111827 100%);
}

.suite-logo {
  display: grid;
  place-items: center;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
}

.suite-logo img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  padding: 3px;
  border-radius: 7px;
  background: #ffffff;
}

.suite-button {
  min-width: 0;
  min-height: 62px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  position: relative;
}

.suite-button:hover {
  color: rgba(255,255,255,0.9);
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.07);
}

.suite-button.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.09);
}

.suite-button.active::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: #2563eb;
  box-shadow: 0 0 8px rgba(37,99,235,0.7);
}

/* Badge on suite-button */
.suite-button[data-badge]:not([data-badge=""])::after {
  content: attr(data-badge);
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 850;
  line-height: 17px;
  text-align: center;
  border: 1.5px solid #0f172a;
}

.suite-icon {
  width: 30px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: rgba(255,255,255,0.8);
  background: rgba(255, 255, 255, 0.09);
  font-size: 11px;
  font-weight: 850;
}

.suite-button.active .suite-icon {
  background: rgba(37,99,235,0.35);
  color: #93c5fd;
}

.suite-copy {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 1px;
  line-height: 1.05;
}

.suite-copy strong,
.suite-copy small {
  min-width: 0;
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0;
}

.suite-copy strong {
  color: inherit;
  font-size: 10px;
  font-weight: 850;
}

.suite-copy small {
  color: rgba(255, 255, 255, 0.36);
  font-size: 9px;
  font-weight: 700;
}

.suite-button.active .suite-copy small,
.suite-button:hover .suite-copy small {
  color: rgba(255, 255, 255, 0.6);
}

.suite-status {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 10px 0 5px;
}

.suite-status span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

/* ── Sidebar ── */
.sidebar {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto auto;
  gap: 10px;
  padding: 13px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0, #f8fafc 90px, var(--nav) 240px);
}

.sidebar-brand {
  min-height: 72px;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(135deg, #fff 0%, #f0f6ff 100%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.9);
}

.sidebar-kicker {
  margin-bottom: 5px;
  color: #2563eb;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-brand .brand-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--official);
  font-size: 18px;
}

.sidebar-brand .brand-domain {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--muted);
}

.security-strip {
  min-width: 0;
  min-height: 46px;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(22, 163, 74, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
}

.security-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.security-strip strong,
.security-strip span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.security-strip strong {
  color: #14532d;
  font-size: 11.5px;
  font-weight: 850;
}

.security-strip span {
  color: var(--green);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: capitalize;
}

.compose-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-weight: 850;
  font-size: 13.5px;
  border: 1px solid rgba(37,99,235,0.3);
  box-shadow: 0 4px 14px rgba(37,99,235,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}

.compose-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(37,99,235,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.sidebar-section {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px 0;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-section strong {
  min-width: 26px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 10.5px;
}

.folder-list,
.sidebar-extras {
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.folder-button {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.folder-copy,
.folder-label,
.folder-button small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-copy {
  display: grid;
  gap: 1px;
}

.folder-label {
  color: inherit;
}

.folder-button small {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
}

.folder-button.active {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
  box-shadow:
    inset 3px 0 0 #2563eb,
    var(--shadow-xs);
  padding-left: 10px;
}

.folder-button:hover {
  border-color: var(--line);
  background: rgba(255,255,255,0.7);
  color: var(--ink-soft);
  transform: translateX(2px);
}

.folder-button.static {
  color: var(--muted);
}

.folder-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
  background: var(--line);
  font-size: 10px;
  font-weight: 900;
  flex: 0 0 auto;
}

.folder-button.active .folder-icon {
  color: #fff;
  background: #2563eb;
}

.folder-count {
  min-width: 24px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 10.5px;
  border: 1px solid var(--line);
  font-weight: 850;
}

.folder-button.active .folder-count {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(37,99,235,0.18);
}

.mailbox-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.mailbox-summary div,
.insight-card {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mailbox-summary div {
  background: linear-gradient(180deg, #fff, #f8fafc);
  box-shadow: var(--shadow-xs);
}

.mailbox-summary span,
.insight-card span,
.delivery-panel span,
.sync-status,
.eyebrow,
.list-toolbar span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.mailbox-summary strong,
.insight-card strong,
.delivery-panel strong {
  color: var(--official);
  font-size: 20px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.mailbox-health {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mailbox-health div {
  min-width: 0;
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.mailbox-health div > span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
}

.mailbox-health strong,
.mailbox-health em {
  min-width: 0;
  display: block;
  grid-column: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mailbox-health strong {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 850;
}

.mailbox-health em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 650;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
}

.sidebar-footer .ghost-button {
  justify-content: flex-start;
  min-height: 40px;
  color: var(--official);
}

.signout-button {
  border-color: rgba(207, 60, 60, 0.18);
  color: var(--accent-dark);
  background: #fff;
}

.signout-button:hover {
  border-color: rgba(207, 60, 60, 0.32);
  background: var(--red-soft);
  color: var(--accent-dark);
}

.signout-button .button-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--accent-dark);
  background: var(--red-soft);
}

.ghost-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink-soft);
  font-weight: 760;
}

.ghost-button:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}

.ghost-button.danger {
  color: var(--accent-dark);
}

/* ── Workspace ── */
.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 58px auto minmax(0, 1fr);
  background: var(--panel);
}

.app-header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fafbfd);
  position: relative;
}

.title-block {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.eyebrow {
  display: block;
  text-transform: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-block h1 {
  min-width: 0;
  max-width: 100%;
  font-size: 20px;
  line-height: 1.06;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-block p {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.search-box {
  position: relative;
}

.search-box span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.search-box input {
  min-height: 36px;
  border-radius: 7px;
  padding-left: 38px;
  border-color: var(--line-strong);
  background:
    linear-gradient(90deg, transparent 33px, #fff 33px),
    radial-gradient(circle at 17px 50%, transparent 0 5px, var(--faint) 5px 6px, transparent 6px),
    #fff;
}

.search-box input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.sync-status {
  min-width: 92px;
  text-align: right;
}

.sync-status.syncing {
  color: var(--blue);
}

.sync-status.syncing::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: currentColor;
  animation: pulse-dot 860ms ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.25; transform: scale(0.82); }
  50%       { opacity: 1;    transform: scale(1); }
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink-soft);
  font-weight: 850;
  font-size: 14px;
}

.icon-button:hover,
.icon-button.active {
  border-color: rgba(37, 99, 235, 0.38);
  color: var(--blue);
  background: var(--blue-soft);
}

/* ── Dashboard strip ── */
.dashboard-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) minmax(210px, 1.3fr) minmax(130px, 1fr);
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.status-tile {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: end;
  min-height: 64px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.status-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 10px 10px 0 0;
}

.status-tile:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.status-tile span,
.status-tile small {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-tile strong {
  min-width: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-tile small {
  grid-column: 1 / -1;
  font-weight: 650;
}

.status-tile.wide strong {
  font-size: 14px;
}

/* ── Suite grid (mail list + reader) ── */
.suite-grid {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(460px, 1fr) 48px;
  background: #fff;
}

.message-list-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 46px 1fr;
  border-right: 1px solid var(--line);
  background: #fff;
}

.list-toolbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.list-toolbar div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.list-toolbar strong {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.filter-chips {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-chips button,
.segmented-control button,
.card-actions button {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  font-weight: 850;
}

.filter-chips button:hover,
.filter-chips button.active,
.segmented-control button:hover,
.segmented-control button.active,
.card-actions button:hover {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.34);
  background: var(--blue-soft);
}

.message-list {
  min-height: 0;
  overflow: auto;
}

.list-empty {
  min-height: 220px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--faint);
  text-align: center;
  padding: 24px;
}

.list-empty {
  animation: view-enter 180ms ease both;
}

.list-empty strong {
  color: var(--muted);
  font-size: 15px;
  font-weight: 850;
}

.list-empty span {
  font-size: 13px;
  color: var(--faint);
}

/* ── Message rows ── */
.message-row {
  width: 100%;
  min-width: 0;
  min-height: 64px;
  display: grid;
  grid-template-columns: 30px 36px minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  text-align: left;
  position: relative;
}

.message-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 160ms ease;
}

.message-row:hover,
.message-row.active {
  background: #f5f9ff;
}

.message-row:hover {
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.message-row.active::before {
  background: var(--blue);
}

.message-row.unread {
  background: #fafcff;
}

.message-row.unread::before {
  background: #2563eb;
  opacity: 0.4;
}

.message-row.unread .message-subject,
.message-row.unread .message-sender {
  color: var(--ink);
  font-weight: 850;
}

.message-row.active.unread::before {
  opacity: 1;
}

/* Avatar in message rows */
.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-self: center;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  flex: 0 0 auto;
  letter-spacing: 0;
  user-select: none;
}

.message-star {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  align-self: start;
  border-radius: 6px;
  color: var(--faint);
  background: transparent;
  font-size: 17px;
}

.message-star:hover,
.message-star.active {
  color: var(--amber);
  background: var(--amber-soft);
  transform: scale(1.06);
}

.message-content {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.message-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.message-sender,
.message-subject,
.message-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-sender {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}

.message-subject {
  font-size: 13px;
  color: var(--muted);
}

.message-date,
.message-preview {
  color: var(--faint);
  font-size: 12px;
}

.message-subject-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.message-subject-line .message-subject {
  flex: 1;
  min-width: 0;
}

.status-chip {
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 10px;
  font-weight: 850;
  flex: 0 0 auto;
  text-transform: capitalize;
}

.status-chip.failed {
  color: var(--accent-dark);
  background: var(--red-soft);
}

.status-chip.delivered {
  color: var(--green);
  background: var(--green-soft);
}

.status-chip.subtle {
  color: var(--muted);
  background: #f1f5f9;
}

.status-chip.high {
  color: var(--accent-dark);
  background: var(--red-soft);
}

.status-chip.low {
  color: var(--green);
  background: var(--green-soft);
}

.important-dot {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--red-soft);
  font-size: 11px;
  font-weight: 950;
  flex: 0 0 auto;
}

/* ── Reader ── */
.reader-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #fff;
}

.empty-reader {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 40px 28px;
  text-align: center;
  color: var(--faint);
}

.empty-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 850;
  border: 1px solid rgba(37, 99, 235, 0.14);
  box-shadow: var(--shadow-sm);
}

.empty-reader h2 {
  font-size: 18px;
  color: var(--muted);
  font-weight: 850;
}

.message-reader {
  padding: 20px 28px 32px;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 0 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.reader-actions::-webkit-scrollbar { display: none; }

.reader-btn-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.reader-btn-group + .reader-btn-group {
  margin-left: 2px;
  padding-left: 10px;
  position: relative;
}

.reader-btn-group + .reader-btn-group::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 1px;
  background: var(--line-strong);
  border-radius: 999px;
}

.reader-btn-group--star {
  margin-left: auto;
  padding-left: 10px;
}

.reader-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease, box-shadow 100ms ease, transform 90ms ease;
}

.reader-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reader-btn:hover {
  background: var(--canvas);
  border-color: var(--line-strong);
  color: var(--ink-soft);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}

.reader-btn:active {
  transform: scale(0.95) translateY(0);
  box-shadow: none;
  transition-duration: 50ms;
}

.reader-btn-primary {
  color: var(--blue);
  background: rgba(37, 99, 235, 0.07);
  border-color: rgba(37, 99, 235, 0.2);
}

.reader-btn-primary:hover {
  color: var(--blue);
  background: rgba(37, 99, 235, 0.13);
  border-color: rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.16);
}

.reader-btn-danger {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.reader-btn-danger:hover {
  color: var(--accent-dark);
  background: rgba(207, 60, 60, 0.07);
  border-color: rgba(207, 60, 60, 0.22);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(207, 60, 60, 0.1);
}

.reader-btn-group--star .icon-button {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 15px;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease, transform 90ms ease;
}

.reader-btn-group--star #reader-star-button:hover,
.reader-btn-group--star #reader-star-button.active {
  background: var(--amber-soft);
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--amber);
  transform: scale(1.12);
}

.reader-btn-group--star #reader-important-button:hover,
.reader-btn-group--star #reader-important-button.active {
  background: var(--red-soft);
  border-color: rgba(207, 60, 60, 0.3);
  color: var(--accent-dark);
  transform: scale(1.12);
}

.message-reader h1 {
  margin-bottom: 16px;
  font-size: 22px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.reader-meta,
.reader-recipients {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  color: var(--muted);
  font-size: 13px;
}

.reader-details,
.reader-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.reader-details span,
.attachment-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 760;
}

.attachment-pill:hover {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.34);
  background: var(--blue-soft);
}

.attachment-pill small {
  color: inherit;
  opacity: 0.74;
}

.reader-body {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ── Right rail ── */
.insights-panel {
  display: none;
}

.right-rail {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 10px 5px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
}

.right-rail button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 850;
  box-shadow: var(--shadow-xs);
}

.right-rail button span {
  width: 26px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--panel-soft);
}

.right-rail button:hover {
  color: var(--official);
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.right-rail button.active {
  color: #fff;
  background: var(--official-soft);
  border-color: rgba(15, 23, 42, 0.4);
}

.right-rail button.active span {
  background: rgba(255, 255, 255, 0.14);
}

/* ── Module panels ── */
.module-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
}

.module-panel:not(.hidden) {
  animation: view-enter 200ms ease both;
}

.module-shell {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.module-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 88px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid #2563eb;
  border-radius: 10px;
  background: linear-gradient(135deg, #fff 0%, #f0f6ff 100%);
  box-shadow: var(--shadow-sm);
}

.module-heading h2,
.module-heading p,
.admin-columns h3 {
  margin: 0;
  letter-spacing: 0;
}

.module-heading h2 {
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
}

.module-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.module-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.module-metric {
  min-width: 0;
  min-height: 90px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.module-metric::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 10px 10px 0 0;
}

.module-metric span,
.module-metric small {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 780;
}

.module-metric strong {
  min-width: 0;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
}

.module-metric small {
  font-size: 11px;
  font-weight: 650;
}

.module-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.toolbar-actions {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.soft-badge,
.mini-tags span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
  font-weight: 800;
}

.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.mini-tags span {
  min-height: 22px;
  padding: 0 7px;
  color: var(--blue);
  background: var(--blue-soft);
}

.module-search {
  width: min(100%, 360px);
}

.module-search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.module-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.module-form.compact {
  grid-template-columns: 1fr;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.module-form.expanded {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.module-form.expanded textarea,
.module-form.expanded .check-row {
  grid-column: span 2;
}

.module-form.expanded button[type="submit"] {
  align-self: end;
}

.check-row {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.check-row input {
  width: 17px;
  min-height: 17px;
  padding: 0;
}

input[type="color"] {
  min-height: 38px;
  padding: 4px;
}

.module-form button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 7px;
  color: #fff;
  background: #2563eb;
  font-weight: 850;
}

.module-form button:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.module-card,
.timeline-item,
.data-list div,
.admin-stats div,
.attachment-row {
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.module-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.module-card:hover,
.timeline-item:hover,
.data-list div:hover,
.attachment-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.avatar-token,
.attachment-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: #2563eb;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.attachment-icon {
  background: var(--canvas);
  color: var(--muted);
  border: 1px solid var(--line);
}

.module-card strong,
.module-card span,
.module-card small,
.timeline-item strong,
.timeline-item small,
.data-list strong,
.data-list span,
.attachment-row strong,
.attachment-row small {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-card span,
.module-card small,
.timeline-item span,
.timeline-item small,
.data-list span,
.attachment-row small,
.attachment-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.card-actions button {
  min-height: 26px;
  padding: 0 8px;
}

.timeline-list,
.data-list {
  display: grid;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 9px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.calendar-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-day {
  min-height: 108px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.calendar-day.today {
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.calendar-day strong {
  color: var(--ink-soft);
  font-size: 13px;
}

.calendar-day span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 6px;
  border-left: 3px solid var(--blue);
  border-radius: 5px;
  background: var(--panel-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 760;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.calendar-week section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.calendar-week h3 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-stats div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.admin-stats div::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  bottom: 0;
  background: linear-gradient(180deg, #2563eb, #7c3aed);
  border-radius: 9px 0 0 9px;
}

.admin-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.admin-stats strong {
  font-size: 26px;
  font-weight: 850;
  color: var(--ink);
}

.admin-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-columns section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.admin-columns h3 {
  font-size: 14px;
  font-weight: 850;
  color: var(--ink);
  margin: 0;
  letter-spacing: 0;
}

.data-list div {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.data-list div:hover {
  background: #fff;
}

.module-empty {
  padding: 36px 28px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--faint);
  background: #fff;
  text-align: center;
  font-size: 14px;
}

.module-empty.compact {
  min-height: 54px;
  display: grid;
  place-items: center;
  padding: 10px;
  font-size: 12px;
}

.attachment-row {
  min-width: 0;
  min-height: 62px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

/* ── Compose ── */
.compose-modal {
  position: fixed;
  inset: 0;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(10, 17, 32, 0.5);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.compose-modal:not(.hidden) {
  animation: composer-backdrop-enter 200ms ease both;
}

@keyframes composer-backdrop-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.compose-panel {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 56px));
  max-height: min(760px, calc(100dvh - 56px));
  display: grid;
  gap: 11px;
  padding: 0 18px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-xl);
  overflow: auto;
  animation: composer-panel-enter 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes composer-panel-enter {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.compose-header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -18px 4px;
  padding: 0 14px 0 18px;
  border-radius: 12px 12px 0 0;
  background: var(--rail);
  color: #fff;
}

.compose-header h2 {
  font-size: 14px;
  font-weight: 850;
}

.compose-header .icon-button {
  width: 30px;
  height: 30px;
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: rgba(255,255,255,0.8);
}

.compose-header .icon-button:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
}

.compose-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(120px, 160px);
  gap: 10px;
}

.compose-tools {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
}

.compose-tools .ghost-button {
  min-height: 38px;
}

.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compose-actions button {
  min-width: 110px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid rgba(15,23,42,0.12);
  border-radius: 9px;
  background: #0f172a;
  color: rgba(255,255,255,0.92);
  box-shadow: var(--shadow-xl);
  z-index: 30;
  font-weight: 800;
  font-size: 13.5px;
}

.toast:not(.hidden) {
  animation: toast-enter 200ms ease both;
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 1240px) {
  .suite-grid {
    grid-template-columns: minmax(340px, 410px) minmax(420px, 1fr) 46px;
  }

  .dashboard-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1440px) {
  .mail-view {
    grid-template-columns: 66px 304px minmax(0, 1fr);
  }

  .suite-grid {
    grid-template-columns: minmax(390px, 470px) minmax(560px, 1fr) 50px;
  }

  .message-reader {
    padding: 26px 36px 38px;
  }
}

@media (max-width: 1040px) {
  .mail-view {
    grid-template-columns: 64px 264px minmax(0, 1fr);
  }

  .app-header {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 58px;
    align-items: stretch;
    gap: 10px;
  }

  .header-actions {
    justify-content: space-between;
  }

  .suite-grid {
    grid-template-columns: minmax(320px, 380px) minmax(360px, 1fr);
  }

  .right-rail {
    display: none;
  }

  .dashboard-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-form.expanded textarea,
  .module-form.expanded .check-row {
    grid-column: 1 / -1;
  }

  .module-form button {
    grid-column: 1 / -1;
  }

  .admin-stats,
  .admin-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .auth-view {
    grid-template-columns: minmax(0, 430px);
    background: linear-gradient(135deg, #0f172a, #1e293b);
  }

  .auth-intro {
    justify-items: start;
  }

  .auth-visual {
    display: none;
  }
}

@media (max-width: 860px) {
  .auth-view {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .auth-visual {
    display: none;
  }

  .mail-view {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    grid-template-columns: 1fr;
  }

  .suite-rail {
    position: sticky;
    top: 0;
    z-index: 8;
    grid-template-columns: 44px repeat(4, minmax(70px, 1fr)) 44px;
    grid-template-rows: none;
    padding: 7px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .suite-logo {
    border-bottom: 0;
  }

  .suite-button {
    min-height: 48px;
  }

  .suite-button.active::before {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: -7px;
    width: auto;
    height: 3px;
  }

  .suite-copy small,
  .suite-status strong {
    display: none;
  }

  .suite-status {
    align-content: center;
    padding: 0;
  }

  .sidebar {
    position: sticky;
    top: 62px;
    z-index: 7;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 10px;
    padding: 12px;
  }

  .sidebar-brand {
    min-width: 0;
    min-height: 62px;
  }

  .sidebar-brand .brand-domain {
    max-width: calc(100vw - 188px);
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .title-block {
    min-height: 0;
  }

  .compose-primary {
    min-width: 126px;
  }

  .security-strip,
  .sidebar-extras,
  .mailbox-summary,
  .mailbox-health,
  .sidebar-footer {
    display: none;
  }

  .sidebar-section {
    grid-column: 1 / -1;
  }

  .folder-list {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .folder-count,
  .folder-button small {
    display: none;
  }

  .suite-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .message-list-panel,
  .reader-panel {
    border-right: 0;
  }

  .message-list {
    max-height: 50vh;
    max-height: 50dvh;
  }

  .calendar-month {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .module-shell {
    padding: 12px;
  }
}

@media (max-width: 640px) {
  .loading-view,
  .auth-view {
    padding: 20px;
  }

  .auth-panel {
    padding: 24px;
  }

  .brand-name {
    font-size: 20px;
  }

  .sidebar {
    top: 62px;
    grid-template-columns: 1fr;
  }

  .sidebar-brand .brand-domain {
    max-width: calc(100vw - 92px);
  }

  .sidebar-brand {
    min-height: 56px;
  }

  .compose-primary {
    width: 100%;
  }

  .folder-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-header {
    padding: 12px;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .sync-status {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .dashboard-strip {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .module-form,
  .module-metrics,
  .admin-stats,
  .admin-columns {
    grid-template-columns: 1fr;
  }

  .module-toolbar,
  .compose-row,
  .compose-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .module-form.expanded textarea,
  .module-form.expanded .check-row {
    grid-column: 1;
  }

  .calendar-month {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-heading {
    padding: 14px;
  }

  .title-block h1 {
    font-size: 22px;
  }

  .message-reader {
    padding: 18px 14px 26px;
  }

  .message-reader h1 {
    font-size: 20px;
  }

  .reader-actions {
    justify-content: flex-start;
  }

  .compose-modal {
    inset: 0;
    width: 100%;
    padding: 14px;
  }

  .compose-panel {
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
  }
}

@media (max-width: 480px) {
  .loading-brand,
  .auth-brand {
    align-items: flex-start;
  }

  .loading-brand img {
    width: 64px;
    height: 38px;
  }

  .auth-view {
    padding: 16px;
    align-content: center;
  }

  .auth-panel {
    padding: 20px;
  }

  .auth-panel h1 {
    font-size: 24px;
  }

  .mail-view {
    display: block;
  }

  .suite-rail {
    grid-template-columns: 42px repeat(4, 62px) 38px;
  }

  .suite-button {
    min-height: 46px;
  }

  .suite-copy strong {
    font-size: 9px;
  }

  .sidebar {
    position: static;
  }

  .sidebar-brand .brand-domain {
    max-width: calc(100vw - 86px);
  }

  .sidebar-brand {
    padding: 10px;
  }

  .folder-list {
    grid-template-columns: 1fr 1fr;
  }

  .folder-button {
    min-height: 44px;
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .folder-icon {
    width: 26px;
    height: 26px;
  }

  .workspace {
    display: block;
  }

  .app-header {
    display: grid;
    gap: 11px;
  }

  .search-box input {
    min-height: 40px;
  }

  .dashboard-strip {
    gap: 8px;
  }

  .status-tile {
    min-height: 56px;
  }

  .list-toolbar {
    min-height: 44px;
    align-items: flex-start;
    padding: 9px 10px;
  }

  .timeline-item,
  .attachment-row {
    grid-template-columns: 1fr;
  }

  .list-toolbar div {
    display: grid;
    gap: 2px;
  }

  .filter-chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .filter-chips button {
    width: 100%;
  }

  .message-row {
    min-height: 68px;
    grid-template-columns: 26px 30px minmax(0, 1fr);
    padding: 10px 10px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .message-row-top {
    align-items: flex-start;
  }

  .message-date {
    flex: 0 0 auto;
  }

  .status-chip {
    display: none;
  }

  .reader-btn {
    height: 28px;
    padding: 0 8px;
    font-size: 11.5px;
    gap: 4px;
  }

  .reader-btn svg {
    width: 12px;
    height: 12px;
  }

  .reader-btn-group + .reader-btn-group {
    padding-left: 8px;
  }

  .compose-modal {
    inset: 0;
    width: 100%;
    padding: 0;
  }

  .compose-panel {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  .compose-header {
    border-radius: 0;
  }
}

@media (max-width: 360px) {
  .auth-view,
  .loading-view {
    padding: 12px;
  }

  .brand-mark {
    width: 58px;
    height: 40px;
  }

  .brand-mark.small {
    width: 40px;
    height: 28px;
  }

  .brand-name {
    font-size: 17px;
  }

  .suite-copy,
  .suite-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  .suite-rail {
    grid-template-columns: 42px repeat(4, 44px);
  }

  .suite-icon {
    width: 28px;
    height: 28px;
  }

  .folder-list {
    grid-template-columns: 1fr;
  }

  .message-reader h1 {
    font-size: 19px;
  }
}

@media (max-height: 620px) and (min-width: 861px) {
  .dashboard-strip {
    display: none;
  }

  .workspace {
    grid-template-rows: 54px minmax(0, 1fr);
  }
}

@media (hover: none) and (pointer: coarse) {
  .compose-primary,
  .ghost-button,
  .icon-button,
  .folder-button,
  .suite-button,
  .right-rail button {
    min-height: 44px;
  }

  .icon-button,
  .right-rail button {
    min-width: 44px;
  }

  input,
  textarea,
  select {
    min-height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Load more ──────────────────────────────────────────────── */

.load-more-button {
  display: block;
  width: calc(100% - 24px);
  margin: 10px 12px 12px;
  min-height: 36px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.load-more-button:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.load-more-button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ─── Settings button in sidebar footer ──────────────────────── */

.settings-button {
  justify-content: flex-start;
  min-height: 40px;
  color: var(--ink-soft);
  background: #fff;
  border-color: var(--line);
}

.settings-button:hover {
  border-color: var(--line-strong);
  color: var(--official);
}

.settings-button .button-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--canvas);
}

.settings-button .button-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Keyboard shortcuts overlay ─────────────────────────────── */

.kbd-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(6px);
  animation: kbd-overlay-enter 160ms ease both;
}

@keyframes kbd-overlay-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.kbd-help-panel {
  width: min(480px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: kbd-panel-enter 200ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes kbd-panel-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.kbd-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.kbd-help-header strong {
  font-size: 15px;
  color: var(--official);
}

.kbd-help-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  padding: 8px 0;
  max-height: 70vh;
  overflow-y: auto;
}

.kbd-help-grid kbd {
  display: block;
  padding: 9px 16px 9px 20px;
  border-bottom: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--official);
  background: var(--panel-soft);
  white-space: nowrap;
}

.kbd-help-grid span {
  display: block;
  padding: 9px 20px 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
}

/* ─── Dark mode theme ─────────────────────────────────────────── */

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f1f5f9;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;
  --line: #1e293b;
  --line-strong: #334155;
  --canvas: #0a0f1a;
  --panel: #0f172a;
  --panel-soft: #111827;
  --field: #1e293b;
  --rail: #020617;
  --rail-soft: #0f172a;
  --nav: #111827;
  --accent: #3d90d4;
  --accent-dark: #2b7fc4;
  --official: #e2e8f0;
  --official-soft: #cbd5e1;
  --blue-soft: #1e3a5f;
  --green-soft: #0a2e1a;
  --amber-soft: #2e1f00;
  --red-soft: #2e0f12;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 28px 64px rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] body {
  background: var(--canvas);
  color: var(--ink);
}

[data-theme="dark"] .loading-view,
[data-theme="dark"] .auth-view {
  background: var(--canvas);
}

[data-theme="dark"] .auth-panel,
[data-theme="dark"] .compose-panel,
[data-theme="dark"] .kbd-help-panel {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--ink);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--field);
  color: var(--ink);
  border-color: var(--line-strong);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--faint);
}

[data-theme="dark"] .message-row:hover {
  background: var(--panel-soft);
}

[data-theme="dark"] .message-row.active {
  background: var(--blue-soft);
  border-left-color: var(--blue);
}

[data-theme="dark"] .ghost-button {
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

[data-theme="dark"] .ghost-button:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

[data-theme="dark"] .reader-btn {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

[data-theme="dark"] .reader-btn:hover {
  background: var(--panel-soft);
  border-color: var(--line-strong);
  color: var(--ink-soft);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

[data-theme="dark"] .reader-btn-primary {
  color: #60a5fa;
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(96, 165, 250, 0.22);
}

[data-theme="dark"] .reader-btn-primary:hover {
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.22);
}

[data-theme="dark"] .reader-btn-danger {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

[data-theme="dark"] .reader-btn-danger:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.25);
  box-shadow: none;
}

[data-theme="dark"] .reader-btn-group + .reader-btn-group::before {
  background: var(--line-strong);
}

[data-theme="dark"] .reader-btn-group--star .icon-button {
  border-color: var(--line);
  color: var(--muted);
}

[data-theme="dark"] .settings-button {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

[data-theme="dark"] .settings-button .button-icon {
  background: var(--panel-soft);
}

[data-theme="dark"] .folder-button.active {
  background: var(--blue-soft);
  color: var(--blue);
}

[data-theme="dark"] .sidebar {
  background: var(--panel);
  border-color: var(--line);
}

[data-theme="dark"] .suite-rail {
  background: var(--rail);
}

[data-theme="dark"] .app-header {
  background: var(--panel);
  border-bottom-color: var(--line);
}

[data-theme="dark"] .module-panel {
  background: var(--canvas);
}

[data-theme="dark"] .module-metric {
  background: var(--panel);
  border-color: var(--line);
}

[data-theme="dark"] .module-card {
  background: var(--panel);
  border-color: var(--line);
}

[data-theme="dark"] .compose-header {
  background: var(--panel-soft);
  border-color: var(--line);
}

[data-theme="dark"] .load-more-button {
  background: var(--panel-soft);
  border-color: var(--line-strong);
  color: var(--muted);
}

[data-theme="dark"] .status-tile {
  background: var(--panel);
  border-color: var(--line);
}

[data-theme="dark"] .reader-panel,
[data-theme="dark"] .message-reader {
  background: var(--panel);
}

[data-theme="dark"] .reader-meta,
[data-theme="dark"] .reader-recipients,
[data-theme="dark"] .reader-details {
  color: var(--muted);
  border-color: var(--line);
}

/* ─── Theme toggle button ─────────────────────────────────────── */

.theme-toggle {
  position: relative;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

/* ─── Bulk action toolbar ─────────────────────────────────────── */

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--blue-soft);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.bulk-toolbar button {
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bulk-toolbar button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.bulk-select-all {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

#bulk-count {
  flex: 1;
  color: var(--blue);
  font-weight: 600;
}

/* ─── Bulk checkbox in message rows ──────────────────────────── */

.message-row {
  position: relative;
}

.message-bulk-check {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 120ms ease;
  z-index: 2;
}

.message-row:hover .message-bulk-check,
.message-row.bulk-selected .message-bulk-check {
  opacity: 1;
}

.message-bulk-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
  cursor: pointer;
}

.message-row.bulk-selected {
  background: var(--blue-soft);
}

[data-theme="dark"] .message-row.bulk-selected {
  background: var(--blue-soft);
}

/* ─── Label chips ─────────────────────────────────────────────── */

.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  white-space: nowrap;
}

.label-chip button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  line-height: 1;
}

.label-chip button:hover {
  color: #fff;
}

.reader-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 0 4px;
}

.reader-labels:empty {
  display: none;
}

.add-label-button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  cursor: pointer;
}

.add-label-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.label-picker {
  position: relative;
  display: inline-block;
}

.label-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 160px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.label-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: 0;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--ink-soft);
}

.label-dropdown button:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.label-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Rich text toolbar ───────────────────────────────────────── */

.rich-text-toolbar {
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: var(--panel-soft);
}

.rich-text-toolbar button[data-rte] {
  min-width: 28px;
  min-height: 26px;
  padding: 0 5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
}

.rich-text-toolbar button[data-rte]:hover {
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}

.compose-body {
  min-height: 160px;
  max-height: 340px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0 0 7px 7px;
  background: var(--field);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  cursor: text;
  transition: border-color 160ms ease;
}

.compose-body:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2.5px rgba(37, 99, 235, 0.18);
}

.compose-body:empty:before {
  content: attr(data-placeholder);
  color: var(--faint);
  pointer-events: none;
}

[data-theme="dark"] .rich-text-toolbar {
  background: var(--panel-soft);
  border-color: var(--line-strong);
}

[data-theme="dark"] .compose-body {
  background: var(--field);
  color: var(--ink);
  border-color: var(--line-strong);
}

/* ─── Thread context in reader ────────────────────────────────── */

.reader-thread {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.reader-thread:empty {
  display: none;
}

.thread-header {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 5px;
  cursor: pointer;
  background: var(--panel-soft);
  transition: background 120ms ease, border-color 120ms ease;
  font-size: 13px;
}

.thread-item:hover {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.thread-item strong {
  flex: 1;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item small {
  color: var(--faint);
  flex-shrink: 0;
}

/* ─── HTML email iframe ───────────────────────────────────────── */

.reader-body-html {
  width: 100%;
  min-height: 200px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

/* ─── Undo send toast ─────────────────────────────────────────── */

.undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--rail);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: undo-toast-enter 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes undo-toast-enter {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.undo-toast button {
  padding: 3px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  background: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.undo-toast button:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.5);
}

/* ─── Suite rail badge fix for dark mode ─────────────────────── */

.suite-button[data-badge]:not([data-badge=""])::after {
  position: absolute;
  top: 4px;
  right: 4px;
  content: attr(data-badge);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

/* ─── TOTP / Session settings UI ─────────────────────────────── */

.totp-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0.1em;
  padding: 8px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink-soft);
  word-break: break-all;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 13px;
}

.session-item > div {
  flex: 1;
  min-width: 0;
}

.session-item strong {
  display: block;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item small {
  color: var(--muted);
}

.session-revoke {
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.session-revoke:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Notification permission button ─────────────────────────── */

#notif-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#notif-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

[data-theme="dark"] .bulk-toolbar {
  background: var(--blue-soft);
  border-color: var(--line);
}

[data-theme="dark"] .bulk-toolbar button {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

[data-theme="dark"] .thread-item {
  background: var(--panel-soft);
  border-color: var(--line);
}

[data-theme="dark"] .thread-item:hover {
  background: var(--blue-soft);
}

[data-theme="dark"] .session-item {
  background: var(--panel-soft);
  border-color: var(--line);
}

[data-theme="dark"] .totp-secret {
  background: var(--panel-soft);
  border-color: var(--line-strong);
}

.kbd-help-grid kbd:last-of-type,
.kbd-help-grid span:last-of-type {
  border-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════════
   AUTH — split screen · IBG stage + elevated sign-in card
   ══════════════════════════════════════════════════════════════════ */
:root {
  --stage-1: #00274a; --stage-2: #004a87; --stage-3: #0a6bb5;
  --scene-line: #cfe4f6; --scene-accent: #7dc4ff;
  --ibg-cyan: #29abe2; --ibg-gold: #f7e11e;
  --form-bg: #eef3f8; --card-bg: #ffffff;
  --form-ink: #0c1a2b; --form-muted: #5c6f83;
  --form-line: #dde6ee; --form-field: #f6f9fc;
  --form-link: #00538f; --form-focus: #004a87;
}
:root[data-theme="dark"] {
  --stage-1: #001a31; --stage-2: #00325c; --stage-3: #064a80;
  --scene-line: #8fb4d4; --scene-accent: #56b0f5;
  --form-bg: #070d17; --card-bg: #0f172a;
  --form-ink: #eef4fa; --form-muted: #93a7bb;
  --form-line: #22304a; --form-field: #16233a;
  --form-link: #7dc4ff; --form-focus: #56b0f5;
}

.auth-view {
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  align-items: stretch; gap: 0; padding: 0;
  background: var(--form-bg); overflow: hidden;
}

/* ── Stage ─────────────────────────────────────────── */
.auth-stage {
  position: relative; display: grid; grid-template-rows: auto 1fr auto;
  gap: 18px; padding: clamp(24px, 3.4vw, 46px);
  color: #fff; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(120% 90% at 10% 4%, rgba(125,196,255,.20), transparent 55%),
    radial-gradient(90% 80% at 92% 94%, rgba(41,171,226,.24), transparent 60%),
    linear-gradient(155deg, var(--stage-1) 0%, var(--stage-2) 55%, var(--stage-3) 100%);
  border-right: 3px solid var(--ibg-cyan);
}
.auth-stage::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(85% 75% at 50% 45%, #000 25%, transparent 100%);
}

.stage-eyebrow {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(255,255,255,.9);
}
.stage-eyebrow i { color: rgba(255,255,255,.4); font-style: normal; }
.stage-eyebrow em {
  font-style: normal; letter-spacing: .1em; font-weight: 600;
  color: rgba(255,255,255,.55); padding-left: 6px;
}

.stage-art { display: grid; align-content: center; min-height: 0; transition: transform 400ms cubic-bezier(.22,1,.36,1); will-change: transform; }
.scene { width: 100%; height: auto; max-height: 50vh; display: block; overflow: visible; }

/* ambient */
.amb { opacity: .5; }
.amb-1 { animation: drift 12s ease-in-out infinite; }
.amb-2 { animation: drift 15s ease-in-out infinite reverse; }
@keyframes drift { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(10px,-12px) scale(1.06); } }

/* routes */
.route { stroke: var(--scene-line); stroke-width: 2; stroke-opacity: .34; stroke-dasharray: 340; stroke-dashoffset: 340; }
.route-main { animation: draw 6s cubic-bezier(.4,0,.2,1) infinite; }
.route-b1 { animation: draw 6s cubic-bezier(.4,0,.2,1) infinite .16s; }
.route-b2 { animation: draw 6s cubic-bezier(.4,0,.2,1) infinite .24s; }
.route-b3 { animation: draw 6s cubic-bezier(.4,0,.2,1) infinite .32s; }
@keyframes draw {
  0% { stroke-dashoffset: 340; stroke-opacity: .1; }
  14% { stroke-dashoffset: 0; stroke-opacity: .38; }
  78% { stroke-dashoffset: 0; stroke-opacity: .38; }
  100% { stroke-dashoffset: 0; stroke-opacity: .1; }
}

/* sender console */
.sd-card { fill: url(#gCard); stroke: rgba(255,255,255,.2); stroke-width: 1.2; }
.sd-bar { fill: var(--ibg-cyan); opacity: .95; }
.sd-l1, .sd-l2, .sd-l3 { fill: #fff; opacity: .3; }
.sd-l1 { animation: type 6s steps(1) infinite; }
.sd-l2 { animation: type 6s steps(1) infinite .25s; }
.sd-l3 { animation: type 6s steps(1) infinite .5s; }
@keyframes type { 0%,2% { opacity: .1; } 8%,100% { opacity: .34; } }
.sd-send { fill: var(--ibg-gold); opacity: .9; animation: sendPulse 6s ease-in-out infinite; }
@keyframes sendPulse { 0%,8% { opacity: .45; } 12% { opacity: 1; } 24%,100% { opacity: .6; } }
.sd-halo { fill: rgba(125,196,255,.3); animation: halo 6s ease-in-out infinite; }
.sd-plate { fill: #fff; }
@keyframes halo { 0%,6% { transform: scale(.85); opacity: .3; } 13% { transform: scale(1.07); opacity: .85; } 30% { transform: scale(.9); opacity: .38; } 100% { transform: scale(.85); opacity: .28; } }

/* checkpoint */
.checkpoint { transform-box: fill-box; transform-origin: center; animation: cp 6s ease-in-out infinite; }
.cp-ring { fill: none; stroke: var(--ibg-cyan); stroke-width: 2; stroke-opacity: .55; animation: cpring 6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.cp-core { fill: rgba(255,255,255,.16); stroke: rgba(255,255,255,.55); stroke-width: 1.3; }
.cp-lock { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes cp { 0%,30% { transform: scale(1); } 35% { transform: scale(1.2); } 43% { transform: scale(1); } 100% { transform: scale(1); } }
@keyframes cpring { 0%,32% { transform: scale(.75); opacity: 0; } 36% { opacity: .85; } 54% { transform: scale(2); opacity: 0; } 100% { transform: scale(.75); opacity: 0; } }

/* recipient cards */
.recipient { transform-box: fill-box; transform-origin: 0% 50%; }
.rc-card { fill: url(#gCard); stroke: rgba(255,255,255,.22); stroke-width: 1.2; }
.rc-dot { fill: rgba(255,255,255,.94); }
.rc-glyph { fill: none; stroke: var(--stage-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rc-l1 { fill: #fff; opacity: .34; }
.rc-l2 { fill: #fff; opacity: .2; }
.rc-tick { fill: #22c55e; opacity: 0; }
.rc-check { fill: none; stroke: #04220f; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.recipient[data-i="1"] { animation: pop 6s ease-out infinite; }
.recipient[data-i="2"] { animation: pop 6s ease-out infinite .2s; }
.recipient[data-i="3"] { animation: pop 6s ease-out infinite .4s; }
.recipient[data-i="1"] .rc-tick, .recipient[data-i="1"] .rc-check { animation: tick 6s ease-out infinite; }
.recipient[data-i="2"] .rc-tick, .recipient[data-i="2"] .rc-check { animation: tick 6s ease-out infinite .2s; }
.recipient[data-i="3"] .rc-tick, .recipient[data-i="3"] .rc-check { animation: tick 6s ease-out infinite .4s; }
@keyframes pop {
  0%,54% { transform: scale(.94); opacity: .5; }
  61% { transform: scale(1.04); opacity: 1; }
  68% { transform: scale(1); opacity: 1; }
  94% { transform: scale(1); opacity: .95; }
  100% { transform: scale(.94); opacity: .5; }
}
@keyframes tick { 0%,58% { opacity: 0; } 66%,92% { opacity: 1; } 100% { opacity: 0; } }

/* envelope + pulses */
.flyer { offset-path: path("M 128 190 C 190 190 210 150 268 150"); offset-rotate: 0deg; animation: fly 6s cubic-bezier(.55,.05,.35,1) infinite; }
.env-flap { fill: none; stroke: var(--stage-2); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.flyer-inner { transform-box: fill-box; transform-origin: center; animation: flybob 6s ease-in-out infinite; }
@keyframes fly { 0%,10% { offset-distance: 0%; opacity: 0; } 14% { opacity: 1; } 31% { offset-distance: 100%; opacity: 1; } 37% { offset-distance: 100%; opacity: 0; } 100% { offset-distance: 100%; opacity: 0; } }
@keyframes flybob { 0%,100% { transform: translateY(0) rotate(0); } 20% { transform: translateY(-6px) rotate(-6deg); } 30% { transform: translateY(2px) rotate(3deg); } }
.pulse { fill: var(--ibg-cyan); opacity: 0; }
.pulse-1 { offset-path: path("M 268 150 C 350 150 388  84 452  84"); animation: pr 6s cubic-bezier(.5,0,.3,1) infinite; }
.pulse-2 { offset-path: path("M 268 150 C 360 150 392 190 452 190"); animation: pr 6s cubic-bezier(.5,0,.3,1) infinite .2s; }
.pulse-3 { offset-path: path("M 268 150 C 352 156 390 296 452 296"); animation: pr 6s cubic-bezier(.5,0,.3,1) infinite .4s; }
@keyframes pr { 0%,39% { offset-distance: 0%; opacity: 0; } 43% { opacity: 1; } 58% { offset-distance: 100%; opacity: 1; } 62% { offset-distance: 100%; opacity: 0; } 100% { offset-distance: 100%; opacity: 0; } }

/* readout */
.stage-readout { display: grid; gap: 10px; }
.ro-head { display: flex; align-items: baseline; gap: 9px; }
.ro-head strong { font-size: clamp(34px, 4.4vw, 52px); font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.ro-head span { font-size: 13px; color: rgba(255,255,255,.66); }
.ro-chip {
  margin-left: auto; align-self: center;
  padding: 5px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  background: rgba(34,197,94,.16); border: 1px solid rgba(34,197,94,.4); color: #86efac;
}
.ro-bars { display: grid; grid-auto-flow: column; gap: 6px; }
.ro-bars i { height: 4px; border-radius: 2px; background: rgba(255,255,255,.16); overflow: hidden; position: relative; }
.ro-bars i::after { content: ""; position: absolute; inset: 0; background: var(--ibg-cyan); transform: scaleX(0); transform-origin: left; animation: barfill 6s ease-out infinite; }
.ro-bars i:nth-child(1)::after { animation-delay: .0s } .ro-bars i:nth-child(2)::after { animation-delay: .12s }
.ro-bars i:nth-child(3)::after { animation-delay: .24s } .ro-bars i:nth-child(4)::after { animation-delay: .36s }
.ro-bars i:nth-child(5)::after { animation-delay: .48s } .ro-bars i:nth-child(6)::after { animation-delay: .60s }
@keyframes barfill { 0%,12% { transform: scaleX(0); } 46%,88% { transform: scaleX(1); } 100% { transform: scaleX(0); } }
.ro-note { margin: 0; font-size: 12.5px; line-height: 1.6; color: rgba(255,255,255,.6); }

/* ── Form side ─────────────────────────────────────── */
.auth-forms {
  position: relative; display: grid; grid-template-rows: auto 1fr;
  padding: clamp(18px, 2.4vw, 30px); overflow-y: auto; background: var(--form-bg);
  min-height: 0;   /* grid items default to min-height:auto and refuse to scroll */
}
.auth-topbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  color: #15803d; background: #dcfce7; border: 1px solid #86efac;
}
:root[data-theme="dark"] .status-chip { color: #86efac; background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.35); }
.status-chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: beat 2.4s ease-out infinite; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.6);} 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0);} 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0);} }
.ghost-icon {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--form-line); border-radius: 10px; background: var(--card-bg); color: var(--form-muted);
  transition: color 140ms ease, border-color 140ms ease;
}
.ghost-icon:hover { color: var(--form-ink); border-color: var(--form-muted); }
.ghost-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.auth-card {
  align-self: center; justify-self: center;
  width: min(100%, 428px);
  position: relative; overflow: hidden;
  padding: 30px clamp(22px, 3vw, 34px) 22px;
  background: var(--card-bg);
  border: 1px solid var(--form-line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(3, 24, 46, .13), 0 2px 6px rgba(3, 24, 46, .06);
  animation: cardIn 480ms cubic-bezier(.22,1,.36,1) both;
}
:root[data-theme="dark"] .auth-card { box-shadow: 0 26px 70px rgba(0,0,0,.6); }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }

.card-stripe { position: absolute; inset: 0 0 auto 0; height: 4px; display: grid; grid-auto-flow: column; }
.card-stripe i:nth-child(1) { background: var(--ibg-cyan); }
.card-stripe i:nth-child(2) { background: var(--ibg-gold); }
.card-stripe i:nth-child(3) { background: var(--stage-2); }

.card-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--form-line); margin-bottom: 20px; }
.card-seal { flex: 0 0 auto; width: 46px; height: 46px; display: grid; place-items: center; background: #fff; border: 1px solid var(--form-line); border-radius: 12px; }
.card-seal img { width: 84%; height: 84%; object-fit: contain; }
.card-names { display: grid; gap: 1px; min-width: 0; }
.card-names strong { font-size: 17px; font-weight: 800; color: var(--form-ink); letter-spacing: -.01em; }
.card-names em { font-style: normal; font-size: 11.5px; color: var(--form-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.auth-view .auth-panel { display: grid; gap: 15px; padding: 0; border: 0; background: none; box-shadow: none; }
.auth-view .auth-panel.hidden { display: none; }
.panel-head { display: grid; gap: 5px; }
.auth-view .auth-panel h1 { margin: 0; font-size: 21px; font-weight: 750; color: var(--form-ink); letter-spacing: -.01em; }
.panel-head p { margin: 0; font-size: 13.5px; color: var(--form-muted); }

.auth-view .auth-panel label { display: grid; gap: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--form-muted); }
.field { position: relative; display: block; }
.field-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; fill: none; stroke: var(--form-muted); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; pointer-events: none; opacity: .8;
}
.auth-view .auth-panel .field input {
  width: 100%; box-sizing: border-box;
  padding: 13px 14px 13px 42px; font-size: 15px; font-weight: 500; color: var(--form-ink);
  background: var(--form-field); border: 1.5px solid var(--form-line); border-radius: 11px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.field:has(.pw-toggle) input { padding-right: 46px; }
.auth-view .auth-panel .field input::placeholder { color: color-mix(in srgb, var(--form-muted) 60%, transparent); }
.auth-view .auth-panel .field input:focus {
  outline: none; background: var(--card-bg); border-color: var(--form-focus);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--form-focus) 20%, transparent);
}
.field input:focus ~ .field-icon, .field:focus-within .field-icon { stroke: var(--form-focus); opacity: 1; }

.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 8px; background: transparent; color: var(--form-muted);
}
.pw-toggle:hover { background: var(--form-field); color: var(--form-ink); }
.pw-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pw-toggle.is-on svg { stroke: var(--form-link); }
.caps-hint { font-size: 11.5px; font-weight: 600; color: #b45309; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.check { display: inline-flex !important; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--stage-2); cursor: pointer; }
.check span { font-size: 13px; font-weight: 550; letter-spacing: normal; text-transform: none; color: var(--form-muted); }

.auth-view .submit-button {
  position: relative; margin-top: 2px; padding: 14px 18px;
  font-size: 15px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--stage-2), var(--stage-3));
  border: 0; border-radius: 11px;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--stage-2) 30%, transparent);
  transition: transform 140ms ease, box-shadow 180ms ease;
}
.auth-view .submit-button:hover { transform: translateY(-1px); box-shadow: 0 14px 28px color-mix(in srgb, var(--stage-2) 38%, transparent); }
.auth-view .submit-button:active { transform: translateY(0); }
.auth-view .submit-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--form-focus) 45%, transparent); outline-offset: 2px; }
.auth-view .submit-button[data-busy="true"] { pointer-events: none; }
.auth-view .submit-button[data-busy="true"] .btn-label { opacity: 0; }
.btn-spinner { display: none; }
.auth-view .submit-button[data-busy="true"] .btn-spinner {
  display: block; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
  border-radius: 50%; border: 2.2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-view .link-button { padding: 4px 2px; font-size: 13px; font-weight: 650; color: var(--form-link); background: none; border: 0; cursor: pointer; }
.auth-view .link-button.center { justify-self: center; }
.auth-view .link-button:hover { text-decoration: underline; }
.auth-view .link-button:focus-visible { outline: 2px solid var(--form-focus); outline-offset: 2px; border-radius: 6px; }
.auth-view .form-message { font-size: 13px; text-align: center; }
.auth-view .form-message:empty { display: none; }
.card-foot { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--form-line); font-size: 11px; text-align: center; color: color-mix(in srgb, var(--form-muted) 85%, transparent); }

/* form-reactive */
.auth-stage.is-armed .sd-halo { fill: rgba(125,196,255,.55); }
.auth-stage.is-armed .sd-send { opacity: 1; }
.auth-stage.is-sending .flyer { animation: flyOnce 1.15s cubic-bezier(.5,0,.3,1) both; }
@keyframes flyOnce { 0% { offset-distance: 0%; opacity: 1; } 85% { offset-distance: 100%; opacity: 1; } 100% { offset-distance: 100%; opacity: 0; } }
.auth-stage.is-error .scene { animation: shake 520ms cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%,90% { transform: translateX(-2px);} 20%,80% { transform: translateX(4px);} 30%,50%,70% { transform: translateX(-7px);} 40%,60% { transform: translateX(7px);} }
.auth-stage.is-success .recipients { animation: celebrate 900ms ease-out both; }
@keyframes celebrate { 0% { transform: scale(1);} 40% { transform: scale(1.05);} 100% { transform: scale(1);} }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1180px) { .auth-view { grid-template-columns: minmax(0,1fr) minmax(0,440px); } .scene { max-height: 44vh; } }
@media (max-width: 900px) {
  .auth-view { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .auth-forms { order: 1; padding: 16px 16px 26px; }
  .auth-stage { order: 2; border-right: 0; border-top: 3px solid var(--ibg-cyan); padding: 26px 20px 30px; }
  .scene { max-height: 250px; }
  .auth-card { width: min(100%, 440px); }
}
@media (max-width: 560px) {
  .auth-card { padding: 26px 18px 18px; border-radius: 16px; }
  .card-names em { font-size: 11px; }
  .scene { max-height: 200px; }
  .ro-head strong { font-size: 32px; }
  .stage-eyebrow em { display: none; }
}
@media (max-width: 380px) {
  .row-between { gap: 6px; }
  .check span { font-size: 12.5px; }
  .auth-card { padding: 22px 14px 16px; }
}
/* short LANDSCAPE only (phones on their side) — portrait small phones keep the art */
@media (max-height: 580px) and (orientation: landscape) {
  .auth-stage { display: none; }
  .auth-view { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .auth-card { padding: 20px 20px 14px; }
  .card-brand { padding-bottom: 13px; margin-bottom: 14px; }
  .auth-view .auth-panel { gap: 12px; }
  .card-foot { margin-top: 14px; padding-top: 12px; }
}
/* when the viewport is short, stop centring the card so it can scroll into reach */
@media (max-height: 760px) {
  .auth-card { align-self: start; }
  .auth-forms { align-content: start; row-gap: 12px; }
}
@media (min-width: 1700px) { .auth-view { grid-template-columns: minmax(0,1fr) minmax(0,600px); } }
@supports (padding: max(0px)) {
  .auth-forms { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .auth-stage { padding-bottom: max(30px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .route, .amb, .sd-l1, .sd-l2, .sd-l3, .sd-send, .sd-halo, .checkpoint, .cp-ring,
  .recipient, .rc-tick, .rc-check, .flyer, .flyer-inner, .pulse, .status-chip i,
  .ro-bars i::after, .auth-card, .stage-art { animation: none !important; transition: none !important; }
  .route { stroke-dashoffset: 0; stroke-opacity: .38; }
  .flyer { offset-distance: 60%; opacity: 1; }
  .pulse { opacity: .9; offset-distance: 70%; }
  .rc-tick, .rc-check { opacity: 1; }
  .ro-bars i::after { transform: scaleX(1); }
  .sd-halo { opacity: .5; }
}
@media (hover: none) and (pointer: coarse) {
  .stage-art { transform: none !important; }
  .pw-toggle { width: 40px; height: 40px; }
}

/* ══════════════════════════════════════════════════════════════════
   INBOX — reclaimed layout, density, date groups, mobile pane swap
   ══════════════════════════════════════════════════════════════════ */

/* The stats strip is gone; give the list a real share of the width and
   let the reader breathe instead of sitting empty. */
.suite-grid { grid-template-columns: minmax(340px, 400px) minmax(520px, 1fr) 48px; }
@media (min-width: 1600px) { .suite-grid { grid-template-columns: minmax(380px, 440px) minmax(640px, 1fr) 48px; } }

/* ── toolbar ─────────────────────────────────────────── */
.list-toolbar { gap: 8px; }
.lt-meta { display: grid; min-width: 0; }
.density-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); }
.density-switch button {
  width: 26px; height: 24px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  transition: background 130ms ease, color 130ms ease;
}
.density-switch button svg { width: 13px; height: 13px; fill: currentColor; }
.density-switch button:hover { color: var(--ink); background: var(--panel); }
.density-switch button.active { color: #fff; background: var(--accent); }
.density-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── date group headers ──────────────────────────────── */
.list-group {
  position: sticky; top: 0; z-index: 2;
  padding: 7px 14px 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

/* ── row marks ───────────────────────────────────────── */
.message-row { position: relative; }
.row-marks { display: flex; align-items: center; gap: 7px; padding-left: 4px; flex: 0 0 auto; }
.row-clip svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.row-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: 0 0 auto; }
.row-label {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; line-height: 1.55;
  color: var(--lc, var(--blue));
  background: color-mix(in srgb, var(--lc, var(--blue)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--lc, var(--blue)) 32%, transparent);
}

/* ── density ─────────────────────────────────────────── */
:root[data-density="comfortable"] .message-row { padding-block: 13px; }
:root[data-density="comfortable"] .message-preview { -webkit-line-clamp: 2; }

:root[data-density="cosy"] .message-row { padding-block: 9px; }
:root[data-density="cosy"] .message-avatar { width: 32px; height: 32px; font-size: 12.5px; }

:root[data-density="compact"] .message-row { padding-block: 5px; gap: 8px; }
:root[data-density="compact"] .message-avatar { width: 26px; height: 26px; font-size: 11px; }
:root[data-density="compact"] .message-preview { display: none; }
:root[data-density="compact"] .message-subject-line { margin-top: 1px; }
:root[data-density="compact"] .list-group { padding: 5px 14px 4px; }

/* ── mobile: list first, reader slides in on tap ─────── */
.reader-back { display: none; }

@media (max-width: 860px) {
  .suite-grid { grid-template-columns: 1fr; }

  /* one pane at a time — the list owns the screen until you open a message */
  .suite-grid > .message-list-panel { display: grid; }
  .suite-grid > .reader-panel { display: none; }
  .suite-grid.reader-open > .message-list-panel { display: none; }
  .suite-grid.reader-open > .reader-panel { display: grid; }

  .reader-back {
    display: inline-flex; align-items: center; gap: 6px;
    margin: 0 0 10px; padding: 8px 12px 8px 8px;
    font-size: 14px; font-weight: 650; color: var(--blue);
    background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  }
  .reader-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

  /* keep the composer reachable and the list tall */
  .message-list-panel { grid-template-rows: auto 1fr; }
  .density-switch { display: none; }
}

@media (max-width: 640px) {
  .message-row { padding-inline: 12px; }
  .list-group { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .density-switch button { transition: none; }
}

/* Toolbar now carries meta + density + filter chips; let it wrap instead of
   being clipped by a fixed 46px grid row. */
.message-list-panel { grid-template-rows: auto 1fr; }
.list-toolbar { padding-block: 7px; row-gap: 7px; }
.list-toolbar .filter-chips { order: 3; flex-basis: 100%; }
@media (min-width: 1500px) {
  .list-toolbar .filter-chips { order: 0; flex-basis: auto; }
}

/* Tighter cosy rows — 82px was barely denser than comfortable. */
:root[data-density="cosy"] .message-row { padding-block: 7px; }
:root[data-density="cosy"] .message-preview {
  -webkit-line-clamp: 1; line-clamp: 1; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden;
}
:root[data-density="comfortable"] .message-row { padding-block: 12px; }

/* ── Mobile: sidebar as a drawer, compose as a FAB ───────────────── */
.folders-toggle { display: none; }
.compose-fab { display: none; }
.sidebar-scrim { display: none; }

@media (max-width: 860px) {
  /* the list now starts at the top of the screen */
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: min(86vw, 330px); max-width: none;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 260ms cubic-bezier(.22,1,.36,1);
    box-shadow: 0 0 0 rgba(0,0,0,0);
    border-right: 1px solid var(--line);
  }
  .sidebar.open { transform: none; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
  body.drawer-open { overflow: hidden; }

  .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(3, 16, 30, .5); backdrop-filter: blur(2px);
    animation: scrimIn 200ms ease both;
  }
  @keyframes scrimIn { from { opacity: 0 } to { opacity: 1 } }

  .folders-toggle {
    display: grid; place-items: center; flex: 0 0 auto;
    width: 40px; height: 40px; cursor: pointer;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--panel); color: var(--ink);
  }
  .folders-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

  .app-header { gap: 10px; align-items: center; }
  .app-header .title-block { min-width: 0; }
  .app-header .title-block p { display: none; }
  .app-header .eyebrow { display: none; }
  .sync-status { display: none; }

  /* filter chips: one swipeable row instead of a stacked grid */
  .list-toolbar .filter-chips {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; padding-bottom: 2px;
  }
  .list-toolbar .filter-chips::-webkit-scrollbar { display: none; }
  .list-toolbar .filter-chips > * { flex: 0 0 auto; }

  .compose-fab {
    display: grid; place-items: center;
    position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 45; width: 56px; height: 56px; cursor: pointer;
    border: 0; border-radius: 18px; color: #fff;
    background: linear-gradient(135deg, var(--stage-2, #004a87), var(--stage-3, #0a6bb5));
    box-shadow: 0 12px 28px rgba(0, 74, 135, .42);
  }
  .compose-fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
  .suite-grid.reader-open ~ .compose-fab, .suite-grid.reader-open .compose-fab { display: none; }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .sidebar-scrim { animation: none; }
}

/* ── Mobile: get the first message near the top of the screen ────── */
@media (max-width: 860px) {
  /* header: one compact row — toggle, search, refresh */
  .app-header {
    padding: 8px 12px;
    display: flex; flex-wrap: nowrap; gap: 8px; align-items: center;
  }
  .app-header .title-block { display: none; }
  .app-header .search-box { flex: 1 1 auto; min-width: 0; margin: 0; }
  .app-header .search-box span { display: none; }
  .app-header .search-box input { padding-block: 9px; }
  .header-actions { flex: 0 0 auto; gap: 4px; }
  /* keep refresh; the rest live in the reader / bulk toolbars */
  .header-actions .icon-button { display: none; }
  .header-actions #refresh-button { display: grid; }

  /* list toolbar: meta on one line, chips on a single swipe row */
  .list-toolbar { padding: 6px 12px; row-gap: 6px; }
  .lt-meta { display: flex; align-items: baseline; gap: 8px; }
  .lt-meta #selection-status { font-size: 11.5px; }
  .list-toolbar .filter-chips { gap: 6px; }
  .list-toolbar .filter-chips button { padding: 5px 12px; font-size: 12.5px; }
}

/* An earlier mobile block sets `.list-toolbar div { display:grid }` and puts
   the chips in a 2-column grid, which stacked the density switch to 82px and
   doubled the chip row. Override both with matching specificity. */
@media (max-width: 860px) {
  .list-toolbar .density-switch { display: none; }
  .list-toolbar div.lt-meta { display: flex; align-items: baseline; gap: 8px; }
  .list-toolbar div.filter-chips {
    display: flex;
    grid-template-columns: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 6px;
  }
  .list-toolbar div.filter-chips::-webkit-scrollbar { display: none; }
  .list-toolbar div.filter-chips > * { flex: 0 0 auto; }
}

/* `display:block` in the mobile block beat the [hidden] attribute, leaving the
   scrim permanently over the page. Honour hidden explicitly. */
.sidebar-scrim[hidden] { display: none !important; }
@media (max-width: 860px) {
  .sidebar-scrim:not([hidden]) { display: block; }
  /* chips should hug their content, not stretch across the row */
  .list-toolbar div.filter-chips > * { flex: 0 0 auto; width: auto; }
}
