/* FJMV — paleta Ford (igual que jmhome) */
:root {
  --bar-h: 42px;   /* alto común de las barras horizontales: cabecera de lista, pestañas y toolbar del lector */
  --c-ink: #001a47;
  --c-blue: #003478;
  --c-blue-mid: #1769FF;
  --c-blue-soft: #4b8bff;
  --c-bg: #f4f6fb;
  --c-card: #ffffff;
  --c-border: #e3e8f1;
  --c-border-soft: #eef1f7;
  --c-text: #15233f;
  --c-muted: #7a8aa8;
  --c-success: #0caf60;
  --c-warn: #ff8a00;
  --c-danger: #e6364a;
  --shadow-card: 0 6px 24px rgba(0, 26, 71, 0.08);
  --shadow-pop: 0 12px 40px rgba(0, 26, 71, 0.18);
  --r: 14px;
  --r-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--c-blue-mid); }

/* ------------- LOGIN ------------- */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}
.login-bg {
  position: absolute; inset: -10%;
  background:
    radial-gradient(60% 60% at 20% 20%, rgba(23,105,255,0.45), transparent 60%),
    radial-gradient(50% 50% at 85% 80%, rgba(75,139,255,0.35), transparent 60%),
    linear-gradient(135deg, #001a47 0%, #003478 50%, #1769FF 100%);
  filter: saturate(110%);
  z-index: -2;
}
.login-bg-grain {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.05), transparent 70%);
  z-index: -1;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 22px;
  padding: 36px 30px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  text-align: center;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.login-card h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 2px;
  color: var(--c-ink);
}
.login-tag { margin: 0 0 24px; color: var(--c-muted); font-size: 14px; }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--c-muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 15px;
  background: #fff;
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--c-blue-mid);
  box-shadow: 0 0 0 3px rgba(23,105,255,0.12);
}
#li-codigo {
  text-align: center;
  font-size: 22px;
  letter-spacing: 10px;
  font-weight: 700;
  font-family: "SF Mono", Consolas, monospace;
}
.btn-primary {
  width: 100%; padding: 13px;
  border: none; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--c-blue-mid), var(--c-blue));
  color: white; font-weight: 600; font-size: 15px;
  box-shadow: 0 6px 16px rgba(23,105,255,0.3);
  transition: transform .1s ease, box-shadow .15s;
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(23,105,255,0.42); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-ghost {
  padding: 10px 16px; border: 1px solid var(--c-border);
  border-radius: var(--r-sm); background: white; color: var(--c-text);
}
.btn-link {
  margin-top: 10px; background: transparent; border: none;
  color: var(--c-blue-mid); font-size: 13px;
}
.login-msg { min-height: 18px; margin: 10px 0 0; font-size: 13px; }
.login-msg.ok { color: var(--c-success); }
.login-msg.err { color: var(--c-danger); }
.login-foot {
  position: absolute; bottom: 18px; left: 0; right: 0;
  text-align: center; color: rgba(255,255,255,0.7); font-size: 12px;
}

/* ------------- APP LAYOUT ------------- */
.app-body {
  display: grid;
  grid-template-columns: var(--list-w, 360px) 6px 1fr;
  height: 100vh;
  height: 100dvh;
  /* En móvil, JS fija --app-h a la altura del viewport visible (sin el teclado). */
  height: var(--app-h, 100dvh);
  overflow: hidden;
}

/* SIDEBAR (cajon hamburguesa, inicia contraido) */
.sidebar {
  background: linear-gradient(180deg, #001a47 0%, #003478 100%);
  color: white;
  display: flex; flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 280px;
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 60;
}
/* La sombra solo cuando está abierto; si no, se filtra por el borde al estar contraído */
.sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.45); }
.sb-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 55;
}
.sb-backdrop.show { opacity: 1; pointer-events: auto; }

/* DIVISOR ARRASTRABLE lista <-> lector */
.splitter {
  background: #fff;
  cursor: col-resize;
  position: relative;
  transition: background .15s;
}
.splitter:hover, .splitter.dragging { background: #fff; }
.splitter::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 4px; height: 42px; border-radius: 3px; background: rgba(0,0,0,0.18);
}

/* RAIL: barra lateral delgada azul, siempre visible */
.rail {
  background: linear-gradient(180deg, #001a47 0%, #003478 100%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 0; z-index: 40;
}
.rail .icon-btn { background: rgba(255,255,255,0.12); color: #fff; }
.rail .icon-btn:hover { background: rgba(255,255,255,0.24); }
.rail .rail-compose {
  background: linear-gradient(160deg, #1769FF, #003478);
  box-shadow: 0 4px 12px rgba(23,105,255,0.45);
}
.rail .rail-compose:hover { background: linear-gradient(160deg, #2f80ff, #0a4296); }
.rail .rail-install { background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.35); }
.rail .rail-install:hover { background: rgba(255,255,255,0.3); }
.rail-spacer { flex: 1; }

/* Botón Redactar (prominente) dentro del cajón */
.sb-compose {
  margin-top: 2px; margin-bottom: 8px;
  border: none; justify-content: center; font-weight: 600; color: #fff;
  background: linear-gradient(160deg, #1769FF, #003478);
  box-shadow: 0 4px 12px rgba(23,105,255,0.35);
}
.sb-compose:hover { background: linear-gradient(160deg, #2f80ff, #0a4296); }
.sb-compose svg { flex-shrink: 0; }

/* Botón de menú en el encabezado de la lista */
.pane-header .hdr-menu { flex-shrink: 0; }

/* Campos de texto del compose */
.field textarea, .field select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--c-border); background: white; color: var(--c-ink);
  font-size: 14px; font-family: inherit; outline: none;
}
.field textarea { resize: vertical; min-height: 130px; line-height: 1.5; }
.field textarea:focus, .field select:focus { border-color: #1769FF; }

/* Carpetas en barra lateral */
.sb-folder { font-size: 13px; padding: 8px 12px; }
.sb-folder .sb-account-label { font-weight: 400; }

/* ===== Compose enriquecido ===== */
.compose-card { max-width: 720px; width: 100%; }

/* ===== Redactor: ocupa la zona del lector como una pestaña más (correos y borradores comparten pestañas) ===== */
#modal-compose {
  position: absolute; inset: 0; z-index: 5;
  display: block; background: #fff; backdrop-filter: none;
  overflow-y: auto; padding: 0;
}
#modal-compose[hidden] { display: none; }
#modal-compose .compose-card {
  width: 100%; max-width: 100%; max-height: none; height: auto;
  margin: 0; box-shadow: none; border: none; border-radius: 0;
  padding: 18px 24px 60px;
}
.compose-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.compose-head h3 { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-head-btns { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
.compose-head-btns .modal-min, .compose-head-btns .modal-close { position: static; }
/* La barra vieja de borradores (abajo) ya no se usa: ahora van en las pestañas del lector */
.compose-tabs { display: none !important; }
.comp-rows { display: grid; gap: 10px; margin-bottom: 12px; }
.rt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 6px; border: 1px solid var(--c-border); border-bottom: none;
  border-radius: 10px 10px 0 0; background: #f6f8fc;
}
.rt-toolbar button {
  min-width: 32px; height: 30px; padding: 0 8px; border: none; border-radius: 7px;
  background: transparent; color: var(--c-ink); cursor: pointer; font-size: 14px;
}
.rt-toolbar button:hover { background: rgba(23,105,255,0.12); }
.rt-toolbar select { height: 30px; border-radius: 7px; border: 1px solid var(--c-border); background: white; font-size: 13px; padding: 0 4px; }
.rt-toolbar input[type=color] { width: 30px; height: 28px; border: none; background: none; cursor: pointer; padding: 0; }
.rt-sep { width: 1px; height: 20px; background: var(--c-border); margin: 0 4px; }
.rt-editor {
  border: 1px solid var(--c-border); border-radius: 0 0 10px 10px;
  min-height: 220px; max-height: 42vh; overflow-y: auto; padding: 14px;
  font-size: 14px; line-height: 1.55; color: var(--c-ink); background: white; outline: none;
}
.rt-editor:empty::before { content: attr(data-placeholder); color: var(--c-muted); }
.rt-editor img { max-width: 100%; height: auto; }

.comp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.comp-firma { font-size: 13px; color: var(--c-muted); display: flex; align-items: center; gap: 6px; }
.comp-firma select { height: 30px; border-radius: 7px; border: 1px solid var(--c-border); background: white; font-size: 13px; }
.btn-mini { padding: 6px 12px !important; font-size: 13px !important; }
.ia-instr { flex: 1; min-width: 160px; height: 32px; border-radius: 8px; border: 1px solid var(--c-border); padding: 0 10px; font-size: 13px; }
.btn-ia {
  border: none; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: linear-gradient(135deg, #7c4dff, #1769FF); color: white;
}
.btn-ia:hover { filter: brightness(1.08); }
.btn-ia:disabled { opacity: .6; cursor: default; }
.ia-preview { margin-top: 12px; border: 1px solid #d9c7ff; background: #f7f2ff; border-radius: 12px; padding: 12px 14px; }
.ia-preview-head { font-size: 12px; font-weight: 700; color: #6d28d9; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.ia-texto { white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: var(--c-ink); max-height: 30vh; overflow-y: auto; }
.ia-actions { display: flex; gap: 8px; margin-top: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
#ia-spin.on::after {
  content: ""; display: inline-block; width: 12px; height: 12px; vertical-align: middle;
  border: 2px solid #b9a2ff; border-top-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}

.firmas-lista { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.firma-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--c-border-soft); border-radius: 8px; font-size: 13px; }
.firma-item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.firma-item button { border: none; background: transparent; color: #e11d2e; cursor: pointer; }
.mover-item { width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--c-border-soft); border-radius: 8px; background: white; cursor: pointer; font-size: 14px; }
.mover-item:hover { background: #f3f6ff; border-color: #1769FF; }
.regla-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; font-size: 14px; }
.regla-row select { height: 32px; border-radius: 8px; border: 1px solid var(--c-border); padding: 0 8px; }

/* Toolbar de acciones en el lector: solo iconos, en fila */
.va-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--c-ink);
  cursor: pointer; flex-shrink: 0; transition: background .12s, border-color .12s, color .12s;
}
.va-btn:hover { background: #f3f6ff; border-color: #1769FF; color: #1769FF; }
.va-btn.danger:hover { background: #fdeced; border-color: #e11d2e; color: #b3121f; }
.sb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px 14px;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: 2px;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: none; border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: white;
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255,255,255,0.14); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.dark { background: transparent; color: var(--c-ink); }
.icon-btn.dark:hover { background: var(--c-border-soft); }

.sb-section {
  padding: 12px 10px 4px;
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
.sb-account, .sb-add {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none; border-radius: 12px;
  background: transparent; color: white;
  font-size: 14px;
  text-align: left;
  transition: background .15s;
}
.sb-account:hover, .sb-add:hover { background: rgba(255,255,255,0.1); }
.sb-account.active {
  background: rgba(255,255,255,0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.sb-avatar {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
  flex-shrink: 0;
}
.sb-account-label { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-account-count { font-size: 12px; opacity: 0.7; }
.sb-account-delete {
  margin-left: 4px; background: transparent; border: none;
  color: rgba(255,255,255,0.5); cursor: pointer; padding: 2px 6px; border-radius: 6px;
  font-size: 14px;
}
.sb-account-delete:hover { color: white; background: rgba(255,255,255,0.1); }

.sb-add {
  margin-top: 8px;
  border: 1px dashed rgba(255,255,255,0.25);
  justify-content: center;
  color: rgba(255,255,255,0.85);
}
.sb-add:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.4); }

.sb-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); }
.sb-user {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border: none; border-radius: 10px;
  background: transparent; color: white;
  text-align: left;
}
.sb-user:hover { background: rgba(255,255,255,0.08); }
.sb-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #4b8bff, #1769FF);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.sb-user-info { display: flex; flex-direction: column; overflow: hidden; }
.sb-user-info span { font-size: 13px; font-weight: 600; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.sb-user-info small { font-size: 11px; opacity: 0.7; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }

/* LISTA */
.pane-lista {
  border-right: 1px solid var(--c-border);
  background: white;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.pane-header {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--bar-h); box-sizing: border-box;   /* mismo alto que las pestañas y la toolbar del lector */
  padding: 4px 14px;
  border-bottom: 1px solid var(--c-border-soft);
  background: white;
  position: sticky; top: 0; z-index: 2;
}
.pane-header.oculta { display: none; }
.pane-header h2 {
  margin: 0; font-size: 17.5px; color: var(--c-ink); font-weight: 600;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Título clicable con menú de bandeja/cuenta */
.pane-titulo-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px;
  background: transparent; border: none; cursor: pointer; padding: 0; text-align: left;
}
.pane-titulo-btn h2 { flex: 0 1 auto; }
.pane-titulo-btn .caret { color: var(--c-muted); flex-shrink: 0; transition: transform .12s; }
.pane-titulo-btn:hover .caret { color: var(--c-blue-mid); }
.titulo-menu {
  position: fixed; z-index: 70; min-width: 230px; max-width: 82vw;
  background: #fff; border: 1px solid var(--c-border); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px;
  max-height: 70vh; overflow-y: auto;
}
.tm-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: transparent; cursor: pointer;
  padding: 9px 10px; border-radius: 8px; font-size: 14.5px; color: var(--c-ink); text-align: left;
}
.tm-item:hover { background: var(--c-border-soft); }
.tm-item.active { background: rgba(23,105,255,.10); color: var(--c-blue-mid); font-weight: 600; }
.tm-dot {
  width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
}
.tm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-sync { font-size: 11px; color: var(--c-muted); }
.hdr-install {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
  padding: 5px; border: 1px solid var(--c-border); border-radius: 999px;
  cursor: pointer; background: #fff; color: var(--c-ink);
  font-size: 13px; font-weight: 700; line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.hdr-install:hover { box-shadow: 0 3px 12px rgba(23,105,255,.28); border-color: var(--c-blue-mid); }
.hdr-install:active { transform: scale(0.96); }
.hdr-install[hidden] { display: none; }
/* tile de icono colorido estilo fjmv-cam */
.hdr-install-ic {
  width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #003478;
  box-shadow: 0 2px 6px rgba(0,52,120,.4);
}
.hdr-install-ic svg { width: 17px; height: 17px; }
/* Ojito en la barra del lector: resalta cuando la lista está oculta */
#btn-peek-header[aria-pressed="true"] { color: var(--c-blue-mid, #1769ff); background: var(--c-border-soft, #eef1f6); }
/* Al presionar el ojo, se contrae TODO el panel de la lista para dar pantalla completa al lector (solo escritorio).
   El lector se fuerza a ocupar TODAS las columnas; si no, al ocultar la lista se reacomoda a la columna 0px y desaparece. */
@media (min-width: 901px) {
  .app-body.lista-oculta { grid-template-columns: 0 0 1fr; }
  .app-body.lista-oculta .pane-lista,
  .app-body.lista-oculta .splitter { display: none; }
  .app-body.lista-oculta .pane-viewer { grid-column: 1 / -1; }
}
/* Botón actualizar en la cabecera + giro al sincronizar */
.hdr-refresh { flex-shrink: 0; }
.spinning svg { animation: spin .8s linear infinite; }
/* Barra de búsqueda de la bandeja */
.buscador {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  margin: 8px 12px; padding: 9px 12px;
  background: transparent; border: 1px solid var(--c-border); border-radius: 11px;
}
.buscador-ico { color: var(--c-muted); flex-shrink: 0; }
.buscador input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--c-ink); padding: 2px 0;
  -webkit-appearance: none;
}
.buscador input::-webkit-search-cancel-button { display: none; }
.buscador input::placeholder { color: var(--c-muted); }
.buscador-clear {
  border: none; cursor: pointer; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.08); color: var(--c-ink);
}
.buscador-clear:hover { background: rgba(0,0,0,.16); }
.buscador-clear[hidden] { display: none; }
/* min-height:0 es imprescindible: sin él la lista no cede espacio en el flex y,
   al abrir el dock de carpetas, se encima en vez de bajar los mensajes. */
.lista { flex: 1; min-height: 0; overflow-y: auto; }
.vacio {
  padding: 60px 24px;
  text-align: center;
  color: var(--c-muted);
  font-size: 15px;
}
.cargar-mas-wrap { padding: 14px; display: flex; justify-content: center; }
.cargar-mas {
  width: 100%; max-width: 320px; padding: 12px 16px;
  border: 1px solid var(--c-border); border-radius: 12px;
  background: white; color: var(--c-blue-mid); font-weight: 600; font-size: 14px;
  transition: background .12s, border-color .12s;
}
.cargar-mas:hover { background: #f3f6ff; border-color: var(--c-blue-mid); }
.cargar-mas:disabled { opacity: .6; cursor: progress; }
.msg-row {
  display: flex; gap: 10px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--c-border-soft);
  cursor: pointer;
  position: relative;
  transition: background .12s;
}
.msg-row:hover { background: #fafbfd; }
.msg-row.active { background: #eff4ff; }
.msg-row.active::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; background: var(--c-blue-mid); border-radius: 0 3px 3px 0;
}
.msg-row.unread .msg-from, .msg-row.unread .msg-subject {
  font-weight: 700; color: var(--c-ink);
}
/* Punto azul de "no leído": eliminado — el no leído se distingue por el texto en negritas */
.msg-dot { display: none; }
.msg-body { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: center; gap: 8px; }
.msg-from { font-size: 14.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-text); }
.msg-date { font-size: 11.5px; color: var(--c-muted); flex-shrink: 0; white-space: nowrap; }
.msg-subject {
  font-size: 13px; color: var(--c-muted);
  margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 6px;
  font-weight: 600;
  color: white;
  vertical-align: middle;
}
/* Botón papelera: pequeño, a la izquierda de la hora, siempre visible */
.msg-del {
  flex-shrink: 0; align-self: center;
  width: 22px; height: 22px; border-radius: 6px;
  border: none; background: transparent; cursor: pointer;
  color: var(--c-muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, opacity .12s;
  opacity: .5;
}
.msg-del svg { width: 14px; height: 14px; }
.msg-del:hover { background: rgba(220,38,38,.12); color: #dc2626; opacity: 1; }
.msg-del:active { transform: scale(0.92); }
.msg-row.borrando { opacity: .4; pointer-events: none; }
/* Botón desuscribir en filas de publicidad */
.msg-unsub {
  flex-shrink: 0; align-self: center;
  width: 22px; height: 22px; border-radius: 6px; border: none; cursor: pointer;
  background: transparent; color: var(--c-muted); opacity: .5;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, opacity .12s;
}
.msg-unsub svg { width: 14px; height: 14px; }
.msg-unsub:hover { background: rgba(234,88,12,.12); color: #ea580c; opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .msg-unsub { opacity: 0; }
  .msg-row:hover .msg-unsub { opacity: .6; }
  .msg-row:hover .msg-unsub:hover { opacity: 1; }
}
/* Pestañas Principal / Publicidad */
.tabs {
  display: flex; gap: 2px; padding: 0 10px;
  border-bottom: 1px solid var(--c-border-soft); background: #fff;
}
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; background: transparent; cursor: pointer;
  padding: 11px 12px; font-size: 14px; font-weight: 600; color: var(--c-muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  transition: color .12s;
}
.tab.active { color: var(--c-blue-mid); border-bottom-color: var(--c-blue-mid); }
.tab-count {
  font-size: 11px; background: var(--c-blue-mid); color: #fff;
  border-radius: 999px; padding: 0 6px; min-width: 16px; text-align: center; font-weight: 700;
}
.tab-count:empty { display: none; }
/* Botón IA en la barra del lector + micrófono grabando */
.va-btn.ia { color: #7c3aed; }
.va-btn.ia:hover { background: rgba(124,58,237,.12); }
#rt-mic.grabando { color: #dc2626; animation: pulseMic 1s ease-in-out infinite; }
@keyframes pulseMic { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
/* Panel de chat IA lateral (colapsable, derecha) */
.chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw;
  background: #fff; border-left: 1px solid var(--c-border);
  box-shadow: -10px 0 40px rgba(0,0,0,.16);
  display: flex; flex-direction: column; z-index: 60;
}
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--c-border-soft);
  background: linear-gradient(120deg,#f5f7ff,#fff);
}
.chat-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--c-ink); }
.chat-title svg { color: #7c3aed; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-hint { color: var(--c-muted); font-size: 13.5px; line-height: 1.5; text-align: center; padding: 20px 8px; }
.chat-msg {
  max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user { align-self: flex-end; background: var(--c-blue-mid); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: var(--c-border-soft); color: var(--c-ink); border-bottom-left-radius: 4px; }
.chat-msg.pensando { opacity: .6; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--c-border-soft); }
.chat-form input {
  flex: 1; min-width: 0; border: 1px solid var(--c-border); border-radius: 999px;
  padding: 10px 14px; font-size: 14.5px; outline: none;
}
.chat-form input:focus { border-color: var(--c-blue-mid); }
.chat-send {
  border: none; background: var(--c-blue-mid); color: #fff;
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.chat-send:hover { background: #1257d6; }
@media (max-width: 600px) { .chat-panel { width: 100vw; max-width: 100vw; } }

/* VIEWER */
.pane-viewer {
  background: #fff;
  display: flex; flex-direction: column;
  overflow: hidden;
  padding: 0;
  position: relative;
}
/* Zona de contenido bajo las pestañas (correo o redactor ocupan todo, uno a la vez) */
.viewer-stage { flex: 1 1 auto; min-height: 0; position: relative; }
#viewer-content {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: 0 28px 80px;
}
/* Barra de pestañas del lector (estilo navegador) */
.viewer-tabs {
  flex-shrink: 0;
  display: flex; align-items: stretch; gap: 4px;
  min-height: var(--bar-h); box-sizing: border-box;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  background: #fff; border-bottom: 1px solid var(--c-border);
  padding: 6px 8px 0;
}
.viewer-tabs[hidden] { display: none; }
.viewer-tabs::-webkit-scrollbar { display: none; }
.vtab {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  max-width: 220px; padding: 8px 8px 8px 12px;
  background: #e9eef7; border: 1px solid transparent; border-bottom: none;
  border-radius: 10px 10px 0 0; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--c-muted);
  transition: background .12s, color .12s;
}
.vtab:hover { background: #dfe7f3; color: var(--c-ink); }
/* Pestaña activa: se "funde" con el contenido de abajo — su borde inferior blanco tapa la línea gris
   del contenedor (border-bottom de .viewer-tabs), así no queda esa rayita gris debajo. */
.vtab.activa { background: #fff; color: var(--c-ink); border-color: var(--c-border); border-bottom: 1px solid #fff; margin-bottom: -1px; }
.vtab-ico { display: inline-flex; flex-shrink: 0; color: var(--c-blue-mid); }
.vtab-ico svg { width: 15px; height: 15px; }
.vtab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtab-close {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: transparent; color: var(--c-muted); cursor: pointer;
  font-size: 16px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.vtab-close:hover { background: var(--c-border-soft); color: var(--c-ink); }
.pane-viewer.empty .viewer-placeholder { display: flex; }
.pane-viewer .viewer-placeholder { display: none; }
.viewer-placeholder {
  position: absolute; inset: 0;
  flex-direction: column; align-items: center; justify-content: center;
  color: var(--c-muted);
  gap: 14px;
  text-align: center;
}
.viewer-placeholder p { margin: 0; font-size: 14px; }

.viewer-toolbar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  min-height: var(--bar-h); box-sizing: border-box;   /* mismo alto que las pestañas del lector */
  position: sticky; top: 0; z-index: 6;
  margin: 0 0 14px; padding: 4px 2px;
  background: #fff;
  transition: transform .28s ease, opacity .2s ease;
}
.viewer-toolbar::-webkit-scrollbar { display: none; }
/* Al bajar por el correo, la barra se esconde hacia arriba; al subir reaparece */
.viewer-toolbar.bar-hidden { transform: translateY(-140%); opacity: 0; pointer-events: none; }

.viewer-head {
  background: transparent;
  border: none;
  border-radius: var(--r);
  padding: 16px 6px 10px;
  margin-bottom: 8px;
}
.viewer-subject {
  margin: 14px 0 4px;
  font-size: 22px; line-height: 1.3; color: var(--c-ink); font-weight: 600;
}
.viewer-meta { display: flex; align-items: center; gap: 12px; }
.viewer-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: transparent;
  border: 2px solid var(--c-blue-mid);
  color: var(--c-blue-mid); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
}
.viewer-meta-text { flex: 1; min-width: 0; }
.viewer-from-name { font-size: 14px; font-weight: 600; }
.viewer-from-email { font-size: 12px; color: var(--c-muted); }
.viewer-date { font-size: 12px; color: var(--c-muted); }

.viewer-body {
  background: white;
  border: none;
  border-radius: var(--r);
  padding: 26px 28px;
  font-size: 16px; line-height: 1.7;
  word-break: break-word;
}
.viewer-body img { max-width: 100%; height: auto; }
.viewer-body a { color: var(--c-blue-mid); }
.viewer-body table { max-width: 100%; }
/* Correo HTML renderizado en iframe aislado (auto-altura via JS) */
.viewer-frame {
  width: 100%;
  border: none;
  border-radius: var(--r);
  background: white;
  display: block;
  min-height: 220px;
}
.hilo-adjuntos { border-style: solid; }
.att-de { color: var(--c-muted); font-weight: 400; }
.att-msg-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--c-border-soft); }
.att-msg-group:first-of-type { border-top: none; }
.att-msg-de { font-size: 12px; font-weight: 700; color: var(--c-ink); margin-bottom: 4px; }
.viewer-attachments {
  margin-top: 12px;
  padding: 14px 16px;
  background: #f9fafd;
  border: 1px dashed var(--c-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--c-muted);
}
.att-head { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 8px; }
.att-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-top: 6px;
  background: #fff; border: 1px solid var(--c-border); border-radius: 8px;
}
.att-name {
  flex: 1 1 auto; min-width: 0; color: var(--c-blue-mid, #1769ff); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; text-decoration: none;
}
.att-name:hover { text-decoration: underline; }
.att-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  color: var(--c-blue-mid, #1769ff); background: var(--c-border-soft, #eef1f6);
  text-decoration: none; transition: background .12s, transform .12s;
}
.att-btn:hover { background: var(--c-border, #dfe3ea); }
.att-btn:active { transform: scale(0.94); }
.att-btn svg { width: 16px; height: 16px; }

/* Visor de adjuntos en pantalla (PDF / imágenes / Office) */
.att-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  background: rgba(15, 23, 42, 0.72);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.att-modal[hidden] { display: none; }
.att-modal-bar {
  flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: #0f172a; color: #fff;
}
.att-modal-name {
  flex: 1 1 auto; min-width: 0; font-size: 14.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att-modal-actions { flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.att-modal-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: none; cursor: pointer; text-decoration: none;
  color: #fff; background: rgba(255,255,255,0.12);
  transition: background .12s, transform .12s;
}
.att-modal-btn:hover { background: rgba(255,255,255,0.24); }
.att-modal-btn:active { transform: scale(0.94); }
.att-modal-body {
  flex: 1 1 auto; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: #525659; overflow: auto;
}
.att-modal-body .att-frame {
  width: 100%; height: 100%; border: none; background: #fff;
}
.att-modal-body .att-imgwrap {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.att-modal-body .att-imgwrap img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.att-loading, .att-fallback {
  color: #e5e7eb; text-align: center; padding: 40px 24px; font-size: 15px;
}
.att-fallback .btn-primary { max-width: 260px; margin: 16px auto 0; display: block; }

/* MODAL */
/* Diálogo compacto propio (reemplaza el prompt() del navegador) */
.mini-modal-ov {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 26, 71, 0.4); backdrop-filter: blur(4px); padding: 20px;
}
.mini-modal {
  background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.28); display: flex; flex-direction: column; gap: 12px;
}
.mini-modal-t { font-size: 16px; font-weight: 700; color: var(--c-ink); }
.mini-modal-inp, .mini-modal-sel {
  width: 100%; padding: 11px 13px; border: 1px solid var(--c-border); border-radius: 10px;
  font-size: 15px; font-family: inherit; outline: none; background: #f7f7fa;
}
.mini-modal-inp:focus, .mini-modal-sel:focus { border-color: var(--c-blue-mid); background: #fff; }
.mini-modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
.sb-folder-nueva { opacity: .92; }
.sb-folder-nueva:hover { opacity: 1; }

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 26, 71, 0.4);
  backdrop-filter: blur(4px);
  padding: 18px;
}
.modal-card {
  background: white;
  border-radius: 18px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  padding: 26px 28px;
  position: relative;
  box-shadow: var(--shadow-pop);
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: transparent;
  font-size: 22px; color: var(--c-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--c-border-soft); color: var(--c-ink); }
.modal h3 { margin: 0 0 4px; color: var(--c-ink); font-size: 19px; }
.modal-sub { margin: 0 0 18px; color: var(--c-muted); font-size: 13px; }

.prov-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.prov-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px;
  background: white;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r);
  cursor: pointer;
  transition: transform .1s, border-color .12s, box-shadow .12s;
}
.prov-card:hover { transform: translateY(-1px); border-color: var(--c-blue-mid); box-shadow: 0 4px 14px rgba(23,105,255,0.12); }
.prov-card .prov-dot {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px;
}
.prov-card .prov-name { font-size: 13px; color: var(--c-text); font-weight: 600; }

.form-add { margin-top: 4px; }
.form-banner {
  padding: 12px 14px;
  background: #f0f4ff;
  border: 1px solid #d6e2ff;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--c-blue);
  margin-bottom: 14px;
  line-height: 1.5;
}
.form-banner a { color: var(--c-blue-mid); font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.advanced { margin: 4px 0 12px; }
.advanced summary { font-size: 12px; color: var(--c-muted); cursor: pointer; padding: 6px 0; }
.advanced[open] summary { color: var(--c-blue-mid); }
.form-msg { font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.form-msg.err { color: var(--c-danger); }
.form-msg.ok { color: var(--c-success); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* TOAST */
.toast {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 18px;
  background: var(--c-ink);
  color: white; font-size: 13px;
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Toast con acción "Deshacer" (3s) tras borrar / spam / desuscribir */
.toast-undo {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  display: flex; align-items: center; gap: 14px;
  padding: 9px 10px 9px 18px;
  background: var(--c-ink); color: #fff; font-size: 13px;
  border-radius: 999px; box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 210;
  max-width: calc(100vw - 24px);
}
.toast-undo.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-undo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-undo button {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.16); color: #fff; border: 0;
  font-weight: 700; font-size: 13px; cursor: pointer;
  padding: 7px 15px; border-radius: 999px;
}
.toast-undo button:hover { background: rgba(255,255,255,0.30); }

/* UTILS */
.abs-tl { position: absolute; top: 14px; left: 14px; z-index: 3; }
.only-mobile { display: none; }
[hidden] { display: none !important; }

/* RESPONSIVE */
@media (max-width: 900px) {
  .app-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .splitter { display: none; }
  .pane-lista, .pane-viewer {
    grid-column: 1; grid-row: 1;
  }
  .pane-viewer {
    transform: translateX(100%);
    transition: transform .25s;
    background: #fff;
    height: 100dvh;
  }
  .pane-viewer.open { transform: translateX(0); }
  .only-mobile { display: inline-flex; }
  #viewer-content { padding: 0 12px 80px; -webkit-overflow-scrolling: touch; }
  .pane-viewer .icon-btn.abs-tl {
    background: white; color: var(--c-ink); box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    top: calc(10px + env(safe-area-inset-top));
  }
  /* lector compacto y legible en pantalla chica */
  .viewer-toolbar {
    padding-left: 52px;                                  /* deja libre el botón "volver" */
    padding-top: calc(10px + env(safe-area-inset-top));  /* no quedar bajo el notch */
  }
  .va-btn { width: 42px; height: 42px; }
  .viewer-head { padding: 16px 16px; margin-bottom: 10px; }
  .viewer-subject { font-size: 19px; margin-bottom: 12px; }
  .viewer-body { padding: 16px 14px; font-size: 16.5px; }
  .viewer-avatar { width: 38px; height: 38px; }
}
@media (max-width: 600px) {
  .login-card { padding: 28px 22px; }
  .login-card h1 { font-size: 24px; }
  .prov-grid { grid-template-columns: 1fr 1fr; }
}

/* En móvil las pestañas del lector dejan espacio al botón "volver" */
@media (max-width: 900px) {
  .viewer-tabs { padding-left: 48px; }
  #modal-compose .compose-card { padding: 14px 14px 60px; }
  .vtab { max-width: 44vw; }
}

/* ===== Árbol de carpetas + arrastrar correos a carpeta ===== */
.tab-carpetas { color: var(--c-blue-mid); font-weight: 700; }
.tab-carpetas.abierto { color: var(--c-ink); border-bottom-color: var(--c-blue-mid); }
.folder-tree {
  border-bottom: 1px solid var(--c-border-soft);
  background: #fbfcfe;
  max-height: 42vh; overflow-y: auto;
}
.folder-tree[hidden] { display: none; }
.ftree-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; position: sticky; top: 0; background: #fbfcfe; z-index: 1;
  border-bottom: 1px solid var(--c-border-soft);
}
.ftree-cuenta { flex: 1; min-width: 0; font-size: 12px; color: var(--c-muted); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree-nueva {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  border: 1px solid var(--c-border); background: #fff; color: var(--c-blue-mid);
  border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.ftree-nueva:hover { background: #f3f6ff; border-color: var(--c-blue-mid); }
.ftree-body { padding: 0 0 6px; }
/* Encabezado de cada cuenta en la vista de carpetas unificada */
.ftree-cuenta-sep {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 4px; margin-top: 4px;
  border-top: 1px solid var(--c-border-soft);
}
.ftree-cuenta-sep:first-child { border-top: none; margin-top: 0; }
.ftree-cuenta-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
/* Modal Mover: botón crear nueva + subcarpetas */
.mover-nueva { display: flex; align-items: center; gap: 7px; color: #1769FF; font-weight: 600; }
.mover-nueva svg { flex-shrink: 0; }
.mover-sub { color: var(--c-muted); }
.ftree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 8px; cursor: pointer;
  font-size: 13.5px; color: var(--c-ink);
  border: 1px solid transparent;
}
.ftree-row:hover { background: #eef3ff; }
.ftree-row.activa { background: #e6efff; font-weight: 600; }
.ftree-row.drop-target { background: #dcecff; border: 1px dashed var(--c-blue-mid); border-radius: 8px; }
.ftree-caret {
  flex-shrink: 0; width: 20px; height: 20px; border: none; background: transparent;
  color: var(--c-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.ftree-caret svg { width: 14px; height: 14px; }
.ftree-caret.open { transform: rotate(90deg); }
.ftree-caret.inv { visibility: hidden; }
.ftree-ico { flex-shrink: 0; display: inline-flex; color: var(--c-blue-soft); }
.ftree-ico svg { width: 16px; height: 16px; }
.ftree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree-kids[hidden] { display: none; }
/* Feedback al arrastrar una pestaña o fila de correo */
.vtab[draggable="true"] { -webkit-user-drag: element; }
.vtab.dragging, .msg-row.dragging { opacity: .5; }

/* ===== Campos de destinatarios como etiquetas (chips) + autocompletado ===== */
.chips {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  width: 100%; padding: 6px 8px; min-height: 42px;
  border: 1px solid var(--c-border); border-radius: 10px; background: #fff;
  cursor: text;
}
.chips:focus-within { border-color: var(--c-blue-mid); box-shadow: 0 0 0 3px rgba(23,105,255,.12); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: #eaf1ff; color: var(--c-ink); border: 1px solid #cfe0ff;
  border-radius: 999px; padding: 3px 5px 3px 10px; font-size: 13px; line-height: 1.4;
}
.chip.mal { background: #fdeaea; border-color: #f4c4c4; }
.chip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x {
  border: none; background: transparent; color: var(--c-muted); cursor: pointer;
  font-size: 15px; line-height: 1; width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chip-x:hover { background: rgba(0,0,0,.12); color: var(--c-ink); }
.chips-input {
  flex: 1; min-width: 120px; border: none; outline: none; background: transparent;
  font-size: 15px; padding: 4px 2px; color: var(--c-ink);
}
.chips-sug {
  position: fixed; z-index: 300; background: #fff;
  border: 1px solid var(--c-border); border-radius: 10px; box-shadow: var(--shadow-pop);
  overflow-y: auto; max-height: 240px; min-width: 220px;
}
.chips-sug[hidden] { display: none; }
.sug-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 12px; cursor: pointer; }
.sug-item.sel, .sug-item:hover { background: #f1f5ff; }
.sug-em { font-size: 13.5px; color: var(--c-ink); }
.sug-nom { font-size: 11.5px; color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Flechas para desplazarse por las pestañas del lector ===== */
.viewer-tabs-wrap {
  flex-shrink: 0; display: flex; align-items: stretch;
  background: #fff; border-bottom: 1px solid var(--c-border);
}
.viewer-tabs-wrap[hidden] { display: none; }
.viewer-tabs-wrap .viewer-tabs { flex: 1 1 auto; border-bottom: none; min-width: 0; }
.vtab-nav {
  flex-shrink: 0; width: 30px; border: none; background: #fff; color: var(--c-muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.vtab-nav:hover { background: var(--c-border-soft); color: var(--c-ink); }
.vtab-nav:disabled { opacity: .3; cursor: default; }

/* ===== Iconos de vista en la barra de la bandeja (carpetas/directorio/calendario) ===== */
.tab-ico {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; padding: 10px 0; border: none; background: transparent; cursor: pointer;
  color: var(--c-muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tab-ico:hover { color: var(--c-ink); }
.tab-ico.activo { color: var(--c-blue-mid); border-bottom-color: var(--c-blue-mid); }
.tabs-sep { width: 1px; align-self: center; height: 20px; background: var(--c-border); margin: 0 4px; }

/* ===== Vista especial: directorio y calendario ===== */
.vista-especial { flex: 1; overflow-y: auto; }
.vista-especial[hidden] { display: none; }
.dir-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px; border: none; background: transparent; cursor: pointer;
  border-bottom: 1px solid var(--c-border-soft); text-align: left;
}
.dir-item:hover { background: #fafbfd; }
.dir-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, var(--c-blue-mid), var(--c-blue));
}
.dir-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dir-nom { font-size: 14.5px; color: var(--c-ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-em { font-size: 12.5px; color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-n { flex-shrink: 0; font-size: 11px; color: var(--c-muted); background: var(--c-border-soft); border-radius: 999px; padding: 2px 8px; }
.dir-head, .cal-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--c-border-soft); font-weight: 700; color: var(--c-ink); font-size: 15px;
}
.cal-head { justify-content: space-between; }
.cal-nav { border: none; background: var(--c-border-soft); color: var(--c-ink); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.cal-nav:hover { background: var(--c-border); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; padding: 10px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--c-muted); font-weight: 700; padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; min-height: 38px; border: 1px solid transparent; border-radius: 9px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: default; font-size: 13px; color: var(--c-ink); position: relative;
}
.cal-cell.otro { color: var(--c-border); }
.cal-cell.hoy { border-color: var(--c-blue-mid); font-weight: 700; }
.cal-cell.con { cursor: pointer; background: #eff4ff; }
.cal-cell.con:hover { background: #dcecff; }
.cal-cell.cita { background: #fff3e0; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c-blue-mid); }
.cal-dot.cita { background: var(--c-warn); }
.cal-dia-lista { border-top: 1px solid var(--c-border-soft); }
.cal-dia-lista .msg-row { border-bottom: 1px solid var(--c-border-soft); }

/* ===== Redactor compacto: campos con placeholder adentro, CC colapsable ===== */
.comp-rows { gap: 7px; margin-bottom: 8px; }
.comp-rows .field { margin-bottom: 0; }
.compose-card .field input, .compose-card .field select { padding: 9px 12px; }
.chips-field { display: flex; align-items: flex-start; gap: 6px; }
.chips-field .chips { flex: 1 1 auto; min-height: 40px; }
.cc-toggle {
  flex-shrink: 0; align-self: center;
  border: 1px solid var(--c-border); background: #fff; color: var(--c-blue-mid);
  border-radius: 8px; padding: 8px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.cc-toggle:hover { background: #f3f6ff; border-color: var(--c-blue-mid); }

/* ===== Botones estilo Ford SYNC (planos, sin degradado) en los diálogos ===== */
#modal-compose .btn-primary, #modal-firmas .btn-primary, #modal-mover .btn-primary,
#modal-regla .btn-primary, #modal-add .btn-primary, #modal-compose .btn-ia {
  background: #1769FF; box-shadow: none; border-radius: 8px; font-weight: 600;
}
#modal-compose .btn-primary:hover, #modal-firmas .btn-primary:hover, #modal-mover .btn-primary:hover,
#modal-regla .btn-primary:hover, #modal-add .btn-primary:hover, #modal-compose .btn-ia:hover {
  background: #0f52cc; box-shadow: none; }
#modal-compose .btn-primary:active, #modal-firmas .btn-primary:active { transform: translateY(1px); }
#modal-compose .btn-ghost, #modal-firmas .btn-ghost, #modal-mover .btn-ghost,
#modal-regla .btn-regla .btn-ghost, #modal-regla .btn-ghost, #modal-add .btn-ghost {
  background: #fff; border: 1px solid var(--c-border); border-radius: 8px; color: var(--c-ink); box-shadow: none;
}
#modal-compose .btn-ghost:hover, #modal-firmas .btn-ghost:hover { background: var(--c-border-soft); }

/* ===== Vista de carpetas: fondo blanco (misma zona que directorio/calendario) ===== */
.vista-especial { background: #fff; }
.ftree-head { background: #fff; }

/* ===== Editor de firmas enriquecido ===== */
#firma-contenido.rt-editor { min-height: 120px; max-height: 220px; overflow-y: auto; }

/* ===== Botones Enviar/Cancelar del redactor: pequeños, blancos, a la derecha (como btn-ia) ===== */
#modal-compose .form-actions { justify-content: flex-end; gap: 8px; }
#modal-compose .form-actions .btn-primary {
  width: auto; padding: 7px 16px; font-size: 13px; font-weight: 700; border-radius: 8px;
  background: #fff; color: var(--c-blue-mid); border: 1px solid var(--c-blue-mid); box-shadow: none;
}
#modal-compose .form-actions .btn-primary:hover { background: #f3f6ff; box-shadow: none; }
#modal-compose .form-actions .btn-primary:disabled { opacity: .6; }
#modal-compose .form-actions .btn-ghost {
  padding: 7px 14px; font-size: 13px; border-radius: 8px;
  background: #fff; color: var(--c-muted); border: 1px solid var(--c-border);
}
#modal-compose .form-actions .btn-ghost:hover { background: var(--c-border-soft); color: var(--c-ink); }

/* ===== Adjuntar archivos (menú cámara/galería/archivos/Drive + lista de adjuntos) ===== */
.att-menu {
  position: fixed; z-index: 320; min-width: 230px;
  background: #fff; border: 1px solid var(--c-border); border-radius: 12px;
  box-shadow: var(--shadow-pop); padding: 6px;
}
.att-menu[hidden] { display: none; }
.att-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: transparent; cursor: pointer;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; color: var(--c-ink); text-align: left;
}
.att-menu button:hover { background: var(--c-border-soft); }
.att-menu button svg { color: var(--c-blue-mid); flex-shrink: 0; }
.comp-adjuntos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.comp-adjuntos:empty { display: none; }
.adj-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 240px;
  background: #eef3ff; border: 1px solid #d6e4ff; border-radius: 10px; padding: 6px 8px 6px 10px;
  font-size: 12.5px; color: var(--c-ink);
}
.adj-chip .adj-ico { color: var(--c-blue-mid); flex-shrink: 0; display: inline-flex; }
.adj-chip .adj-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.adj-chip .adj-size { color: var(--c-muted); flex-shrink: 0; }
.adj-chip .adj-x {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; border: none; background: transparent;
  color: var(--c-muted); cursor: pointer; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.adj-chip .adj-x:hover { background: rgba(0,0,0,.1); color: var(--c-ink); }

/* ===== Calendario: badges de compromisos por tipo ===== */
.cal-recargar { font-size: 17px; }
.cal-badge { font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.cal-badge.cal-cita { background: linear-gradient(135deg, #1769FF, #003478); }
.cal-badge.cal-deadline { background: linear-gradient(135deg, #ff8a00, #e6364a); }
.cal-badge.cal-compromiso { background: linear-gradient(135deg, #0caf60, #047a44); }

/* ===== La barra de iconos/pestañas se oculta al bajar y reaparece al subir ===== */
/* flex:0 0 auto = estas barras NO se encogen; solo la lista/región flexiona.
   Sin esto el flex recorta las pestañas y los mensajes se le montan encima.
   position/z-index las mantienen por encima de la región de la lista. */
#tabs-bandeja { flex: 0 0 auto; position: relative; z-index: 2; overflow: hidden; transition: max-height .25s ease, opacity .2s ease; max-height: 120px; }
#tabs-bandeja.bar-hidden { max-height: 0; opacity: 0; border-bottom-color: transparent; }

/* La cabecera de la bandeja (título + acciones) también se colapsa al bajar */
.pane-header { flex: 0 0 auto; overflow: hidden; transition: max-height .25s ease, opacity .2s ease, padding .25s ease; max-height: 90px; }
.pane-header.bar-hidden { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; border-bottom-color: transparent; }

/* ===== Sidebar (cajón) en fondo blanco ===== */
.sidebar { background: #fff; color: var(--c-ink); border-right: 1px solid var(--c-border); }
.sidebar .icon-btn { background: var(--c-border-soft); color: var(--c-ink); }
.sidebar .icon-btn:hover { background: var(--c-border); }
.sb-brand { color: var(--c-ink); }
.sb-section { color: var(--c-muted); }
.sb-account, .sb-add { color: var(--c-ink); }
.sb-account:hover, .sb-add:hover { background: var(--c-border-soft); }
.sb-account.active { background: rgba(23,105,255,0.10); color: var(--c-blue-mid); }
.sb-add { border: 1px solid var(--c-border); }
.sb-add:hover { background: var(--c-border-soft); border-color: var(--c-blue-mid); }
.sb-account-delete { color: var(--c-muted); }
.sb-account-delete:hover { color: var(--c-danger); background: var(--c-border-soft); }
.sb-footer { border-top: 1px solid var(--c-border); }
.sb-user { color: var(--c-ink); }
.sb-user:hover { background: var(--c-border-soft); }
.sb-folder .sb-account-label { color: var(--c-ink); }
/* El botón Redactar sigue azul con texto blanco — SIEMPRE (incluido hover). Doble clase para ganarle
   a `.sb-add:hover` que le ponía fondo claro dejando el texto blanco invisible. */
.sb-add.sb-compose,
.sb-add.sb-compose:hover {
  color: #fff;
  border: none;
  background: linear-gradient(160deg, #1769FF, #003478);
}
.sb-add.sb-compose:hover { background: linear-gradient(160deg, #2f80ff, #0a4296); }

/* ---- Selección múltiple de correos (casillas + barra de acciones masivas) ---- */
.msg-check { display: inline-flex; align-items: center; flex-shrink: 0; margin-right: 4px; cursor: pointer; }
.msg-check input { width: 14px; height: 14px; cursor: pointer; accent-color: var(--c-blue-mid); margin: 0; }
.msg-row.sel { background: rgba(23,105,255,0.12); }
.msg-row.sel:hover { background: rgba(23,105,255,0.16); }
.sel-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: flex; align-items: center; gap: 8px;
  background: var(--c-ink); color: #fff;
  padding: 8px 10px; border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.28);
  max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none;
}
.sel-bar::-webkit-scrollbar { display: none; }
.sel-bar .sel-n { font-size: 13px; font-weight: 600; white-space: nowrap; padding: 0 2px; }
.sel-bar .sel-sp { width: 1px; align-self: stretch; background: rgba(255,255,255,.22); margin: 2px 1px; }
.sel-bar .sel-btn, .sel-bar .sel-x {
  border: none; background: rgba(255,255,255,.14); color: #fff; cursor: pointer;
  border-radius: 9px; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.sel-bar .sel-btn:hover, .sel-bar .sel-x:hover { background: rgba(255,255,255,.26); }
.sel-bar .sel-btn.danger { background: #e5484d; }
.sel-bar .sel-btn.danger:hover { background: #c93b3f; }
.sel-bar .sel-x { padding: 8px 11px; font-size: 15px; line-height: 1; }

/* ===== Botón IA en la barra + chat IA sobre los correos ===== */
.tab-ico.ia { gap: 3px; width: auto; padding: 10px 6px; }
.tab-ico.ia .tab-ia-txt { font-size: 12px; font-weight: 800; letter-spacing: .02em; }
/* contenedor del chat dentro de la vista especial (solo en modo IA) */
.vista-especial.ia-mode { display: flex; flex-direction: column; overflow: hidden; }
.ia-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; font-size: 13px; font-weight: 700; color: var(--c-ink);
  border-bottom: 1px solid var(--c-border-soft); background: #fff;
}
.ia-head svg { color: var(--c-blue-mid); }
.ia-head .ia-limpiar {
  margin-left: auto; border: none; background: transparent; color: var(--c-muted);
  font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.ia-head .ia-limpiar:hover { background: #f0f0f5; color: var(--c-ink); }
.ia-msgs { flex: 1; overflow-y: auto; padding: 14px 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.ia-vacio { text-align: center; margin: auto; max-width: 340px; padding: 20px; color: var(--c-muted); }
.ia-vacio-ic { color: var(--c-blue-mid); opacity: .85; margin-bottom: 6px; }
.ia-vacio-t { font-size: 16px; font-weight: 700; color: var(--c-ink); margin-bottom: 6px; }
.ia-vacio-s { font-size: 13px; line-height: 1.5; }
.ia-b { max-width: 86%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.ia-b.user { align-self: flex-end; background: #1769FF; color: #fff; border-bottom-right-radius: 5px; }
.ia-b.ia { align-self: flex-start; background: #eef4ff; color: var(--c-ink); border: 1px solid #dbe7ff; border-bottom-left-radius: 5px; }
.ia-cite { color: var(--c-blue-mid); font-weight: 700; font-size: .72em; }
.ia-b.ia.pensando { display: inline-flex; gap: 4px; align-items: center; }
.ia-b.ia.pensando span { width: 6px; height: 6px; border-radius: 50%; background: #9dc0ff; animation: iablink 1s infinite; }
.ia-b.ia.pensando span:nth-child(2) { animation-delay: .2s; }
.ia-b.ia.pensando span:nth-child(3) { animation-delay: .4s; }
@keyframes iablink { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }
.ia-fuentes { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.ia-fuente {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  max-width: 200px; text-align: left; cursor: pointer;
  border: 1px solid #cfe0ff; background: #fff; border-radius: 8px; padding: 5px 8px;
}
.ia-fuente:hover { border-color: var(--c-blue-mid); background: #f2f7ff; }
.ia-fuente-de { font-size: 10.5px; font-weight: 700; color: var(--c-blue-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 184px; }
.ia-fuente-asunto { font-size: 11.5px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 184px; }
.ia-adjuntos { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.ia-adj {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  border: 1px solid #cfe0ff; background: #fff; border-radius: 8px; padding: 6px 10px;
  color: var(--c-blue-mid); font-size: 12px; font-weight: 600; max-width: 220px;
}
.ia-adj:hover { border-color: var(--c-blue-mid); background: #f2f7ff; }
.ia-adj-nom { color: var(--c-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.ia-adj-img { flex-direction: column; align-items: stretch; padding: 6px; max-width: 160px; }
.ia-adj-img img { width: 100%; max-height: 130px; object-fit: cover; border-radius: 6px; display: block; }
.ia-adj-img .ia-adj-nom { margin-top: 4px; max-width: 148px; font-size: 11px; }
.ia-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--c-border-soft); background: #fff; }
.ia-input textarea {
  flex: 1; resize: none; border: 1px solid var(--c-border); border-radius: 18px;
  padding: 9px 14px; font-size: 14px; font-family: inherit; line-height: 1.4;
  max-height: 120px; outline: none; background: #f7f7fa;
}
.ia-input textarea:focus { border-color: var(--c-blue-mid); background: #fff; }
.ia-send {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--c-blue-mid); color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.ia-send:hover { background: var(--c-blue); }
.ia-send:active { transform: scale(0.94); }

/* ===== Hilos / conversaciones en la bandeja ===== */
.msg-thread { position: relative; }
/* chip con el número de correos de la conversación (abre el árbol) */
.thread-toggle {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 2px;
  height: 19px; padding: 0 5px 0 7px; border-radius: 999px; cursor: pointer;
  border: 1px solid #cfe0ff; background: #eef4ff; color: var(--c-blue-mid);
  font-size: 11.5px; font-weight: 800; line-height: 1;
}
.thread-toggle svg { transition: transform .15s; }
.thread-toggle.open svg { transform: rotate(180deg); }
.thread-toggle:hover { background: #e0ecff; border-color: var(--c-blue-mid); }
.es-hilo .msg-subject { font-weight: 600; }
/* árbol de correos anteriores del hilo */
.msg-thread-kids { position: relative; margin: 0 0 4px 0; }
.msg-thread-kids.oculto { display: none; }
.msg-sub {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 14px 6px 40px; position: relative;
  border-bottom: 1px solid var(--c-border-soft);
}
.msg-sub::before {   /* conector tipo árbol */
  content: ''; position: absolute; left: 24px; top: 0; bottom: 50%;
  width: 10px; border-left: 1.5px solid #cfe0ff; border-bottom: 1.5px solid #cfe0ff;
  border-bottom-left-radius: 6px;
}
.msg-sub:hover { background: #f2f7ff; }
.msg-sub-from { flex: 1; min-width: 0; font-size: 13px; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-sub.unread .msg-sub-from { font-weight: 700; color: var(--c-ink); }
.msg-sub-date { font-size: 11.5px; color: var(--c-muted); flex-shrink: 0; }

/* ===== Barra de conversación dentro del lector (un solo tab por hilo) ===== */
.viewer-convo { margin: 0 0 8px; border: 1px solid var(--c-border-soft); border-radius: 10px; overflow: hidden; background: #fbfcff; }
.vc-head { padding: 7px 12px; font-size: 12px; font-weight: 700; color: var(--c-blue-mid); background: #eef4ff; border-bottom: 1px solid #dbe7ff; }
.vc-list { display: flex; flex-direction: column; max-height: 168px; overflow-y: auto; }
.vc-item {
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left;
  padding: 8px 12px; border: none; background: transparent; border-bottom: 1px solid var(--c-border-soft);
  border-left: 3px solid transparent;
}
.vc-item:last-child { border-bottom: none; }
.vc-item:hover { background: #f2f7ff; }
.vc-item.act { background: #eaf1ff; border-left-color: var(--c-blue-mid); }
.vc-de { flex: 1; min-width: 0; font-size: 13.5px; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-item.unread .vc-de { font-weight: 700; color: var(--c-ink); }
.vc-item.act .vc-de { font-weight: 700; }
.vc-fe { font-size: 11.5px; color: var(--c-muted); flex-shrink: 0; }

/* Región que agrupa la vista-especial y la lista de correos. Por defecto se
   apila (columna): la vista-especial reemplaza la lista en directorio/agenda/IA. */
.lista-region { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; position: relative; z-index: 0; }

/* ===== Carpetas como PANEL IZQUIERDO: árbol a la izquierda y correos a la
   derecha, para arrastrar correos a las carpetas sin encimar la lista. ===== */
.carpetas-dock .lista-region { flex-direction: row; }
.carpetas-dock #vista-especial {
  flex: 0 0 46%; max-width: 300px; min-width: 148px;
  max-height: none; height: auto;
  border-right: 3px solid var(--c-border); border-bottom: none;
  box-shadow: 3px 0 10px rgba(0,26,71,.06);
  overflow-y: auto;
}
.carpetas-dock #lista-mensajes { flex: 1 1 auto; min-width: 0; }
/* En PC ensancha el panel de lista para que quepan cómodos el árbol y los correos
   (en móvil el grid es de una sola columna, así que --list-w no aplica). */
.app-body.carpetas-dock { --list-w: min(760px, 62vw); }
.ftree-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; background: #f7f9ff;
  border-bottom: 1px solid var(--c-border-soft);
  font-size: 11.5px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.ftree-head > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree-nueva-top {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--c-blue-mid); background: #fff; color: var(--c-blue-mid);
  border-radius: 8px; padding: 5px 10px; font-size: 11px; font-weight: 700;
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
.ftree-nueva-top:hover { background: var(--c-blue-mid); color: #fff; }
.mini-modal-lbl { display: block; font-size: 12px; font-weight: 600; color: var(--c-muted); margin: 2px 0 -4px; }
.mini-modal-padre {
  width: 100%; padding: 9px 10px; border: 1px solid var(--c-border);
  border-radius: 9px; font-size: 14px; background: #fff; color: var(--c-ink);
}
/* Cabecera de cuenta plegable (acordeón) */
.ftree-acct-toggle {
  flex: 1; min-width: 0; text-align: left; border: none; cursor: pointer;
  background: transparent; display: flex; align-items: center; gap: 8px;
  padding: 4px 2px; border-radius: 8px;
  font-size: 12px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.ftree-acct-caret { flex-shrink: 0; color: var(--c-muted); transition: transform .15s; }
.ftree-acct-toggle.abierta .ftree-acct-caret { transform: rotate(90deg); }
.ftree-acct-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree-acct-toggle:hover { background: #f7f9ff; }
.ftree-acct-nueva {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--c-border); background: #fff; color: var(--c-blue-mid);
  border-radius: 8px; padding: 5px 9px; font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.ftree-acct-nueva:hover { background: #f3f6ff; border-color: var(--c-blue-mid); }
.ftree-acct-body[hidden] { display: none; }

/* fantasma del arrastre táctil de correos */
.drag-ghost {
  position: fixed; z-index: 9999; transform: translate(-50%, -140%);
  pointer-events: none; background: var(--c-blue-mid); color: #fff;
  font-size: 12.5px; font-weight: 700; padding: 7px 12px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0,26,71,.28); white-space: nowrap;
}
.msg-row.dragging, .msg-sub.dragging { opacity: .45; }
