/* ============================================================
   EpicMail Design System — app.css
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --em-sidebar-width: 240px;
  --em-topbar-height: 56px;

  --em-bg:          #f6f8fa;
  --em-surface:     #ffffff;
  --em-border:      #e1e4e8;
  --em-border-mid:  #d0d7de;

  --em-text-primary:   #1f2328;
  --em-text-secondary: #57606a;
  --em-text-muted:     #8c959f;
  --em-text-link:      #0969da;

  --em-accent:         #0969da;
  --em-accent-hover:   #0860ca;
  --em-accent-light:   #dbeafe;

  --em-unread-bg:  #ffffff;
  --em-read-bg:    #f6f8fa;
  --em-hover-bg:   #f0f4f8;
  --em-selected-bg:#e8f0fe;

  --em-danger:     #cf222e;
  --em-warn:       #bf8700;
  --em-success:    #1a7f37;

  --em-radius-sm: 4px;
  --em-radius:    8px;
  --em-radius-lg: 12px;

  --em-shadow-sm: 0 1px 2px rgba(0,0,0,.08);
  --em-shadow:    0 4px 12px rgba(0,0,0,.12);
  --em-shadow-lg: 0 8px 24px rgba(0,0,0,.16);

  --em-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --em-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --em-transition: 150ms ease;
}

/* ── Splash Screen (shown before Blazor initialises) ────────── */
.em-splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0f0ff 0%, #f0e8ff 100%);
  gap: 28px;
}

.em-splash__logo {
  height: 50px;
  width: auto;
  animation: em-fade-in .4s ease;
}

.em-splash__dots {
  display: flex;
  gap: 8px;
}

.em-splash__dots span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6d28d9;
  animation: em-dot-pulse 1.4s ease-in-out infinite;
}

.em-splash__dots span:nth-child(1) { animation-delay: 0s; }
.em-splash__dots span:nth-child(2) { animation-delay: .2s; }
.em-splash__dots span:nth-child(3) { animation-delay: .4s; }

@keyframes em-dot-pulse {
  0%, 80%, 100% { transform: scale(.6); opacity: .35; }
  40%           { transform: scale(1);  opacity: 1;   }
}

@keyframes em-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ── Blazor Error Toast ──────────────────────────────────────── */
#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}

.em-error-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #1f2328;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  font-size: 14px;
  white-space: nowrap;
}

.em-error-toast__icon { font-size: 18px; color: #f59e0b; }
.em-error-toast a { color: #93c5fd; text-decoration: underline; }

.em-error-toast__dismiss {
  margin-left: 12px;
  background: none;
  border: none;
  color: #8c959f;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}

/* ── Bootstrap override guard ────────────────────────────────── */
/* Our CSS loads after Bootstrap so these selectors win */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--em-font) !important;
  font-size: 14px;
  color: var(--em-text-primary);
  background: var(--em-bg);
  -webkit-font-smoothing: antialiased;
}

/* Strip browser/Bootstrap default borders from headings */
h1, h2, h3, h4, h5, h6 { border: none; outline: none; }

/* Bootstrap sets a:hover color — override for our nav links */
a { color: var(--em-text-link); }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ── App Shell ──────────────────────────────────────────────── */
.em-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

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

.em-main {
  flex: 1;
  overflow-y: auto;
  background: var(--em-bg);
}

/* ── Top Bar ────────────────────────────────────────────────── */
.em-topbar {
  display: flex;
  align-items: center;
  height: var(--em-topbar-height);
  padding: 0 16px;
  background: var(--em-surface);
  border-bottom: 1px solid var(--em-border);
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.em-topbar__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
  white-space: nowrap;
}

.em-topbar__logo-icon {
  height: 28px;
  width: 28px;
  flex-shrink: 0;
}

.em-topbar__logo-img {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.em-topbar__logo-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #6d28d9, #1d4ed8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.em-topbar__menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--em-text-secondary);
  font-size: 20px;
  flex-shrink: 0;
  transition: background var(--em-transition);
}
.em-topbar__menu-btn:hover { background: var(--em-hover-bg); }

.em-topbar__search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--em-text-muted);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
}
.em-topbar__search-clear:hover { color: var(--em-text-primary); }

.em-topbar__search {
  flex: 1;
  max-width: 560px;
  position: relative;
}

.em-topbar__search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--em-border);
  border-radius: 20px;
  background: var(--em-bg);
  color: var(--em-text-primary);
  transition: border-color var(--em-transition), box-shadow var(--em-transition);
}

.em-topbar__search input:focus {
  outline: none;
  border-color: var(--em-accent);
  box-shadow: 0 0 0 3px rgba(9,105,218,.15);
}

.em-topbar__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--em-text-muted);
  font-size: 16px;
  pointer-events: none;
}

.em-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
}

.em-topbar__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--em-text-secondary);
  font-size: 18px;
  transition: background var(--em-transition), color var(--em-transition);
}

.em-topbar__icon-btn:hover {
  background: var(--em-hover-bg);
  color: var(--em-text-primary);
}

/* Avatar button — same shape as icon-btn but with a subtle accent ring */
.em-topbar__avatar .em-topbar__avatar-initial {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--em-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.em-user-menu {
  position: relative;
}

.em-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--em-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.em-user-menu__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  box-shadow: var(--em-shadow);
  min-width: 200px;
  z-index: 200;
  overflow: hidden;
}

.em-user-menu__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--em-border);
}

.em-user-menu__name {
  font-weight: 600;
  font-size: 13px;
}

.em-user-menu__email {
  font-size: 12px;
  color: var(--em-text-muted);
  margin-top: 2px;
}

.em-user-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--em-text-primary);
  font-size: 13px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background var(--em-transition);
}

.em-user-menu__item:hover { background: var(--em-hover-bg); }

.em-user-menu__item--danger { color: var(--em-danger); }

/* ── Sidebar ────────────────────────────────────────────────── */
.em-sidebar {
  width: var(--em-sidebar-width);
  background: var(--em-surface);
  border-right: 1px solid var(--em-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.em-compose-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #6d28d9 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--em-transition), box-shadow var(--em-transition);
  box-shadow: 0 2px 8px rgba(109,40,217,.35);
}

.em-compose-btn:hover {
  opacity: .9;
  box-shadow: 0 4px 14px rgba(109,40,217,.45);
}

.em-compose-btn__icon { font-size: 18px; line-height: 1; }

/* Sidebar sections */
.em-sidebar__section { padding: 4px 0; }

.em-sidebar__section + .em-sidebar__section {
  border-top: 1px solid var(--em-border);
  margin-top: 4px;
  padding-top: 8px;
}

.em-sidebar__section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--em-text-muted);
}

.em-sidebar__section-label button {
  background: transparent;
  border: none;
  color: var(--em-text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px;
  border-radius: var(--em-radius-sm);
  cursor: pointer;
}

.em-sidebar__section-label button:hover { color: var(--em-text-primary); background: var(--em-hover-bg); }

/* Nav items */
.em-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  border-radius: 0 20px 20px 0;
  margin-right: 12px;
  font-size: 13px;
  color: var(--em-text-primary);
  cursor: pointer;
  transition: background var(--em-transition);
  position: relative;
}

.em-nav-item:hover { background: var(--em-hover-bg); }

.em-nav-item--active {
  background: var(--em-selected-bg);
  color: var(--em-accent);
  font-weight: 600;
}

.em-nav-item__icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.em-nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.em-nav-item__count {
  font-size: 11px;
  font-weight: 600;
  background: var(--em-accent);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
  line-height: 18px;
}

/* Account list in sidebar */
.em-account-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--em-text-secondary);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background var(--em-transition);
}

.em-account-item:hover { background: var(--em-hover-bg); color: var(--em-text-primary); }

.em-account-item__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.em-account-item__email { font-size: 11px; color: var(--em-text-muted); }

/* ── Account Dot ────────────────────────────────────────────── */
.em-account-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.em-account-dot--lg {
  width: 14px;
  height: 14px;
}

/* ── Settings pages ─────────────────────────────────────────── */
.em-settings-title { font-size: 1.4rem; font-weight: 700; color: var(--em-text-primary); }

/* Label management row */
.em-label-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--em-border);
}
.em-label-row:last-child { border-bottom: none; }
.em-label-row--editing { align-items: flex-start; background: var(--em-bg-hover); }
.em-label-edit-form { flex: 1; padding: 4px 0; }

/* ── Label Chip ─────────────────────────────────────────────── */
.em-label-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 18px;
}

.em-label-chip--removable {
  position: relative;
  transition: padding-right 0.15s;
}
.em-label-chip--removable:hover { padding-right: 20px; }

.em-label-chip__remove {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.em-label-chip__remove .mdi { font-size: 10px; line-height: 1; }
.em-label-chip--removable:hover .em-label-chip__remove { opacity: 0.85; }
.em-label-chip__remove:hover { opacity: 1 !important; background: rgba(0,0,0,0.2); }

/* ── View Layout ────────────────────────────────────────────── */
.em-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.em-view__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--em-border);
  background: var(--em-surface);
  flex-shrink: 0;
}

.em-view__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--em-text-primary);
  flex-shrink: 0;
}

.em-view__count { font-size: 13px; color: var(--em-text-muted); }
.em-view__count-unread { font-weight: 700; color: var(--em-accent); }
.em-view__count-sep { color: var(--em-border-mid); margin: 0 1px; }
.em-view__count-total { font-weight: 400; }

.em-view__account-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Account filter pills */
.em-account-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--em-border);
  background: var(--em-surface);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--em-transition), border-color var(--em-transition);
  color: var(--em-text-primary);
}

.em-account-pill:hover { background: var(--em-hover-bg); border-color: var(--em-border-mid); }

.em-account-pill--active {
  background: var(--em-accent-light);
  border-color: var(--em-accent);
  color: var(--em-accent);
  font-weight: 600;
}

.em-account-pill--clear {
  color: var(--em-text-muted);
  border-style: dashed;
}

/* ── Message List ───────────────────────────────────────────── */
.em-message-list { flex: 1; overflow-y: auto; overflow-x: hidden; }

/* Toolbar */
.em-list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--em-border);
  background: var(--em-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.em-list-toolbar__check { width: 18px; height: 18px; cursor: pointer; accent-color: var(--em-accent); }

.em-list-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.em-list-toolbar__count {
  margin-left: auto;
  font-size: 12px;
  color: var(--em-text-muted);
}

.em-filter-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius-sm);
  background: var(--em-surface);
  font-size: 12px;
  cursor: pointer;
  color: var(--em-text-secondary);
  transition: background var(--em-transition), border-color var(--em-transition);
}

.em-filter-btn:hover { background: var(--em-hover-bg); border-color: var(--em-border-mid); }
.em-filter-btn--active { background: var(--em-accent-light); border-color: var(--em-accent); color: var(--em-accent); font-weight: 600; }

/* ── Message Row ────────────────────────────────────────────── */
.em-message-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  border-bottom: 1px solid var(--em-border);
  background: var(--em-unread-bg);
  cursor: pointer;
  transition: background var(--em-transition);
  position: relative;
  min-height: 40px;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.em-message-row:hover { background: var(--em-hover-bg); }
.em-message-row--read { background: var(--em-read-bg); }
.em-message-row--selected { background: var(--em-selected-bg); }
.em-message-row--selected:hover { background: #dce8fd; }

.em-message-row__check { width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; accent-color: var(--em-accent); }

.em-message-row__dot { flex-shrink: 0; }

/* Quick action buttons — left side, always visible */
.em-message-row__quick-actions {
  display: flex;
  flex-direction: row;
  gap: 2px;
  flex-shrink: 0;
}

.em-row-action-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: var(--em-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--em-text-muted);
  cursor: pointer;
  padding: 0;
  transition: background var(--em-transition), color var(--em-transition);
}

.em-row-action-btn:hover { background: var(--em-hover-bg); color: var(--em-text-primary); }
.em-row-action-btn--danger:hover { background: #fee2e2; color: #dc2626; }

.em-message-row__star {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--em-text-muted);
  font-size: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--em-radius-sm);
  transition: color var(--em-transition);
  cursor: pointer;
}

.em-message-row__star:hover { color: #f59e0b; }
.em-message-row__star--starred { color: #f59e0b; }

.em-message-row__from {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.em-message-row__from-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--em-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.em-message-row__from-date {
  font-size: 10px;
  color: var(--em-text-muted);
  white-space: nowrap;
}

.em-message-row--read .em-message-row__from-name { font-weight: 400; color: var(--em-text-secondary); }

.em-message-row__subject-wrap,
.em-message-row__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}
.em-message-row__top-line {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  min-width: 0;
}
.em-message-row__chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.em-message-row__labels { display: flex; gap: 4px; flex-shrink: 0; }

.em-message-row__subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--em-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.em-message-row--read .em-message-row__subject { font-weight: 400; }

.em-message-row__preview {
  color: var(--em-text-muted);
  font-weight: 400;
  margin-left: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.em-message-row__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 8px;
}

.em-message-row__date {
  font-size: 12px;
  color: var(--em-text-muted);
  white-space: nowrap;
  font-weight: 400;
}

.em-message-row--unread .em-message-row__date { font-weight: 600; color: var(--em-text-primary); }

.em-message-row__has-attach { color: var(--em-text-muted); font-size: 14px; }

/* Hover actions */
.em-message-row__hover-actions {
  display: none;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--em-hover-bg);
  border-radius: var(--em-radius);
  padding: 2px 4px;
  gap: 2px;
  align-items: center;
  box-shadow: var(--em-shadow-sm);
}

.em-message-row:hover .em-message-row__hover-actions { display: flex; }

.em-hover-action {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--em-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--em-text-secondary);
  cursor: pointer;
  transition: background var(--em-transition), color var(--em-transition);
}

.em-hover-action:hover { background: var(--em-border); color: var(--em-text-primary); }

/* Skeleton */
.em-skeleton {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: em-shimmer 1.4s infinite;
  border-radius: var(--em-radius-sm);
  height: 12px;
}

@keyframes em-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.em-skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--em-border);
}

/* Load more */
.em-load-more {
  padding: 16px;
  text-align: center;
}

.em-load-more-btn {
  padding: 8px 24px;
  border: 1px solid var(--em-border);
  border-radius: 20px;
  background: var(--em-surface);
  color: var(--em-text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--em-transition), border-color var(--em-transition);
}

.em-load-more-btn:hover { background: var(--em-hover-bg); border-color: var(--em-border-mid); }

/* Empty state */
.em-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--em-text-muted);
  gap: 12px;
}

.em-empty-state__icon { font-size: 56px; color: var(--em-border-mid); line-height: 1; }
.em-empty-state__title { font-size: 18px; font-weight: 600; color: var(--em-text-secondary); }
.em-empty-state__subtitle { font-size: 13px; }

/* ── Message Detail View (legacy — kept for compat) ─────────── */
.em-message-view { height: 100%; display: flex; flex-direction: column; overflow: hidden; }

/* ── em-msgview (new epic layout) ───────────────────────────── */
.em-msgview {
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

/* Action bar */
.em-msgview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  padding: 8px 12px;
  box-shadow: var(--em-shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

.em-msgview__bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.em-msgview__bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--em-text-secondary);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: var(--em-radius-sm);
  cursor: pointer;
  transition: background var(--em-transition), color var(--em-transition);
  white-space: nowrap;
}

.em-msgview__bar-btn i { font-size: 16px; }
.em-msgview__bar-btn:hover { background: var(--em-hover-bg); color: var(--em-text-primary); }
.em-msgview__bar-btn--danger:hover { background: #fee2e2; color: #dc2626; }
.em-msgview__bar-btn--starred { color: #f59e0b; }
.em-msgview__bar-btn--primary {
  background: var(--em-accent);
  color: #fff;
  border-radius: 0;
}
.em-msgview__bar-btn--primary:first-of-type { border-radius: var(--em-radius-sm) 0 0 var(--em-radius-sm); }
.em-msgview__bar-btn--primary:hover { background: #5b21b6; color: #fff; }

.em-msgview__reply-caret {
  border-left: 1px solid rgba(255,255,255,0.25);
  padding: 5px 6px;
  border-radius: 0 var(--em-radius-sm) var(--em-radius-sm) 0 !important;
}

/* Dropdown */
.em-msgview__dropdown { position: relative; display: inline-flex; }

.em-msgview__dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 160px;
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  box-shadow: var(--em-shadow-md);
  z-index: 1000;
  padding: 4px 0;
}

.em-msgview__dropdown-menu--right { left: auto; right: 0; }

.em-msgview__dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--em-text-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--em-transition);
}

.em-msgview__dropdown-item:hover { background: var(--em-hover-bg); }
.em-msgview__dropdown-item--active { font-weight: 600; }
.em-msgview__dropdown-empty { padding: 8px 14px; font-size: 12px; color: var(--em-text-muted); }
.em-msgview__dropdown-divider { border-top: 1px solid var(--em-border); margin: 4px 0; }
.em-msgview__new-label-row { display: flex; align-items: center; gap: 4px; padding: 6px 8px; }
.em-msgview__new-label-input {
  flex: 1; border: 1px solid var(--em-border); border-radius: 4px;
  padding: 4px 8px; font-size: 13px; background: var(--em-bg); color: var(--em-text); outline: none;
}
.em-msgview__new-label-input:focus { border-color: var(--em-accent); }
.em-msgview__new-label-btn {
  flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 4px;
  background: var(--em-accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.em-msgview__new-label-btn:disabled { opacity: 0.4; cursor: default; }

/* Message card */
.em-msgview__card {
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  box-shadow: var(--em-shadow-sm);
  width: 100%;
}

.em-msgview__subject-row {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--em-border);
}

.em-msgview__subject {
  font-size: 22px;
  font-weight: 700;
  color: var(--em-text-primary);
  line-height: 1.3;
  margin: 0 0 10px;
}

.em-msgview__label-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.em-msgview__meta {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--em-border);
}

.em-msgview__sender-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.em-msgview__sender-info { flex: 1; min-width: 0; }

.em-msgview__sender-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--em-text-primary);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
}

.em-msgview__sender-email { font-size: 12px; color: var(--em-text-muted); font-weight: 400; }
.em-msgview__sender-meta { font-size: 12px; color: var(--em-text-muted); margin-top: 2px; }
.em-msgview__account-name { font-weight: 500; color: var(--em-text-secondary); }
.em-msgview__to-line { font-size: 12px; color: var(--em-text-muted); margin-top: 2px; }
.em-msgview__to-label { font-weight: 600; margin-right: 4px; }

.em-msgview__divider { margin: 0; border-color: var(--em-border); }

/* Image bar */
.em-msgview__image-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--em-hover-bg);
  border-bottom: 1px solid var(--em-border);
  font-size: 13px;
  color: var(--em-text-secondary);
}
.em-msgview__image-bar .mdi { font-size: 16px; }
.em-msgview__image-bar-btn {
  border: none;
  background: none;
  color: var(--em-accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.em-msgview__image-bar-btn:hover { color: var(--em-accent-hover, var(--em-accent)); opacity: 0.85; }

/* Body */
.em-msgview__body { padding: 0; width: 100%; overflow: hidden; }

.em-msgview__iframe {
  width: 100%;
  border: none;
  display: block;
  background: #fff;
  min-height: 400px;
}

.em-msgview__text {
  padding: 24px 28px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--em-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Attachments */
.em-msgview__attachments { padding: 16px 28px 20px; }
.em-msgview__attachments-title { font-size: 13px; font-weight: 600; color: var(--em-text-secondary); margin-bottom: 10px; display: flex; gap: 6px; align-items: center; }
.em-msgview__attachment-list { display: flex; flex-direction: column; gap: 8px; }
.em-msgview__attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--em-bg);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
}
.em-msgview__attachment-icon { font-size: 20px; color: var(--em-text-muted); }
.em-msgview__attachment-info { flex: 1; min-width: 0; }
.em-msgview__attachment-name { font-size: 13px; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-msgview__attachment-size { font-size: 11px; color: var(--em-text-muted); }

.em-message-view__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--em-border);
  background: var(--em-surface);
  flex-shrink: 0;
}

.em-message-view__body { flex: 1; overflow-y: auto; padding: 20px; }

.em-message-header {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--em-border);
}

.em-message-header__subject {
  font-size: 22px;
  font-weight: 600;
  color: var(--em-text-primary);
  margin-bottom: 12px;
  line-height: 1.3;
}

.em-message-header__meta {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.em-message-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--em-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.em-message-header__from { font-size: 14px; font-weight: 600; }
.em-message-header__email { font-size: 12px; color: var(--em-text-muted); margin-left: 4px; }
.em-message-header__date { font-size: 12px; color: var(--em-text-muted); margin-top: 2px; }

.em-message-body iframe {
  width: 100%;
  border: none;
  display: block;
  min-height: 400px;
  background: #fff;
}

.em-message-body__text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--em-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Attachments */
.em-attachments { margin-top: 20px; }
.em-attachments__title { font-size: 13px; font-weight: 600; color: var(--em-text-secondary); margin-bottom: 8px; }

.em-attachments__list { display: flex; gap: 8px; flex-wrap: wrap; }

.em-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  background: var(--em-surface);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--em-transition);
}

.em-attachment:hover { background: var(--em-hover-bg); }
.em-attachment__icon { font-size: 20px; }
.em-attachment__name { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-attachment__size { color: var(--em-text-muted); }

/* Reply box */
.em-reply-box {
  margin-top: 20px;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  overflow: hidden;
  background: var(--em-surface);
}

.em-reply-box__header {
  padding: 8px 12px;
  background: var(--em-bg);
  border-bottom: 1px solid var(--em-border);
  font-size: 12px;
  color: var(--em-text-muted);
  font-weight: 600;
}

.em-reply-box__body { padding: 12px; min-height: 120px; font-size: 14px; outline: none; }

.em-reply-box__quote {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-left: 3px solid var(--em-border-mid);
  color: var(--em-text-muted);
  font-size: 13px;
}

.em-reply-box__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--em-border);
  background: var(--em-bg);
}

/* ── Compose Modal ───────────────────────────────────────────── */
.em-compose-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
}

.em-compose {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--em-surface);
  border-radius: var(--em-radius-lg) var(--em-radius-lg) 0 0;
  box-shadow: var(--em-shadow-lg);
  z-index: 501;
  overflow: hidden;
  pointer-events: all;
}

.em-compose__header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #6d28d9 0%, #1d4ed8 100%);
  color: #fff;
  cursor: pointer;
  user-select: none;
}

.em-compose__title { font-size: 14px; font-weight: 600; flex: 1; }

.em-compose__header-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.7);
  font-size: 16px;
  border-radius: var(--em-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--em-transition), color var(--em-transition);
}

.em-compose__header-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

.em-compose__field {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--em-border);
}

.em-compose__field--autocomplete {
  position: relative;
  flex-wrap: wrap;
}

.em-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--em-border-mid);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  z-index: 1000;
  overflow: hidden;
}

.em-autocomplete__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--em-text-primary);
}

.em-autocomplete__item:hover { background: var(--em-bg); }

.em-autocomplete__icon { color: var(--em-text-muted); font-size: 1.1rem; }

.em-compose__field-label {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--em-text-muted);
  font-weight: 600;
  min-width: 48px;
  flex-shrink: 0;
}

.em-compose__field-input {
  flex: 1;
  border: none;
  padding: 10px 8px;
  font-size: 13px;
  outline: none;
  background: transparent;
  color: var(--em-text-primary);
}

.em-compose__from-select {
  flex: 1;
  border: none;
  padding: 8px;
  font-size: 13px;
  outline: none;
  background: transparent;
  color: var(--em-text-primary);
  cursor: pointer;
}

.em-compose__body {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
}

.em-compose__textarea {
  width: 100%;
  min-height: 200px;
  padding: 12px 16px;
  border: none;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  font-family: inherit;
  background: transparent;
  color: var(--em-text-primary);
}

.em-compose__quote {
  margin: 8px 16px;
  padding: 8px 12px;
  border-left: 3px solid var(--em-border-mid);
  color: var(--em-text-muted);
  font-size: 13px;
  white-space: pre-wrap;
}

.em-compose__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--em-border);
  background: var(--em-bg);
}

/* ── Account Wizard ──────────────────────────────────────────── */
.em-wizard {
  max-width: 540px;
  margin: 32px auto;
  padding: 0 16px;
}

.em-wizard__steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}

.em-wizard__step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.em-wizard__step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--em-border);
  color: var(--em-text-muted);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--em-transition), color var(--em-transition);
}

.em-wizard__step--active .em-wizard__step-num {
  background: var(--em-accent);
  color: #fff;
}

.em-wizard__step--done .em-wizard__step-num {
  background: var(--em-success);
  color: #fff;
}

.em-wizard__step-label { font-size: 12px; font-weight: 600; color: var(--em-text-muted); }
.em-wizard__step--active .em-wizard__step-label { color: var(--em-accent); }
.em-wizard__step--done .em-wizard__step-label { color: var(--em-success); }

.em-wizard__connector {
  flex: 1;
  height: 2px;
  background: var(--em-border);
  margin: 0 8px;
}

.em-wizard__card {
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius-lg);
  padding: 24px;
  box-shadow: var(--em-shadow-sm);
}

.em-wizard__title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.em-wizard__subtitle { font-size: 13px; color: var(--em-text-muted); margin-bottom: 20px; }

/* Detection status */
.em-detect-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--em-radius);
  font-size: 13px;
  margin-top: 12px;
}

.em-detect-status--detecting { background: var(--em-accent-light); color: var(--em-accent); }
.em-detect-status--success { background: #d1fae5; color: var(--em-success); }
.em-detect-status--warn { background: #fef3c7; color: var(--em-warn); }
.em-detect-status--error { background: #fee2e2; color: var(--em-danger); }

.em-detect-result {
  margin-top: 12px;
  padding: 12px;
  background: var(--em-bg);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  font-size: 12px;
  color: var(--em-text-secondary);
}

.em-detect-result__row { display: flex; gap: 8px; margin-bottom: 4px; }
.em-detect-result__key { font-weight: 600; min-width: 80px; }
.em-detect-result__note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--em-border); color: var(--em-warn); font-weight: 600; }

/* Server field group */
.em-field-group {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 8px;
}

.em-field-group--3 { grid-template-columns: 1fr 80px auto; }

/* Color swatch picker */
.em-color-picker { display: flex; flex-wrap: wrap; gap: 6px; }

.em-color-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.em-color-palette--sm .em-color-swatch { width: 22px; height: 22px; border-width: 2px; }

.em-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform var(--em-transition), box-shadow var(--em-transition);
  outline: none;
  flex-shrink: 0;
}

.em-color-swatch:hover { transform: scale(1.15); }

.em-color-swatch--selected,
.em-color-swatch--active {
  border-color: var(--em-text-primary);
  box-shadow: 0 0 0 2px #fff inset;
}

/* Gradient color picker */
.em-color-preview {
  height: 36px;
  border-radius: var(--em-radius);
  margin-bottom: 10px;
  border: 1px solid var(--em-border);
  transition: background var(--em-transition);
}

.em-color-mode-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius-sm);
  overflow: hidden;
  width: fit-content;
  margin-bottom: 10px;
}

.em-color-mode-tab {
  padding: 5px 16px;
  border: none;
  background: var(--em-surface);
  color: var(--em-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--em-transition), color var(--em-transition);
}
.em-color-mode-tab:hover { background: var(--em-hover-bg); }
.em-color-mode-tab--active {
  background: var(--em-accent);
  color: #fff;
  font-weight: 600;
}

.em-color-two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.em-color-col-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--em-text-muted);
  margin-bottom: 4px;
}

/* ── Auth Pages ──────────────────────────────────────────────── */
.em-auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0f0ff 0%, #f0e8ff 100%);
  padding: 20px;
}

.em-auth__card {
  width: 100%;
  max-width: 400px;
  background: var(--em-surface);
  border-radius: var(--em-radius-lg);
  padding: 40px 32px;
  box-shadow: var(--em-shadow-lg);
}

.em-auth__logo {
  text-align: center;
  margin-bottom: 12px;
}

.em-auth__logo img {
  height: 44px;
  width: auto;
}

.em-auth__tagline {
  text-align: center;
  font-size: 13px;
  color: var(--em-text-muted);
  margin-bottom: 28px;
}

.em-auth__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  border: none;
  outline: none;
}

.em-auth__switch {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--em-text-muted);
}

/* ── Form Elements ───────────────────────────────────────────── */
.em-form-group { margin-bottom: 16px; }

.em-form-field { margin-bottom: 16px; }

.em-form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.em-form-field--grow { flex: 1 1 160px; min-width: 0; }
.em-form-field--narrow { flex: 0 0 90px; }

.em-edit-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--em-text-muted);
  border-bottom: 1px solid var(--em-border);
  padding-bottom: 4px;
  margin-bottom: 10px;
  margin-top: 4px;
}

.em-form-group label,
.em-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--em-text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.em-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius-sm);
  background: var(--em-surface);
  color: var(--em-text-primary);
  font-size: 14px;
  transition: border-color var(--em-transition), box-shadow var(--em-transition);
}

/* Username + @epicmail.com suffix */
.em-input-suffix-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius-sm);
  background: var(--em-surface);
  transition: border-color var(--em-transition), box-shadow var(--em-transition);
}

.em-input-suffix-wrap:focus-within {
  border-color: var(--em-accent);
  box-shadow: 0 0 0 3px var(--em-accent-light);
}

.em-input--no-right-radius {
  border: none !important;
  border-radius: var(--em-radius-sm) 0 0 var(--em-radius-sm) !important;
  box-shadow: none !important;
  flex: 1;
  min-width: 0;
}

.em-input-suffix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--em-bg);
  color: var(--em-text-secondary);
  font-size: 13px;
  border-left: 1px solid var(--em-border);
  border-radius: 0 var(--em-radius-sm) var(--em-radius-sm) 0;
  white-space: nowrap;
  user-select: none;
}

.em-form-hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--em-text-muted);
}

.em-form-hint strong {
  color: var(--em-text-secondary);
}

.em-label__hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--em-text-muted);
  font-size: 11px;
}

.em-input:focus {
  outline: none;
  border-color: var(--em-accent);
  box-shadow: 0 0 0 3px rgba(9,105,218,.15);
}

.em-input--error { border-color: var(--em-danger); }

.em-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius-sm);
  background: var(--em-surface);
  color: var(--em-text-primary);
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--em-transition), box-shadow var(--em-transition);
  font-family: inherit;
}

.em-textarea:focus {
  outline: none;
  border-color: var(--em-accent);
  box-shadow: 0 0 0 3px rgba(9,105,218,.15);
}

.em-select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius-sm);
  background: var(--em-surface);
  color: var(--em-text-primary);
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  padding-right: 28px;
}

.em-select:focus { outline: none; border-color: var(--em-accent); box-shadow: 0 0 0 3px rgba(9,105,218,.15); }

.em-form-error { color: var(--em-danger); font-size: 12px; margin-top: 4px; }
.em-form-hint { color: var(--em-text-muted); font-size: 12px; margin-top: 4px; }

/* Checkbox */
.em-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--em-text-primary);
}

.em-checkbox { width: 16px; height: 16px; accent-color: var(--em-accent); cursor: pointer; }

/* ── Buttons ─────────────────────────────────────────────────── */
.em-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--em-radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--em-transition), border-color var(--em-transition), box-shadow var(--em-transition);
  white-space: nowrap;
  text-decoration: none;
}

.em-btn:disabled { opacity: .5; cursor: not-allowed; }

.em-btn--primary { background: var(--em-accent); color: #fff; border-color: var(--em-accent); }
.em-btn--primary:hover:not(:disabled) { background: var(--em-accent-hover); border-color: var(--em-accent-hover); }

.em-btn--secondary { background: var(--em-surface); color: var(--em-text-primary); border-color: var(--em-border-mid); }
.em-btn--secondary:hover:not(:disabled) { background: var(--em-hover-bg); border-color: var(--em-border-mid); }

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

.em-btn--ghost { background: transparent; color: var(--em-text-secondary); border-color: transparent; }
.em-btn--ghost:hover:not(:disabled) { background: var(--em-hover-bg); color: var(--em-text-primary); }

.em-btn--sm { padding: 4px 10px; font-size: 12px; }
.em-btn--lg { padding: 10px 24px; font-size: 15px; }
.em-btn--full { width: 100%; }
.em-btn--icon { padding: 7px; }

/* Icon-only round button */
.em-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--em-text-secondary);
  cursor: pointer;
  transition: background var(--em-transition), color var(--em-transition);
}

.em-icon-btn:hover { background: var(--em-hover-bg); color: var(--em-text-primary); }

/* ── Badge ───────────────────────────────────────────────────── */
.em-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.em-badge--accent { background: var(--em-accent-light); color: var(--em-accent); }
.em-badge--success { background: #d1fae5; color: var(--em-success); }
.em-badge--warn { background: #fef3c7; color: var(--em-warn); }
.em-badge--danger { background: #fee2e2; color: var(--em-danger); }
.em-badge--muted { background: var(--em-border); color: var(--em-text-muted); }

/* ── Alert ───────────────────────────────────────────────────── */
.em-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--em-radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.em-alert--error { background: #fee2e2; color: var(--em-danger); border: 1px solid #fca5a5; }
.em-alert--success { background: #d1fae5; color: var(--em-success); border: 1px solid #6ee7b7; }
.em-alert--info { background: var(--em-accent-light); color: var(--em-accent); border: 1px solid #93c5fd; }
.em-alert--warn { background: #fef3c7; color: var(--em-warn); border: 1px solid #fcd34d; }

/* ── Spinner ─────────────────────────────────────────────────── */
.em-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--em-border);
  border-top-color: var(--em-accent);
  border-radius: 50%;
  animation: em-spin .7s linear infinite;
  display: inline-block;
}

.em-spinner--sm { width: 14px; height: 14px; border-width: 2px; }
.em-spinner--lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes em-spin { to { transform: rotate(360deg); } }

.em-loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* ── Divider ─────────────────────────────────────────────────── */
.em-divider { border: none; border-top: 1px solid var(--em-border); margin: 16px 0; }

/* ── Dropdown / Menu ─────────────────────────────────────────── */
.em-dropdown {
  position: relative;
  display: inline-block;
}

.em-topbar__user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  box-shadow: var(--em-shadow-lg);
  z-index: 500;
  overflow: hidden;
}

.em-dropdown__header {
  padding: 10px 14px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--em-text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--em-border);
}

.em-dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 160px;
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  box-shadow: var(--em-shadow);
  z-index: 300;
  overflow: hidden;
}

.em-dropdown__menu--right { left: auto; right: 0; }

.em-dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--em-text-primary);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background var(--em-transition);
}

.em-dropdown__item:hover { background: var(--em-hover-bg); text-decoration: none; color: inherit; }
a.em-dropdown__item { color: inherit; text-decoration: none; }
.em-dropdown__item--danger { color: var(--em-danger); }
.em-dropdown__divider { border-top: 1px solid var(--em-border); margin: 4px 0; }

/* ── Card ────────────────────────────────────────────────────── */
.em-card {
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  overflow: hidden;
}

.em-card--pad { padding: 20px; }
.em-card--shadow { box-shadow: var(--em-shadow-sm); }

/* ── Page layouts ────────────────────────────────────────────── */
.em-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px;
}

.em-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.em-page__title { font-size: 22px; font-weight: 700; }

/* Account list on accounts page */
.em-account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--em-border);
  background: var(--em-surface);
  transition: background var(--em-transition);
}

.em-account-card:hover { background: var(--em-hover-bg); }

.em-account-card__color-bar {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}

.em-account-card__info { flex: 1; min-width: 0; }

.em-account-card__name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.em-account-card__email { font-size: 12px; color: var(--em-text-muted); margin-top: 2px; }

.em-account-card__status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.em-account-card__status--active { background: #d1fae5; color: var(--em-success); }
.em-account-card__status--error { background: #fee2e2; color: var(--em-danger); }
.em-account-card__status--syncing { background: var(--em-accent-light); color: var(--em-accent); }

/* ── Sidebar items (BEM) ─────────────────────────────────────── */
.em-sidebar__section { padding: 4px 0; }

/* Loading skeleton for sidebar nav items */
.em-sidebar__section--skeleton { padding: 8px 0; }
.em-sidebar__skeleton-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
}
.em-sidebar__skeleton-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 3px;
}
.em-sidebar__skeleton-label {
  height: 12px;
  border-radius: 3px;
  flex: 1;
  max-width: 120px;
}

.em-sidebar__divider { height: 1px; background: var(--em-border); margin: 4px 0; }

.em-sidebar__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--em-text-muted);
}

.em-sidebar__section-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--em-radius-sm);
  color: var(--em-text-muted);
  text-decoration: none;
  font-size: 16px;
  transition: background var(--em-transition), color var(--em-transition);
}
.em-sidebar__section-icon-btn:hover { background: var(--em-hover-bg); color: var(--em-text-primary); text-decoration: none; }

.em-sidebar__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  border-radius: 0 20px 20px 0;
  margin-right: 8px;
  font-size: 13px;
  color: var(--em-text-primary);
  cursor: pointer;
  transition: background var(--em-transition);
}
.em-sidebar__item:hover { background: var(--em-hover-bg); text-decoration: none; color: inherit; }
.em-sidebar__item--active { background: var(--em-selected-bg); color: var(--em-accent); font-weight: 600; }
a.em-sidebar__item { color: inherit; text-decoration: none; }
.em-sidebar__item--muted { color: var(--em-text-muted); font-size: 12px; }

.em-sidebar__item-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  color: var(--em-text-secondary);
}
.em-sidebar__item--active .em-sidebar__item-icon { color: var(--em-accent); }
.em-sidebar__item--muted .em-sidebar__item-icon { color: var(--em-text-muted); }

.em-sidebar__item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.em-sidebar__badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--em-accent);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}
.em-sidebar__badge--sm { font-size: 10px; padding: 0 4px; min-width: 14px; line-height: 14px; }

.em-sidebar__total {
  font-size: 11px;
  color: var(--em-text-muted);
  font-weight: 400;
}

.em-sidebar__account {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  font-size: 13px;
  color: var(--em-text-secondary);
}
.em-sidebar__account--excluded { opacity: .45; }
.em-sidebar__account-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-sidebar__error-icon { color: var(--em-warn); font-size: 14px; line-height: 1; }

.em-sidebar__item--add-account { color: var(--em-accent); margin-top: 2px; }
.em-sidebar__item--add-account .em-sidebar__item-icon { color: var(--em-accent); }
.em-sidebar__item--add-account:hover { background: var(--em-accent-light); }

.em-label-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ── Status dots (account status) ───────────────────────────── */
.em-status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.em-status-dot--ok      { background: var(--em-success); }
.em-status-dot--syncing { background: var(--em-accent); animation: em-dot-pulse 1.4s ease-in-out infinite; }
.em-status-dot--error   { background: var(--em-danger); }
.em-status-dot--inactive { background: var(--em-text-muted); }

/* ── Message list toolbar ────────────────────────────────────── */
.em-message-list__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--em-border);
  background: var(--em-surface);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 44px;
}

.em-message-list__toolbar-left  { display: flex; align-items: center; gap: 4px; }
.em-message-list__toolbar-right { display: flex; align-items: center; gap: 4px; }

.em-message-list__selection-count { font-size: 12px; color: var(--em-text-muted); margin-left: 4px; }

/* ── Pager ───────────────────────────────────────────────────── */
.em-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--em-border);
  background: var(--em-surface);
  gap: 12px;
}

.em-pager__info {
  font-size: 12px;
  color: var(--em-text-muted);
  white-space: nowrap;
}

.em-pager__controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.em-pager__btn {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--em-border);
  background: var(--em-surface);
  border-radius: var(--em-radius-sm);
  font-size: 12px;
  color: var(--em-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--em-transition), border-color var(--em-transition), color var(--em-transition);
}

.em-pager__btn:hover:not(:disabled) { background: var(--em-hover-bg); border-color: var(--em-accent); color: var(--em-accent); }
.em-pager__btn:disabled { opacity: 0.35; cursor: default; }
.em-pager__btn--active { background: var(--em-accent); border-color: var(--em-accent); color: #fff; font-weight: 700; }
.em-pager__btn--active:hover { background: var(--em-accent); color: #fff; }
.em-pager__ellipsis { font-size: 12px; color: var(--em-text-muted); padding: 0 4px; }

@keyframes em-spin { to { transform: rotate(360deg); } }
.em-toolbar-btn--spinning .mdi { animation: em-spin 0.8s linear infinite; display: inline-block; }

.em-toolbar-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--em-radius-sm);
  color: var(--em-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background var(--em-transition), color var(--em-transition);
}
.em-toolbar-btn:hover { background: var(--em-hover-bg); color: var(--em-text-primary); }

.em-toolbar-page-info {
  font-size: 12px;
  color: var(--em-text-secondary);
  white-space: nowrap;
  padding: 0 4px;
}

.em-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--em-border);
  margin: 0 4px;
}

/* ── LabelPickerDropdown component ───────────────────────────── */
.em-label-picker { position: relative; display: inline-flex; }
.em-label-picker__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1000;
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 220px;
  padding: 4px 0;
}
.em-label-picker__menu--right { left: auto; right: 0; }
.em-label-picker__empty { padding: 8px 14px; font-size: 12px; color: var(--em-text-muted); }
.em-label-picker__divider { border-top: 1px solid var(--em-border); margin: 4px 0; }
/* Toggle mode rows */
.em-label-picker__toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 12px; font-size: 13px;
  background: none; border: none; color: var(--em-text); cursor: pointer; text-align: left;
}
.em-label-picker__toggle:hover { background: var(--em-hover-bg); }
.em-label-picker__toggle--active { font-weight: 600; }
/* Add/Move mode rows */
.em-label-picker__item {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px;
}
.em-label-picker__item:hover { background: var(--em-hover-bg); }
.em-label-picker__name { flex: 1; font-size: 13px; }
.em-label-picker__action {
  font-size: 11px; padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--em-border); background: transparent;
  color: var(--em-text); cursor: pointer; white-space: nowrap;
}
.em-label-picker__action:hover { background: var(--em-hover-bg); }
.em-label-picker__action--move { border-color: var(--em-accent); color: var(--em-accent); }
.em-label-picker__action--move:hover { background: var(--em-accent); color: #fff; }
/* New label row */
.em-label-picker__new-row { display: flex; align-items: center; gap: 4px; padding: 6px 8px; }
.em-label-picker__new-input {
  flex: 1; border: 1px solid var(--em-border); border-radius: 4px;
  padding: 4px 8px; font-size: 13px; background: var(--em-bg); color: var(--em-text); outline: none;
}
.em-label-picker__new-input:focus { border-color: var(--em-accent); }
.em-label-picker__new-btn {
  flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 4px;
  background: var(--em-accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.em-label-picker__new-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Toggle pill (Unread filter) ─────────────────────────────── */
.em-toggle-pill { display: flex; align-items: center; cursor: pointer; user-select: none; }
.em-toggle-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.em-toggle-pill__track {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid var(--em-border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--em-text-secondary);
  background: var(--em-surface);
  transition: all var(--em-transition);
  white-space: nowrap;
}
.em-toggle-pill input:checked + .em-toggle-pill__track {
  background: var(--em-accent-light);
  border-color: var(--em-accent);
  color: var(--em-accent);
  font-weight: 600;
}
.em-toggle-pill:hover .em-toggle-pill__track { border-color: var(--em-border-mid); }

/* ── Skeleton loading rows ───────────────────────────────────── */
.em-loading-rows { padding: 4px 0; }
.em-loading-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--em-border);
}

/* ── Compose additions ───────────────────────────────────────── */
.em-compose__header-actions { display: flex; align-items: center; gap: 4px; }

.em-compose__fields { border-bottom: 1px solid var(--em-border); }

.em-compose__cc-toggle {
  padding: 6px 16px;
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--em-text-link);
  cursor: pointer;
  text-align: left;
}
.em-compose__cc-toggle:hover { text-decoration: underline; }

.em-compose__send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: linear-gradient(135deg, #6d28d9 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--em-transition), box-shadow var(--em-transition);
  box-shadow: 0 2px 8px rgba(109,40,217,.3);
}
.em-compose__send-btn:hover:not(:disabled) { opacity: .9; box-shadow: 0 4px 12px rgba(109,40,217,.4); }
.em-compose__send-btn:disabled { opacity: .45; cursor: not-allowed; }

.em-compose__discard-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--em-text-muted);
  border-radius: var(--em-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background var(--em-transition), color var(--em-transition);
}
.em-compose__discard-btn:hover { background: #fee2e2; color: var(--em-danger); }

.em-compose__error { font-size: 12px; color: var(--em-danger); }

/* ── Toasts ──────────────────────────────────────────────────── */
.em-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.em-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--em-shadow-lg);
  animation: em-toast-in 0.2s ease;
  pointer-events: auto;
}

.em-toast--success { background: #166534; color: #dcfce7; }
.em-toast--error   { background: #991b1b; color: #fee2e2; }
.em-toast--info    { background: #1e3a5f; color: #dbeafe; }

.em-toast i { font-size: 18px; flex-shrink: 0; }

.em-toast__close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
}
.em-toast__close:hover { opacity: 1; }
.em-toast__close i { font-size: 16px; }

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

/* ── Send status bar ─────────────────────────────────────────── */
.em-send-status-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--em-text);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
  animation: em-statusbar-in 0.2s ease;
}

.em-send-status-bar__icon { font-size: 16px; color: var(--em-accent); }

.em-send-status-bar__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--em-border);
  border-top-color: var(--em-accent);
  border-radius: 50%;
  animation: em-spin 0.8s linear infinite;
}

@keyframes em-statusbar-in {
  from { opacity: 0; transform: translateX(-50%) translateY(100%); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .em-topbar__menu-btn { display: flex; }

  .em-sidebar {
    position: fixed;
    left: -100%;
    top: var(--em-topbar-height);
    height: calc(100vh - var(--em-topbar-height));
    z-index: 200;
    transition: left var(--em-transition);
    box-shadow: var(--em-shadow-lg);
  }

  .em-sidebar--open { left: 0; }

  .em-message-row__from { width: 100px; }

  .em-compose { width: 100%; right: 0; }

  .em-wizard { margin: 16px auto; }
}

@media (max-width: 480px) {
  .em-topbar__search { display: none; }
  .em-message-row__preview { display: none; }
}

/* ── Sidebar new-label form ─────────────────────────────────────────────── */
.em-sidebar__new-label-form {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}
.em-sidebar__new-label-input {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    font-size: .8rem;
    border: 1px solid var(--em-border);
    border-radius: 6px;
    background: var(--em-surface);
    color: var(--em-text-primary);
    outline: none;
}
.em-sidebar__new-label-input:focus { border-color: var(--em-primary); }
.em-sidebar__new-label-save,
.em-sidebar__new-label-cancel {
    display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 4px; border: none;
    cursor: pointer; font-size: .85rem; padding: 0;
    background: transparent;
}
.em-sidebar__new-label-save { color: var(--em-success, #16a34a); }
.em-sidebar__new-label-save:hover { background: #dcfce7; }
.em-sidebar__new-label-cancel { color: var(--em-text-muted); }
.em-sidebar__new-label-cancel:hover { background: var(--em-hover); }
.em-sidebar__new-label-save:disabled { opacity: .4; cursor: default; }

/* ── Message row label picker ───────────────────────────────────────────── */
.em-message-row__label-picker {
    position: relative;
}
.em-row-label-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--em-surface);
    border: 1px solid var(--em-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 1000;
    padding: 4px 0;
    max-height: 260px;
    overflow-y: auto;
}
.em-row-label-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 12px;
    font-size: .85rem;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    color: var(--em-text-primary);
    white-space: nowrap;
}
.em-row-label-item:hover { background: var(--em-hover); }
.em-row-label-item--active { font-weight: 500; }
.em-row-label-item--create { color: var(--em-text-muted); font-style: italic; }
.em-row-label-empty {
    padding: 8px 12px;
    font-size: .8rem;
    color: var(--em-text-muted);
}
.em-row-label-divider {
    height: 1px;
    background: var(--em-border);
    margin: 4px 0;
}
.em-row-label-create {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}
.em-row-label-create-input {
    flex: 1;
    min-width: 0;
    padding: 3px 6px;
    font-size: .8rem;
    border: 1px solid var(--em-border);
    border-radius: 4px;
    outline: none;
}
.em-row-label-create-input:focus { border-color: var(--em-primary); }
.em-row-label-create-save {
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 3px; border: none;
    cursor: pointer; font-size: .8rem; padding: 0;
    background: transparent; color: var(--em-success, #16a34a);
}
.em-row-label-create-save:hover { background: #dcfce7; }
.em-row-label-create-save:disabled { opacity: .4; cursor: default; }

/* ── Signatures Page ──────────────────────────────────────────────────────── */

.em-sig-account {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.em-sig-account__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.em-sig-account__email {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

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

.em-sig-card {
  padding: 0.875rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.625rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.em-sig-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.em-sig-card__meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.em-sig-card__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.em-sig-card__badges {
  display: flex;
  gap: 0.35rem;
}

.em-sig-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.em-sig-badge--compose {
  background: #dbeafe;
  color: #1d4ed8;
}

.em-sig-badge--reply {
  background: #dcfce7;
  color: #15803d;
}

.em-sig-card__preview {
  font-size: 0.88rem;
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
  margin-bottom: 0.75rem;
  overflow: auto;
}

.em-sig-card__defaults {
  display: flex;
  gap: 1.25rem;
}

.em-sig-default-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.em-sig-card__btns {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.em-sig-editor {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.em-sig-editor__name {
  font-size: 0.95rem;
}

.em-sig-editor__template-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.em-sig-editor__template-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.em-sig-editor__actions {
  display: flex;
  gap: 0.5rem;
}

.em-sig-add-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
}

.em-sig-add-btn:hover {
  background: var(--surface-hover);
}

/* Storage banner */
.em-storage-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff3cd;
  border-bottom: 1px solid #ffc107;
  color: #664d03;
  font-size: 13px;
}
.em-storage-banner__icon { font-size: 1rem; flex-shrink: 0; }
.em-storage-banner__link { color: inherit; font-weight: 600; text-decoration: underline; }
.em-storage-banner__link:hover { opacity: .8; }
.em-storage-banner--danger { background: #f8d7da; border-bottom-color: #dc3545; color: #58151c; }

/* Rich text editor */
.em-rte__wrapper {
  display: block;
}

.em-rte__source-toggle {
  display: block;
  margin-left: auto;
  margin-bottom: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--em-accent);
  color: #fff;
  border-color: var(--em-accent);
  cursor: pointer;
  line-height: 1.6;
}

.em-rte__source-toggle:hover { filter: brightness(1.1); }
.em-rte__source-toggle--active { background: var(--em-accent); color: #fff; border-color: var(--em-accent); }
.em-rte__source-toggle--active:hover { filter: brightness(1.1); }

.em-rte__source-textarea {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  resize: vertical;
  tab-size: 2;
}

.em-rte__source-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.em-rte__preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 160px;
  background: #fff;
  overflow: auto;
}

/* Rich text editor container */
.em-rte__container {
  min-height: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.em-rte__container .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt, #f8f9fa);
}

.em-rte__container .ql-container {
  border: none;
  font-size: 0.95rem;
  min-height: 120px;
  background: #fff;
}

.em-rte__container .ql-editor {
  background: #fff;
  min-height: 120px;
}

/* Compose signature */
.em-compose__sig-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.em-compose__sig-preview {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary, #555);
}

.em-compose__sig-switcher {
  margin-left: auto;
}

.em-compose__sig-select {
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

/* Shared utility buttons/inputs */
.em-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.em-btn--primary {
  background: var(--em-accent);
  color: #fff;
  border-color: var(--em-accent);
}

.em-btn--primary:hover:not(:disabled) { filter: brightness(1.08); }

.em-btn--ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}

.em-btn--ghost:hover { background: var(--surface-hover); }

.em-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
  width: 100%;
}

.em-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.em-btn--primary:disabled {
  background: #b0b0b0 !important;
  color: #fff !important;
  border-color: #b0b0b0 !important;
  opacity: 1;
}

.em-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.em-icon-btn {
  background: none;
  border: none;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
}

.em-icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.em-icon-btn--danger:hover { color: #dc2626; }

/* ── Owner Panel ─────────────────────────────────────────────────────────── */
.em-owner-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.em-stat-card {
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  padding: 20px 18px;
  box-shadow: var(--em-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.em-stat-card--plan {
  border-left: 3px solid var(--em-accent);
}

.em-stat-card__value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--em-text-primary);
  line-height: 1;
}

.em-stat-card__label {
  font-size: 0.78rem;
  color: var(--em-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.em-owner-toolbar {
  margin-bottom: 16px;
}

.em-owner-search {
  width: 320px;
  max-width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  font-size: 0.9rem;
  background: var(--em-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%238c959f' d='M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z'/%3E%3C/svg%3E") no-repeat 10px center;
  outline: none;
  color: var(--em-text-primary);
  transition: border-color var(--em-transition);
}

.em-owner-search:focus { border-color: var(--em-accent); box-shadow: 0 0 0 3px var(--em-accent-light); }

.em-owner-table-wrap {
  background: var(--em-surface);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  box-shadow: var(--em-shadow-sm);
  overflow-x: auto;
}

.em-owner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.em-owner-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--em-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--em-border);
  white-space: nowrap;
  background: var(--em-bg);
}

.em-owner-table tbody tr {
  border-bottom: 1px solid var(--em-border);
  transition: background var(--em-transition);
}

.em-owner-table tbody tr:last-child { border-bottom: none; }
.em-owner-table tbody tr:hover { background: var(--em-hover-bg); }

.em-owner-table td {
  padding: 10px 14px;
  vertical-align: middle;
}

.em-owner-table__row--owner { background: #fffbeb; }
.em-owner-table__row--owner:hover { background: #fef9c3; }

.em-owner-table__email {
  color: var(--em-text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.em-text--center { text-align: center; }
.em-text--small { font-size: 0.8rem; }
.em-text--muted { color: var(--em-text-muted); }
.em-text--danger { color: var(--em-danger); }
.em-text--success { color: var(--em-success); }

/* Owner & plan badges */
.em-badge--owner {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
}

.em-badge--plan {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.em-badge--plan-adventurer { background: #f1f5f9; color: #475569; }
.em-badge--plan-champion   { background: #dcfce7; color: #15803d; }
.em-badge--plan-epic       { background: #dbeafe; color: #1d4ed8; }
.em-badge--plan-legendary  { background: #f3e8ff; color: #7c3aed; }

/* Owner modal */
.em-owner-modal {
  min-width: 400px;
  max-width: 480px;
}

.em-owner-modal--danger .em-modal__header {
  color: var(--em-danger);
}

.em-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 900;
  backdrop-filter: blur(2px);
}

.em-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 901;
  background: var(--em-surface);
  border-radius: var(--em-radius-lg);
  box-shadow: var(--em-shadow-lg);
  display: flex;
  flex-direction: column;
  animation: em-modal-in 0.18s ease;
}

@keyframes em-modal-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% - 12px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

.em-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--em-border);
}

.em-modal__header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.em-modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--em-text-muted);
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}

.em-modal__close:hover { background: var(--em-hover-bg); color: var(--em-text-primary); }

.em-modal__body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.em-modal__body p { margin: 0; font-size: 0.9rem; color: var(--em-text-secondary); }

.em-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--em-border);
}

.em-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.em-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--em-accent);
}

.em-field-hint {
  font-size: 0.8rem;
  color: var(--em-text-muted);
  margin: 4px 0 0;
}
