/* =====================================================================
   HidrógenoMail · Design System
   v2.0 — Tokens + Components + Light/Dark
   Inspirado en Gmail / Superhuman / Hey.com. Calidad comercial.
   ===================================================================== */

/* =====================================================================
   1. DESIGN TOKENS
   ===================================================================== */
:root {
  /* ---------- Brand ---------- */
  --brand-500: #0b66ff;           /* azul primario */
  --brand-600: #0052d4;
  --brand-700: #003fae;
  --brand-400: #3d87ff;
  --brand-50:  #e8f0ff;
  --brand-100: #d1e1ff;

  /* ---------- Neutral ---------- */
  --neutral-0:   #ffffff;
  --neutral-50:  #f7f9fc;
  --neutral-100: #eef2f7;
  --neutral-150: #e3e8ef;
  --neutral-200: #d8dee7;
  --neutral-300: #c1c9d4;
  --neutral-400: #9aa4b2;
  --neutral-500: #6b7685;
  --neutral-600: #4a5464;
  --neutral-700: #323a48;
  --neutral-800: #1f2630;
  --neutral-900: #11161e;
  --neutral-950: #080b10;

  /* ---------- Semánticos ---------- */
  --success-500: #12a454;
  --success-50:  #e8f7ee;
  --warning-500: #d98200;
  --warning-50:  #fff4e1;
  --danger-500:  #d93843;
  --danger-50:   #fde8ea;
  --info-500:    #0b8fb5;
  --info-50:     #e3f3f8;
  --star: #e9b400;

  /* ---------- Tipografía ---------- */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px;
  --fs-16: 16px; --fs-18: 18px; --fs-20: 20px; --fs-24: 24px; --fs-30: 30px;
  --lh-tight: 1.2; --lh-snug: 1.35; --lh-body: 1.55; --lh-loose: 1.7;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --tracking-tight: -0.01em; --tracking-normal: 0; --tracking-wide: 0.04em;

  /* ---------- Espaciado (grid 4px) ---------- */
  --s-0: 0; --s-1: 2px; --s-2: 4px; --s-3: 6px; --s-4: 8px;
  --s-5: 12px; --s-6: 16px; --s-7: 20px; --s-8: 24px;
  --s-9: 32px; --s-10: 40px; --s-11: 48px; --s-12: 64px;

  /* ---------- Bordes ---------- */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px; --r-2xl: 16px; --r-full: 9999px;

  /* ---------- Sombras ---------- */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 10px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.12), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.18);
  --ring-focus: 0 0 0 3px rgba(11, 102, 255, 0.22);

  /* ---------- Motion ---------- */
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --ease-emph:     cubic-bezier(.3, 0, 0, 1);
  --dur-fast: 120ms; --dur-base: 180ms; --dur-slow: 240ms;

  /* ---------- Layout ---------- */
  --topbar-h: 64px;
  --sidebar-w: 260px;
  --list-w: 380px;

  /* ---------- Roles semánticos (tema claro) ---------- */
  --bg-app:         var(--neutral-50);
  --bg-surface:     var(--neutral-0);
  --bg-surface-2:   var(--neutral-100);
  --bg-surface-3:   var(--neutral-150);
  --bg-hover:       rgba(15, 20, 30, 0.04);
  --bg-hover-strong:rgba(15, 20, 30, 0.08);
  --bg-selected:    var(--brand-50);
  --bg-selected-strong: #d6e4ff;
  --bg-input:       var(--neutral-100);
  --bg-input-focus: var(--neutral-0);
  --bg-overlay:     rgba(15, 20, 30, 0.55);

  --border-subtle:  var(--neutral-150);
  --border-default: var(--neutral-200);
  --border-strong:  var(--neutral-300);
  --border-focus:   var(--brand-500);

  --text-primary:   var(--neutral-900);
  --text-secondary: var(--neutral-600);
  --text-muted:     var(--neutral-500);
  --text-disabled:  var(--neutral-400);
  --text-inverse:   var(--neutral-0);
  --text-link:      var(--brand-600);
  --text-on-brand:  #ffffff;

  --accent:         var(--brand-500);
  --accent-hover:   var(--brand-600);
  --accent-active:  var(--brand-700);

  color-scheme: light;
}

/* ---------- Tema oscuro ---------- */
[data-theme="dark"] {
  --brand-500: #4f8dff;
  --brand-600: #6ba1ff;
  --brand-700: #8ab8ff;
  --brand-400: #3d87ff;
  --brand-50:  #0e1f3a;
  --brand-100: #13284d;

  --bg-app:         #0b0f16;
  --bg-surface:     #121822;
  --bg-surface-2:   #181f2b;
  --bg-surface-3:   #1f2833;
  --bg-hover:       rgba(255, 255, 255, 0.05);
  --bg-hover-strong:rgba(255, 255, 255, 0.09);
  --bg-selected:    #152544;
  --bg-selected-strong: #1a2f56;
  --bg-input:       #1a2230;
  --bg-input-focus: #212a39;
  --bg-overlay:     rgba(0, 0, 0, 0.7);

  --border-subtle:  #1c2532;
  --border-default: #2a3444;
  --border-strong:  #394456;

  --text-primary:   #eef2f7;
  --text-secondary: #b0bac8;
  --text-muted:     #8791a0;
  --text-disabled:  #5a6474;
  --text-inverse:   var(--neutral-900);
  --text-link:      var(--brand-400);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 10px -2px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 24px -6px rgba(0, 0, 0, 0.55), 0 4px 8px -4px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
  --ring-focus: 0 0 0 3px rgba(79, 141, 255, 0.35);

  color-scheme: dark;
}

/* =====================================================================
   2. RESET & BASE
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-body);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; padding: 0; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: none; box-shadow: var(--ring-focus); border-radius: var(--r-md); }

img, svg { display: block; max-width: 100%; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; border: 2px solid transparent; }

::selection { background: var(--brand-100); color: var(--text-primary); }
[data-theme="dark"] ::selection { background: var(--brand-700); color: #fff; }

/* =====================================================================
   3. BOOT LOADER
   ===================================================================== */
.boot-loader {
  position: fixed; inset: 0;
  z-index: 10000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-7);
  background: var(--bg-app);
  transition: opacity var(--dur-slow) var(--ease-standard);
}
.boot-loader.hidden { opacity: 0; pointer-events: none; }
.boot-brand-mark {
  width: 56px; height: 56px;
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid; place-items: center;
  font-weight: var(--fw-bold);
  font-size: var(--fs-20);
  letter-spacing: var(--tracking-tight);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,255,255,.15) inset;
}
.boot-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border-default);
  border-top-color: var(--brand-500);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   4. LOGIN
   ===================================================================== */
.login-screen {
  position: fixed; inset: 0;
  z-index: 9000;
  display: grid; place-items: center;
  padding: var(--s-8);
  background:
    radial-gradient(1000px 600px at 85% -5%, rgba(11,102,255,.10), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(11,102,255,.06), transparent 60%),
    var(--bg-app);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--s-11) var(--s-10) var(--s-9);
  animation: cardIn var(--dur-slow) var(--ease-emph);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.login-brand {
  display: flex; align-items: center; gap: var(--s-5);
  margin-bottom: var(--s-9);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid; place-items: center;
  font-weight: var(--fw-bold); font-size: var(--fs-16);
  box-shadow: 0 0 0 1px rgba(255,255,255,.15) inset, var(--shadow-xs);
}
.brand-name {
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.brand-name span { color: var(--accent); font-weight: var(--fw-bold); }

.login-title {
  font-size: var(--fs-24);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  margin: 0 0 var(--s-2);
}
.login-subtitle {
  font-size: var(--fs-14);
  color: var(--text-secondary);
  margin: 0 0 var(--s-8);
}

.login-form { display: flex; flex-direction: column; gap: var(--s-5); }
.login-field { display: flex; flex-direction: column; gap: var(--s-3); }
.login-field label {
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}
.login-field input {
  height: 44px;
  padding: 0 var(--s-5);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  color: var(--text-primary);
  font-size: var(--fs-14);
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
}
.login-field input::placeholder { color: var(--text-muted); }
.login-field input:hover { border-color: var(--border-strong); }
.login-field input:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
  outline: none;
}

.login-error {
  padding: var(--s-4) var(--s-5);
  background: var(--danger-50);
  color: var(--danger-500);
  border-radius: var(--r-md);
  font-size: var(--fs-13);
}
[data-theme="dark"] .login-error { background: rgba(217, 56, 67, .12); color: #ff9097; }

.login-submit {
  height: 44px;
  margin-top: var(--s-3);
  background: var(--accent);
  color: var(--text-on-brand);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-14);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: background var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
.login-submit:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.login-submit:active:not(:disabled) { background: var(--accent-active); transform: translateY(1px); box-shadow: var(--shadow-xs); }
.login-submit:disabled { opacity: .6; cursor: not-allowed; }

.login-footer {
  margin-top: var(--s-8);
  text-align: center;
  font-size: var(--fs-12);
  color: var(--text-muted);
}

/* =====================================================================
   5. APP LAYOUT
   ===================================================================== */
#appRoot { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-6);
  padding: 0 var(--s-6);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: relative; z-index: 30;
}
.topbar .brand { display: flex; align-items: center; gap: var(--s-4); }

.searchbar {
  height: 44px;
  max-width: 720px;
  display: flex; align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--r-xl);
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.searchbar:hover { background: var(--bg-surface-2); }
.searchbar:focus-within {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}
.searchbar .icon-search {
  display: grid; place-items: center;
  color: var(--text-muted);
  padding: 0 var(--s-2);
}
.searchbar input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none; outline: none;
  color: var(--text-primary);
  font-size: var(--fs-14);
}
.searchbar input::placeholder { color: var(--text-muted); }
.icon-filter {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-filter:hover { background: var(--bg-hover); color: var(--text-primary); }

.top-actions { display: flex; align-items: center; gap: var(--s-2); }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--text-secondary);
  position: relative;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { background: var(--bg-hover-strong); }

.icon-btn .dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger-500);
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
}

/* Avatares */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--bg-surface);
  transition: transform var(--dur-fast);
  user-select: none;
}
.avatar:hover { transform: scale(1.05); }
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  flex: 0 0 32px;
  user-select: none;
}
.avatar-lg {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: var(--fs-15);
  font-weight: var(--fw-semibold);
  flex: 0 0 44px;
  user-select: none;
}

/* User menu */
.user-menu {
  position: absolute;
  top: calc(var(--topbar-h) - 6px);
  right: var(--s-6);
  min-width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--s-4);
  z-index: 50;
  animation: menuIn var(--dur-base) var(--ease-emph);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.user-menu .menu-head {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4);
  border-radius: var(--r-lg);
}
.user-menu .menu-head .who { min-width: 0; flex: 1; }
.user-menu .menu-head .who-name {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-14);
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu .menu-head .who-sub {
  font-size: var(--fs-12);
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--s-3) 0;
}
.user-menu .menu-item {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: var(--fs-13);
  width: 100%;
  text-align: left;
  transition: background var(--dur-fast);
}
.user-menu .menu-item:hover { background: var(--bg-hover); }

/* Grid principal */
.app {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  overflow: hidden;
}

/* =====================================================================
   6. SIDEBAR
   ===================================================================== */
.sidebar {
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: var(--s-5) var(--s-3) var(--s-5);
  display: flex; flex-direction: column;
  gap: var(--s-3);
  overflow-y: auto;
}

.compose-btn {
  height: 52px;
  margin: 0 var(--s-2) var(--s-4);
  padding: 0 var(--s-6) 0 var(--s-5);
  display: inline-flex; align-items: center; gap: var(--s-4);
  background: var(--accent);
  color: var(--text-on-brand);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-14);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-md);
  align-self: flex-start;
  transition: background var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}
.compose-btn:hover { background: var(--accent-hover); box-shadow: var(--shadow-lg); }
.compose-btn:active { background: var(--accent-active); transform: translateY(1px); box-shadow: var(--shadow-sm); }
.compose-btn svg { flex: 0 0 20px; }

.nav-section { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-5) 0 var(--s-6);
  height: 36px;
  border-radius: 0 var(--r-full) var(--r-full) 0;
  color: var(--text-secondary);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  user-select: none;
}
.nav-item svg { flex: 0 0 18px; color: var(--text-muted); transition: color var(--dur-fast); }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count {
  font-size: var(--fs-11);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-semibold);
  min-width: 18px;
  padding: 2px 6px;
  border-radius: var(--r-full);
  text-align: center;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item .count:empty { display: none; }
.nav-item.active .count {
  background: var(--accent);
  color: var(--text-on-brand);
}
.nav-item:not(.active) .count:not(:empty) {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item:hover svg { color: var(--text-primary); }

.nav-item.active {
  background: var(--bg-selected);
  color: var(--accent);
  font-weight: var(--fw-semibold);
}
.nav-item.active svg { color: var(--accent); }
.nav-item.active .count { color: var(--accent); }
[data-theme="dark"] .nav-item.active { color: #cfe0ff; }
[data-theme="dark"] .nav-item.active svg { color: #cfe0ff; }

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--s-4) var(--s-5);
}
.nav-label {
  padding: 0 var(--s-6);
  margin: var(--s-2) 0 var(--s-3);
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

.storage {
  margin-top: auto;
  padding: var(--s-5) var(--s-6);
  font-size: var(--fs-11);
  color: var(--text-muted);
}
.storage-bar {
  height: 4px;
  background: var(--bg-surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: var(--s-3);
}
.storage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
  border-radius: inherit;
  transition: width var(--dur-slow);
  width: 0;
}

/* =====================================================================
   7. LIST PANE
   ===================================================================== */
.list-pane {
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex; flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.list-toolbar {
  height: 48px;
  flex: 0 0 48px;
  display: flex; align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
}
.list-toolbar .icon-btn { width: 36px; height: 36px; }

.tabs {
  margin-left: var(--s-5);
  display: flex; align-items: center; gap: var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  height: 32px;
  padding: 0 var(--s-5);
  display: inline-flex; align-items: center;
  border-radius: var(--r-full);
  color: var(--text-secondary);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}
.tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab.active {
  background: var(--bg-selected);
  color: var(--accent);
  font-weight: var(--fw-semibold);
}
[data-theme="dark"] .tab.active { color: #cfe0ff; }

.list-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* Message row */
.msg-row {
  display: grid;
  grid-template-columns: 24px 24px 32px minmax(120px, 1fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast);
}
.msg-row:hover { background: var(--bg-hover); }
.msg-row.selected { background: var(--bg-selected); }
.msg-row.selected::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.msg-row.unread .from,
.msg-row.unread .subject,
.msg-row.unread .date { color: var(--text-primary); font-weight: var(--fw-semibold); }
.msg-row:not(.unread) .from,
.msg-row:not(.unread) .subject { color: var(--text-secondary); }
.msg-row:not(.unread) .date { color: var(--text-muted); }

.msg-row .checkbox {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.msg-row .checkbox:hover { background: var(--bg-hover-strong); color: var(--text-primary); }

.msg-row .star {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.msg-row .star:hover { background: var(--bg-hover-strong); color: var(--star); }
.msg-row .star.on { color: var(--star); }

.msg-row .from {
  font-size: var(--fs-13);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-row .subject-line {
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-13);
}
.msg-row .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row .date {
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.msg-row .attach-icon { color: var(--text-muted); display: inline-flex; align-items: center; }

/* Skeleton */
.list-skeleton { padding: var(--s-4) 0; }
.list-skeleton-row {
  height: 56px;
  margin: 0 var(--s-6) var(--s-4);
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--bg-surface-2) 0%, var(--bg-surface-3) 50%, var(--bg-surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =====================================================================
   8. READ PANE
   ===================================================================== */
.read-pane {
  background: var(--bg-surface);
  display: flex; flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.read-toolbar {
  height: 48px;
  flex: 0 0 48px;
  display: flex; align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
}
.read-toolbar .icon-btn { width: 36px; height: 36px; }
.read-toolbar .sep {
  width: 1px; height: 20px;
  background: var(--border-subtle);
  margin: 0 var(--s-2);
}
.read-toolbar .spacer { flex: 1; }
.read-toolbar .pager {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-12);
  color: var(--text-muted);
}

.read-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: var(--s-9) var(--s-10);
  max-width: 980px;
  width: 100%;
  align-self: center;
}

.read-subject {
  font-size: var(--fs-24);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
  margin: 0 0 var(--s-7);
  color: var(--text-primary);
}

.read-meta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-5);
  align-items: flex-start;
  padding-bottom: var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--s-7);
}
.read-meta .who { min-width: 0; }
.read-meta .who-line-1 { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.read-meta .name {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-14);
  color: var(--text-primary);
}
.read-meta .email { font-size: var(--fs-13); color: var(--text-muted); }
.read-meta .to-line { font-size: var(--fs-12); color: var(--text-muted); margin-top: var(--s-2); }
.read-meta .date {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-12);
  color: var(--text-muted);
  white-space: nowrap;
}

.read-content {
  color: var(--text-primary);
  font-size: var(--fs-15);
  line-height: var(--lh-loose);
}
.message-html-frame {
  width: 100%;
  border: 0;
  min-height: 200px;
  background: transparent;
  color-scheme: light;
}
[data-theme="dark"] .message-html-frame { background: #fff; border-radius: var(--r-md); }
.message-plain {
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: var(--fs-14);
  line-height: var(--lh-body);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin: 0;
}

/* Attachments */
.attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-7);
}
.att {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast), background var(--dur-fast);
  cursor: pointer;
  min-width: 0;
}
.att:hover { border-color: var(--border-strong); background: var(--bg-surface-3); }
.att-icon {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  color: #fff;
  font-size: 10px; font-weight: var(--fw-bold);
  letter-spacing: .04em;
}
/* Miniatura de imagen adjunta en read-pane */
.att-img-thumb {
  width: 56px; height: 56px;
  flex: 0 0 56px;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-subtle);
}
.att.is-image { align-items: center; }
.att-info { min-width: 0; flex: 1; }
.att-name {
  font-size: var(--fs-13); font-weight: var(--fw-medium);
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-meta { font-size: var(--fs-11); color: var(--text-muted); }

/* Reply actions */
.reply-actions {
  display: flex; gap: var(--s-3);
  flex-wrap: wrap;
  margin-top: var(--s-7);
}
.btn {
  height: 40px;
  padding: 0 var(--s-6);
  display: inline-flex; align-items: center; gap: var(--s-3);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { background: var(--bg-hover-strong); }
.btn-primary {
  background: var(--accent);
  color: var(--text-on-brand);
  border-color: transparent;
  font-weight: var(--fw-semibold);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: var(--s-12) var(--s-6);
  color: var(--text-muted);
  min-height: 300px;
  height: 100%;
}
.em-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-surface-2);
  color: var(--text-muted);
  margin-bottom: var(--s-6);
}
.empty-state h3 {
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--s-3);
}
.empty-state p { margin: 0; font-size: var(--fs-13); max-width: 340px; line-height: var(--lh-body); }

/* =====================================================================
   9. COMPOSE MODAL
   ===================================================================== */
.compose-tray {
  position: fixed;
  right: var(--s-6);
  bottom: 0;
  z-index: 100;
  display: flex; gap: var(--s-4); align-items: flex-end;
  pointer-events: none;
}
.compose-modal {
  width: 560px;
  height: 600px;
  max-width: 90vw;
  max-height: calc(100vh - 80px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column;
  pointer-events: auto;
  animation: composeIn var(--dur-slow) var(--ease-emph);
  overflow: hidden;
}
@keyframes composeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
.compose-modal.minimized { height: 44px !important; }
.compose-modal.minimized .compose-body { display: none; }

.compose-header {
  height: 44px;
  flex: 0 0 44px;
  padding: 0 var(--s-5);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--neutral-800);
  color: #fff;
  cursor: move;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
}
[data-theme="dark"] .compose-header { background: #0f141c; }
.compose-header .hdr-actions { display: flex; align-items: center; gap: var(--s-2); }
.hdr-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.8);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.hdr-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.compose-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.compose-field {
  display: flex; align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-6);
  height: 44px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;      /* para el dropdown de contactos */
}
.compose-field .label {
  font-size: var(--fs-12);
  color: var(--text-muted);
  min-width: 48px;
}
.compose-field input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text-primary);
  font-size: var(--fs-14);
  height: 100%;
}
.compose-field input::placeholder { color: var(--text-muted); }
.compose-field.subject-field .label { display: none; }
.compose-field.subject-field input { font-weight: var(--fw-semibold); }

/* ---------------- Chip field (destinatarios tipo Gmail) ---------------- */
.compose-field.has-chips {
  height: auto;
  min-height: 44px;
  padding: var(--s-2) var(--s-6);
  align-items: flex-start;
}
.compose-field.has-chips .label {
  padding-top: 8px;
  flex-shrink: 0;
}
.chip-field {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 4px 0;
  cursor: text;
}
.chip-field .chip-input {
  flex: 1;
  min-width: 100px;
  height: 28px;
  background: transparent;
  border: none; outline: none;
  color: var(--text-primary);
  font-size: var(--fs-14);
  padding: 0 4px;
}
.chip-field .chip-input::placeholder { color: var(--text-muted); }

/* Pill del destinatario */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 2px;
  height: 28px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  font-size: var(--fs-13);
  color: var(--text-primary);
  max-width: 240px;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  user-select: none;
}
.chip:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-strong);
}
.chip.is-suspicious {
  background: var(--warning-50);
  border-color: var(--warning-500);
  color: #885300;
}
[data-theme="dark"] .chip.is-suspicious {
  background: rgba(217, 130, 0, 0.15);
  border-color: rgba(217, 130, 0, 0.5);
  color: #ffc266;
}
.chip-warn {
  font-size: 13px;
  margin-left: 2px;
  cursor: help;
}
.chip.is-invalid {
  background: var(--danger-50);
  border-color: var(--danger-500);
  color: var(--danger-500);
}
[data-theme="dark"] .chip.is-invalid {
  background: rgba(217, 56, 67, 0.15);
  border-color: rgba(217, 56, 67, 0.45);
  color: #ff9097;
}
.chip-avatar {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  user-select: none;
}
.chip.is-invalid .chip-avatar { background: var(--danger-500) !important; }
.chip-text {
  font-weight: var(--fw-medium);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-right: 2px;
}
.chip-remove {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.chip-remove:hover {
  background: var(--bg-hover-strong);
  color: var(--text-primary);
}
.chip.is-invalid .chip-remove:hover {
  background: var(--danger-500);
  color: #fff;
}

/* Dropdown de autocompletado de contactos (Para/Cc/Cco) */
.contact-dropdown {
  position: absolute;
  top: calc(100% - 1px);
  left: var(--s-6);
  right: var(--s-6);
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 120;
  animation: menuIn var(--dur-fast) var(--ease-emph);
}
.contact-row {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur-fast);
}
.contact-row:last-child { border-bottom: none; }
.contact-row:hover,
.contact-row.active { background: var(--bg-selected); }
[data-theme="dark"] .contact-row.active,
[data-theme="dark"] .contact-row:hover { background: var(--bg-selected-strong); }
.contact-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  flex: 0 0 32px;
  user-select: none;
}
.contact-info { min-width: 0; flex: 1; }
.contact-name {
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-email {
  font-size: var(--fs-12);
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono);
}

/* Cc / Cco pills en la fila de Para */
.compose-field .cc-bcc {
  color: var(--text-muted);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast), color var(--dur-fast);
  user-select: none;
}
.compose-field .cc-bcc:hover { background: var(--bg-hover); color: var(--text-primary); }

.compose-body textarea {
  flex: 1;
  min-height: 200px;
  padding: var(--s-6);
  background: transparent;
  border: none; outline: none; resize: none;
  color: var(--text-primary);
  font-size: var(--fs-14);
  line-height: var(--lh-body);
  font-family: var(--font-sans);
}
.compose-body textarea::placeholder { color: var(--text-muted); }

/* ---------------- Rich-text editor (contenteditable) ---------------- */
.rich-editor {
  flex: 1;
  min-height: 220px;
  padding: var(--s-6);
  background: transparent;
  border: none; outline: none;
  color: var(--text-primary);
  font-size: var(--fs-14);
  line-height: var(--lh-body);
  font-family: var(--font-sans);
  overflow-y: auto;
  word-break: break-word;
}
/* Placeholder del contenteditable */
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
  white-space: pre-wrap;
}
.rich-editor ul, .rich-editor ol { margin: 8px 0 8px 24px; padding: 0; }
.rich-editor blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
}
.rich-editor a { color: var(--text-link); text-decoration: underline; }

/* ---------------- Toolbar de formato ---------------- */
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  animation: dropIn var(--dur-fast) var(--ease-standard);
}
.rte-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: var(--fs-13);
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative;
}
.rte-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.rte-btn:active,
.rte-btn.is-active { background: var(--bg-selected); color: var(--accent); }

.rte-sep {
  width: 1px; height: 20px;
  background: var(--border-subtle);
  margin: 0 6px;
}
.rte-font, .rte-size {
  height: 30px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--fs-12);
  cursor: pointer;
  max-width: 110px;
}
.rte-font:hover, .rte-size:hover { border-color: var(--border-strong); }
.rte-size { max-width: 90px; }

/* Color picker */
.rte-color-wrap { position: relative; }
.rte-color-btn { padding: 0 4px; gap: 2px; display: flex; }
.rte-color-dot {
  width: 14px; height: 4px;
  border-radius: 2px;
  margin-top: 1px;
  transition: background var(--dur-fast);
}
.rte-color-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 24px);
  gap: 4px;
  padding: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  z-index: 130;
}
.rte-color-pop button {
  width: 24px; height: 24px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: transform var(--dur-fast);
}
.rte-color-pop button:hover { transform: scale(1.1); }

/* Format button activado */
.foot-icon.is-active {
  background: var(--bg-selected);
  color: var(--accent);
}

.compose-footer {
  height: 56px;
  flex: 0 0 56px;
  padding: 0 var(--s-5);
  display: flex; align-items: center; gap: var(--s-4);
  border-top: 1px solid var(--border-subtle);
}
.compose-footer .spacer { flex: 1; }

/* Indicador "Guardando borrador / Borrador guardado" */
.save-hint {
  font-size: var(--fs-12);
  color: var(--text-muted);
  margin-left: var(--s-5);
  transition: color var(--dur-fast);
  min-width: 140px;
  font-variant-numeric: tabular-nums;
}
.save-hint[data-kind="saving"] { color: var(--accent); }
.save-hint[data-kind="saved"]  { color: var(--success-500); }
.save-hint[data-kind="error"]  { color: var(--danger-500); }
.save-hint[data-kind="dirty"]  { color: var(--text-muted); font-style: italic; }

/* ---------------- Menú contextual (click derecho) ---------------- */
.ctx-menu {
  position: fixed;
  z-index: 500;
  min-width: 240px;
  padding: var(--s-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  animation: menuIn var(--dur-fast) var(--ease-emph);
}
.ctx-item {
  width: 100%;
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-size: var(--fs-13);
  color: var(--text-primary);
  text-align: left;
  transition: background var(--dur-fast);
}
.ctx-item:hover:not(:disabled) { background: var(--bg-hover); }
.ctx-item:disabled { opacity: .5; cursor: not-allowed; }
.ctx-item.is-danger { color: var(--danger-500); }
.ctx-item.is-danger:hover { background: var(--danger-50); }
[data-theme="dark"] .ctx-item.is-danger:hover { background: rgba(217,56,67,.15); }
.ctx-icon {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ctx-item.is-danger .ctx-icon { color: var(--danger-500); }
.ctx-item:hover .ctx-icon { color: var(--text-primary); }
.ctx-item.is-danger:hover .ctx-icon { color: var(--danger-500); }
.ctx-label { flex: 1; }
.ctx-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--s-3) calc(-1 * var(--s-3));
}

/* Botón Enviar split (send-main + send-more dropdown) */
.send-btn {
  display: inline-flex;
  align-items: stretch;
  height: 36px;
  background: var(--accent);
  color: var(--text-on-brand);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-fast);
}
.send-btn:hover { box-shadow: var(--shadow-md); }
.send-main {
  padding: 0 var(--s-8);
  display: inline-flex; align-items: center;
  background: transparent;
  color: inherit;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-13);
  transition: background var(--dur-fast);
}
.send-main:hover:not(:disabled) { background: var(--accent-hover); }
.send-main:active:not(:disabled) { background: var(--accent-active); }
.send-main:disabled { opacity: .6; cursor: not-allowed; }
.send-more {
  width: 28px;
  display: grid; place-items: center;
  border-left: 1px solid rgba(255,255,255,.25);
  color: inherit;
  transition: background var(--dur-fast);
}
.send-more:hover { background: var(--accent-hover); }
.send-more:active { background: var(--accent-active); }

/* Íconos del footer (formato / adjuntar / link / emoji / imagen) */
.foot-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--text-muted);
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative;
}
.foot-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.foot-icon:active { background: var(--bg-hover-strong); }

/* Lista de adjuntos dentro del compose */
.compose-attachments {
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  padding: 0 var(--s-6) var(--s-3);
  max-height: 120px; overflow-y: auto;
}
.compose-attachments:empty { padding: 0; }
.compose-att {
  display: inline-flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  font-size: var(--fs-12);
  color: var(--text-primary);
  max-width: 260px;
}
.compose-att svg { flex: 0 0 14px; color: var(--text-muted); }

/* Miniatura de imagen en el chip del compose */
.compose-att.has-thumb { padding-left: 2px; }
.att-thumb {
  width: 36px; height: 28px;
  flex: 0 0 36px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--bg-surface-3);
}
.compose-att .att-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: var(--fw-medium);
}
.compose-att .att-size { color: var(--text-muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.compose-att .att-remove {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.compose-att .att-remove:hover { background: var(--danger-50); color: var(--danger-500); }
[data-theme="dark"] .compose-att .att-remove:hover { background: rgba(217,56,67,.15); color: #ff9097; }

/* Estados del chip de adjunto */
.compose-att.is-loading { background: var(--brand-50); border-color: var(--brand-100); }
[data-theme="dark"] .compose-att.is-loading { background: var(--brand-50); border-color: var(--brand-100); }
.compose-att.is-loading .att-size { color: var(--accent); font-style: italic; }
.compose-att.is-error { background: var(--danger-50); border-color: var(--danger-50); }
[data-theme="dark"] .compose-att.is-error { background: rgba(217,56,67,.12); border-color: rgba(217,56,67,.25); }
.compose-att.is-error .att-size { color: var(--danger-500); }
[data-theme="dark"] .compose-att.is-error .att-size { color: #ff9097; }

/* Spinner del chip loading */
.att-spin {
  width: 14px; height: 14px;
  flex: 0 0 14px;
  border: 2px solid var(--bg-surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Input file oculto de forma compatible con iOS Safari
   (el atributo hidden bloquea el click del label en iOS) */
.att-input-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0; padding: 0; margin: 0;
  opacity: 0;
  pointer-events: none;
}
/* Label que dispara el input — cursor pointer para evitar "stuck" visual */
label.foot-icon { cursor: pointer; }

/* ---------------- DRAG & DROP visual en compose ---------------- */
.compose-modal .compose-body { position: relative; }

/* Overlay azul que aparece al arrastrar archivos sobre el compose */
.compose-modal.is-dropping .compose-body::after {
  content: "Suelta los archivos aquí para adjuntarlos";
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  background: rgba(11, 102, 255, 0.08);
  border: 2px dashed var(--accent);
  border-radius: var(--r-lg);
  color: var(--accent);
  font-size: var(--fs-15);
  font-weight: var(--fw-semibold);
  pointer-events: none;
  z-index: 10;
  animation: dropIn 120ms var(--ease-standard);
}
[data-theme="dark"] .compose-modal.is-dropping .compose-body::after {
  background: rgba(79, 141, 255, 0.15);
}
@keyframes dropIn {
  from { opacity: 0; transform: scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* Hint sutil en el placeholder del textarea sobre drag/paste */
.compose-body textarea[data-hint]::placeholder {
  white-space: pre-line;
}

/* Emoji popup */
.emoji-pop {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: var(--s-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 110;
  min-width: 200px;
}
.emoji-pop button {
  width: 32px; height: 32px;
  font-size: 18px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast);
}
.emoji-pop button:hover { background: var(--bg-hover); }

/* Adjuntos en read-pane: cursor pointer para indicar que son clicables */
.att { cursor: pointer; }

.compose-footer .trash {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--text-muted);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.compose-footer .trash:hover { background: var(--danger-50); color: var(--danger-500); }
[data-theme="dark"] .compose-footer .trash:hover { background: rgba(217,56,67,.15); color: #ff9097; }

/* =====================================================================
   10. TOAST
   ===================================================================== */
.toast {
  position: fixed;
  left: var(--s-7); bottom: var(--s-7);
  z-index: 200;
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-6);
  background: var(--neutral-900);
  color: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-13);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--dur-base), transform var(--dur-base);
}
[data-theme="dark"] .toast { background: #0f141c; border: 1px solid var(--border-default); }
.toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast .undo {
  margin-left: var(--s-3);
  color: var(--brand-400);
  cursor: pointer;
  font-weight: var(--fw-semibold);
}
.toast .undo:hover { text-decoration: underline; }
.toast svg { color: var(--success-500); flex: 0 0 18px; }

/* =====================================================================
   11. RESPONSIVE
   ===================================================================== */
@media (max-width: 1200px) {
  :root { --sidebar-w: 220px; --list-w: 340px; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; --list-w: 300px; }
  .brand-name, .nav-item .label, .nav-label, .nav-divider, .storage { display: none; }
  .nav-item { justify-content: center; padding: 0; width: 44px; height: 44px; border-radius: var(--r-full); margin: 0 auto; }
  .compose-btn { width: 48px; height: 48px; padding: 0; justify-content: center; margin: 0 auto var(--s-4); }
  .compose-btn span { display: none; }
  .searchbar { max-width: none; }
  .topbar { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto; }
}
@media (max-width: 600px) {
  :root { --topbar-h: 56px; }
  .sidebar { display: none; }
  .app { grid-template-columns: var(--list-w) 1fr; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 var(--s-4); }
  .read-body { padding: var(--s-6); }
  .msg-row { grid-template-columns: 24px 32px 1fr auto; gap: var(--s-3); }
  .msg-row .checkbox, .msg-row .from { display: none; }
  .compose-modal { width: 100vw; height: calc(100vh - 64px); max-height: none; right: 0; bottom: 0; border-radius: 0; }
  .compose-tray { right: 0; left: 0; }
}

/* =====================================================================
   12. UTILITIES
   ===================================================================== */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
