/* ============================================
   Webmail Client — Premium CSS
   ============================================ */

/* --- CSS Custom Properties / Themes --- */

:root {
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Monaco, Consolas, monospace;
  --max-w: 520px;
  --accent: #6C5CE7;
  --accent-hover: #5A4BD1;
  --accent-rgb: 108, 92, 231;
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

[data-theme="dark"] {
  --bg: #08080d;
  --bg-gradient: linear-gradient(145deg, #08080d 0%, #0d0d18 50%, #08080d 100%);
  --card-bg: rgba(18, 18, 26, 0.7);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --card-hover-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(var(--accent-rgb), 0.1);
  --text: #e8e8f0;
  --text-secondary: #8888a0;
  --text-tertiary: #55556a;
  --border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-border: rgba(255, 255, 255, 0.1);
  --input-focus-border: rgba(var(--accent-rgb), 0.6);
  --input-focus-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
  --code-bg: rgba(0, 0, 0, 0.4);
  --table-row-hover: rgba(255, 255, 255, 0.03);
  --badge-read-bg: rgba(52, 211, 153, 0.15);
  --badge-read-text: #34d399;
  --badge-unread-bg: rgba(136, 136, 160, 0.15);
  --badge-unread-text: #8888a0;
  --phishing-bg: rgba(239, 68, 68, 0.1);
  --phishing-border: rgba(239, 68, 68, 0.3);
  --phishing-text: #fca5a5;
  --toast-bg: rgba(18, 18, 26, 0.95);
  --scrollbar-track: rgba(255, 255, 255, 0.02);
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --sidebar-bg: rgba(12, 12, 20, 0.95);
  --topbar-bg: rgba(12, 12, 20, 0.85);
  --msg-row-hover: rgba(255, 255, 255, 0.04);
  --msg-row-selected: rgba(var(--accent-rgb), 0.08);
  --msg-row-unread-bg: rgba(var(--accent-rgb), 0.03);
  --compose-bg: rgba(18, 18, 26, 0.98);
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
}

[data-theme="light"] {
  --bg: #f0f2f5;
  --bg-gradient: linear-gradient(145deg, #f0f2f5 0%, #e8ecf2 50%, #f0f2f5 100%);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(0, 0, 0, 0.06);
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --card-hover-shadow: 0 8px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(var(--accent-rgb), 0.12);
  --text: #1a1a2e;
  --text-secondary: #5a5a78;
  --text-tertiary: #9090a8;
  --border: rgba(0, 0, 0, 0.08);
  --input-bg: rgba(0, 0, 0, 0.02);
  --input-border: rgba(0, 0, 0, 0.12);
  --input-focus-border: rgba(var(--accent-rgb), 0.5);
  --input-focus-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
  --code-bg: rgba(0, 0, 0, 0.04);
  --table-row-hover: rgba(0, 0, 0, 0.02);
  --badge-read-bg: rgba(16, 185, 129, 0.12);
  --badge-read-text: #059669;
  --badge-unread-bg: rgba(107, 114, 128, 0.12);
  --badge-unread-text: #6b7280;
  --phishing-bg: rgba(239, 68, 68, 0.06);
  --phishing-border: rgba(239, 68, 68, 0.2);
  --phishing-text: #dc2626;
  --toast-bg: rgba(255, 255, 255, 0.95);
  --scrollbar-track: rgba(0, 0, 0, 0.02);
  --scrollbar-thumb: rgba(0, 0, 0, 0.12);
  --sidebar-bg: rgba(255, 255, 255, 0.95);
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --msg-row-hover: rgba(0, 0, 0, 0.03);
  --msg-row-selected: rgba(var(--accent-rgb), 0.06);
  --msg-row-unread-bg: rgba(var(--accent-rgb), 0.02);
  --compose-bg: rgba(255, 255, 255, 0.98);
  --overlay-bg: rgba(0, 0, 0, 0.3);
  --noise: none;
}

/* --- Reset & Base --- */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  background: var(--bg-gradient);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  transition: background var(--transition), color var(--transition);
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  background-repeat: repeat;
  pointer-events: none;
  z-index: 0;
}

/* --- Scrollbar --- */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--accent-rgb), 0.3); }

/* --- Animations --- */

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

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
}

@keyframes checkmark {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(0deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

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

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

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

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

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

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

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

.fade-in-up {
  opacity: 0;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--delay, 0) * 0.1s);
}


/* ==========================================
   SCREEN 1: LOGIN
   ========================================== */

.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  max-width: var(--max-w);
  width: 100%;
  padding: 40px 20px 60px;
}

.login-header {
  text-align: center;
  padding: 20px 0 32px;
  position: relative;
}

@media (max-width: 480px) {
  .login-container { padding: 24px 16px 48px; }
}

/* --- Phishing Banner --- */

.phishing-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--phishing-bg);
  border-bottom: 1px solid var(--phishing-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.phishing-banner-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.phishing-icon { width: 20px; height: 20px; color: var(--phishing-text); flex-shrink: 0; }

.phishing-text {
  flex: 1;
  font-size: 13px;
  color: var(--phishing-text);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.phishing-text strong { font-weight: 600; }

.phishing-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--phishing-text);
  opacity: 0.7;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.phishing-close:hover { opacity: 1; }
.phishing-close svg { width: 16px; height: 16px; }

/* --- Header Controls --- */

.header-controls {
  position: absolute;
  top: 20px;
  right: 0;
  display: flex;
  gap: 8px;
  align-items: center;
}

.lang-toggle {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.lang-toggle:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
  transform: scale(1.05);
}
.lang-toggle:active { transform: scale(0.95); }

.theme-toggle {
  position: relative;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
  transform: scale(1.05);
}
.theme-toggle:active { transform: scale(0.95); }

.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  position: absolute;
}

[data-theme="dark"] .icon-sun { opacity: 1; transform: rotate(0deg); }
[data-theme="dark"] .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }
[data-theme="light"] .icon-sun { opacity: 0; transform: rotate(90deg) scale(0.5); }
[data-theme="light"] .icon-moon { opacity: 1; transform: rotate(0deg); }

/* --- Brand --- */

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-emoji { font-size: 36px; line-height: 1; }

.brand-name {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 60%, #fff) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-slogan {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

@media (max-width: 480px) {
  .brand-emoji { font-size: 28px; }
  .brand-name { font-size: 26px; }
  .brand-slogan { font-size: 13px; }
  .header-controls { top: 12px; }
  .lang-toggle, .theme-toggle { width: 38px; height: 38px; }
}

/* --- Card --- */

.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
  transition: box-shadow var(--transition), border-color var(--transition), background var(--transition);
  overflow: hidden;
}
.card:hover { box-shadow: var(--card-hover-shadow); }

.login-card { padding: 32px 28px; }

@media (max-width: 480px) {
  .login-card { padding: 24px 20px; }
}

/* --- Input --- */

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color var(--transition);
  z-index: 1;
}
.input-group:has(.input:focus) .input-icon { color: var(--accent); }

.input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition);
  -webkit-appearance: none;
}
.input::placeholder { color: var(--text-tertiary); }
.input:focus {
  border-color: var(--input-focus-border);
  box-shadow: var(--input-focus-shadow);
  background: transparent;
}
.input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.input-error {
  display: none;
  font-size: 12px;
  color: #ef4444;
  margin-top: 6px;
  padding-left: 2px;
}
.input-error.visible { display: block; }

@media (max-width: 480px) {
  .input {
    padding: 16px 16px 16px 44px;
    font-size: 16px;
  }
}

/* --- Button --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  box-shadow: 0 2px 12px rgba(var(--accent-rgb), 0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.4);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 6px rgba(var(--accent-rgb), 0.3);
}

.btn-secondary {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
}

.btn-large {
  width: 100%;
  padding: 16px 24px;
  font-size: 15px;
  border-radius: var(--radius-sm);
}

.btn-icon { width: 16px; height: 16px; }

.btn-arrow {
  width: 18px;
  height: 18px;
  transition: transform var(--transition);
}
.btn:hover .btn-arrow { transform: translateX(3px); }

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-text { transition: opacity var(--transition); }

@media (max-width: 480px) {
  .btn-large { padding: 18px 24px; font-size: 16px; min-height: 54px; }
}

/* --- Checkbox --- */

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 0;
  margin-top: 4px;
  -webkit-tap-highlight-color: transparent;
}

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

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--input-border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  position: relative;
}
.checkbox-custom::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.checkbox:checked + .checkbox-custom { border-color: var(--accent); }
.checkbox:checked + .checkbox-custom::after { transform: scale(1); }
.checkbox:focus-visible + .checkbox-custom { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15); }

.checkbox-custom.small {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}
.checkbox-custom.small::after {
  width: 8px;
  height: 8px;
}

.checkbox-text {
  font-size: 13px;
  color: var(--text-secondary);
}

@media (max-width: 480px) {
  .checkbox-custom { width: 22px; height: 22px; }
  .checkbox-custom::after { width: 12px; height: 12px; }
  .checkbox-text { font-size: 14px; }
}

/* --- Footer (Login) --- */

.footer {
  text-align: center;
  padding: 32px 0 0;
}
.footer p { font-size: 12px; color: var(--text-tertiary); margin-bottom: 4px; }
.footer-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
.footer-link:hover { opacity: 0.8; text-decoration: underline; }

/* --- Toast Notifications --- */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--toast-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  max-width: 340px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.dismissing { animation: slideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-success { border-left: 3px solid #34d399; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-info { border-left: 3px solid var(--accent); }
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast-success .toast-icon { color: #34d399; }
.toast-error .toast-icon { color: #ef4444; }
.toast-info .toast-icon { color: var(--accent); }

@media (max-width: 480px) {
  .toast-container { top: auto; bottom: 20px; right: 16px; left: 16px; }
  .toast { max-width: 100%; }
}


/* ==========================================
   SCREEN 2: MAILBOX APPLICATION
   ========================================== */

.mailbox-screen {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.mailbox-active {
  overflow: hidden;
}

/* --- Top Bar --- */

.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-brand-emoji { font-size: 20px; line-height: 1; }
.topbar-brand-name {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 60%, #fff) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}

.topbar-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
  padding: 0;
}
.topbar-btn svg { width: 18px; height: 18px; }
.topbar-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}
.topbar-btn:active { transform: scale(0.95); }

.topbar-btn span {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

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

.sidebar-toggle-btn {
  display: none;
}

.lang-toggle-sm {
  width: 36px;
  height: 36px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.user-email {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* --- Search Box --- */

.search-box {
  position: relative;
  width: 100%;
  max-width: 480px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 36px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 99px;
  outline: none;
  transition: all var(--transition);
}
.search-input:focus {
  border-color: var(--input-focus-border);
  box-shadow: var(--input-focus-shadow);
  background: transparent;
}
.search-input::placeholder { color: var(--text-tertiary); }

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear:hover { color: var(--text); }

/* --- Compose Button (topbar) --- */

.compose-btn {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 99px;
  white-space: nowrap;
}
.compose-btn svg { width: 16px; height: 16px; }

/* --- Tools Dropdown --- */

.tools-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  min-width: 220px;
  overflow: hidden;
  z-index: 200;
  animation: slideUp 0.2s ease-out;
}

.tools-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.tools-dropdown-item svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.tools-dropdown-item:hover { background: var(--table-row-hover); }
.tools-dropdown-item + .tools-dropdown-item { border-top: 1px solid var(--border); }


/* --- Sidebar --- */

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 90;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  display: none;
}

.sidebar-close-btn {
  display: none;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-tertiary);
  font-size: 12px;
}
.sidebar-user-info svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Sidebar Overlay (mobile) --- */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 89;
  opacity: 0;
  transition: opacity 0.3s;
}
.sidebar-overlay.visible { opacity: 1; }

/* --- Folder List --- */

.folder-list {
  padding: 8px;
  flex: 1;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.folder-item:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--text);
}
.folder-item.active {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  font-weight: 600;
}

.folder-icon { width: 18px; height: 18px; flex-shrink: 0; }
.folder-icon svg { width: 18px; height: 18px; }

.folder-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}


/* --- Main Content Area --- */

.mail-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Message List View --- */

.message-list-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

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

.folder-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.refresh-btn svg {
  transition: transform 0.3s;
}
.refresh-btn.spinning svg {
  animation: spinOnce 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Bulk Actions Bar --- */

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: rgba(var(--accent-rgb), 0.06);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  animation: fadeIn 0.2s;
}

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

.bulk-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.bulk-btns {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.bulk-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.bulk-btn svg { width: 16px; height: 16px; }
.bulk-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
}
.bulk-btn#bulk-trash:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* --- Loading Skeleton --- */

.list-loading {
  padding: 8px 0;
}

.skeleton-row {
  height: 56px;
  margin: 0 16px 4px;
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg,
    var(--input-bg) 25%,
    rgba(var(--accent-rgb), 0.04) 50%,
    var(--input-bg) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* --- Empty State --- */

.list-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}
.list-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.list-empty p {
  font-size: 15px;
  font-weight: 500;
}

/* --- Message List Rows --- */

.message-list {
  flex: 1;
}

.msg-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.msg-row:hover { background: var(--msg-row-hover); }
.msg-row.selected { background: var(--msg-row-selected); }
.msg-row.unread { background: var(--msg-row-unread-bg); }
.msg-row.unread:hover { background: var(--msg-row-hover); }

.msg-checkbox-wrap {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 2px 4px 0;
  flex-shrink: 0;
}

.msg-star {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  margin-right: 2px;
  color: var(--text-tertiary);
  transition: color var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.msg-star svg { width: 16px; height: 16px; }
.msg-star:hover { color: #f59e0b; }
.msg-star.flagged { color: #f59e0b; }

.msg-sender {
  max-width: 140px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 6px;
}
.msg-row.unread .msg-sender {
  font-weight: 700;
  color: var(--text);
}

.msg-content-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  overflow: hidden;
  font-size: 13px;
}

.msg-subject-text {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  max-width: 50%;
}
.msg-row.unread .msg-subject-text { font-weight: 600; }

.msg-preview-sep {
  color: var(--text-tertiary);
  flex-shrink: 0;
  padding: 0 2px;
}

.msg-preview-text {
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.msg-attachment-icon {
  flex-shrink: 0;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  padding: 0 4px;
}
.msg-attachment-icon svg { width: 14px; height: 14px; }

.msg-date {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
  padding-left: 8px;
  min-width: 55px;
  text-align: right;
}
.msg-row.unread .msg-date {
  color: var(--accent);
  font-weight: 600;
}


/* --- Pagination --- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pagination-btn {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.pagination-btn svg { width: 18px; height: 18px; }
.pagination-btn:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
}
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}


/* --- Message View (Single Email) --- */

.message-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: fadeIn 0.2s;
}

.msg-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.msg-view-header .topbar-btn {
  width: auto;
  padding: 0 8px;
  gap: 4px;
}

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

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

.msg-subject-line {
  padding: 20px 24px 12px;
}

.msg-subject {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.msg-meta {
  padding: 0 24px 16px;
  border-bottom: 1px solid var(--border);
}

.msg-meta-row {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
}

.msg-meta-label {
  color: var(--text-tertiary);
  font-weight: 500;
  min-width: 50px;
  flex-shrink: 0;
}

.msg-meta-value {
  color: var(--text-secondary);
  word-break: break-all;
}

/* --- Attachments --- */

.msg-attachments {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.msg-attachments-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.msg-attachments-title svg { width: 16px; height: 16px; }

.msg-attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  transition: all var(--transition);
}
.attachment-item svg { width: 14px; height: 14px; color: var(--text-tertiary); flex-shrink: 0; }
.attachment-item:hover {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.3);
}

.attachment-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* --- Message Body (iframe) --- */

.msg-body-container {
  padding: 0 24px 24px;
  flex: 1;
}

.msg-body-frame {
  width: 100%;
  min-height: 300px;
  border: none;
  background: transparent;
  margin-top: 16px;
  border-radius: var(--radius-xs);
}


/* ==========================================
   COMPOSE MODAL
   ========================================== */

.compose-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}

body.compose-open {
  overflow: hidden;
}

.compose-modal {
  background: var(--compose-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tools-modal {
  max-width: 600px;
  max-height: 90vh;
  border-radius: var(--radius);
  align-self: center;
}

.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.compose-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.compose-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.tools-panel-body {
  padding: 16px 20px;
}

.compose-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.compose-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  min-width: 45px;
  flex-shrink: 0;
}

.compose-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  padding: 6px 0;
}
.compose-input::placeholder { color: var(--text-tertiary); }

.compose-toggles {
  display: flex;
  gap: 6px;
  padding: 4px 0;
}

.compose-toggle-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
}
.compose-toggle-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}

/* --- Compose Toolbar --- */

.compose-toolbar {
  display: flex;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.toolbar-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all var(--transition);
}
.toolbar-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.2);
  color: var(--accent);
}

/* --- Compose Editor --- */

.compose-editor {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 12px 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  outline: none;
}
.compose-editor:empty::before {
  content: '';
  color: var(--text-tertiary);
}

.compose-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.compose-footer .btn svg { width: 16px; height: 16px; }

.compose-attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.compose-attachments {
  padding: 0 20px;
}

.compose-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.file-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text);
}

.file-size {
  color: var(--text-secondary);
  font-size: 11px;
}

.file-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.file-remove:hover {
  color: #ef4444;
}

/* --- Profile / Avatar --- */

.profile-avatar-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: none;
}
.topbar-avatar[src]:not([src=""]) { display: block; }
.topbar-avatar[src]:not([src=""]) + .topbar-avatar-fallback { display: none; }

.topbar-avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.profile-modal {
  max-width: 400px;
}

.profile-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  border: 2px solid var(--border);
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.profile-avatar-img[src]:not([src=""]) { display: block; }
.profile-avatar-img[src]:not([src=""]) + .profile-avatar-letter { display: none; }

.profile-avatar-letter {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
}

.profile-avatar-upload {
  cursor: pointer;
}

.profile-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: -12px;
}


/* ==========================================
   TRACKING & PHONE (reused in tools panel)
   ========================================== */

.tracking-form {
  padding-top: 8px;
}

.pixel-result {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.result-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.code-block {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 14px 48px 14px 16px;
  overflow-x: auto;
}
.code-block code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre;
  word-break: break-all;
  line-height: 1.5;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.copy-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
}
.copy-btn svg { width: 14px; height: 14px; position: absolute; }
.copy-btn .copy-icon { opacity: 1; transition: opacity 0.2s; }
.copy-btn .check-icon { opacity: 0; color: #34d399; }
.copy-btn.copied .copy-icon { opacity: 0; }
.copy-btn.copied .check-icon { opacity: 1; animation: checkmark 0.4s cubic-bezier(0.16, 1, 0.3, 1); }

/* --- Tracking History --- */

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

.subsection-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.history-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-tertiary);
}
.history-empty svg { width: 32px; height: 32px; margin-bottom: 8px; opacity: 0.5; }
.history-empty p { font-size: 13px; line-height: 1.5; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tracking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tracking-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tracking-table td {
  padding: 12px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tracking-table tbody tr { transition: background var(--transition); cursor: pointer; }
.tracking-table tbody tr:hover { background: var(--table-row-hover); }
.tracking-table tbody tr:last-child td { border-bottom: none; }
.tracking-table .cell-truncate {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-read { background: var(--badge-read-bg); color: var(--badge-read-text); }
.badge-unread { background: var(--badge-unread-bg); color: var(--badge-unread-text); }

/* --- Tab Switcher --- */

.tab-switcher {
  display: flex;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
  position: relative;
  margin-top: 8px;
}

.tab-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--accent);
  border-radius: calc(var(--radius-sm) - 4px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 0;
}
.tab-indicator.right { transform: translateX(100%); }

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: calc(var(--radius-sm) - 4px);
  transition: color var(--transition);
  position: relative;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn svg { width: 16px; height: 16px; }
.tab-btn.active { color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Setup Steps --- */

.setup-steps {
  list-style: none;
  margin-bottom: 24px;
}
.setup-steps li {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setup-steps li:last-child { border-bottom: none; }

.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.step-content strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.step-content p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.step-content em { color: var(--accent); font-style: normal; font-weight: 500; }

/* --- Server Settings --- */

.server-settings { margin-top: 4px; }
.settings-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; }

.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.settings-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--input-bg);
}
.settings-table td {
  padding: 10px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.settings-table tr:last-child td { border-bottom: none; }
.settings-table .label-cell {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  width: 90px;
}

.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- QR Section --- */

.qr-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.qr-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.qr-wrapper {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.qr-image { width: 180px; height: 180px; image-rendering: pixelated; }


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

/* Tablet: hide sidebar, show hamburger */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    top: 0;
    z-index: 500;
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .sidebar-brand-emoji { font-size: 20px; }
  .sidebar-brand-name {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 60%, #fff) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .sidebar-close-btn { display: flex; }

  .sidebar-toggle-btn { display: flex; }

  .mail-content { margin-left: 0; }

  .topbar-brand { display: none; }
}

/* Mobile */
@media (max-width: 640px) {
  .topbar { padding: 0 10px; gap: 6px; }

  .topbar-right { gap: 2px; }

  .compose-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
  }
  .compose-btn-text { display: none; }
  .compose-btn svg { margin: 0; }

  .user-email { display: none; }
  .topbar-user { border-left: none; padding-left: 0; margin-left: 0; }

  .search-box { max-width: 100%; }

  .msg-sender { max-width: 100px; width: auto; font-size: 12px; }
  .msg-row { padding: 0 12px; height: 54px; gap: 2px; }
  .msg-content-preview { font-size: 12px; }
  .msg-date { font-size: 11px; min-width: 45px; }

  .msg-subject-line { padding: 16px 16px 8px; }
  .msg-subject { font-size: 17px; }
  .msg-meta { padding: 0 16px 12px; }
  .msg-attachments { padding: 12px 16px; }
  .msg-body-container { padding: 0 12px 16px; }

  .compose-modal {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .tools-modal {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .list-header { padding: 10px 12px; }
  .folder-title { font-size: 16px; }

  .bulk-actions { padding: 8px 12px; }

  .pagination { padding: 12px; }

  .msg-view-header { padding: 8px 12px; }
}

/* Very small */
@media (max-width: 380px) {
  .msg-sender { max-width: 70px; width: auto; }
  .msg-preview-sep,
  .msg-preview-text { display: none; }
  .msg-attachment-icon { display: none; }
}

@media (max-width: 480px) {
  .tab-btn { padding: 12px 16px; font-size: 14px; min-height: 44px; }
  .tracking-table .col-last-opened { display: none; }
  .tracking-table { font-size: 12px; }
  .tracking-table th, .tracking-table td { padding: 8px 10px; }
  .settings-table { font-size: 12px; }
  .settings-table th, .settings-table td { padding: 8px 10px; }
  .qr-image { width: 160px; height: 160px; }
  .setup-steps li { padding: 10px 0; }
}

/* Desktop: three-column layout styles already via sidebar + content */
@media (min-width: 901px) {
  .sidebar-toggle-btn { display: none; }
  .sidebar-overlay { display: none; }
}


/* ==========================================
   UTILITY CLASSES
   ========================================== */

::selection {
  background: rgba(var(--accent-rgb), 0.25);
  color: var(--text);
}

*:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.5);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

[hidden] { display: none !important; }
