/* ============================================================
   Niehaus Webmail — Haupt-Stylesheet
   Premium-Design (Protonmail / Linear.app / Vercel Dashboard Stil)
   ============================================================ */

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

/* === Custom Properties === */
:root {
  --bg: #080c14;
  --surface: #0f1623;
  --surface-2: #161d2e;
  --border: rgba(255, 255, 255, 0.06);
  --accent: #4f8ef7;
  --accent-2: #7c3aed;
  --accent-glow: rgba(79, 142, 247, 0.15);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 180ms ease;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.03em;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  color: var(--text);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 8px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   === Login ===
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* Animiertes Grid-Pattern */
.login-page::before {
  content: '';
  position: absolute;
  inset: -10%;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: grid-shift 30s linear infinite;
  pointer-events: none;
}

@keyframes grid-shift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(48px, 48px); }
}

/* Blauer Glow oben */
.login-page::after {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: fadeUp 500ms ease;
}

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

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.login-logo svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.35rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.95rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  min-height: 44px;
}

.btn-primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(79, 142, 247, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

/* ============================================================
   === App-Layout ===
   ============================================================ */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.05rem;
  white-space: nowrap;
}

.topbar-logo svg {
  width: 22px;
  height: 22px;
}

.topbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.topbar-search svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.hamburger:hover {
  background: var(--surface-2);
}

/* Haupt-Bereich: 3 Spalten */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* === Sidebar === */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  overflow-y: auto;
  transition: width var(--transition), transform var(--transition);
}

.btn-compose {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 8px 20px var(--accent-glow);
  margin-bottom: 1.25rem;
  transition: transform var(--transition), box-shadow var(--transition);
  min-height: 44px;
}

.btn-compose:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(79, 142, 247, 0.32);
}

.btn-compose svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.folder-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.folder-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
}

.folder-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.folder-item.active {
  background: var(--accent-glow);
  color: var(--text);
}

.folder-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

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

.folder-item .folder-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.folder-badge.pulse {
  animation: pulse 1.6s ease-in-out infinite;
}

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

/* === Mail-Liste === */
.mail-list-col {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.mail-list-header {
  padding: 1rem 1.1rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mail-list-header h2 {
  font-size: 1.05rem;
}

.mail-item {
  position: relative;
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  min-height: 44px;
}

.mail-item:hover {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 rgba(79, 142, 247, 0.35);
}

.mail-item.selected {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.mail-item.unread {
  background: rgba(79, 142, 247, 0.04);
}

.mail-item.unread .mail-subject {
  font-weight: 700;
  color: var(--text);
}

.mail-item.unread .mail-from {
  color: var(--text);
}

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

/* Avatar-Gradienten nach Anfangsbuchstabe */
.avatar-a, .avatar-h, .avatar-o, .avatar-v { background: linear-gradient(135deg, #4f8ef7, #7c3aed); }
.avatar-b, .avatar-i, .avatar-p, .avatar-w { background: linear-gradient(135deg, #10b981, #4f8ef7); }
.avatar-c, .avatar-j, .avatar-q, .avatar-x { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar-d, .avatar-k, .avatar-r, .avatar-y { background: linear-gradient(135deg, #7c3aed, #ef4444); }
.avatar-e, .avatar-l, .avatar-s, .avatar-z { background: linear-gradient(135deg, #4f8ef7, #10b981); }
.avatar-f, .avatar-m, .avatar-t { background: linear-gradient(135deg, #ef4444, #f59e0b); }
.avatar-g, .avatar-n, .avatar-u { background: linear-gradient(135deg, #7c3aed, #4f8ef7); }

.mail-item-body {
  flex: 1;
  min-width: 0;
}

.mail-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.mail-from {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: right;
}

.mail-subject {
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mail-subject .attach-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.mail-list-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Skeleton Loading */
.skeleton {
  padding: 0.85rem 1.1rem;
  display: flex;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.skeleton-avatar, .skeleton-line {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skeleton-line {
  height: 10px;
}
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-90 { width: 90%; }

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

/* === Mail-Inhalt === */
.mail-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg);
}

.mail-content-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-direction: column;
  gap: 0.75rem;
}

.mail-content-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.mail-header {
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
}

.mail-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.mail-subject-full {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.mail-header-from {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mail-header-from .avatar {
  width: 44px;
  height: 44px;
  font-size: 1rem;
}

.mail-from-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.mail-from-email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mail-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.mail-header-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.mail-action-icons {
  display: flex;
  gap: 0.35rem;
}

.mail-body {
  padding: 1.5rem 2rem;
  flex: 1;
}

.mail-body iframe {
  width: 100%;
  min-height: 200px;
  border: none;
  background: #fff;
  border-radius: var(--radius-md);
}

.mail-body pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Inter', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  max-height: 60vh;
  overflow-y: auto;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.blocked-image-notice {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

/* Anhänge */
.attachments-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0 2rem 1.5rem;
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  min-width: 200px;
  transition: background var(--transition), transform var(--transition);
}

.attachment-card:hover {
  background: var(--surface-2);
  transform: translateY(-1px);
}

.attachment-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.attachment-icon svg {
  width: 18px;
  height: 18px;
}

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

.attachment-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.attachment-download {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.attachment-download:hover {
  background: var(--surface-2);
  color: var(--accent);
}

/* Antworten-Composer (ausklappbar) */
.reply-composer {
  margin: 0 2rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  max-height: 0;
  transition: max-height 250ms ease;
}

.reply-composer.open {
  max-height: 600px;
}

.reply-composer-inner {
  padding: 1.25rem;
}

.reply-toolbar {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.reply-editor {
  min-height: 120px;
  padding: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
}

.reply-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.reply-actions {
  margin-top: 0.85rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ============================================================
   === Compose Modal ===
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.compose-modal {
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transform: translateY(16px) scale(0.98);
  transition: transform var(--transition);
}

.modal-overlay.active .compose-modal {
  transform: translateY(0) scale(1);
}

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

.compose-header h3 {
  font-size: 1.05rem;
}

.compose-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.compose-close:hover {
  background: var(--surface-2);
  color: var(--danger);
}

.compose-body {
  padding: 1.1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.compose-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.compose-field label {
  width: 44px;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.tag-input {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.82rem;
}

.tag-chip button {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.tag-chip button:hover {
  color: var(--danger);
}

.tag-input input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  padding: 0.25rem 0;
}

.tag-input input:focus {
  outline: none;
}

.compose-subject {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 0;
}

.compose-subject:focus {
  outline: none;
}

.compose-toolbar {
  display: flex;
  gap: 0.25rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.toolbar-btn:hover, .toolbar-btn.active {
  background: var(--surface-2);
  color: var(--accent);
}

.compose-editor {
  min-height: 200px;
  padding: 0.5rem 0.25rem;
  font-size: 0.92rem;
  line-height: 1.6;
  outline: none;
}

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

.dropzone {
  margin-top: 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: border-color var(--transition), background var(--transition);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
}

.attachment-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.attachment-preview-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
}

.attachment-preview-item button {
  color: var(--text-muted);
}

.attachment-preview-item button:hover {
  color: var(--danger);
}

.compose-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.btn-send {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  box-shadow: 0 8px 24px var(--accent-glow);
  transition: transform var(--transition), box-shadow var(--transition);
  min-height: 44px;
}

.btn-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(79, 142, 247, 0.3);
}

.btn-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

/* ============================================================
   === Toasts ===
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 200;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  font-size: 0.88rem;
  min-width: 260px;
  animation: toast-in 220ms ease;
}

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

.toast.toast-hide {
  animation: toast-out 220ms ease forwards;
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(16px); }
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }

/* ============================================================
   === Fade-Transitions & Utility ===
   ============================================================ */

.fade-transition {
  animation: fade-in 200ms ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hidden {
  display: none !important;
}

/* ============================================================
   === Responsive ===
   ============================================================ */

@media (max-width: 1024px) {
  .sidebar {
    width: 64px;
    padding: 1rem 0.5rem;
  }

  .sidebar .folder-label,
  .sidebar .btn-compose span {
    display: none;
  }

  .btn-compose {
    justify-content: center;
  }

  .folder-item {
    justify-content: center;
  }

  .folder-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.6rem;
    min-width: 16px;
  }
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    z-index: 50;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar .folder-label,
  .sidebar .btn-compose span {
    display: inline;
  }

  .folder-item, .btn-compose {
    justify-content: flex-start;
  }

  .mail-list-col {
    width: 100%;
  }

  .topbar-search {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .app-body {
    position: relative;
  }

  .mail-list-col, .mail-content {
    width: 100%;
    display: none;
  }

  .app-body.view-list .mail-list-col,
  .app-body.view-content .mail-content {
    display: flex;
  }

  .mail-back-btn {
    display: inline-flex;
  }

  .mail-header {
    padding: 1rem 1.1rem 0.75rem;
  }

  .mail-body, .attachments-row {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }

  .reply-composer {
    margin-left: 1.1rem;
    margin-right: 1.1rem;
  }

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

.mail-back-btn {
  display: none;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
  min-height: 44px;
}
