@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surface */
  --page:    #09090b;
  --sidebar: #0c0c10;
  --card:    #18181b;
  --raised:  #27272a;
  --overlay: rgba(0,0,0,0.65);

  /* Border */
  --edge:    rgba(255,255,255,0.08);
  --edge-2:  rgba(255,255,255,0.05);

  /* Text */
  --fg:   #f4f4f5;
  --fg-2: #a1a1aa;
  --fg-3: #71717a;
  --fg-4: #52525b;

  /* Brand */
  --indigo:  #6366f1;
  --violet:  #7c3aed;
  --indigo-d:#4f46e5;

  /* Semantic */
  --success: #10b981;
  --success-dim: rgba(16,185,129,0.12);
  --danger:  #ef4444;
  --danger-d:#dc2626;
  --danger-dim: rgba(239,68,68,0.1);
  --warning: #f59e0b;
  --warning-dim: rgba(245,158,11,0.1);
  --info:    #6366f1;
  --info-dim: rgba(99,102,241,0.12);

  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 228px;
  --topbar-h: 56px;
}

/* ── Base ── */
html { font-size: 14px; }
body {
  background: var(--page);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
code, pre, .mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* ── App shell ── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.1rem 1.1rem 1rem;
  border-bottom: 1px solid var(--edge);
}

.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}

.sidebar-logo .logo-icon svg { width: 16px; height: 16px; color: #fff; }

.sidebar-logo strong { font-size: 0.875rem; font-weight: 600; color: var(--fg); line-height: 1.2; }
.sidebar-logo span   { font-size: 0.7rem; color: var(--fg-4); display: block; }

nav { padding: 0.5rem 0; flex: 1; }

nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  margin: 1px 0.5rem;
  border-radius: 8px;
  color: var(--fg-3);
  text-decoration: none;
  font-size: 0.855rem;
  font-weight: 450;
  letter-spacing: 0.01em;
  transition: color 0.1s, background 0.1s;
}

nav a:hover { color: var(--fg-2); background: rgba(255,255,255,0.04); }
nav a.active {
  color: #fff;
  background: rgba(99,102,241,0.14);
  font-weight: 500;
}
nav a.active .nav-icon { color: var(--indigo); }

.nav-icon { font-size: 0.85rem; width: 16px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--edge);
  flex-shrink: 0;
}

.user-pill { margin-bottom: 0.6rem; }
.user-pill strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.btn-signout {
  width: 100%;
  padding: 0.4rem 0.65rem;
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: 8px;
  color: var(--fg-4);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.btn-signout:hover { border-color: rgba(239,68,68,0.4); color: #f87171; background: var(--danger-dim); }

/* ── Main ── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: rgba(9,9,11,0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
  flex-shrink: 0;
}

.breadcrumb { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--fg-3); }
.breadcrumb a { color: var(--fg-3); text-decoration: none; transition: color 0.1s; }
.breadcrumb a:hover { color: var(--fg-2); }
.breadcrumb .sep { color: var(--fg-4); opacity: 0.6; font-size: 0.7rem; }
.breadcrumb .current { color: var(--fg-2); font-weight: 500; }

/* ── Content ── */
.content { flex: 1; padding: 1.5rem; max-width: 1280px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.page-header h2 { font-size: 1.05rem; font-weight: 600; color: var(--fg); letter-spacing: -0.2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.845rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff;
  box-shadow: 0 2px 10px rgba(99,102,241,0.25);
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; box-shadow: 0 4px 16px rgba(99,102,241,0.35); }

.btn-secondary {
  background: var(--raised);
  color: var(--fg-2);
  border: 1px solid var(--edge);
}
.btn-secondary:hover:not(:disabled) { color: var(--fg); background: #303033; border-color: rgba(255,255,255,0.12); }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-d); }

.btn-ghost { background: transparent; color: var(--fg-3); }
.btn-ghost:hover { color: var(--fg-2); background: rgba(255,255,255,0.04); }

.btn-sm  { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-xs  { padding: 0.18rem 0.45rem; font-size: 0.73rem; }
.btn-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-success { background: var(--success-dim); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-muted   { background: rgba(39,39,42,0.8); color: var(--fg-4); border: 1px solid var(--edge); }
.badge-accent  { background: var(--info-dim); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }
.badge-warning { background: var(--warning-dim); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.badge-danger  { background: var(--danger-dim); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-info    { background: var(--info-dim); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  background: var(--card);
}

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--edge);
}

tbody tr { border-bottom: 1px solid var(--edge-2); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

tbody td {
  padding: 0.7rem 1rem;
  color: var(--fg-3);
  font-size: 0.855rem;
  vertical-align: middle;
}
tbody td.primary { color: var(--fg); font-weight: 500; }
td.actions { white-space: nowrap; }

td code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  background: rgba(255,255,255,0.06);
  padding: 0.12rem 0.4rem;
  border-radius: 5px;
  color: var(--fg-3);
  border: 1px solid var(--edge);
}

.link { color: var(--indigo); text-decoration: none; }
.link:hover { color: #818cf8; text-decoration: underline; }

/* ── Email list ── */
.email-row td { cursor: pointer; }
.email-row.unread td { color: var(--fg-2); }
.email-row.unread td.primary { color: var(--fg); }
.email-row.unread .unread-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 0 6px rgba(99,102,241,0.7);
  margin-right: 0.4rem;
}
.unread-dot { display: none; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--edge);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}
.tab {
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--fg-4);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tab:hover { color: var(--fg-3); }
.tab.active { color: var(--indigo); border-bottom-color: var(--indigo); }

/* ── Filters ── */
.filters { display: flex; gap: 0.65rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input,
.filters select {
  padding: 0.45rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.845rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filters input:focus,
.filters select:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.filters input { flex: 1; min-width: 200px; }
.filters input::placeholder { color: var(--fg-4); }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 0.3rem; margin-top: 1rem; justify-content: center; }
.page-btn {
  padding: 0.28rem 0.6rem;
  border-radius: 7px;
  border: 1px solid var(--edge);
  background: var(--card);
  color: var(--fg-3);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.1s;
}
.page-btn:hover:not(:disabled) { border-color: rgba(99,102,241,0.4); color: var(--indigo); background: rgba(99,102,241,0.06); }
.page-btn.active { background: var(--indigo); border-color: var(--indigo); color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: 0.35; cursor: default; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--fg-2);
  letter-spacing: 0.01em;
  margin-bottom: 0.4rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: var(--page);
  border: 1px solid var(--edge);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.855rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--fg-4); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-group select option { background: var(--card); }
.form-group textarea { resize: vertical; min-height: 96px; line-height: 1.6; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.855rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
  color: var(--fg-2);
}
.checkbox-label input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--indigo);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--edge);
  margin-top: 1.25rem;
}
.form-error { color: #f87171; font-size: 0.8rem; margin-top: 0.6rem; }
.form-hint  { font-size: 0.74rem; color: var(--fg-4); margin-top: 0.3rem; }

/* ── Modal ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--edge);
}
.modal-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--fg); letter-spacing: -0.2px; }
.modal-close {
  background: none;
  border: none;
  color: var(--fg-4);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  transition: all 0.1s;
  line-height: 1;
}
.modal-close:hover { color: var(--fg-2); background: rgba(255,255,255,0.06); }
.modal-body { padding: 1.4rem; }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.845rem;
  font-weight: 500;
  min-width: 210px;
  max-width: 340px;
  opacity: 0;
  transform: translateX(16px) scale(0.97);
  transition: all 0.22s cubic-bezier(0.16,1,0.3,1);
  pointer-events: auto;
  backdrop-filter: blur(12px);
}
.toast.show { opacity: 1; transform: translateX(0) scale(1); }
.toast-success { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.25); color: #34d399; }
.toast-error   { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.25);  color: #f87171; }
.toast-info    { background: rgba(99,102,241,0.12);  border: 1px solid rgba(99,102,241,0.25);  color: #818cf8; }
.toast-warning { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.25); color: #fbbf24; }

/* ── Loading / Empty ── */
.loading { display: flex; align-items: center; justify-content: center; padding: 4rem; }
.spinner {
  width: 24px; height: 24px;
  border: 2px solid rgba(255,255,255,0.08);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 4rem 2rem; color: var(--fg-4); }
.empty-state .empty-icon { font-size: 2.2rem; margin-bottom: 0.9rem; opacity: 0.6; }
.empty-state p { font-size: 0.875rem; color: var(--fg-4); }

.error-state { text-align: center; padding: 3rem; color: #f87171; font-size: 0.875rem; }

/* ── Dashboard stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: rgba(255,255,255,0.12); }
.stat-card .stat-label { font-size: 0.72rem; color: var(--fg-4); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.55rem; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; color: var(--fg); letter-spacing: -1px; }
.stat-card .stat-sub   { font-size: 0.72rem; color: var(--fg-4); margin-top: 0.2rem; }

/* ── Email detail ── */
.email-detail { max-width: 800px; }
.email-subject { font-size: 1.05rem; font-weight: 600; color: var(--fg); margin-bottom: 0.85rem; letter-spacing: -0.2px; }

.email-meta {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.email-meta-row { display: flex; gap: 0.65rem; margin-bottom: 0.35rem; font-size: 0.845rem; }
.email-meta-row:last-child { margin-bottom: 0; }
.email-meta-label { color: var(--fg-4); min-width: 44px; font-size: 0.78rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 1px; }
.email-meta-value { color: var(--fg-2); word-break: break-all; }

.email-body {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
}
.email-body iframe { width: 100%; border: none; min-height: 400px; display: block; background: #fff; }
.email-body pre { padding: 1.25rem; white-space: pre-wrap; word-break: break-word; color: var(--fg-2); font-family: inherit; line-height: 1.7; font-size: 0.855rem; }

.ai-section {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.ai-section h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg-3);
  margin-bottom: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ai-draft {
  width: 100%;
  background: var(--page);
  border: 1px solid var(--edge);
  border-radius: 9px;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.855rem;
  line-height: 1.65;
  padding: 0.75rem;
  resize: vertical;
  min-height: 140px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ai-draft:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* ── Section card ── */
.section-card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  margin-bottom: 1.1rem;
  overflow: hidden;
}
.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--edge);
  background: rgba(255,255,255,0.015);
}
.section-card-header h3 { font-size: 0.855rem; font-weight: 600; color: var(--fg-2); }
.section-card-body { padding: 1.1rem 1.25rem; }

/* ── Mailbox ── */
/* Push mailbox to fill content area edge-to-edge */
.content:has(.mailbox) { padding: 0; overflow: hidden; }

.mailbox {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
}

.mailbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--edge);
  background: rgba(255,255,255,0.015);
  flex-shrink: 0;
  gap: 1rem;
}

.mailbox-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.mailbox-conf-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.mailbox-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Folder sidebar */
.mailbox-sidebar {
  width: 192px;
  flex-shrink: 0;
  border-right: 1px solid var(--edge);
  background: rgba(255,255,255,0.01);
  overflow-y: auto;
  padding: 0.6rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  font-size: 0.845rem;
  color: var(--fg-3);
  user-select: none;
}

.folder-item:hover { background: rgba(255,255,255,0.04); color: var(--fg-2); }
.folder-item.active { background: rgba(99,102,241,0.12); color: #fff; }
.folder-item.active .folder-icon { color: var(--indigo); }

.folder-icon { font-size: 0.75rem; width: 14px; text-align: center; flex-shrink: 0; color: var(--fg-4); }
.folder-label { flex: 1; }

.folder-badge {
  background: var(--indigo);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

.folder-total {
  font-size: 0.7rem;
  color: var(--fg-4);
}

/* Email list pane */
.mailbox-pane {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.mailbox-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--edge);
  flex-shrink: 0;
  gap: 0.75rem;
  background: rgba(255,255,255,0.01);
}

.mailbox-folder-title {
  font-size: 0.855rem;
  font-weight: 600;
  color: var(--fg-2);
}

.mailbox-search input {
  padding: 0.38rem 0.75rem;
  background: var(--raised);
  border: 1px solid var(--edge);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.825rem;
  font-family: inherit;
  outline: none;
  width: 200px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mailbox-search input::placeholder { color: var(--fg-4); }
.mailbox-search input:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Mail rows */
.mail-list { flex: 1; }

.mail-row {
  display: grid;
  grid-template-columns: 10px 150px 1fr 80px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--edge-2);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.845rem;
  color: var(--fg-4);
}
.mail-row:hover { background: rgba(255,255,255,0.03); }
.mail-row:last-child { border-bottom: none; }

.mail-row.unread { color: var(--fg-2); }
.mail-row.unread .mail-subject { color: var(--fg); font-weight: 600; }
.mail-row.unread .mail-unread-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 0 5px rgba(99,102,241,0.8);
}

.mail-unread-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.mail-from { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: inherit; }
.mail-subject-wrap { overflow: hidden; }
.mail-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; color: var(--fg-3); }
.mail-date { font-size: 0.76rem; color: var(--fg-4); text-align: right; white-space: nowrap; }

/* Email detail (inside pane) */
.mailbox-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.1rem 1.25rem;
}

.mailbox-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.mbd-subject {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.85rem;
  letter-spacing: -0.2px;
  line-height: 1.4;
}

.mbd-meta {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
}

.mbd-meta-row {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.3rem;
  font-size: 0.825rem;
}
.mbd-meta-row:last-child { margin-bottom: 0; }
.mbd-label { color: var(--fg-4); min-width: 40px; font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 1px; }
.mbd-val   { color: var(--fg-2); word-break: break-all; }

.mbd-body {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.85rem;
  flex-shrink: 0;
}
.mbd-text { padding: 1rem; white-space: pre-wrap; word-break: break-word; color: var(--fg-2); font-family: inherit; font-size: 0.845rem; line-height: 1.7; }
.mbd-empty { padding: 1rem; color: var(--fg-4); font-size: 0.845rem; }

.mbd-ai {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 1rem;
  flex-shrink: 0;
}
.mbd-ai-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.65rem;
}

/* ── Nav divider ── */
.nav-divider {
  height: 1px;
  background: var(--edge);
  margin: 0.4rem 0.75rem;
}

/* ── Compose pane ── */
.compose-form { display: flex; flex-direction: column; gap: 0; }

.compose-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--edge);
  padding: 0.1rem 0;
}
.compose-label {
  width: 52px;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 0.25rem 0 0;
}
.compose-input {
  flex: 1;
  padding: 0.55rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
}
.compose-input::placeholder { color: var(--fg-4); }
.compose-input:focus { background: transparent; }
select.compose-input { cursor: pointer; }
select.compose-input option { background: var(--card); }

.compose-body-wrap {
  min-height: 180px;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--edge);
}
.compose-body {
  min-height: 160px;
  color: var(--fg);
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.65;
  outline: none;
  white-space: pre-wrap;
}
.compose-body:empty::before {
  content: attr(data-placeholder);
  color: var(--fg-4);
  pointer-events: none;
}
.compose-body blockquote {
  border-left: 3px solid var(--edge);
  margin: 0.5rem 0;
  padding-left: 0.75rem;
  color: var(--fg-3);
}

.compose-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.5rem 0.25rem;
}
.compose-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Loading screen ── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--page);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
