/* ===========================================================
   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; }

.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);
}

.tree { flex: 1; overflow-y: auto; padding: 0 6px 12px; scrollbar-width: thin; }
.tree::-webkit-scrollbar { width: 6px; }
.tree::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 6px; }

.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); }

/* ============================================================
   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); } }

/* ============================================================
   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);
}

.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; }
}

/* 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;
}

/* 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; }
}

/* ---- 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); }
  .page { padding: 32px 18px 200px; }
  .title { font-size: clamp(28px, 7vw, 36px); }
}
