/* ═══════════════════════════════════════════════════════════════════════════
   MeyerMail – Modern Webmail CSS
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Colors */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --accent: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Light theme */
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-panel: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #eef2ff;
  --bg-input: #f1f5f9;
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --bg-badge: #ef4444;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-width: 260px;
  --header-height: 60px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════ DARK THEME ═══════════════════════════════════════════ */
[data-theme="dark"] {
  --bg-app: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-panel: #1e293b;
  --bg-hover: #334155;
  --bg-active: #312e81;
  --bg-input: #334155;
  --bg-card: #1e293b;
  --bg-modal: #1e293b;

  --border: #334155;
  --border-light: #1e293b;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.4);

  --primary-light: #312e81;
  --primary-glow: rgba(99, 102, 241, 0.25);
}

/* ═══════════════════ STAR WARS THEME ════════════════════════════════════ */
[data-theme="starwars"] {
  --primary: #00d4ff;
  --primary-hover: #00b8e6;
  --primary-light: #001a33;
  --primary-glow: rgba(0, 212, 255, 0.3);
  --accent: #bf5af2;
  --success: #00ff41;
  --warning: #ffd700;
  --danger: #ff1744;

  --bg-app: #000008;
  --bg-sidebar: #06060f;
  --bg-panel: #08081a;
  --bg-hover: #12122a;
  --bg-active: #001a33;
  --bg-input: #0e0e22;
  --bg-card: #08081a;
  --bg-modal: #0a0a1e;
  --bg-badge: #ff1744;

  --border: #1a1a3e;
  --border-light: #0e0e22;

  --text-primary: #d4d4ff;
  --text-secondary: #8888bb;
  --text-muted: #555588;
  --text-inverse: #000000;

  --shadow-sm: 0 1px 3px rgba(0, 212, 255, 0.08);
  --shadow-md: 0 4px 8px rgba(0, 212, 255, 0.08);
  --shadow-lg: 0 8px 16px rgba(0, 212, 255, 0.08);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.5);
}

/* Starfield background */
[data-theme="starwars"] body {
  background-color: #000008;
  background-image:
    radial-gradient(1.2px 1.2px at 10% 20%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 65%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(255,255,255,0.55) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1.2px 1.2px at 90% 80%, rgba(255,255,255,0.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 85%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 55% 55%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 5% 50%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1.2px 1.2px at 65% 90%, rgba(255,255,255,0.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 30%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 85% 60%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 75%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 30, 60, 0.15) 0%, transparent 70%);
  background-size: 300px 300px, 250px 250px, 350px 200px, 200px 350px, 300px 250px,
    250px 300px, 350px 350px, 200px 200px, 300px 350px, 250px 200px,
    350px 300px, 200px 250px, 280px 280px, 100% 100%;
  background-repeat: repeat, repeat, repeat, repeat, repeat, repeat, repeat,
    repeat, repeat, repeat, repeat, repeat, repeat, no-repeat;
}

/* Orbitron font for headers */
[data-theme="starwars"] .logo-text,
[data-theme="starwars"] .panel-header h2,
[data-theme="starwars"] .reader-subject,
[data-theme="starwars"] .calendar-nav h2,
[data-theme="starwars"] .modal-header h3,
[data-theme="starwars"] .login-logo .logo-text {
  font-family: 'Orbitron', 'Inter', sans-serif;
  letter-spacing: 0.05em;
}

/* Logo glow */
[data-theme="starwars"] .logo-text {
  background: linear-gradient(135deg, #00d4ff, #bf5af2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.5));
}

/* Nav icon glow */
[data-theme="starwars"] .nav-icon-btn:hover {
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.15);
}
[data-theme="starwars"] .nav-icon-btn.active {
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.25);
  border: 1px solid rgba(0, 212, 255, 0.15);
}

/* Button glow */
[data-theme="starwars"] .btn-primary {
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.35);
}
[data-theme="starwars"] .btn-primary:hover {
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.55);
}

/* Danger – Imperial red */
[data-theme="starwars"] .btn-danger {
  background: #ff1744;
  box-shadow: 0 0 12px rgba(255, 23, 68, 0.35);
}
[data-theme="starwars"] .btn-danger:hover {
  box-shadow: 0 0 20px rgba(255, 23, 68, 0.55);
}

/* Scrollbar glow */
[data-theme="starwars"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.25);
}
[data-theme="starwars"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 212, 255, 0.45);
}

/* Calendar events – neon border glow */
[data-theme="starwars"] .calendar-event.color-0 { background: #001a33; color: #00d4ff; border: 1px solid rgba(0, 212, 255, 0.4); box-shadow: 0 0 6px rgba(0, 212, 255, 0.2); }
[data-theme="starwars"] .calendar-event.color-1 { background: #001a00; color: #00ff41; border: 1px solid rgba(0, 255, 65, 0.4); box-shadow: 0 0 6px rgba(0, 255, 65, 0.2); }
[data-theme="starwars"] .calendar-event.color-2 { background: #1a1a00; color: #ffd700; border: 1px solid rgba(255, 215, 0, 0.4); box-shadow: 0 0 6px rgba(255, 215, 0, 0.2); }
[data-theme="starwars"] .calendar-event.color-3 { background: #1a0020; color: #bf5af2; border: 1px solid rgba(191, 90, 242, 0.4); box-shadow: 0 0 6px rgba(191, 90, 242, 0.2); }
[data-theme="starwars"] .calendar-event.color-4 { background: #0d001a; color: #a78bfa; border: 1px solid rgba(167, 139, 250, 0.4); box-shadow: 0 0 6px rgba(167, 139, 250, 0.2); }
[data-theme="starwars"] .calendar-event.color-5 { background: #001a1a; color: #00ffd5; border: 1px solid rgba(0, 255, 213, 0.4); box-shadow: 0 0 6px rgba(0, 255, 213, 0.2); }

/* Mailbox active glow */
[data-theme="starwars"] .mailbox-item.active {
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.15);
}

/* Message active glow */
[data-theme="starwars"] .message-item.active {
  border-left-color: #00d4ff;
  box-shadow: inset 3px 0 10px rgba(0, 212, 255, 0.12);
}

/* Contact card glow */
[data-theme="starwars"] .contact-card:hover {
  border-color: #00d4ff;
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.15);
}

/* Calendar today */
[data-theme="starwars"] .calendar-day.today {
  box-shadow: inset 0 0 15px rgba(0, 212, 255, 0.08);
}

/* Calendar sidebar */
[data-theme="starwars"] .calendar-sidebar {
  border-right-color: rgba(0, 212, 255, 0.1);
}

[data-theme="starwars"] .cal-mini-day.today {
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

[data-theme="starwars"] .view-mode-btn.active {
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

[data-theme="starwars"] .cal-time-event {
  box-shadow: 0 0 6px rgba(0, 212, 255, 0.15);
}

/* Input focus glow */
[data-theme="starwars"] .form-group input:focus,
[data-theme="starwars"] .form-group textarea:focus,
[data-theme="starwars"] .search-box:focus-within,
[data-theme="starwars"] .mail-search-box:focus-within {
  border-color: #00d4ff;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.25);
}

/* Modal glow */
[data-theme="starwars"] .modal {
  border: 1px solid rgba(0, 212, 255, 0.15);
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.1), var(--shadow-xl);
}

/* Toast glow */
[data-theme="starwars"] .toast.success { box-shadow: 0 0 12px rgba(0, 255, 65, 0.3); }
[data-theme="starwars"] .toast.error { box-shadow: 0 0 12px rgba(255, 23, 68, 0.3); }
[data-theme="starwars"] .toast.info { box-shadow: 0 0 12px rgba(0, 212, 255, 0.3); }

/* Resize handle glow */
[data-theme="starwars"] .resize-handle:hover,
[data-theme="starwars"] .resize-handle.active {
  background: #00d4ff;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
}

/* Sidebar border glow */
[data-theme="starwars"] .sidebar {
  border-right-color: rgba(0, 212, 255, 0.08);
}

/* Login card glow */
[data-theme="starwars"] .login-card {
  border: 1px solid rgba(0, 212, 255, 0.15);
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.1);
}

[data-theme="starwars"] .login-error {
  background: #1a0000;
  border-color: #ff1744;
  color: #ff6e7a;
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Resizing state ──────────────────────────────────────────────────────── */
body.is-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}
body.is-resizing * {
  transition: none !important;
  cursor: col-resize !important;
}

/* ── App Layout ──────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Login Screen ────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 36px;
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  justify-content: center;
  margin-top: 8px;
}

.login-remember {
  margin: 8px 0 12px;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

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

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}

.login-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}

[data-theme="dark"] .login-info {
  background: #1e3a5f;
  border-color: #1e40af;
  color: #93c5fd;
}

[data-theme="starwars"] .login-info {
  background: #001a33;
  border-color: rgba(0, 212, 255, 0.3);
  color: #00d4ff;
}

[data-theme="dark"] .login-error {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  transition: width var(--transition);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-mini-picker {
  margin-top: 12px;
  margin-bottom: 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.compose-btn {
  width: 100%;
  margin-top: 14px;
  justify-content: center;
  padding: 10px 16px;
}

/* Icon nav bar at bottom */
.sidebar-nav-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

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

.nav-icon-btn.active {
  background: var(--bg-active);
  color: var(--primary);
}

.nav-icon-btn .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--bg-badge);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
  line-height: 1.2;
}

/* Settings grid */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
}

.settings-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.settings-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-active);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}

.settings-item-danger .settings-item-icon {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.settings-item-title {
  font-weight: 600;
  font-size: 14px;
}

.settings-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Mailbox List */
.mailbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.mailbox-list-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 14px 6px;
}

.mailbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  font-size: 13px;
}

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

.mailbox-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.mailbox-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.mailbox-item.active svg {
  opacity: 1;
}

/* Mailbox tree toggle */
.mailbox-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--transition);
  opacity: 0.5;
}
.mailbox-toggle:hover {
  opacity: 1;
}
.mailbox-toggle.expanded {
  transform: rotate(90deg);
}
.mailbox-toggle-spacer {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  margin-top: auto;
}

.sidebar-cal-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ── Resize Handle ───────────────────────────────────────────────────────── */
.resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  left: -3px;
  right: -3px;
  bottom: 0;
}
.resize-handle:hover,
.resize-handle.active {
  background: var(--primary);
}

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* ── Panel Header ────────────────────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
  min-height: var(--header-height);
  gap: 12px;
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

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

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-text {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-text:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-danger:hover {
  background: #dc2626;
}

/* ── Search Box ──────────────────────────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-box input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  width: 200px;
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* Mail search box (inline in panel header) */
.mail-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  flex: 1;
  max-width: 240px;
}
.mail-search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  max-width: 300px;
}
.mail-search-box svg {
  flex-shrink: 0;
  color: var(--text-muted);
}
.mail-search-box input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.mail-search-box input::placeholder {
  color: var(--text-muted);
}
.search-clear-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.search-clear-btn:hover {
  color: var(--text-primary);
}

/* ═══════════════════ MAIL VIEW ═══════════════════════════════════════════ */
.mail-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.message-list-panel {
  width: 420px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  transition: width var(--transition);
}

.message-list-panel .panel-header {
  padding: 14px 18px;
}

.message-list {
  flex: 1;
  overflow-y: auto;
}

.message-reader-panel {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-app);
}

/* Message Item */
.message-item {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

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

.message-item.active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding-left: 15px;
}

.message-item.unread {
  background: var(--bg-panel);
}

.message-item.unread .message-subject {
  font-weight: 600;
  color: var(--text-primary);
}

.message-item.unread::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  background: var(--primary);
  border-radius: 50%;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  color: white;
  flex-shrink: 0;
}

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

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

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

.message-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 8px;
}

.message-subject {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.message-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Message Reader */
.message-reader-panel .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--text-muted);
}

.reader-content {
  padding: 32px;
  max-width: 900px;
}

.reader-subject {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.3;
}

.reader-meta {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.reader-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.reader-meta-info {
  flex: 1;
}

.reader-from-name {
  font-weight: 600;
  font-size: 14px;
}

.reader-from-email {
  color: var(--text-muted);
  font-size: 12px;
}

.reader-to {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

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

.reader-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn-text-primary {
  color: var(--primary);
  font-weight: 600;
}

.btn-text-primary:hover {
  background: var(--primary-light);
}

.reader-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
}

.reader-body iframe {
  width: 100%;
  border: none;
  min-height: 300px;
  background: white;
  border-radius: var(--radius-sm);
}

.reader-attachments {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.reader-attachments h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 0 8px 8px 0;
  color: var(--text-secondary);
}

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

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

.pagination span {
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════════════════ CALENDAR VIEW ════════════════════════════════════════ */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-nav h2 {
  min-width: 180px;
  text-align: center;
}

/* ── View Mode Buttons ── */
.calendar-view-modes {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin-left: 12px;
}

.view-mode-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.view-mode-btn:hover {
  color: var(--text-primary);
}

.view-mode-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ── Calendar Layout (sidebar + main) ── */
.calendar-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.calendar-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.calendar-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Mini Date Picker ── */
.cal-mini-picker {
  user-select: none;
}

.cal-mini-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-mini-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-xs {
  width: 24px !important;
  height: 24px !important;
  padding: 0 !important;
}

.cal-mini-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.cal-mini-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.cal-mini-day {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  margin: 0 auto;
}

.cal-mini-day:hover {
  background: var(--bg-hover);
}

.cal-mini-day.other {
  color: var(--text-muted);
  opacity: 0.4;
}

.cal-mini-day.today {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.cal-mini-day.selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.cal-mini-day.today.selected {
  background: var(--primary);
  color: white;
}

/* ── Calendar List ── */
.cal-list-section {
  flex: 1;
}

.cal-list-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cal-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background var(--transition);
}

.cal-list-item:hover {
  background: var(--bg-hover);
}

.cal-list-item input[type="checkbox"] {
  accent-color: var(--primary);
}

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

.cal-list-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 24px 24px;
}

/* ── Day/Week View (hourly grid) ── */
.cal-time-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 24px 24px;
}

.cal-week-header {
  display: grid;
  gap: 1px;
  padding: 0 24px;
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  z-index: 2;
}

.cal-week-header-day {
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.cal-week-header-day.today {
  color: var(--primary);
  font-weight: 700;
}

.cal-week-header-day .day-num {
  display: block;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.cal-time-row {
  display: flex;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
}

.cal-time-label {
  width: 56px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  padding-right: 10px;
  padding-top: 2px;
  position: relative;
  top: -7px;
}

.cal-time-slots {
  flex: 1;
  display: grid;
  gap: 1px;
  position: relative;
}

.cal-time-slot {
  min-height: 48px;
  border-left: 1px solid var(--border);
  padding: 2px 4px;
  position: relative;
  cursor: pointer;
}

.cal-time-slot:hover {
  background: var(--bg-hover);
}

.cal-time-event {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  margin-bottom: 1px;
}

.cal-day-header {
  text-align: center;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

/* ── Agenda View ── */
.cal-agenda {
  padding: 16px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
}

.cal-agenda-day {
  display: flex;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}

.cal-agenda-day.past {
  opacity: 0.5;
}

.cal-agenda-day.today {
  opacity: 1;
}

.cal-agenda-date {
  width: 80px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 16px;
  border-right: 2px solid var(--border);
}

.cal-agenda-day.today .cal-agenda-date {
  border-right-color: var(--primary);
}

.cal-agenda-date-num {
  display: block;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.cal-agenda-date-num.today {
  color: var(--primary);
}

.cal-agenda-date-info {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.cal-agenda-events {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.cal-agenda-event {
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.cal-agenda-event:hover {
  background: var(--bg-hover);
}

.cal-agenda-event-time {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
}

.cal-agenda-event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.cal-agenda-event-loc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.cal-agenda-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: 4px;
}

.calendar-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  flex: 1;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-day {
  background: var(--bg-panel);
  padding: 6px 8px;
  min-height: 90px;
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}

.calendar-day:hover {
  background: var(--bg-hover);
}

.calendar-day.other-month {
  opacity: 0.35;
}

.calendar-day.today {
  background: var(--primary-light);
}

.calendar-day-number {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.calendar-day.today .calendar-day-number {
  background: var(--primary);
  color: white;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
}

.calendar-event {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-weight: 500;
}

.calendar-event.color-0 { background: #dbeafe; color: #1e40af; }
.calendar-event.color-1 { background: #dcfce7; color: #166534; }
.calendar-event.color-2 { background: #fef3c7; color: #92400e; }
.calendar-event.color-3 { background: #fce7f3; color: #9d174d; }
.calendar-event.color-4 { background: #e0e7ff; color: #3730a3; }
.calendar-event.color-5 { background: #ccfbf1; color: #115e59; }

[data-theme="dark"] .calendar-event.color-0 { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .calendar-event.color-1 { background: #14532d; color: #86efac; }
[data-theme="dark"] .calendar-event.color-2 { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .calendar-event.color-3 { background: #831843; color: #f9a8d4; }
[data-theme="dark"] .calendar-event.color-4 { background: #312e81; color: #a5b4fc; }
[data-theme="dark"] .calendar-event.color-5 { background: #134e4a; color: #5eead4; }

/* ═══════════════════ CONTACTS VIEW ═══════════════════════════════════════ */
.contacts-grid {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  align-content: start;
}

.contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
}

.contact-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.contact-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.contact-name {
  font-size: 15px;
  font-weight: 600;
}

.contact-org {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.contact-detail {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.contact-detail svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.contact-detail a {
  color: var(--primary);
  text-decoration: none;
}

.contact-detail a:hover {
  text-decoration: underline;
}

/* ═══════════════════ MODAL ═══════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-modal);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.compose-modal {
  max-width: 960px;
  width: 90vw;
  border-radius: 24px;
  overflow: visible;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal.compose-modal .modal-header {
  display: none;
}

.modal.compose-modal .modal-body {
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ── Compose Split Layout (form left, AI right) ── */
.compose-split {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.compose-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
}

.compose-right {
  width: 260px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-light);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-input);
}

/* New mail without AI panel - full width */
.compose-split.compose-new-mail .compose-left {
  flex: 1;
  max-width: 100%;
}

.compose-right .compose-ai-suggestions {
  display: block !important;
  padding: 0;
}

.compose-right .ai-suggestions-bubbles {
  gap: 10px;
}

.compose-right .ai-bubble {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
}

/* Draft button */
.compose-draft-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.compose-draft-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-color: var(--text-muted);
}

/* Signature settings */
.signature-settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sig-account-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sig-account-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.sig-textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Courier New', monospace;
  padding: 12px 14px;
  border-radius: 10px;
  outline: none;
  resize: vertical;
  min-height: 160px;
  line-height: 1.6;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.sig-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.sig-html-preview {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-panel);
  font-size: 9pt;
  line-height: 1.5;
}

.sig-html-preview img {
  max-width: 200px;
  height: auto;
}

.compose-sig-preview {
  display: none;
  margin-top: 8px;
  padding: 12px 16px;
  border: 1px dashed var(--border-light);
  border-radius: 10px;
  background: var(--bg-panel);
  font-size: 9pt;
  line-height: 1.5;
}

.compose-sig-preview img {
  max-width: 200px;
  height: auto;
}

/* ── Compose Form – Friendly Design ──────────────────────────────────────── */

/* Hero header with gradient */
.compose-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 26px;
  background: linear-gradient(135deg, var(--primary-light), var(--bg-modal));
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  border-radius: 24px 24px 0 0;
}

.compose-hero-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.compose-hero-info {
  flex: 1;
  min-width: 0;
}

.compose-hero-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.compose-hero-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compose-close-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.compose-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Field group */
.compose-form {
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.compose-field-group {
  padding: 14px 26px 6px;
}

.compose-field-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.compose-extra-row {
  animation: fadeSlideIn 0.2s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; max-height: 0; margin-bottom: 0; }
  to { opacity: 1; max-height: 60px; margin-bottom: 8px; }
}

.compose-field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 64px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compose-field-label svg {
  opacity: 0.55;
}

.compose-input {
  flex: 1;
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  padding: 9px 14px;
  border-radius: 10px;
  outline: none;
  transition: all var(--transition);
  min-width: 0;
}

.compose-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-panel);
}

.compose-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* From select */
.compose-from-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* CC/BCC toggle button */
.compose-cc-toggle {
  flex-shrink: 0;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: 0.02em;
  margin-left: 6px;
}

.compose-cc-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* Body area */
.compose-body-area {
  padding: 0 26px;
}

.compose-body-area textarea {
  width: 100%;
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  padding: 14px 16px;
  border-radius: 12px;
  outline: none;
  resize: vertical;
  min-height: 180px;
  line-height: 1.7;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.compose-body-area textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-panel);
}

.compose-body-area textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Compose Attachments */
.compose-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 0;
  margin: 0 26px;
}

.compose-att-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-size: 12px;
  color: var(--text-secondary);
}

.compose-att-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.compose-att-item .att-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-att-item .att-size {
  color: var(--text-muted);
  font-size: 11px;
}

.compose-att-item .att-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  font-family: inherit;
}

.compose-att-item .att-remove:hover {
  color: var(--danger);
}

/* AI Suggestion Bubbles */
.compose-ai-suggestions {
  padding: 10px 26px 6px;
}

.ai-suggestions-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.ai-suggestions-header svg {
  color: var(--accent);
}

.ai-suggestions-bubbles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* AI bubble styles are in the COMPOSE TOOLBAR / AI SUGGESTION BUBBLES section below */

[data-theme="starwars"] .ai-suggestions-header svg {
  color: #bf5af2;
}

/* AI hint */
.compose-ai-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 26px 2px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.6;
}

/* Action bar – sticky bottom */
.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px 18px;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-modal);
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 24px 24px;
}

.compose-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compose-discard {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.compose-discard:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-color: var(--text-muted);
}

.compose-send-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 26px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  box-shadow: 0 4px 14px var(--primary-glow);
  white-space: nowrap;
}

.compose-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.compose-send-btn:active {
  transform: translateY(0);
}

/* AI Button */
.btn-ai {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-ai:hover {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
  transform: translateY(-1px);
}

.btn-ai:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.btn-ai.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

.ai-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  letter-spacing: 0.03em;
}

.btn-ai:hover .ai-badge {
  background: rgba(255,255,255,0.25);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* AI Prompt Popover */
.ai-prompt-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 260px;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  z-index: 150;
  animation: popoverIn 0.15s ease;
}

@keyframes popoverIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-prompt-popover-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 16px 6px;
}

.ai-prompt-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.1s;
}

.ai-prompt-option:hover {
  background: var(--bg-hover);
}

.ai-prompt-option svg {
  color: var(--accent);
  flex-shrink: 0;
}

.ai-prompt-option:hover svg {
  color: var(--primary);
}

.ai-prompt-custom {
  color: var(--text-secondary);
}

.ai-prompt-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.ai-prompt-custom-input {
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-prompt-custom-input textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  outline: none;
  resize: none;
  line-height: 1.5;
}

.ai-prompt-custom-input textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.ai-prompt-custom-input textarea::placeholder {
  color: var(--text-muted);
}

.ai-prompt-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}

.ai-prompt-submit:hover {
  box-shadow: 0 3px 10px var(--primary-glow);
}

/* Reader AI popover - position above the button */
.reader-ai-popover {
  bottom: calc(100% + 8px);
  left: auto;
  right: 0;
}

/* Star Wars popover */
[data-theme="starwars"] .ai-prompt-popover {
  border-color: rgba(0, 212, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.08), var(--shadow-lg);
}

[data-theme="starwars"] .ai-prompt-option:hover {
  background: rgba(0, 212, 255, 0.06);
}

[data-theme="starwars"] .ai-prompt-option svg {
  color: #bf5af2;
}

[data-theme="starwars"] .ai-prompt-submit {
  background: linear-gradient(135deg, #00d4ff, #bf5af2);
}

/* Dark theme hero */
[data-theme="dark"] .compose-hero {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), var(--bg-modal));
}

/* Star Wars compose */
[data-theme="starwars"] .compose-hero {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.06), var(--bg-modal));
}

[data-theme="starwars"] .compose-hero-icon {
  background: linear-gradient(135deg, #00d4ff, #bf5af2);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}

[data-theme="starwars"] .compose-send-btn {
  background: linear-gradient(135deg, #00d4ff, #bf5af2);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}

[data-theme="starwars"] .compose-send-btn:hover {
  box-shadow: 0 6px 24px rgba(0, 212, 255, 0.5);
}

[data-theme="starwars"] .compose-input:focus,
[data-theme="starwars"] .compose-body-area textarea:focus {
  border-color: #00d4ff;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

[data-theme="starwars"] .compose-cc-toggle:hover {
  border-color: #00d4ff;
  color: #00d4ff;
  background: rgba(0, 212, 255, 0.06);
}

[data-theme="starwars"] .compose-close-btn:hover {
  color: #00d4ff;
}

/* Star Wars AI button glow */
[data-theme="starwars"] .btn-ai {
  border-color: #bf5af2;
  color: #bf5af2;
}
[data-theme="starwars"] .btn-ai:hover {
  background: #bf5af2;
  color: white;
  box-shadow: 0 0 16px rgba(191, 90, 242, 0.4);
}
[data-theme="starwars"] .ai-badge {
  background: #bf5af2;
  box-shadow: 0 0 6px rgba(191, 90, 242, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
}

/* Form styles */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ═══════════════════ STATES ═════════════════════════════════════════════ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ═══════════════════ TOAST ══════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 360px;
}

.toast.success {
  background: var(--success);
  color: white;
}

.toast.error {
  background: var(--danger);
  color: white;
}

.toast.info {
  background: var(--primary);
  color: white;
}

/* ═══════════════════ THEME TOGGLE ═══════════════════════════════════════ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--primary);
}

/* ═══════════════════ SCROLLBAR ══════════════════════════════════════════ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══════════════════ ANIMATIONS ═════════════════════════════════════════ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ═══════════════════ BULK SELECTION ════════════════════════════════════ */
.message-checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  position: relative;
  cursor: pointer;
  margin-right: -6px;
}

.message-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.message-checkbox .checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 4px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-checkbox:hover .checkmark {
  border-color: var(--primary);
}

.message-checkbox input:checked ~ .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.message-checkbox input:checked ~ .checkmark::after {
  content: '';
  display: block;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -1px;
}

.message-item.selected {
  background: var(--primary-light);
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-input);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.bulk-toolbar .bulk-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  min-width: 80px;
}

.bulk-toolbar .bulk-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.bulk-toolbar .bulk-select:focus {
  border-color: var(--primary);
}

.bulk-toolbar .bulk-select-all-link {
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
  background: none;
  font-family: inherit;
}

.bulk-toolbar .bulk-select-all-link:hover {
  color: var(--primary-hover);
}

/* ═══════════════════ CONTEXT MENU ═════════════════════════════════════ */
.context-menu {
  position: fixed;
  z-index: 300;
  min-width: 200px;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  animation: fadeIn 0.12s ease;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.context-menu-item:hover {
  background: var(--bg-hover);
}

.context-menu-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.context-menu-item:hover svg {
  color: var(--text-primary);
}

.context-menu-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.context-menu-item.danger {
  color: var(--danger);
}

.context-menu-item.danger svg {
  color: var(--danger);
}

/* Star Wars context menu glow */
[data-theme="starwars"] .context-menu {
  border-color: rgba(0, 212, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1), var(--shadow-lg);
}

[data-theme="starwars"] .context-menu-item:hover {
  background: rgba(0, 212, 255, 0.08);
}

/* ═══════════════════ ACCOUNT SECTIONS ═══════════════════════════════════ */
.account-section {
  margin-bottom: 4px;
}

.account-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 4px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  border-radius: var(--radius-sm);
}

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

.account-header-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform var(--transition);
  opacity: 0.5;
  color: var(--text-muted);
}

.account-header-toggle.expanded {
  transform: rotate(90deg);
}

.account-header-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
}

.account-header-email {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Different color for extra accounts */
.account-section:nth-child(2) .account-header-icon {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.account-section:nth-child(3) .account-header-icon {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}

/* ═══════════════════ DRAG & DROP ════════════════════════════════════════ */
.message-item[draggable="true"] {
  cursor: grab;
}

.message-item[draggable="true"]:active {
  cursor: grabbing;
}

.message-item.dragging {
  opacity: 0.4;
}

.mailbox-item.drag-over {
  background: var(--primary-light) !important;
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  color: var(--primary) !important;
  font-weight: 600;
}

[data-theme="starwars"] .mailbox-item.drag-over {
  outline-color: #00d4ff;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.25);
}

/* Drag & Drop Confirmation Dialog */
.dd-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.dd-confirm-dialog {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  box-shadow: var(--shadow-xl);
  text-align: center;
  max-width: 380px;
  width: 90%;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dd-confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.dd-confirm-text {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.dd-confirm-text strong {
  color: var(--primary);
}

.dd-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

[data-theme="starwars"] .dd-confirm-dialog {
  border-color: rgba(0, 212, 255, 0.15);
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.1), var(--shadow-xl);
}

[data-theme="starwars"] .dd-confirm-icon {
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

/* Star Wars nav icon glow */
[data-theme="starwars"] .nav-icon-btn:hover {
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.15);
}

[data-theme="starwars"] .nav-icon-btn.active {
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
  border: 1px solid rgba(0, 212, 255, 0.12);
}

/* ═══════════════════ COMPOSE TOOLBAR ═══════════════════════════════════ */
.compose-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-input);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  flex-wrap: wrap;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.15s;
}

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

.tb-btn:active {
  background: var(--primary-light);
  color: var(--primary);
}

.tb-sep {
  width: 1px;
  height: 18px;
  background: var(--border-light);
  margin: 0 4px;
  flex-shrink: 0;
}

.tb-select {
  padding: 3px 6px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.tb-select:focus {
  border-color: var(--primary);
}

.tb-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.tb-option:hover {
  color: var(--text-primary);
}

.tb-option input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: var(--primary);
}

/* ═══════════════════ COMPOSE EDITOR (contenteditable) ═════════════════ */
.compose-editor {
  flex: 1;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  overflow-y: auto;
  min-height: 180px;
  outline: none;
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--bg-panel);
}

.compose-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.08);
}

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

.compose-editor .email-signature {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 9pt;
  color: var(--text-secondary);
}

.compose-editor .email-signature img {
  max-width: 200px;
  height: auto;
}

/* ═══════════════════ AI SUGGESTION BUBBLES ════════════════════════════ */
.ai-bubble {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  background: transparent;
}

.ai-bubble:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.ai-bubble svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-bubble-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-bubble-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ai-bubble-text {
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Positive = green */
.ai-bubble-positive {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.06);
  color: #059669;
}
.ai-bubble-positive:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.5);
}
.ai-bubble-positive .ai-bubble-label { color: #059669; }
.ai-bubble-positive svg { color: #10b981; }

/* Negative = red */
.ai-bubble-negative {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.06);
  color: #dc2626;
}
.ai-bubble-negative:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.5);
}
.ai-bubble-negative .ai-bubble-label { color: #dc2626; }
.ai-bubble-negative svg { color: #ef4444; }

/* Neutral = blue */
.ai-bubble-neutral {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.06);
  color: #2563eb;
}
.ai-bubble-neutral:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.5);
}
.ai-bubble-neutral .ai-bubble-label { color: #2563eb; }
.ai-bubble-neutral svg { color: #3b82f6; }

/* Loading bubble */
.ai-bubble-loading {
  border-color: var(--border-light);
  color: var(--text-muted);
  cursor: default;
  justify-content: center;
}
.ai-bubble-loading:hover {
  transform: none;
  box-shadow: none;
}

@keyframes bubbleFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Dark theme adjustments */
[data-theme="dark"] .ai-bubble-positive {
  color: #6ee7b7;
}
[data-theme="dark"] .ai-bubble-positive .ai-bubble-label { color: #6ee7b7; }
[data-theme="dark"] .ai-bubble-negative {
  color: #fca5a5;
}
[data-theme="dark"] .ai-bubble-negative .ai-bubble-label { color: #fca5a5; }
[data-theme="dark"] .ai-bubble-neutral {
  color: #93c5fd;
}
[data-theme="dark"] .ai-bubble-neutral .ai-bubble-label { color: #93c5fd; }

/* Star Wars theme */
[data-theme="starwars"] .ai-bubble-positive {
  border-color: rgba(0, 255, 100, 0.25);
  background: rgba(0, 255, 100, 0.05);
  color: #4ade80;
}
[data-theme="starwars"] .ai-bubble-negative {
  border-color: rgba(255, 50, 50, 0.25);
  background: rgba(255, 50, 50, 0.05);
  color: #f87171;
}
[data-theme="starwars"] .ai-bubble-neutral {
  border-color: rgba(0, 212, 255, 0.25);
  background: rgba(0, 212, 255, 0.05);
  color: #67e8f9;
}

/* ═══════════════════ AI SETTINGS ══════════════════════════════════════ */
.ai-settings {
  max-width: 520px;
}

.ai-provider-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-provider-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-input);
}

.ai-provider-card:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.ai-provider-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.ai-provider-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-provider-icon {
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  border-radius: 8px;
  flex-shrink: 0;
}

.ai-provider-info {
  flex: 1;
  min-width: 0;
}

.ai-provider-name {
  font-weight: 600;
  font-size: 14px;
  display: block;
  color: var(--text-primary);
}

.ai-provider-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.ai-provider-check {
  color: var(--primary);
  flex-shrink: 0;
  width: 20px;
}

.ai-provider-options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-opt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.ai-opt-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.ai-opt-select:focus {
  border-color: var(--primary);
}

.ai-opt-input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.ai-opt-input:focus {
  border-color: var(--primary);
}

/* ═══════════════════ SIGNATURE EDITOR ═════════════════════════════════ */
.signature-settings {
  max-width: 560px;
}

.sig-account-block {
  margin-bottom: 16px;
}

.sig-account-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.sig-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg-input);
}

.sig-editor {
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 12px 14px;
  min-height: 160px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-panel);
  outline: none;
  overflow-y: auto;
}

.sig-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.08);
}

.sig-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.sig-editor img {
  max-width: 200px;
  height: auto;
}

/* ═══════════════════ RESPONSIVE ═════════════════════════════════════════ */
@media (max-width: 1024px) {
  .message-list-panel {
    width: 340px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  .sidebar .logo-text,
  .sidebar .mailbox-list,
  .sidebar .compose-btn {
    display: none;
  }

  .resize-handle {
    display: none;
  }

  .message-list-panel {
    width: 100%;
    border-right: none;
  }

  .message-reader-panel {
    display: none;
  }

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