/* ===========================================================
   Notas · Latinos  —  línea gráfica Latinos FM
   Naranja vibrante #FF6600 + secundario #FF8800 + rojo #e63d32
   Outfit (display) + Nunito Sans (UI/body). Bordes limpios.
   =========================================================== */

:root {
  /* Latinos FM colors */
  --or:        #FF6600;
  --or2:       #FF8800;
  --or-deep:   #E65100;
  --red:       #e63d32;
  --amber:     #FFD23F;
  --blk:       #1a1a1a;
  --blk2:      #212121;
  --gris:      #666666;
  --gris2:     #888888;
  --gris-cl:   #f5f5f5;
  --borde:     #e0e0e0;
  --borde-cl:  #f0f0f0;

  /* Mapping a tokens semánticos */
  --bg:           #FFFFFF;
  --bg-grain:     #FAFAFA;
  --surface:      #FFFFFF;
  --surface-2:    #F5F5F5;
  --ink:          #111111;
  --ink-soft:     #333333;
  --muted:        #888888;
  --muted-2:      #B5B5B5;
  --rule:         #E5E5E5;
  --rule-soft:    #F0F0F0;
  --accent:       #FF6600;
  --accent-2:     #FF8800;
  --accent-soft:  #FFE9D6;          /* fondo claro para chips/selección */
  --accent-ink:   #B34800;          /* texto sobre fondos cálidos */
  --highlight:    #FFD23F;
  --danger:       #e63d32;

  --shadow:       0 1px 0 rgba(26,26,26,.04), 0 14px 38px -16px rgba(26,26,26,.22);
  --shadow-pop:   0 6px 18px rgba(26,26,26,.10), 0 26px 70px -22px rgba(26,26,26,.30);
  --shadow-or:    0 8px 22px -10px rgba(255,102,0,.55);
  --radius:       10px;
  --radius-lg:    16px;

  --font-display: 'Outfit', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-body:    'Nunito Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-ui:      'Nunito Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w:    288px;
  --page-w:       780px;
}

[data-theme="dark"] {
  --bg:           #0E0E0F;
  --bg-grain:     #131314;
  --surface:      #17171A;
  --surface-2:    #1F1F22;
  --ink:          #F5F5F5;
  --ink-soft:     #D6D6D6;
  --muted:        #8A8A8E;
  --muted-2:      #555558;
  --rule:         #2A2A2D;
  --rule-soft:    #1F1F22;
  --accent:       #FF8033;
  --accent-2:     #FFAA66;
  --accent-soft:  #2A1B10;
  --accent-ink:   #FFC299;
  --highlight:    #FFD23F;
  --danger:       #FF5C50;
  --shadow:       0 1px 0 rgba(0,0,0,.5), 0 18px 50px -20px rgba(0,0,0,.7);
  --shadow-pop:   0 6px 18px rgba(0,0,0,.5), 0 28px 80px -24px rgba(0,0,0,.85);
  --shadow-or:    0 10px 28px -12px rgba(255,128,51,.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #0E0E0F;
    --bg-grain:     #131314;
    --surface:      #17171A;
    --surface-2:    #1F1F22;
    --ink:          #F5F5F5;
    --ink-soft:     #D6D6D6;
    --muted:        #8A8A8E;
    --muted-2:      #555558;
    --rule:         #2A2A2D;
    --rule-soft:    #1F1F22;
    --accent:       #FF8033;
    --accent-2:     #FFAA66;
    --accent-soft:  #2A1B10;
    --accent-ink:   #FFC299;
    --highlight:    #FFD23F;
    --danger:       #FF5C50;
    --shadow:       0 1px 0 rgba(0,0,0,.5), 0 18px 50px -20px rgba(0,0,0,.7);
    --shadow-pop:   0 6px 18px rgba(0,0,0,.5), 0 28px 80px -24px rgba(0,0,0,.85);
    --shadow-or:    0 10px 28px -12px rgba(255,128,51,.55);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(900px 460px at -10% -20%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 55%),
    radial-gradient(700px 360px at 115% 110%, color-mix(in srgb, var(--accent) 9%, transparent) 0%, transparent 60%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
::selection { background: var(--highlight); color: #1a1a1a; }

/* ============================================================
   LOGIN
   ============================================================ */
.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  isolation: isolate;
}
.auth::before {
  /* Disco naranja gigante de fondo (eco al logo Latinos FM) */
  content: "";
  position: absolute;
  width: 720px; height: 720px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent-2), var(--accent) 55%, var(--or-deep));
  filter: blur(2px);
  opacity: .18;
  top: -180px; left: -180px;
  z-index: -1;
}
[data-theme="dark"] .auth::before,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth::before { opacity: .25; } }

.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
  position: relative;
}
.auth-stamp {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 32px;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
  box-shadow: var(--shadow-or);
  position: relative;
  transform: rotate(-4deg);
}
.auth-stamp::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid var(--blk);
  border-radius: 50%;
  opacity: .12;
}
.auth h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 5vw, 44px);
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  line-height: 1.05;
}
.auth h1 em { font-style: normal; color: var(--accent); }
.auth .lede { color: var(--muted); margin: 0 0 24px; font-size: 14.5px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 700;
  font-family: var(--font-display);
}
.field input {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-weight: 500;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 13px 16px;
  margin-top: 10px;
  background: var(--accent);
  color: #FFFFFF;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: 15px;
  box-shadow: var(--shadow-or);
  transition: transform .12s ease, background .15s, box-shadow .15s;
}
.btn-primary:hover { background: var(--or2); box-shadow: 0 12px 28px -10px rgba(255,102,0,.7); }
.btn-primary:active { transform: translateY(1px); }
.auth-err {
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
  font-weight: 600;
}
.auth-foot {
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}
.shell.collapsed { grid-template-columns: 0 1fr; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--bg-grain);
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: opacity .2s;
}
.shell.collapsed .sidebar { opacity: 0; pointer-events: none; }

.brand {
  padding: 16px 18px 6px;
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.brand-disc {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-or);
  transform: rotate(-4deg);
}
.brand em { font-style: normal; color: var(--accent); font-weight: 800; }

.user-chip {
  margin: 6px 14px 14px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  background: transparent;
  transition: background .15s;
  font-weight: 600;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-or);
}

.search {
  margin: 0 14px 10px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input {
  background: none; border: 0; outline: none;
  flex: 1; min-width: 0;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
}
.search kbd {
  font-family: var(--font-ui);
  font-size: 10.5px;
  padding: 2px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-2);
  font-weight: 700;
}

.side-actions { padding: 0 10px 4px; display: flex; flex-direction: column; gap: 1px; }
.side-action {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
  transition: background .12s, color .12s;
}
.side-action:hover { background: var(--surface-2); color: var(--ink); }
.side-action .ico { width: 16px; height: 16px; color: var(--accent); flex: none; }
.side-action .plus { margin-left: auto; opacity: 0; transition: opacity .12s; }
.side-action:hover .plus { opacity: 1; }

/* Pestaña Trabajo: acción principal del cuaderno, siempre resaltada. */
.side-action.work-action {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 800;
  font-family: var(--font-display);
  margin-bottom: 5px;
}
.side-action.work-action .ico { font-size: 15px; }
.side-action.work-action:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--accent-soft));
  color: var(--ink);
}
.side-action.work-action.active-side { color: var(--accent-ink); }

.side-section {
  padding: 14px 16px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 800;
  font-family: var(--font-display);
}

/* Zona media de la barra lateral (Chat IA + Favoritos + Páginas): un único
   scroll para todo, así nada queda cortado abajo sin barra de desplazamiento. */
.side-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.side-scroll::-webkit-scrollbar { width: 6px; }
.side-scroll::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 6px; }

.tree { padding: 0 6px 12px; }

.tree-node { user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 6px;
  margin: 1px 4px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.tree-row:hover { background: var(--surface-2); color: var(--ink); }
.tree-row.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}
[data-theme="dark"] .tree-row.active,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tree-row.active { color: var(--accent); } }

.tree-row .twist {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  color: var(--muted);
  border-radius: 4px;
  flex: none;
  transition: transform .12s, background .12s;
}
.tree-row .twist:hover { background: var(--rule); color: var(--ink); }
.tree-row.expanded .twist { transform: rotate(90deg); }
.tree-row .twist.empty { opacity: 0; pointer-events: none; }

.tree-row .ico {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', var(--font-display);
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex: none;
}
.tree-row .label {
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-ui);
}
.tree-row .label.untitled { color: var(--muted); font-style: italic; font-weight: 500; }
.tree-row .row-actions {
  display: flex; gap: 0; opacity: 0;
  transition: opacity .12s;
}
.tree-row:hover .row-actions { opacity: 1; }
.tree-row .row-btn {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 5px;
  color: var(--muted);
}
.tree-row .row-btn:hover { background: var(--rule); color: var(--ink); }

.tree-children { padding-left: 14px; }

.tree-empty {
  margin: 8px 16px;
  padding: 18px 14px;
  border: 1px dashed var(--rule);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  line-height: 1.5;
}
.tree-empty button {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.side-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--rule);
  display: flex; gap: 6px;
  align-items: center;
}
.side-foot .ghost {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
  transition: background .15s, color .15s, box-shadow .15s;
}
.side-foot .ghost:hover { background: var(--accent); color: #fff; box-shadow: var(--shadow-or); }
.side-foot .ghost svg { color: var(--accent); }
.side-foot .ghost:hover svg { color: #fff; }
.side-foot .icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--muted);
  border: 1px solid var(--rule);
  background: var(--surface);
  transition: color .15s, background .15s, border-color .15s;
}
.side-foot .icon-btn:hover { color: var(--accent); background: var(--surface-2); border-color: var(--accent); }

#install-btn { display: none; }
#install-btn.show { display: inline-flex; }

/* ============================================================
   MAIN — DOCUMENT
   ============================================================ */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: 50px;
  padding: 0 14px 0 10px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--bg);
  position: relative;
  z-index: 2;
}
.topbar .icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.topbar .icon-btn:hover { background: var(--surface-2); color: var(--accent); }

.crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0; flex: 1;
  overflow: hidden; white-space: nowrap;
  font-weight: 600;
}
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .sep { color: var(--muted-2); }
.crumbs .icn { font-size: 12px; opacity: .9; }

.savestate {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  white-space: nowrap;
  font-family: var(--font-display);
}
.savestate.saving { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.canvas {
  flex: 1; overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.canvas::-webkit-scrollbar { width: 10px; }
.canvas::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 8px; }

.page {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 56px clamp(24px, 6vw, 96px) 320px;
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--ink);
}

.page-icon {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', var(--font-display);
  font-size: 52px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 10px;
  margin-bottom: 8px;
  display: inline-block;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}
.page-icon:hover { background: var(--surface-2); }
.page-icon.empty {
  font-size: 13px;
  color: var(--accent);
  padding: 7px 12px;
  border: 1.5px dashed var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
  font-family: var(--font-display);
}

.title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 5vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 6px 0 24px;
  outline: none;
  caret-color: var(--accent);
  word-wrap: break-word;
  color: var(--ink);
}
.title:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-2);
  font-weight: 700;
}

/* ---- Blocks ---- */
.blocks { display: flex; flex-direction: column; }
.block {
  position: relative;
  padding: 3px 0;
  margin: 1px 0;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  border-radius: 6px;
}
.block .gutter {
  position: absolute;
  left: -44px;
  top: 6px;
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity .12s;
}
.block:hover .gutter,
.block.focus .gutter { opacity: 1; }
.gutter .gbtn {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.gutter .gbtn:hover { background: var(--surface-2); color: var(--accent); }
.gutter .gbtn.drag { cursor: grab; }

.block .ce {
  flex: 1;
  outline: none;
  min-height: 1.6em;
  caret-color: var(--accent);
  font-family: var(--font-body);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.block .ce:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-2);
  pointer-events: none;
}
.block.empty:not(.focus) .ce:empty::before { content: ""; }

.block.h1 .ce { font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1.2; margin-top: 22px; letter-spacing: -0.02em; }
.block.h2 .ce { font-family: var(--font-display); font-weight: 700; font-size: 23px; line-height: 1.25; margin-top: 16px; letter-spacing: -0.015em; }
.block.h3 .ce { font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.3; margin-top: 10px; letter-spacing: -0.01em; }

.block.bul, .block.num, .block.todo {
  align-items: flex-start;
}
.block.bul .marker, .block.num .marker, .block.todo .marker {
  flex: none;
  width: 22px;
  margin-top: 7px;
  text-align: center;
  font-family: var(--font-display);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}
.block.bul .marker { color: var(--accent); font-size: 20px; line-height: 1; margin-top: 10px; }
.block.num .marker { color: var(--accent); }
.block.todo .marker {
  width: 22px;
  display: grid;
  place-items: center;
  margin-top: 5px;
}
.todo-check {
  width: 17px; height: 17px;
  border: 2px solid var(--muted-2);
  border-radius: 5px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.todo-check:hover { border-color: var(--accent); }
.todo-check.on { background: var(--accent); border-color: var(--accent); transform: scale(.96); }
.todo-check.on::after { content: "✓"; color: #fff; font-size: 12px; line-height: 1; font-weight: 900; }
.block.todo.done .ce { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }

.block.quote .ce {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 17px;
  color: var(--ink-soft);
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 6px 0;
  font-weight: 500;
}

.block.code {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 8px 0;
  position: relative;
}
.block.code::before {
  content: "CODE";
  position: absolute;
  top: 8px; right: 12px;
  font-family: var(--font-display);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--muted-2);
  font-weight: 800;
}
.block.code .ce {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}

.block.callout {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px 12px 14px;
  margin: 10px 0;
  display: flex; gap: 12px; align-items: flex-start;
}
.block.callout .marker {
  font-size: 20px;
  flex: none;
  user-select: none;
  cursor: pointer;
  line-height: 1.4;
}
.block.callout .ce { color: var(--accent-ink); font-weight: 500; }

.block.divider {
  padding: 14px 0;
  pointer-events: none;
}
.block.divider::after {
  content: "";
  display: block;
  height: 3px;
  width: 60px;
  margin: 0 auto;
  background: var(--accent);
  border-radius: 999px;
}
.block.divider .gutter { pointer-events: auto; }

.block.image figure {
  margin: 8px 0;
  display: flex; flex-direction: column; gap: 6px;
  width: 100%;
}
.block.image img {
  max-width: 100%; max-height: 480px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  object-fit: cover;
}
.block.image .ce {
  font-size: 13px; color: var(--muted); font-style: italic;
  font-family: var(--font-body);
}
.block.image .img-empty {
  padding: 28px;
  background: var(--surface-2);
  border: 1px dashed var(--rule);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.block.image input.img-url {
  width: 100%;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 12px;
  margin-top: 6px;
  outline: none;
  font-size: 13px;
  font-weight: 500;
}
.block.image input.img-url:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Drop zone para subir imágenes */
.block.image .img-drop {
  padding: 36px 20px;
  background: var(--surface-2);
  border: 2px dashed var(--rule);
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.block.image .img-drop:hover,
.block.image .img-drop.hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.block.image .img-drop-ic { font-size: 32px; line-height: 1; margin-bottom: 8px; }
.block.image .img-drop-tt {
  font-family: var(--font-display);
  font-weight: 700; font-size: 15px;
  color: var(--ink);
}
.block.image .img-drop-sb {
  font-size: 12px; color: var(--muted); margin-top: 3px;
}
.block.image .img-toolbar {
  display: flex; gap: 6px; margin-top: 4px;
}
.block.image .img-tool {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.block.image .img-tool:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.img-file-hidden { display: none !important; }

/* ============================================================
   CARPETAS — vista de grid cuando notas_pages.is_folder = 1
   ============================================================ */
.tree-row.is-folder .ico { filter: saturate(1.15); }
.tree-row.is-folder .label { font-weight: 700; }

.folder-page { padding-top: 12px; }
.folder-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
}
.folder-icon-big {
  font-size: 44px; line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.05));
}
.folder-title-input {
  flex: 1;
  font-family: var(--font-display);
  font-size: 32px; font-weight: 800;
  border: none; outline: none;
  background: transparent;
  color: var(--ink);
  padding: 0;
}
.folder-title-input::placeholder { color: var(--muted); }
.folder-meta {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.folder-actions {
  display: flex; gap: 8px; margin-bottom: 18px;
}
.folder-cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 9px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.folder-cta:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.folder-cta .ic { font-size: 15px; line-height: 1; }
.folder-cta.danger { margin-left: auto; color: #b8331e; }
.folder-cta.danger:hover { background: #fde2dd; border-color: #b8331e; color: #b8331e; }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.folder-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 18px 16px 14px;
  cursor: pointer;
  transition: transform .1s, border-color .12s, box-shadow .12s, background .12s;
  font-family: var(--font-body);
}
.folder-card-menu {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  background: var(--surface-2);
  opacity: .6;
  transition: opacity .12s, background .12s, color .12s;
}
.folder-card:hover .folder-card-menu { opacity: 1; }
.folder-card-menu:hover { background: var(--surface-2); color: var(--ink); }
.folder-card-menu svg { width: 16px; height: 16px; }
.folder-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 18%, transparent);
}
.folder-card.folder {
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%);
}
.folder-card-ic { font-size: 28px; line-height: 1; }
.folder-card-tt {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.folder-card-sb {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.folder-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 42px 16px;
  background: var(--surface-2);
  border: 1px dashed var(--rule);
  border-radius: 14px;
}
.folder-empty-ic { font-size: 38px; line-height: 1; margin-bottom: 6px; }
.folder-empty-tt {
  font-family: var(--font-display);
  font-weight: 700; font-size: 16px;
  color: var(--ink);
}
.folder-empty-sb {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* ============================================================
   EVENTOS — visibilidad privada/compartida
   ============================================================ */
.ev-visibility .ev-vis-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ev-vis-btn {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 1px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: background .12s, border-color .12s, color .12s, transform .1s;
}
.ev-vis-btn:hover { border-color: var(--accent); }
.ev-vis-btn.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.ev-vis-btn:disabled { opacity: .6; cursor: not-allowed; }
.ev-vis-btn .ev-vis-ic { font-size: 18px; line-height: 1; }
.ev-vis-btn .ev-vis-tt {
  font-family: var(--font-display);
  font-weight: 700; font-size: 13px;
}
.ev-vis-btn .ev-vis-sb {
  font-size: 11px; color: var(--muted);
}

/* Tercera opción: compartir con usuarios concretos. */
.ev-visibility .ev-vis-toggle.ev-vis-3 { grid-template-columns: 1fr 1fr 1fr; }
.ev-vis-3 .ev-vis-btn { padding: 9px 8px; }
.ev-vis-3 .ev-vis-btn .ev-vis-tt { font-size: 12.5px; }
.ev-vis-3 .ev-vis-btn .ev-vis-sb { font-size: 10px; }
@media (max-width: 520px) {
  .ev-visibility .ev-vis-toggle.ev-vis-3 { grid-template-columns: 1fr; }
}

.ev-share-box {
  margin-top: 10px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 10px 12px;
}
.ev-share-hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.ev-share-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 200px; overflow-y: auto;
}
.ev-share-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px; border-radius: 8px;
  cursor: pointer; font-size: 13.5px; color: var(--ink);
}
.ev-share-row:hover { background: var(--surface); }
.ev-share-row input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.ev-share-empty { font-size: 12.5px; color: var(--muted); padding: 4px 2px; }

/* ===== Vista de administrador: contenido ajeno en solo lectura ===== */
.ro-banner {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12px; font-weight: 700;
  padding: 5px 11px; border-radius: 999px;
  margin: 0 0 14px;
}
.ro-banner.sm { margin: 0; font-size: 11px; padding: 3px 9px; }
.page.readonly .gutter { display: none !important; }
.page.readonly .title,
.page.readonly .ce { cursor: default; }
.tree-row.readonly-row .label { color: var(--ink-soft); }
.chat-owner-sub { margin-top: 6px; color: var(--accent-ink); }
.chat-ro-note {
  margin: auto 16px 16px; padding: 12px 14px;
  background: var(--surface-2); border: 1px dashed var(--rule);
  border-radius: 12px; color: var(--muted);
  font-size: 13px; text-align: center;
}

.ev-owner-tag {
  margin-left: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.event-dlg.read-only .ev-title,
.event-dlg.read-only textarea,
.event-dlg.read-only input { cursor: default; opacity: .92; }

/* Chips del calendario: compartidos llevan un borde sólido extra
   y los ajenos llevan rayas diagonales sutiles. */
.cal-chip .chip-vis {
  font-size: 9px;
  margin-right: 2px;
  opacity: .85;
}
.cal-chip.shared {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, currentColor 35%, transparent);
}
.cal-chip.shared.theirs {
  background-image: repeating-linear-gradient(
    135deg,
    color-mix(in srgb, currentColor 6%, transparent) 0 5px,
    transparent 5px 10px
  );
}

/* ============================================================
   ADJUNTOS DE EVENTOS (imágenes + enlaces)
   ============================================================ */
.ev-atts { display: flex; flex-direction: column; gap: 8px; }
.ev-atts-loading,
.ev-att-hint,
.ev-att-empty,
.ev-att-err {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0;
}
.ev-att-err { color: #b91c1c; }
.ev-att-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
}
.ev-att-img {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 4 / 3;
  border: 1px solid var(--rule);
}
.ev-att-img img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.ev-att-del {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  font-size: 14px; line-height: 1;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s;
}
.ev-att-img:hover .ev-att-del,
.ev-att-link:hover .ev-att-del { opacity: 1; }

.ev-att-links {
  display: flex; flex-direction: column; gap: 4px;
}
.ev-att-link {
  position: relative;
  display: flex; align-items: center;
  gap: 8px;
  padding: 6px 30px 6px 8px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.ev-att-link a {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
}
.ev-att-link a:hover { color: var(--accent); }
.ev-att-link-ic { font-size: 13px; }
.ev-att-link-tt {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev-att-link .ev-att-del {
  position: absolute; right: 4px; top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--rule);
}

.ev-att-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.ev-att-add {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2);
  border: 1px dashed var(--rule);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.ev-att-add:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ============================================================
   PALETTE de búsqueda global — secciones por tipo de resultado
   ============================================================ */
.palette .results .res-section {
  display: flex; flex-direction: column;
  margin-top: 4px;
}
.palette .results .res-section:first-child { margin-top: 0; }
.palette .results .res-section-h {
  padding: 8px 12px 4px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.palette .results .res-empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ============================================================
   SLASH MENU
   ============================================================ */
.slash-menu, .ai-menu, .emoji-menu, .palette {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 100;
  min-width: 264px;
  max-height: 340px;
  overflow-y: auto;
}
.menu-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--muted); font-weight: 800;
  font-family: var(--font-display);
  padding: 8px 10px 4px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .1s;
}
.menu-item:hover, .menu-item.sel { background: var(--surface-2); }
.menu-item.sel { background: var(--accent-soft); }
.menu-item .glyph {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
}
.menu-item.sel .glyph {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-or);
}
.menu-item .body { display: flex; flex-direction: column; }
.menu-item .name { font-size: 13.5px; color: var(--ink); font-weight: 700; }
.menu-item .desc { font-size: 11.5px; color: var(--muted); font-weight: 500; }

/* ---- AI inline panel ---- */
.ai-bar {
  display: flex; flex-direction: column; gap: 10px;
  margin: 14px 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.ai-bar::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--or2));
  border-radius: 4px 0 0 4px;
}
.ai-bar.busy { border-color: var(--accent); }
.ai-bar .head {
  display: flex; align-items: center; gap: 10px;
  font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--accent);
  font-weight: 800;
  font-family: var(--font-display);
}
.ai-bar .head .spark {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); }
  50%      { box-shadow: 0 0 0 10px transparent; }
}
.ai-bar textarea {
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.55;
  min-height: 24px;
  color: var(--ink);
  font-weight: 500;
}
.ai-bar .row {
  display: flex; gap: 6px; flex-wrap: wrap;
  border-top: 1px solid var(--rule-soft);
  padding-top: 10px;
}
.ai-bar .chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-display);
  transition: background .12s, border-color .12s, color .12s;
}
.ai-bar .chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ai-bar .chip.primary {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
  margin-left: auto;
  box-shadow: var(--shadow-or);
}
.ai-bar .chip.primary:hover { background: var(--or2); border-color: var(--or2); color: #fff; }
.ai-bar pre.out {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 4px 0 0;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule-soft);
  padding-top: 10px;
  font-weight: 500;
}
.ai-bar pre.out:empty { display: none; }

/* ---- Emoji menu ---- */
.emoji-menu {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 30px);
  gap: 2px;
}
.emoji-menu .em {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 7px;
  font-size: 18px;
  cursor: pointer;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', serif;
}
.emoji-menu .em:hover { background: var(--accent-soft); }
.emoji-menu .em.clear {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---- Search palette ---- */
.palette {
  position: fixed;
  top: 14vh; left: 50%;
  transform: translateX(-50%);
  width: min(560px, 92vw);
  max-height: 60vh;
  z-index: 200;
  padding: 0;
}
.palette input {
  width: 100%;
  background: transparent;
  border: 0; outline: none;
  padding: 14px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  border-bottom: 1px solid var(--rule);
  letter-spacing: -0.01em;
}
.palette .results { padding: 6px; }
.palette .res {
  display: flex; gap: 12px; padding: 9px 10px;
  border-radius: 9px; cursor: pointer;
  align-items: flex-start;
}
.palette .res:hover, .palette .res.sel { background: var(--surface-2); }
.palette .res.sel { background: var(--accent-soft); }
.palette .res .ic { font-size: 18px; line-height: 1.3; flex: none; }
.palette .res .name { font-weight: 700; }
.palette .res .name.untitled { color: var(--muted); font-style: italic; font-weight: 600; }
.palette .res .snip { color: var(--muted); font-size: 12.5px; line-height: 1.4; font-weight: 500; }

.scrim {
  position: fixed; inset: 0;
  background: rgba(26,26,26,.30);
  backdrop-filter: blur(3px);
  z-index: 150;
}
[data-theme="dark"] .scrim,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .scrim { background: rgba(0,0,0,.55); } }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--blk);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  z-index: 300;
  animation: rise .25s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Aviso emergente de mensaje entrante del chat de equipo. */
.dm-pop-host {
  position: fixed; top: 16px; right: 16px;
  z-index: 320;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
}
.dm-pop {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 12px 12px 13px;
  box-shadow: var(--shadow-pop);
  cursor: pointer;
  opacity: 0; transform: translateX(20px);
  transition: opacity .22s ease, transform .22s ease;
}
.dm-pop.show { opacity: 1; transform: translateX(0); }
.dm-pop:hover { border-color: var(--accent); }
.dm-pop-av {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px;
  font-family: var(--font-display);
}
.dm-pop-body { min-width: 0; flex: 1; }
.dm-pop-name {
  font-family: var(--font-display);
  font-weight: 700; font-size: 13.5px; color: var(--ink);
  margin-bottom: 2px;
}
.dm-pop-text {
  font-size: 12.5px; color: var(--ink-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.dm-pop-x {
  flex: none; width: 20px; height: 20px;
  border-radius: 6px;
  color: var(--muted); font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.dm-pop-x:hover { background: var(--surface-2); color: var(--ink); }

/* ============================================================
   CHAT IA
   ============================================================ */
.chat-list { padding: 0 6px 0; display: flex; flex-direction: column; }
.chat-row { padding: 5px 8px 5px 6px; gap: 8px; }
.chat-row .chat-bullet {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-row.active .chat-bullet {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Cabecera "Chat IA" con botón de nueva carpeta. */
.chat-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-right: 10px;
}
.chat-sec-head .sec-add {
  display: inline-flex; align-items: center; gap: 1px;
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  transition: background .12s, color .12s;
}
.chat-sec-head .sec-add:hover { background: var(--surface-2); color: var(--accent); }
.chat-sec-head .sec-add .pl { font-weight: 800; }

/* Carpeta de chats en la barra lateral. */
.chat-folder-row .ico { font-size: 14px; }
.chat-folder-row .label { font-weight: 700; }
.chat-folder-row .chat-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 9px;
  padding: 0 7px;
  min-width: 18px; text-align: center;
}
.chat-folder-row:hover .chat-count,
.chat-folder-row.expanded .chat-count { display: none; }
.chat-folder-empty {
  padding: 4px 10px 6px 14px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.chat-sub {
  padding: 8px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

/* Menú contextual de chats/carpetas/páginas (reusa .slash-menu).
   z-index alto para quedar por encima de la barra lateral móvil (z-index 110). */
.chat-ctx-menu { min-width: 210px; max-height: 320px; overflow-y: auto; z-index: 320; }
.chat-ctx-menu .menu-sep { height: 1px; background: var(--rule); margin: 4px 6px; }
.chat-ctx-menu .menu-item .glyph { font-size: 15px; }

/* En pantallas táctiles no hay hover: los botones de acción (⋯, +, etc.)
   deben verse siempre, si no es imposible mover/abrir su menú. */
@media (hover: none) {
  .tree-row .row-actions,
  .folder-card-menu { opacity: 1; }
}

.chat-canvas { display: flex; flex-direction: column; padding: 0; }
.chatview {
  display: flex; flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(20px, 4vw, 36px) 14px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--bg);
}
.chat-head-l { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
  width: 36px; height: 36px;
  font-size: 16px;
}
.chat-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.chat-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-display);
  margin-top: 2px;
}

.chat-conv {
  flex: 1;
  overflow-y: auto;
  padding: 22px clamp(20px, 4vw, 36px) 12px;
  display: flex; flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}
.chat-conv::-webkit-scrollbar { width: 10px; }
.chat-conv::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 8px; }

.msg {
  display: flex; gap: 12px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  align-items: flex-start;
  animation: msgIn .25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-av {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12.5px;
  flex: none;
  color: #fff;
  letter-spacing: -0.01em;
}
.msg.user .msg-av {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: var(--shadow-or);
}
.msg.model .msg-av {
  background: var(--blk);
  color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent) inset;
}
.msg.error .msg-av { background: var(--danger); color: #fff; box-shadow: none; }

.msg-body {
  flex: 1;
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.62;
  color: var(--ink);
  min-width: 0;
}
.msg.user .msg-body {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 14px;
  color: var(--accent-ink);
  font-weight: 500;
}
.msg.model .msg-body {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px 4px 14px 14px;
  padding: 10px 16px;
}
[data-theme="dark"] .msg.user .msg-body,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .msg.user .msg-body { color: var(--accent-ink); }
}
.msg.error .msg-body { color: var(--danger); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, transparent); }

.thinking {
  display: inline-flex; gap: 6px; padding: 4px 0;
}
.thinking span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: think 1.2s infinite;
}
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes think {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40%           { opacity: 1;  transform: translateY(-3px); }
}

/* Markdown rendering inside chat */
.md > * + * { margin-top: 8px; }
.md > .md-br { height: 4px; }
.md .md-p { margin: 0; }
.md .md-h { font-family: var(--font-display); font-weight: 700; line-height: 1.2; letter-spacing: -0.015em; color: var(--ink); margin-top: 14px; }
.md .md-h2 { font-size: 22px; }
.md .md-h3 { font-size: 18px; }
.md .md-h4 { font-size: 15.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.md .md-ul, .md .md-ol { padding-left: 22px; margin: 6px 0; }
.md .md-ul { list-style: none; }
.md .md-ul li { position: relative; padding-left: 2px; }
.md .md-ul li::before {
  content: "";
  position: absolute;
  left: -14px; top: 11px;
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
}
.md .md-ol li { padding-left: 4px; }
.md .md-ol li::marker { color: var(--accent); font-weight: 700; }
.md strong { font-weight: 700; color: var(--ink); }
.md em { font-style: italic; }
.md .md-icode {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--ink-soft);
}
.md .md-pre {
  background: var(--blk);
  color: #FFE9D6;
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  overflow-x: auto;
  margin: 8px 0;
}
.md .md-q {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--ink-soft);
  font-style: italic;
}
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.2px; }

/* Fuentes RAG bajo la respuesta del asistente */
.sources {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
}
.sources-label {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 6px;
}
.sources-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.source-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .1s;
  max-width: 280px;
}
.source-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.source-chip:active { transform: translateY(1px); }
.source-n {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 11px;
  opacity: .85;
}
.source-ic { font-size: 13px; }
.source-tt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .source-chip,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .source-chip { color: var(--accent); }
  :root:not([data-theme="light"]) .source-chip:hover { color: #fff; }
}

/* Chips de fuentes web (google_search grounding) — azules para distinguir del RAG naranja del cuaderno */
.sources.web { margin-top: 10px; }
.source-chip.web-chip {
  background: color-mix(in srgb, #2563eb 12%, transparent);
  border-color: color-mix(in srgb, #2563eb 30%, transparent);
  color: #1d4ed8;
  text-decoration: none;
  max-width: 360px;
}
.source-chip.web-chip:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.source-chip.web-chip .source-dm {
  font-size: 10px;
  opacity: .7;
  font-weight: 500;
}
[data-theme="dark"] .source-chip.web-chip,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .source-chip.web-chip { color: #93c5fd; }
  :root:not([data-theme="light"]) .source-chip.web-chip:hover { color: #fff; }
}

/* Welcome */
.chat-welcome {
  max-width: 720px;
  width: 100%;
  margin: 6vh auto 0;
  text-align: center;
  padding: 0 8px;
}
.chat-welcome-stamp {
  width: 76px; height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 36px;
  letter-spacing: -0.02em;
  transform: rotate(-4deg);
  box-shadow: var(--shadow-or);
}
.chat-welcome h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 4vw, 36px);
  letter-spacing: -0.025em;
  margin: 0 0 8px;
  color: var(--ink);
}
.chat-welcome p {
  color: var(--muted);
  font-size: 14.5px;
  max-width: 480px;
  margin: 0 auto 24px;
  line-height: 1.55;
}
.sugs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-width: 600px;
  margin: 0 auto;
}
.sug {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, transform .1s;
}
.sug:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.sug:active { transform: translateY(1px); }

/* Input */
.chat-input-wrap {
  padding: 10px clamp(20px, 4vw, 36px) 16px;
  background: var(--bg);
  border-top: 1px solid var(--rule-soft);
}
.chat-input {
  max-width: 880px;
  margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 8px 8px 8px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-input textarea {
  flex: 1;
  background: transparent;
  border: 0; outline: none;
  resize: none;
  min-height: 22px;
  max-height: 220px;
  padding: 8px 4px;
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 500;
}
.chat-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  flex: none;
  cursor: pointer;
  box-shadow: var(--shadow-or);
  transition: background .15s, transform .12s, box-shadow .15s;
}
.chat-send:hover { background: var(--or2); box-shadow: 0 12px 28px -10px rgba(255,102,0,.7); }
.chat-send:active { transform: translateY(1px); }
.chat-send:disabled { background: var(--muted-2); cursor: wait; box-shadow: none; }
.chat-send svg { transform: translate(-1px, 1px); }

.chat-foot {
  max-width: 880px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Adjuntos del chat IA — botón, bandeja y burbuja */
.chat-attach-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  display: grid; place-items: center;
  flex: none;
  cursor: pointer;
  align-self: flex-end;
  transition: color .15s, background .15s;
}
.chat-attach-btn:hover { color: var(--accent); background: var(--accent-soft); }
.chat-emoji-btn { font-size: 19px; line-height: 1; }

/* Picker de emojis del chat */
.emoji-picker {
  position: absolute;
  z-index: 330;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 24px 60px -22px rgba(0,0,0,.45);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.emoji-tabs {
  display: flex; gap: 2px;
  padding: 6px; overflow-x: auto;
  border-bottom: 1px solid var(--rule-soft);
}
.emoji-tabs::-webkit-scrollbar { height: 0; }
.emoji-tab {
  flex: none; width: 32px; height: 32px;
  border: 0; background: transparent; cursor: pointer;
  border-radius: 8px; font-size: 17px;
  display: grid; place-items: center;
  font-family: 'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji', serif;
}
.emoji-tab:hover, .emoji-tab.on { background: var(--accent-soft); }
.emoji-body { position: relative; max-height: 244px; overflow-y: auto; padding: 0 8px 10px; }
.emoji-sec-h {
  position: sticky; top: 0; z-index: 1;
  padding: 9px 2px 4px; background: var(--surface);
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-grid .em {
  height: 32px; border: 0; background: transparent; cursor: pointer;
  border-radius: 7px; font-size: 19px;
  display: grid; place-items: center;
  font-family: 'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji', serif;
}
.emoji-grid .em:hover { background: var(--accent-soft); }

.chat-attach-tray {
  max-width: 880px;
  margin: 0 auto 8px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.attach-chip {
  display: flex; align-items: center; gap: 8px;
  max-width: 240px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 5px 8px 5px 5px;
}
.attach-chip.uploading { opacity: .7; }
.attach-thumb { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; flex: none; }
.attach-ic { font-size: 18px; width: 30px; text-align: center; flex: none; }
.attach-name {
  font-size: 13px; color: var(--ink); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-x {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; color: var(--muted); cursor: pointer;
}
.attach-x:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.attach-x svg { width: 13px; height: 13px; }
.attach-spin {
  width: 16px; height: 16px; flex: none;
  border: 2px solid var(--rule); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-att-img { display: block; max-width: 220px; border-radius: 12px; overflow: hidden; }
.msg-att-img img { display: block; width: 100%; height: auto; max-height: 260px; object-fit: cover; }
.msg-att-file {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 10px; padding: 8px 12px;
  color: var(--ink); text-decoration: none; max-width: 240px;
}
.msg-att-file:hover { border-color: var(--accent); }
.att-file-ic { font-size: 20px; flex: none; }
.att-file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Favoritos */
.fav-btn { color: var(--muted-2); transition: color .15s, transform .12s; }
.fav-btn:hover { color: var(--accent); transform: scale(1.08); }
.fav-btn.on { color: var(--accent); }
.fav-btn.on svg { fill: var(--accent); stroke: var(--accent); }

/* Bloque toggle (plegable) */
.block.toggle { display: block; }
.toggle-head { display: flex; align-items: flex-start; gap: 4px; padding: 2px 0; }
.toggle-arrow {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex: none;
  font-size: 14px;
  color: var(--muted);
  border-radius: 5px;
  transition: transform .15s, background .12s, color .12s;
}
.toggle-arrow:hover { background: var(--surface-2); color: var(--ink); }
.toggle-arrow.on { transform: rotate(90deg); color: var(--accent); }
.toggle-summary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16.5px;
  flex: 1;
  color: var(--ink);
}
.toggle-body {
  margin-left: 26px;
  margin-top: 2px;
  padding: 6px 8px 6px 12px;
  border-left: 2px solid var(--rule);
  font-family: var(--font-body);
  font-size: 15.5px;
  color: var(--ink-soft);
  white-space: pre-wrap;
  min-height: 2.2em;
}
.toggle-body:focus { border-left-color: var(--accent); }

/* Bloque embed */
.block.embed { display: block; }
.embed-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--rule);
}
.embed-frame iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}
.embed-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  padding: 40px 20px;
  background: var(--surface-2);
  border: 1px dashed var(--rule);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.embed-empty-glyph { font-size: 28px; color: var(--accent); }
.embed-url {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  outline: none;
}
.embed-url:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Bloque tabla */
.block.table { display: block; }
.block-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  font-size: 14px;
  margin: 4px 0 2px;
}
.block-table td {
  padding: 8px 10px;
  border: 1px solid var(--rule);
  outline: none;
  vertical-align: top;
  min-width: 60px;
  font-family: var(--font-body);
  font-weight: 500;
}
.block-table td.hdr {
  background: var(--surface-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
}
.block-table td:focus { background: var(--accent-soft); }
.tbl-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 6px 0 0;
}
.tbl-act {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--muted);
  letter-spacing: 0.04em;
  transition: background .12s, color .12s, border-color .12s;
}
.tbl-act:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ============================================================
   CALENDARIO
   ============================================================ */
.side-action.active-side {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}
[data-theme="dark"] .side-action.active-side,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side-action.active-side { color: var(--accent); } }

.btn-mini {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
  transition: background .12s, border-color .12s, color .12s;
}
.btn-mini:hover { background: var(--surface-2); color: var(--ink); border-color: var(--accent); }
.btn-mini.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-or); }
.btn-mini.primary:hover { background: var(--or2); border-color: var(--or2); }
.btn-mini.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--rule)); }
.btn-mini.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.calendar-canvas { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.cal-head {
  flex: 1;
  display: flex; align-items: center; gap: 14px;
  min-width: 0;
}
.cal-nav { display: flex; gap: 4px; align-items: center; }
.cal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-transform: capitalize;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid var(--rule);
}
.cal-tab {
  padding: 4px 12px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.cal-tab:hover { color: var(--ink); }
.cal-tab.on { background: var(--accent); color: #fff; box-shadow: var(--shadow-or); }

/* Color tokens de eventos */
.color-orange { --evc: #FF6600; --evcs: #FFE0CC; --evct: #B34800; }
.color-red    { --evc: #E33C2C; --evcs: #FBDAD6; --evct: #8C1F12; }
.color-amber  { --evc: #D8A300; --evcs: #FBEFC9; --evct: #6F5300; }
.color-green  { --evc: #2EA862; --evcs: #D2F1DF; --evct: #11532E; }
.color-blue   { --evc: #2C6BD9; --evcs: #D6E4FB; --evct: #133970; }
.color-pink   { --evc: #C940A0; --evcs: #F5D7EA; --evct: #69215A; }
.color-gray   { --evc: #6F6F6F; --evcs: #E5E5E5; --evct: #2E2E2E; }
[data-theme="dark"] .color-orange,
[data-theme="dark"] .color-red,
[data-theme="dark"] .color-amber,
[data-theme="dark"] .color-green,
[data-theme="dark"] .color-blue,
[data-theme="dark"] .color-pink,
[data-theme="dark"] .color-gray,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .color-orange { --evcs: #3a2010; --evct: #FFCFA8; }
  :root:not([data-theme="light"]) .color-red    { --evcs: #3a1612; --evct: #F5A19A; }
  :root:not([data-theme="light"]) .color-amber  { --evcs: #2e2607; --evct: #E5C765; }
  :root:not([data-theme="light"]) .color-green  { --evcs: #102a1b; --evct: #87D6A8; }
  :root:not([data-theme="light"]) .color-blue   { --evcs: #11203b; --evct: #99B7E5; }
  :root:not([data-theme="light"]) .color-pink   { --evcs: #2e1226; --evct: #ECA0CB; }
  :root:not([data-theme="light"]) .color-gray   { --evcs: #1f1f1f; --evct: #C0C0C0; }
}

/* ---- VISTA MES ---- */
.cal-month {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  border-top: 1px solid var(--rule-soft);
}
.cal-mhead {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--rule);
  background: var(--bg-grain);
}
.cal-mhead-d {
  padding: 6px 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.cal-mgrid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  background: var(--rule);
  gap: 1px;
  overflow: hidden;
}
.cal-mcell {
  background: var(--bg);
  padding: 6px 8px 6px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 0;
  cursor: pointer;
  overflow: hidden;
  transition: background .15s;
}
.cal-mcell:hover { background: var(--surface-2); }
.cal-mcell.out { background: var(--surface-2); }
.cal-mcell.out .cal-mday { color: var(--muted-2); }
.cal-mday {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
}
.cal-mday.on {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-or);
}
.cal-mevs {
  display: flex; flex-direction: column; gap: 2px;
  overflow: hidden;
  min-height: 0;
}
.cal-chip {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--evcs);
  color: var(--evct);
  font-size: 11.5px;
  font-weight: 600;
  border-left: 3px solid var(--evc);
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background .12s, transform .1s;
}
.cal-chip:hover { background: color-mix(in srgb, var(--evc) 24%, var(--evcs)); }
.cal-chip:active { transform: translateY(1px); }
.chip-time {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10.5px;
  color: var(--evc);
  flex: none;
}
.chip-title {
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-more {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  align-self: flex-start;
  padding: 1px 6px;
  border-radius: 5px;
}
.cal-more:hover { background: var(--rule); color: var(--ink); }

/* ---- VISTA SEMANA ---- */
.cal-week {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
.cal-whead {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  background: var(--bg-grain);
  border-bottom: 1px solid var(--rule);
  border-top: 1px solid var(--rule-soft);
}
.cal-wallhead {
  padding: 8px 10px;
  font-family: var(--font-display);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 700;
}
.cal-whead-d {
  padding: 6px 8px;
  text-align: center;
  border-left: 1px solid var(--rule);
}
.cal-whead-d .wd {
  font-family: var(--font-display);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}
.cal-whead-d .wn {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.cal-whead-d.today .wn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  margin-top: 2px;
  box-shadow: var(--shadow-or);
}

.cal-wallrow {
  display: grid; grid-template-columns: 56px repeat(7, 1fr);
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  min-height: 38px;
}
.cal-wallrow-label {}
.cal-wallcell {
  border-left: 1px solid var(--rule);
  padding: 4px 4px;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer;
  transition: background .12s;
}
.cal-wallcell:hover { background: var(--surface-2); }

.cal-wgrid {
  flex: 1;
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  min-height: 0;
  overflow-y: auto;
  position: relative;
  background: var(--bg);
}
.cal-day-grid { grid-template-columns: 56px 1fr; }
.cal-whours {
  display: flex; flex-direction: column;
  background: var(--bg-grain);
  border-right: 1px solid var(--rule);
}
.cal-whour {
  height: 44px;
  padding: 0 8px;
  font-family: var(--font-display);
  font-size: 10.5px; font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule-soft);
  display: flex; align-items: flex-start;
  padding-top: 2px;
}
.cal-wcol {
  position: relative;
  border-left: 1px solid var(--rule);
  display: flex; flex-direction: column;
  cursor: pointer;
}
.cal-wslot {
  height: 44px;
  border-bottom: 1px solid var(--rule-soft);
}
.cal-wcol:hover .cal-wslot { background: color-mix(in srgb, var(--accent) 2%, transparent); }
.cal-wblock {
  position: absolute;
  left: 4px; right: 4px;
  background: var(--evcs);
  border-left: 3px solid var(--evc);
  color: var(--evct);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  z-index: 2;
  transition: box-shadow .12s, transform .1s;
}
.cal-wblock:hover { box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--evc) 50%, transparent); }
.cal-wblock:active { transform: translateY(1px); }
.cal-wblock .wb-time { font-family: var(--font-display); font-size: 10.5px; font-weight: 700; opacity: .85; letter-spacing: 0.04em; }
.cal-wblock .wb-title { font-weight: 700; }
.cal-wblock .wb-loc { font-size: 11px; opacity: .8; font-style: italic; }

/* ---- VISTA DÍA ---- */
.cal-day { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cal-day-allday {
  padding: 10px clamp(16px, 4vw, 24px);
  display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule);
  background: var(--bg-grain);
}
.cal-day-allday-l {
  font-family: var(--font-display);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 700;
}
.cal-day-col {}

/* ---- MODAL EVENTO ---- */
.event-dlg {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(540px, 92vw);
  max-height: 86vh;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  z-index: 200;
  display: flex; flex-direction: column;
  animation: rise .2s ease;
}
.event-dlg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule-soft);
}
.event-dlg-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.015em;
}
.event-dlg-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.event-dlg-foot {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--rule-soft);
}
.event-dlg-foot .spacer { flex: 1; }

.ev-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.015em;
  border: 0; outline: none;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
}
.ev-title:focus { border-color: var(--accent); }
.ev-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.ev-field { display: flex; flex-direction: column; gap: 4px; }
.ev-field label {
  font-family: var(--font-display);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 700;
}
.ev-field input, .ev-field select, .ev-field textarea {
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  outline: none;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink);
}
.ev-field input:focus, .ev-field select:focus, .ev-field textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ev-checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-soft); cursor: pointer;
}
.ev-checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.ev-colors { display: flex; gap: 6px; padding-top: 2px; }
.ev-color {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--evc);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s, border-color .12s;
}
.ev-color:hover { transform: scale(1.08); }
.ev-color.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--evc); }

@media (max-width: 700px) {
  .cal-mhead-d { font-size: 9.5px; padding: 4px; }
  .cal-mcell { padding: 4px; }
  .cal-mday { width: 20px; height: 20px; font-size: 11.5px; }
  .cal-chip { font-size: 10.5px; }
  .cal-title { font-size: 16px; }
  .cal-tabs { display: none; }
  .ev-row { grid-template-columns: 1fr; }
}

/* ---- Scrim de la sidebar (solo móvil; oculto en escritorio) ---- */
.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .42);
  z-index: 105;
  opacity: 0;
  transition: opacity .22s ease;
  pointer-events: none;
}

/* ---- Responsive ---- */
@media (max-width: 720px) {
  .shell { grid-template-columns: 0 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: 86vw; max-width: 320px;
    z-index: 110;
    box-shadow: var(--shadow-pop);
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .shell.mobile-open .sidebar { transform: translateX(0); }
  .shell.mobile-open .sidebar-scrim {
    display: block; opacity: 1; pointer-events: auto;
  }

  /* Lectura cómoda en móvil: menos padding lateral, tipografías mejor
     escaladas, breadcrumbs sin desbordar, controles más grandes. */
  .page { padding: 24px 14px 180px; }
  .title { font-size: clamp(24px, 6.5vw, 32px); }
  .folder-page { padding: 18px 12px 180px; }
  .folder-head { gap: 10px; align-items: flex-start; }
  .folder-title-input { font-size: 22px; }
  .folder-actions { flex-wrap: wrap; gap: 6px; }
  .folder-cta { padding: 10px 14px; flex: 1 1 auto; min-width: 130px; justify-content: center; }
  .folder-cta.danger { margin-left: 0; flex-basis: 100%; }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .folder-card { padding: 12px 10px; }

  /* Topbar: mantener el botón hamburguesa visible y dejar respirar al título. */
  .topbar { padding: 10px 12px; gap: 6px; }
  .crumbs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
  .crumbs a, .crumbs span { font-size: 14px; }
  .savestate { display: none; }    /* en móvil sobra texto en la topbar */

  /* Chat IA y DMs: que el composer no choque con la barra de navegación
     del navegador y que las burbujas usen más ancho. */
  .chat-conv { padding: 12px 10px 120px; }
  .dm-body, .chat-bubble { max-width: 86%; }
  .chat-input-wrap { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .chat-input textarea { font-size: 16px; }   /* evita zoom del navegador iOS/Android */
  #dm-input { font-size: 16px; }
  .dm-canvas { padding: 14px 10px 110px; }

  /* Calendario: mejor uso del ancho. */
  .cal-mhead-d, .cal-mcell { font-size: 11px; }
  .cal-day-grid { gap: 1px; }

  /* Toques cómodos: botones e iconos un pelín más grandes. */
  .icon-btn { width: 40px; height: 40px; }
  .row-btn { width: 32px; height: 32px; }
}

/* Pantallas MUY estrechas (320–360 px típicas): aún menos padding. */
@media (max-width: 380px) {
  .page { padding: 18px 10px 160px; }
  .folder-page { padding: 14px 8px 160px; }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .dm-body, .chat-bubble { max-width: 90%; }
}

/* ====================================================================== */
/* Chat de equipo (persona-persona)                                       */
/* ====================================================================== */
.dm-badge {
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; display: inline-grid; place-items: center;
  margin-left: auto;
}

.dm-canvas { padding: clamp(16px, 3vw, 28px); overflow-y: auto; }
.dm-list { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 2px; }
.dm-contact {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 11px 14px; border-radius: 12px;
  background: transparent; border: 1px solid transparent;
  transition: background .12s;
}
.dm-contact:hover { background: var(--surface-2); }
.dm-c-av {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700;
}
.dm-c-main { flex: 1; min-width: 0; }
.dm-c-name { font-weight: 600; color: var(--ink); }
.dm-c-sub { font-size: 12.5px; color: var(--muted); }
.dm-empty { text-align: center; color: var(--muted); padding: 30px 16px; }

.dm-msg { display: flex; margin: 5px 0; }
.dm-msg.mine { justify-content: flex-end; }
.dm-body {
  max-width: 74%; padding: 9px 13px; border-radius: 14px;
  word-break: break-word;
}
.dm-msg.mine .dm-body { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.dm-msg.theirs .dm-body { background: var(--surface); border: 1px solid var(--rule); color: var(--ink); border-bottom-left-radius: 5px; }
.dm-text { white-space: pre-wrap; line-height: 1.45; font-size: 15px; }
.dm-time { font-size: 10px; opacity: .7; margin-top: 3px; text-align: right; }
.dm-msg.theirs .dm-time { color: var(--muted); }

.dm-att-img { display: block; max-width: 240px; border-radius: 10px; overflow: hidden; margin-bottom: 4px; }
.dm-att-img img { display: block; width: 100%; height: auto; max-height: 280px; object-fit: cover; }
.dm-att-file {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px;
  text-decoration: none; color: inherit; margin-bottom: 4px;
}
.dm-msg.mine .dm-att-file { background: rgba(255,255,255,.18); color: #fff; }
.dm-msg.theirs .dm-att-file { background: var(--surface-2); color: var(--ink); }

/* ===================== CRM (solo admin) ===================== */
.crm-canvas { padding: 22px 26px 60px; max-width: 1040px; margin: 0 auto; width: 100%; }
.crm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.crm-tab {
  background: none; border: none; cursor: pointer; font: inherit;
  padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; border-radius: 8px 8px 0 0;
}
.crm-tab:hover { color: var(--ink); background: var(--surface-2); }
.crm-tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.crm-stats { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.crm-stat {
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: var(--radius-lg); padding: 12px 18px; min-width: 110px;
}
.crm-stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.crm-stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.crm-stat.ok   .crm-stat-num { color: #1a8f4c; }
.crm-stat.warn .crm-stat-num { color: #c9871f; }

/* Contadores por gestión: más compactos y clicables como filtro. */
.crm-stats--gestion { margin-top: -6px; }
.crm-stats--gestion .crm-stat { padding: 9px 14px; min-width: 96px; }
.crm-stats--gestion .crm-stat-num { font-size: 20px; }
.crm-stat.clickable { cursor: pointer; transition: border-color .12s, background .12s; }
.crm-stat.clickable:hover { border-color: var(--accent, #c9871f); }
.crm-stat.clickable.active {
  border-color: var(--accent, #c9871f);
  background: rgba(201,135,31,.12);
}
.crm-stat.clickable.active .crm-stat-num { color: var(--accent, #c9871f); }

.crm-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.crm-search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 240px;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: 10px; padding: 7px 12px; color: var(--muted);
}
.crm-search input { border: none; background: none; outline: none; font: inherit; color: var(--ink); width: 100%; }
.crm-select {
  font: inherit; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer;
}
.crm-select.sm { padding: 4px 6px; font-size: 12px; }
.crm-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font: inherit; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
}
.crm-btn:hover { background: var(--surface-2); }
.crm-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.crm-btn[disabled] { opacity: .55; cursor: default; }
.crm-btn .ico { width: 16px; height: 16px; }

.crm-list { display: flex; flex-direction: column; gap: 8px; }
.crm-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius-lg); padding: 12px 14px;
}
.crm-ava {
  flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%;
  overflow: hidden; background: var(--surface-2); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.crm-ava img { width: 100%; height: 100%; object-fit: cover; }
.crm-main { flex: 1 1 auto; min-width: 0; }
.crm-name { font-weight: 600; }
.crm-name a { color: inherit; text-decoration: none; }
.crm-name a:hover { text-decoration: underline; }
.crm-sub { font-size: 13px; color: var(--ink-soft); margin-top: 1px; }
.crm-contact { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 14px; flex-wrap: wrap; }
.crm-status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }

.crm-flags { margin-top: 7px; display: flex; gap: 8px; flex-wrap: wrap; }
.crm-flag {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--surface-2); color: var(--muted);
  cursor: pointer; white-space: nowrap; transition: background .12s, color .12s, border-color .12s;
}
.crm-flag:hover { border-color: var(--accent, #c9871f); color: var(--ink-soft); }
.crm-flag.on {
  background: rgba(26,143,76,.14); color: #1a8f4c; border-color: rgba(26,143,76,.35);
}
.crm-flag.on.warn {
  background: rgba(200,60,60,.14); color: var(--danger, #c83c3c); border-color: rgba(200,60,60,.35);
}

.crm-email-input {
  font-size: 12px; padding: 2px 8px; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink-soft);
  min-width: 180px; max-width: 260px; flex: 0 1 auto;
}
.crm-email-input:focus { outline: none; border-color: var(--accent, #c9871f); background: var(--surface); }

.crm-notes {
  display: block; width: 100%; margin-top: 8px; resize: vertical;
  font: inherit; font-size: 12px; line-height: 1.4; padding: 6px 9px;
  border-radius: 8px; border: 1px solid var(--rule);
  background: var(--surface-2); color: var(--ink-soft); min-height: 34px;
}
.crm-notes:focus { outline: none; border-color: var(--accent, #c9871f); background: var(--surface); }
.crm-notes::placeholder { color: var(--muted); }

.crm-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.crm-badge--publicado  { background: rgba(26,143,76,.14);  color: #1a8f4c; }
.crm-badge--activo     { background: rgba(26,143,76,.14);  color: #1a8f4c; }
.crm-badge--contactado { background: rgba(201,135,31,.16); color: #c9871f; }
.crm-badge--pendiente  { background: var(--surface-2);     color: var(--muted); }
.crm-badge--baja       { background: rgba(200,60,60,.14);  color: var(--danger); }

.crm-empty { padding: 28px; text-align: center; color: var(--muted); }
.crm-hint { margin-top: 14px; padding: 12px 14px; font-size: 13px; color: var(--muted);
  background: var(--surface-2); border-radius: var(--radius-lg); }

@media (max-width: 640px) {
  .crm-canvas { padding: 16px 12px 50px; }
  .crm-row { flex-wrap: wrap; }
  .crm-status { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; }
}

/* =====================================================================
   CORREO — webmail (IMAP/SMTP) sobre buzón Hostinger. Solo admin.
   ===================================================================== */
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--bg); color: var(--ink); cursor: pointer;
  font: 500 13px/1 var(--font-ui); transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-ghost svg { width: 15px; height: 15px; }

.mail-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.mail-compose-btn { display: inline-flex; align-items: center; gap: 6px; }
.mail-compose-btn svg { width: 15px; height: 15px; }

.mail-canvas { padding: 0; height: 100%; overflow: hidden; }
.mail-layout { display: flex; height: 100%; min-height: 0; }

/* Columna de carpetas */
.mail-folders {
  width: 200px; flex: 0 0 200px; border-right: 1px solid var(--rule);
  padding: 14px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.mail-folder {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px; background: transparent;
  color: var(--ink-soft, var(--ink)); cursor: pointer; text-align: left;
  font: 500 13.5px/1.2 var(--font-ui);
}
.mail-folder:hover { background: var(--accent-soft); }
.mail-folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.mail-folder .ico { width: 16px; height: 16px; flex: 0 0 16px; }
.mail-folder span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Contenido (lista / lector / redacción) */
.mail-content { flex: 1; min-width: 0; overflow-y: auto; }

.mail-list-wrap { display: flex; flex-direction: column; height: 100%; }
.mail-list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--rule); position: sticky; top: 0;
  background: var(--bg); z-index: 2;
}
.mail-list-head h2 { margin: 0; font: 700 17px/1 var(--font-display); }
.mail-list-tools { display: flex; align-items: center; gap: 6px; }
.mail-count { font: 500 12px/1 var(--font-ui); color: var(--muted); margin-right: 6px; }

.mail-list { display: flex; flex-direction: column; }
.mail-row {
  display: grid; grid-template-columns: 190px 1fr auto; gap: 14px; align-items: baseline;
  padding: 12px 20px; border: 0; border-bottom: 1px solid var(--rule-soft, var(--rule));
  background: transparent; cursor: pointer; text-align: left; width: 100%;
  font: 400 14px/1.3 var(--font-ui); color: var(--ink);
}
.mail-row:hover { background: var(--accent-soft); }
.mail-row.unread { font-weight: 700; }
.mail-row.unread::before {
  content: ''; position: absolute; left: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); margin-top: 5px;
}
.mail-row { position: relative; }
.mail-row-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row-subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.mail-row-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mail-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Lector */
.mail-reader { padding: 18px 24px 60px; max-width: 820px; }
.mail-reader-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.mail-subject { margin: 6px 0 12px; font: 700 24px/1.2 var(--font-display); }
.mail-meta { font: 400 13px/1.6 var(--font-ui); color: var(--ink-soft, var(--ink)); margin-bottom: 8px; }
.mail-meta strong { color: var(--ink); font-weight: 600; }
.mail-meta-date { color: var(--muted); margin-top: 2px; }
.mail-body { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 18px; }
.mail-iframe { width: 100%; min-height: 60vh; border: 0; background: #fff; border-radius: 8px; }
.mail-text { white-space: pre-wrap; word-break: break-word; font: 400 14px/1.6 var(--font-body); color: var(--ink); }

.mail-atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.mail-att {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--rule); border-radius: 9px; background: var(--bg);
  cursor: pointer; font: 500 12.5px/1 var(--font-ui); color: var(--ink);
}
.mail-att:hover { border-color: var(--accent); background: var(--accent-soft); }
.mail-att svg { width: 14px; height: 14px; }
.mail-att-size { color: var(--muted); }
.mail-att-x { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; }

/* Redacción */
.mail-compose { padding: 18px 24px 40px; max-width: 760px; }
.mail-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.mail-field > span { font: 600 12px/1 var(--font-ui); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mail-field input, .mail-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: 400 14px/1.4 var(--font-ui);
}
.mail-field input:focus, .mail-textarea:focus { outline: none; border-color: var(--accent); }
.mail-textarea { resize: vertical; font-family: var(--font-body); line-height: 1.6; }
.mail-cc-toggle { align-self: flex-start; border: 0; background: transparent; color: var(--accent); cursor: pointer; font: 600 12px/1 var(--font-ui); margin-bottom: 12px; }
.mail-compose-foot { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.mail-attach-btn { cursor: pointer; }

/* Ajustes */
.mail-settings { padding: 24px; max-width: 640px; }
.mail-settings h2 { margin: 0 0 6px; font: 700 20px/1.2 var(--font-display); }
.mail-settings-hint { color: var(--muted); font: 400 13px/1.5 var(--font-ui); margin: 0 0 20px; }
.mail-settings .mail-field { margin-bottom: 14px; }
.mail-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.mail-settings-foot { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .mail-layout { flex-direction: column; }
  .mail-folders {
    width: 100%; flex: 0 0 auto; flex-direction: row; gap: 6px;
    border-right: 0; border-bottom: 1px solid var(--rule); overflow-x: auto; padding: 10px;
  }
  .mail-folder { width: auto; flex: 0 0 auto; }
  .mail-folder span { max-width: 110px; }
  .mail-row { grid-template-columns: 1fr auto; }
  .mail-row-from { grid-column: 1; }
  .mail-row-date { grid-column: 2; grid-row: 1; }
  .mail-row-subj { grid-column: 1 / -1; }
  .mail-settings-grid { grid-template-columns: 1fr; }
}
