/* Eximir IA — Memoria (gestión de nodos, estilo "Bases")
   Paleta: espacio profundo + liquid glass, igual que el launcher. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #eef2fa;
  --soft: #8b96ab;
  --muted: #5c667a;
  --hairline: rgba(255,255,255,0.12);
  --bg: #05070d;
  --bg1: #0a0f1c;
  --card: rgba(255,255,255,0.055);
  --panel: rgba(13,19,34,0.88);
  --glass-edge: rgba(255,255,255,0.14);
  --accent: #4a9dff;
  --danger: #ff6b6b;
}

html, body { width: 100%; min-height: 100%; touch-action: pan-x pan-y; }
body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- Fondo: mesh profundo (fijo) + estrellas con deriva ---------- */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(52% 44% at 18% 10%, rgba(74,157,255,.14) 0%, transparent 70%),
    radial-gradient(46% 40% at 85% 16%, rgba(139,108,255,.12) 0%, transparent 70%),
    radial-gradient(50% 46% at 78% 88%, rgba(24,201,154,.08) 0%, transparent 70%),
    radial-gradient(44% 40% at 12% 86%, rgba(255,92,157,.07) 0%, transparent 70%),
    radial-gradient(120% 100% at 50% 0%, var(--bg1) 0%, var(--bg) 68%);
}
body::after {
  content: ""; position: fixed; left: 6%; top: 8%; width: 2px; height: 2px;
  border-radius: 50%; background: transparent; z-index: -1; pointer-events: none;
  will-change: transform;
  box-shadow: 11vw 7vh 0 #9fb4d8, 26vw 16vh 0 #7f92b8, 45vw 5vh 0 #9fb4d8, 61vw 12vh 0 #7f92b8,
    82vw 9vh 0 #9fb4d8, 7vw 36vh 0 #7f92b8, 21vw 54vh 0 #9fb4d8, 38vw 68vh 0 #7f92b8,
    57vw 42vh 0 #9fb4d8, 73vw 60vh 0 #7f92b8, 89vw 34vh 0 #9fb4d8, 14vw 80vh 0 #7f92b8,
    46vw 84vh 0 #9fb4d8, 68vw 76vh 0 #7f92b8, 86vw 86vh 0 #9fb4d8, 33vw 28vh 0 #7f92b8;
  animation: twinkle 6s ease-in-out infinite, starDrift 120s linear infinite alternate;
}
@keyframes twinkle { 0%, 100% { opacity: 0.18; } 50% { opacity: 0.6; } }
@keyframes starDrift { from { transform: translate3d(0,0,0); } to { transform: translate3d(-65px,-55px,0); } }

/* ---------- Header ---------- */
#header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px; border-bottom: 1px solid var(--hairline);
  background: rgba(10,15,28,0.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 10;
}
#header-left, #header-right { display: flex; align-items: center; gap: 16px; }
#brand { font-size: 17px; font-weight: 300; letter-spacing: -0.01em; }
#brand b { font-weight: 600; }
.nav-link {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; text-decoration: none; color: var(--soft);
  border: 1px solid var(--hairline); background: rgba(255,255,255,0.05);
  padding: 8px 12px; border-radius: 2px; transition: color .2s ease, border-color .2s ease;
}
.nav-link:hover { color: var(--ink); border-color: rgba(255,255,255,0.4); }

/* ---------- Layout ---------- */
#main { max-width: 1100px; margin: 0 auto; padding: 26px 22px 60px; }

#toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
#search-wrap {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--hairline); border-radius: 2px;
  padding: 9px 12px; color: var(--muted);
}
#search-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: 'Space Grotesk', sans-serif; font-size: 13.5px; color: var(--ink);
}
#toolbar select {
  background: var(--card); border: 1px solid var(--hairline); border-radius: 2px;
  padding: 9px 10px; font-family: 'Space Grotesk', sans-serif; font-size: 13px;
  color: var(--ink); outline: none; cursor: pointer;
}
#toolbar select option { background: #0d1322; color: var(--ink); }
#count { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.tool-btn {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; background: var(--card); border: 1px solid var(--hairline);
  border-radius: 2px; padding: 9px 12px; color: var(--soft); cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.tool-btn:hover { color: var(--ink); border-color: rgba(255,255,255,0.4); }

#content { display: flex; gap: 18px; align-items: flex-start; }
#node-list { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* ---------- Filas de nodos (glass) ---------- */
.node-row {
  background: var(--card); border: 1px solid var(--hairline); border-radius: 4px;
  padding: 13px 16px; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease;
  display: flex; gap: 12px; align-items: flex-start;
}
.node-row:hover { border-color: rgba(255,255,255,0.3); box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.node-row.selected { border-color: var(--accent); box-shadow: 0 6px 24px rgba(74,157,255,.18); }
.node-row.archived { opacity: .55; }

.node-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.node-body { flex: 1; min-width: 0; }
.node-title-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.node-titulo { font-size: 14.5px; font-weight: 600; }
.node-tipo { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; }
.node-desc { font-size: 13px; color: var(--soft); line-height: 1.45; margin-top: 3px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.node-foot { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.node-tags { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); }
.node-fecha { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); margin-left: auto; }
.badge {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 20px; border: 1px solid var(--hairline); color: var(--soft);
}
.badge.archived { border-color: #e5c07b55; color: #e0b566; }

#list-empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }

/* ---------- Editor (panel glass) ---------- */
#editor {
  width: 340px; flex-shrink: 0; position: sticky; top: 92px;
  background: var(--panel); border: 1px solid var(--glass-edge); border-radius: 4px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 20px; box-shadow: 0 16px 50px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,0.08);
}
#editor.hidden { display: none; }
#editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
#editor-head h2 { font-size: 15px; font-weight: 600; }
#editor-close { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; }
#editor label {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: 9.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 12px 0 5px;
}
#editor input, #editor textarea, #editor select {
  width: 100%; background: rgba(255,255,255,0.06); border: 1px solid var(--hairline); border-radius: 2px;
  padding: 9px 11px; font-family: 'Space Grotesk', sans-serif; font-size: 13px; color: var(--ink);
  outline: none; resize: vertical;
}
#editor select option { background: #0d1322; color: var(--ink); }
#editor input:focus, #editor textarea:focus, #editor select:focus { border-color: rgba(74,157,255,0.55); }
#edit-meta { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); margin-top: 12px; line-height: 1.7; }

/* ---------- Conexiones y backlinks ---------- */
#links-list, #backlinks-list { display: flex; flex-direction: column; gap: 5px; }
.link-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--hairline); border-radius: 2px;
  padding: 6px 9px; font-size: 12.5px;
}
.link-chip .link-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-chip button {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1;
}
.link-chip button:hover { color: var(--danger); }
.link-chip.backlink { cursor: pointer; transition: border-color .15s ease; }
.link-chip.backlink:hover { border-color: var(--accent); }
.links-empty { font-size: 11.5px; color: var(--muted); padding: 2px 0; }
#link-add { display: flex; gap: 6px; margin-top: 6px; }
#link-add select { flex: 1; min-width: 0; }
#btn-add-link {
  font-family: 'Space Grotesk', sans-serif; font-size: 12px; padding: 8px 12px;
  border-radius: 2px; border: 1px solid var(--hairline); background: rgba(255,255,255,0.05);
  color: var(--ink); cursor: pointer; white-space: nowrap;
}
#btn-add-link:hover { border-color: rgba(255,255,255,0.4); }
#editor-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
#editor-actions button {
  font-family: 'Space Grotesk', sans-serif; font-size: 12.5px; padding: 9px 13px;
  border-radius: 2px; border: none; cursor: pointer; transition: opacity .15s ease;
}
#editor-actions button:hover { opacity: .85; }
#btn-save { background: var(--ink); color: #0a0f1c; font-weight: 600; }
#btn-archive { background: transparent; color: var(--soft); border: 1px solid var(--hairline) !important; }
#btn-delete { background: transparent; color: var(--danger); border: 1px solid rgba(255,107,107,0.3) !important; }
#editor-status { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--accent); margin-top: 10px; min-height: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  #content { flex-direction: column; }
  #editor { width: 100%; position: static; }
}
