/* MailPro - Advanced Email Client
   Modern dark-theme design with glassmorphism */

/* === CSS Variables === */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Dark theme (default) */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-elevated: #1e1e32;
  --bg-hover: rgba(255,255,255,0.05);
  --bg-active: rgba(99,102,241,0.15);
  --bg-glass: rgba(18,18,26,0.85);

  --text-primary: #e8e8f0;
  --text-secondary: #9898b0;
  --text-tertiary: #6b6b85;
  --text-inverse: #0a0a0f;

  --border: rgba(255,255,255,0.08);
  --border-subtle: rgba(255,255,255,0.04);

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99,102,241,0.15);
  --accent-glow: rgba(99,102,241,0.3);

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --gradient-brand: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --topbar-h: 56px;
  --sidebar-w: 240px;
  --list-w: 380px;

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

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f5f5f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f0f5;
  --bg-elevated: #ffffff;
  --bg-hover: rgba(0,0,0,0.04);
  --bg-active: rgba(99,102,241,0.1);
  --bg-glass: rgba(255,255,255,0.9);

  --text-primary: #1a1a2e;
  --text-secondary: #5a5a72;
  --text-tertiary: #9898b0;
  --text-inverse: #ffffff;

  --border: rgba(0,0,0,0.1);
  --border-subtle: rgba(0,0,0,0.05);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* ============================
   MULTI-COLOR ACCENT THEMES
   ============================ */

/* Indigo (default) - no override needed, :root already has it */

/* Ocean Blue */
[data-color="blue"] {
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59,130,246,0.15);
  --accent-glow: rgba(59,130,246,0.3);
  --gradient-brand: linear-gradient(135deg, #3b82f6, #2563eb, #60a5fa);
  --gradient-accent: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* Emerald Green */
[data-color="green"] {
  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-soft: rgba(16,185,129,0.15);
  --accent-glow: rgba(16,185,129,0.3);
  --gradient-brand: linear-gradient(135deg, #10b981, #059669, #34d399);
  --gradient-accent: linear-gradient(135deg, #10b981, #059669);
}

/* Rose Pink */
[data-color="rose"] {
  --accent: #f43f5e;
  --accent-hover: #fb7185;
  --accent-soft: rgba(244,63,94,0.15);
  --accent-glow: rgba(244,63,94,0.3);
  --gradient-brand: linear-gradient(135deg, #f43f5e, #e11d48, #fb7185);
  --gradient-accent: linear-gradient(135deg, #f43f5e, #e11d48);
}

/* Amber Orange */
[data-color="amber"] {
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245,158,11,0.15);
  --accent-glow: rgba(245,158,11,0.3);
  --gradient-brand: linear-gradient(135deg, #f59e0b, #d97706, #fbbf24);
  --gradient-accent: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Violet Purple */
[data-color="violet"] {
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-soft: rgba(139,92,246,0.15);
  --accent-glow: rgba(139,92,246,0.3);
  --gradient-brand: linear-gradient(135deg, #8b5cf6, #7c3aed, #a78bfa);
  --gradient-accent: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* Teal Cyan */
[data-color="teal"] {
  --accent: #14b8a6;
  --accent-hover: #2dd4bf;
  --accent-soft: rgba(20,184,166,0.15);
  --accent-glow: rgba(20,184,166,0.3);
  --gradient-brand: linear-gradient(135deg, #14b8a6, #0d9488, #2dd4bf);
  --gradient-accent: linear-gradient(135deg, #14b8a6, #0d9488);
}

/* Light theme + color overrides: adjust bg-active per accent */
[data-theme="light"][data-color="blue"] { --bg-active: rgba(59,130,246,0.1); }
[data-theme="light"][data-color="green"] { --bg-active: rgba(16,185,129,0.1); }
[data-theme="light"][data-color="rose"] { --bg-active: rgba(244,63,94,0.1); }
[data-theme="light"][data-color="amber"] { --bg-active: rgba(245,158,11,0.1); }
[data-theme="light"][data-color="violet"] { --bg-active: rgba(139,92,246,0.1); }
[data-theme="light"][data-color="teal"] { --bg-active: rgba(20,184,166,0.1); }

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

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* === Loader === */
.loader-ring {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.loader-ring.large { width: 40px; height: 40px; border-width: 4px; }

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

/* === Material Symbols Override === */
.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  font-size: 20px;
  vertical-align: middle;
}

/* ===========================
   LOGIN SCREEN
   =========================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 40px 0;
}

/* When email interface is active, lock body scroll */
.login-screen.hidden ~ .email-interface {
  position: fixed;
  inset: 0;
}

.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 12s ease-in-out infinite;
}

.login-orb-1 {
  width: 400px; height: 400px;
  background: #6366f1;
  top: -100px; left: -100px;
  animation-delay: 0s;
}

.login-orb-2 {
  width: 350px; height: 350px;
  background: #8b5cf6;
  bottom: -80px; right: -80px;
  animation-delay: -4s;
}

.login-orb-3 {
  width: 250px; height: 250px;
  background: #a78bfa;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -8s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: auto;
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
}

.brand-icon {
  margin: 0 auto 16px;
  background: var(--gradient-brand);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-icon .material-symbols-rounded {
  font-size: 32px;
  color: white;
  font-variation-settings: 'FILL' 1;
}

.login-brand h1 {
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.brand-tagline {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* Login Tabs */
.login-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.login-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.login-tab .material-symbols-rounded { font-size: 16px; }

.login-tab:hover { color: var(--text-primary); background: var(--bg-hover); }

.login-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-glow);
}

/* Login Forms */
.login-form { display: none; }
.login-form.active { display: block; }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group label .material-symbols-rounded { font-size: 16px; color: var(--accent); }

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

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

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-tertiary);
}

.form-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Login Button */
.btn-login {
  width: 100%;
  padding: 12px 20px;
  background: var(--gradient-accent);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

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

.btn-content, .btn-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-loader .loader-ring {
  width: 18px; height: 18px;
  border-width: 2px;
  border-color: rgba(255,255,255,0.3);
  border-top-color: white;
}

/* Login Error */
.login-error {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 13px;
}

/* ===========================
   GET CODE TAB STYLES
   =========================== */
.getcode-type-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.getcode-type-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.getcode-type-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.getcode-type-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Get Code Results */
.getcode-results {
  margin-top: 16px;
  max-height: 400px;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-primary);
}

.getcode-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.getcode-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  color: var(--danger);
  font-size: 13px;
}

.getcode-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.getcode-summary strong {
  color: var(--accent);
}

.getcode-type-badge {
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.getcode-copy-all {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.getcode-copy-all:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.getcode-copy-all .material-symbols-rounded {
  font-size: 14px;
}

.getcode-list {
  display: flex;
  flex-direction: column;
}

.getcode-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.getcode-item:last-child {
  border-bottom: none;
}

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

.getcode-item.success {
  border-left: 3px solid var(--success, #22c55e);
}

.getcode-item.fail {
  border-left: 3px solid var(--danger);
  opacity: 0.7;
}

.getcode-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.getcode-item-email {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.getcode-item-date {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.getcode-item-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--danger);
}

.getcode-item-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.getcode-item-code {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 2px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.getcode-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.getcode-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.getcode-copy-btn .material-symbols-rounded {
  font-size: 14px;
}

.getcode-item-content {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* IMAP info box */
.imap-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.imap-info .material-symbols-rounded {
  font-size: 18px;
  color: var(--primary);
  flex-shrink: 0;
}

/* Method selector */
.getcode-method-grid {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.getcode-method-select,
.bulk-method-select {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.getcode-method-select:hover,
.bulk-method-select:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.getcode-method-select.active,
.bulk-method-select.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Method badges in results */
.getcode-method-badge {
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.getcode-method-badge.graph {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

.getcode-method-badge.oauth2 {
  background: rgba(234,179,8,0.15);
  color: #eab308;
}

/* ===========================
   MAIN EMAIL INTERFACE
   =========================== */
.email-interface {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
}

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

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mini-icon {
  font-size: 22px;
  color: var(--accent);
  font-variation-settings: 'FILL' 1;
}

.brand-mini-text {
  font-size: 16px;
  font-weight: 700;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-center { flex: 1; max-width: 540px; }

.search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 38px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.search-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon { color: var(--text-tertiary); font-size: 18px; }

.search-container input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
}

.search-container input::placeholder { color: var(--text-tertiary); }

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

/* Icon Button */
.icon-btn {
  display: inline-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: var(--transition);
  position: relative;
  font-family: var(--font);
}

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

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.icon-btn.danger:hover {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* User Menu */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-brand);
  border: none;
  color: white;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.user-avatar:hover { box-shadow: var(--shadow-glow); transform: scale(1.05); }

/* === Color Picker === */
.color-picker-wrapper { position: relative; }

.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: block;
  border: 2px solid var(--border);
  transition: var(--transition);
}

.icon-btn:hover .color-dot { border-color: var(--accent); transform: scale(1.1); }

.color-picker-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 250;
  padding: 12px;
  animation: fadeIn 0.15s;
}

.color-picker-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  padding: 3px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-swatch span {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  transition: transform 0.15s;
}

.color-swatch:hover {
  border-color: var(--text-tertiary);
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--text-secondary);
}

.color-swatch.active span { transform: scale(0.85); }

.user-menu { position: relative; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}

.dropdown-header {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-name { font-weight: 600; font-size: 14px; }
.dropdown-email { font-size: 12px; color: var(--text-secondary); }
.dropdown-divider { height: 1px; background: var(--border); }

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

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item .material-symbols-rounded { font-size: 18px; color: var(--text-secondary); }

/* === Main Layout === */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px 0;
  flex-shrink: 0;
  transition: var(--transition);
}

.nav-folders { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  user-select: none;
}

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

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

.nav-item .material-symbols-rounded { font-size: 18px; }
.nav-item.active .material-symbols-rounded { font-variation-settings: 'FILL' 1; }

.nav-label { flex: 1; }

.nav-badge {
  font-size: 11px;
  font-weight: 700;
  color: white;
  background: var(--accent);
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.nav-badge:empty { display: none; }

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

/* Sidebar Sections */
.sidebar-section { padding: 0 8px; }

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
}

.section-header .material-symbols-rounded { font-size: 16px; }
.section-header.collapsible { cursor: pointer; }
.section-arrow { margin-left: auto; font-size: 18px!important; transition: var(--transition); }
.section-header.collapsed .section-arrow { transform: rotate(-90deg); }

/* Code Extraction Grid */
.code-extract-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px 4px 8px;
}

.code-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.code-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.code-btn-all {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Folder List */
.folder-list .nav-item {
  padding: 7px 12px;
  font-size: 12px;
}

/* Accounts List */
.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

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

.account-item:hover { background: var(--bg-hover); }
.account-item.active { background: var(--accent-soft); color: var(--accent); }

.account-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.account-dot.error { background: var(--danger); }
.account-dot.loading { background: var(--warning); animation: pulse 1s infinite; }

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

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

/* ===========================
   EMAIL LIST
   =========================== */
.email-list-panel {
  width: var(--list-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.message-count { font-size: 12px; color: var(--text-tertiary); }
.page-info { font-size: 11px; color: var(--text-tertiary); min-width: 40px; text-align: center; }

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

.list-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--text-tertiary);
}

.list-placeholder p { font-size: 13px; }

/* Email Item */
.email-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

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

.email-item.selected {
  background: var(--bg-active);
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}

.email-item.unread {
  background: rgba(99,102,241,0.04);
}

.email-item.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

.email-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.email-body-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.email-row-1 {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.email-item.unread .email-sender { font-weight: 700; }

.email-date {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.email-subject {
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-item.unread .email-subject { font-weight: 600; }

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

.email-tags {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.email-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.email-tag.attachment {
  background: rgba(245,158,11,0.15);
  color: var(--warning);
}

.email-tag.important {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
  text-align: center;
  height: 100%;
}

.empty-state .material-symbols-rounded {
  font-size: 56px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p { font-size: 13px; }

/* ===========================
   READING PANE
   =========================== */
.reading-pane {
  flex: 1;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  min-height: 48px;
}

.reading-actions { display: flex; gap: 4px; }

.reading-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.reading-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  text-align: center;
}

.empty-icon {
  font-size: 72px!important;
  opacity: 0.2;
  margin-bottom: 16px;
}

.reading-empty h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.reading-empty p { font-size: 13px; }

/* Email View */
.email-view {
  max-width: 100%;
}

.email-view-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.email-view-subject {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

.email-view-meta {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

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

.email-view-info { flex: 1; min-width: 0; }

.email-view-from {
  font-size: 14px;
  font-weight: 600;
}

.email-view-from-email {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 400;
}

.email-view-to {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.email-view-date {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.email-view-body {
  padding: 24px 32px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.email-html-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.email-html-content img { max-width: 100%; height: auto; }
.email-html-content table { max-width: 100%; }
.email-html-content a { color: var(--accent); }

/* ===========================
   CODE MODAL
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

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

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s;
}

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

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

.modal-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
}

.modal-header h2 .material-symbols-rounded {
  color: var(--accent);
  font-variation-settings: 'FILL' 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.code-result {
  width: 100%;
  padding: 16px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

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

.code-result-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.code-result-date {
  font-size: 11px;
  color: var(--text-tertiary);
}

.code-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--success);
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
}

.code-content {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.code-copy-btn:hover { background: var(--accent-hover); }
.code-copy-btn .material-symbols-rounded { font-size: 14px; }

.code-error {
  color: var(--danger);
  text-align: center;
  padding: 20px;
}

.code-no-result {
  color: var(--text-tertiary);
  text-align: center;
  padding: 20px;
}

/* Accounts Dropdown */
.accounts-dropdown {
  position: fixed;
  top: var(--topbar-h);
  right: 100px;
  width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}

.accounts-dropdown-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.accounts-dropdown-list { padding: 4px; }

/* ===========================
   TOAST NOTIFICATIONS
   =========================== */
.toast-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  animation: toastIn 0.3s;
  min-width: 260px;
}

.toast .material-symbols-rounded { font-size: 20px; flex-shrink: 0; }
.toast.success .material-symbols-rounded { color: var(--success); }
.toast.error .material-symbols-rounded { color: var(--danger); }
.toast.info .material-symbols-rounded { color: var(--info); }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===========================
   RESPONSIVE
   =========================== */

/* Large screens: everything visible */
@media (min-width: 1025px) {
  .sidebar { position: relative; left: 0 !important; }
  .reading-pane { position: relative; transform: none !important; }
  #menu-toggle { display: none; }
}

/* Tablet: sidebar slides as overlay, list + reading pane side by side */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 260px;
  }

  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-w));
    top: var(--topbar-h);
    bottom: 0;
    z-index: 150;
    box-shadow: var(--shadow-lg);
    transition: left 0.3s ease;
  }

  .sidebar.open { left: 0; }

  .email-list-panel {
    width: 100% !important;
    flex: 1;
  }

  .reading-pane {
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .reading-pane.open { transform: translateX(0); }

  .login-card { padding: 32px 24px; }
  .login-container { max-width: 420px; }
}

/* Mobile: single-panel mode, compact UI */
@media (max-width: 768px) {
  :root {
    --topbar-h: 48px;
    --sidebar-w: 280px;
    --list-w: 100%;
  }

  .topbar { padding: 0 8px; gap: 8px; }
  .topbar-left { min-width: auto; gap: 8px; }

  .login-screen { padding: 16px 0; }
  .login-container { padding: 12px; max-width: 100%; }
  .login-card { 
    padding: 24px 16px; 
    border-radius: var(--radius-lg); 
  }

  .login-brand { margin-bottom: 20px; }
  .login-brand h1 { font-size: 22px; }
  .brand-icon { width: 52px; height: 52px; }
  .brand-icon .material-symbols-rounded { font-size: 26px; }

  .login-tabs { gap: 3px; padding: 3px; }
  .login-tab { 
    padding: 6px 8px; 
    font-size: 11px; 
    gap: 4px; 
  }
  .login-tab .material-symbols-rounded { font-size: 14px; }

  .getcode-type-grid { gap: 4px; }
  .getcode-type-btn { padding: 4px 8px; font-size: 10px; }

  .form-group input,
  .form-group textarea { padding: 8px 12px; font-size: 13px; }
  .btn-login { padding: 10px 16px; font-size: 13px; }

  /* Email view compact */
  .email-view-header { padding: 16px; }
  .email-view-subject { font-size: 18px; margin-bottom: 14px; }
  .email-view-body { padding: 16px; }
  .email-view-meta { flex-wrap: wrap; gap: 10px; }
  .email-view-date { width: 100%; padding-left: 58px; }

  /* Modal compact */
  .modal { width: 95%; border-radius: var(--radius-md); max-height: 90vh; }
  .modal-header { padding: 12px 16px; }
  .modal-body { padding: 16px; }

  /* Toast full width */
  .toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { min-width: auto; width: 100%; }

  /* Accounts dropdown full width */
  .accounts-dropdown { 
    right: 8px; 
    left: 8px; 
    width: auto; 
  }

  /* Email items more compact */
  .email-item { padding: 10px 12px; }
  .email-avatar { width: 32px; height: 32px; font-size: 12px; }

  /* Code extraction grid */
  .code-extract-grid { grid-template-columns: repeat(4, 1fr); gap: 3px; }
  .code-btn { height: 30px; }

  /* Color picker responsive */
  .color-picker-dropdown { right: -40px; width: 180px; padding: 10px; }
  .color-picker-grid { gap: 6px; }
  .color-swatch { width: 30px; height: 30px; }
}

/* Small phones */
@media (max-width: 480px) {
  .login-card { padding: 18px 12px; }
  .login-brand h1 { font-size: 20px; }
  .brand-tagline { font-size: 11px; }

  .login-tabs { gap: 2px; padding: 2px; }
  .login-tab { padding: 5px 6px; font-size: 10px; }

  .getcode-method-grid { flex-direction: column; }
  .getcode-method-select,
  .bulk-method-select { padding: 8px; }

  .email-item { gap: 8px; }
  .email-sender { font-size: 12px; }
  .email-subject { font-size: 11px; }
  .email-preview { font-size: 11px; }
  .email-date { font-size: 10px; }

  .code-value { font-size: 24px; letter-spacing: 2px; }
  .getcode-item-code { font-size: 16px; letter-spacing: 1px; }
  .getcode-item-email { max-width: 140px; font-size: 11px; }

  .topbar { padding: 0 6px; }
  .user-avatar { width: 32px; height: 32px; font-size: 12px; }

  .email-view-header { padding: 12px; }
  .email-view-subject { font-size: 16px; margin-bottom: 10px; }
  .email-view-body { padding: 12px; font-size: 13px; }
  .email-view-avatar { width: 36px; height: 36px; font-size: 14px; }
  .email-view-from { font-size: 13px; }
  .email-view-date { padding-left: 50px; }
}

/* === Sidebar overlay backdrop for mobile === */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--topbar-h);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 140;
  transition: opacity 0.3s;
}

.sidebar-backdrop.active { display: block; }

/* Refresh animation */
.icon-btn.spinning .material-symbols-rounded {
  animation: spin 1s linear infinite;
}

/* === Safe area for notched phones === */
@supports (padding: env(safe-area-inset-bottom)) {
  .toast-container { padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
}

/* === Landscape phone optimization === */
@media (max-height: 500px) and (orientation: landscape) {
  .login-screen { padding: 8px 0; }
  .login-card { padding: 16px 14px; }
  .login-brand { margin-bottom: 12px; }
  .brand-icon { width: 40px; height: 40px; margin-bottom: 8px; }
  .brand-icon .material-symbols-rounded { font-size: 22px; }
  .login-brand h1 { font-size: 18px; }
  .form-group { margin-bottom: 10px; }
  .getcode-results { max-height: 200px; }
}
