/* CONCIENCIUS NOTE — estilos */
:root {
  --bg: #0d0a1a;
  --surface: #161129;
  --surface2: #221a3f;
  --text: #ece9f8;
  --muted: #9a93b8;
  --border: rgba(255, 255, 255, .08);
  --accent: #8b5cf6;
  --accent2: #06b6d4;
  --danger: #ef4444;
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  --bot: calc(66px + var(--safe-b));
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f3fb;
  --surface: #ffffff;
  --surface2: #ece8f8;
  --text: #1b1530;
  --muted: #6b6585;
  --border: rgba(20, 10, 60, .1);
  --shadow: 0 12px 32px rgba(40, 20, 90, .18);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body {
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  background:
    radial-gradient(60% 40% at 15% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(50% 35% at 100% 10%, color-mix(in srgb, var(--accent2) 10%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Cabecera ---------- */
.head {
  position: sticky; top: 0; z-index: 20;
  padding-top: var(--safe-t);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar { height: 56px; padding: 0 12px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; font-weight: 800; letter-spacing: .08em; font-size: 15px; }
.brand svg { width: 32px; height: 32px; filter: drop-shadow(0 4px 12px rgba(139, 92, 246, .45)); }
.brand b { color: var(--accent2); margin-left: 5px; }
.icon-btn { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); font-size: 17px; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.on { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); border-color: var(--accent); }
.searchbar { padding: 0 12px 8px; }
.searchbar input {
  width: 100%; padding: 11px 14px; border-radius: 14px; outline: 0;
  background: var(--surface); border: 1px solid var(--border);
}
.searchbar input:focus { border-color: var(--accent); }

/* ---------- Chips de lóbulos ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 12px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
body:not(.v-notes) .chips { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 13px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  font-size: 13.5px; white-space: nowrap; transition: transform .15s, background .15s;
}
.chip i { font-style: normal; font-size: 11px; color: var(--muted); background: var(--surface2); padding: 1px 7px; border-radius: 99px; }
.chip.active { background: color-mix(in srgb, var(--c, var(--accent)) 26%, var(--surface)); border-color: var(--c, var(--accent)); }
.chip.add { color: var(--muted); border-style: dashed; }
body.is-dragging .chip[data-lobe]:not([data-lobe="all"]) { border-style: dashed; border-color: var(--c); }
.chip.over { transform: scale(1.12); background: var(--c); color: #fff; }
.chip.over i { color: #fff; background: rgba(0, 0, 0, .2); }

/* ---------- Vistas ---------- */
.view { display: none; }
.view.active { display: block; }
.hint { margin: 2px 12px 8px; padding: 10px 12px; font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.hint button { color: var(--accent2); font-weight: 600; margin-left: 4px; }

/* ---------- Tarjetas ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; padding: 4px 12px calc(var(--bot) + 28px); }
.card {
  position: relative; overflow: hidden;
  background: color-mix(in srgb, var(--c) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 32%, transparent);
  border-radius: 16px; padding: 13px 12px 8px; min-height: 96px;
  display: flex; flex-direction: column; gap: 6px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: pan-y; transition: transform .15s, opacity .15s;
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c); }
.card:active { transform: scale(.98); }
.card h3 { margin: 0; font-size: 15px; line-height: 1.25; word-break: break-word; padding-right: 14px; }
.card .body {
  flex: 1; font-size: 13.5px; white-space: pre-wrap; word-break: break-word;
  color: color-mix(in srgb, var(--text) 82%, transparent);
  display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden;
}
.card footer { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.card .copy { width: 32px; height: 32px; margin: -6px -7px -6px 0; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }
.card .copy:active { background: var(--surface2); }
.card .pin { position: absolute; top: 7px; right: 8px; font-size: 12px; }
.card .links { font-size: 11px; color: var(--accent2); }
.card.dragging { opacity: .25; transform: scale(.95); }
.card.ghost { position: fixed; z-index: 1000; margin: 0; pointer-events: none; box-shadow: var(--shadow); opacity: .95; transition: none; }
.tag { color: var(--accent2); font-weight: 600; }

.empty { text-align: center; padding: 48px 28px; color: var(--muted); }
.empty .big { font-size: 46px; margin-bottom: 8px; }
.empty b { color: var(--text); }

.trash {
  position: fixed; left: 50%; bottom: calc(var(--bot) + 14px); z-index: 900;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  padding: 14px 24px; border-radius: 999px; font-weight: 600;
  background: rgba(239, 68, 68, .14); color: #fca5a5; border: 1.5px dashed rgba(239, 68, 68, .6);
  backdrop-filter: blur(8px); transition: .2s;
}
body.is-dragging .trash { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.trash.over { background: var(--danger); color: #fff; border-style: solid; transform: translate(-50%, 0) scale(1.08); }

/* ---------- Barra inferior ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--bot); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.nav { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 6px 0; }
.nav svg { width: 23px; height: 23px; }
.nav.active { color: var(--text); }
.nav.active svg { color: var(--accent); }
.fab {
  justify-self: center; width: 58px; height: 58px; margin-top: -28px; border-radius: 20px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 26px rgba(139, 92, 246, .55);
}
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.94); }

/* ---------- Cerebro ---------- */
#view-brain { position: fixed; inset: 0 0 var(--bot) 0; }
#view-brain:not(.active) { display: none; }
#brain {
  width: 100%; height: 100%; display: block; touch-action: none;
  background: radial-gradient(ellipse at 50% 55%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%);
}
#brain text { user-select: none; pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.dendrite { fill: none; stroke: var(--c); stroke-opacity: .35; stroke-width: 1.6; }
.synapse { stroke: var(--accent2); stroke-width: 2.6; stroke-opacity: .9; stroke-linecap: round; filter: url(#glow); }
.lobe-node { cursor: grab; }
.lobe-node .halo { fill: var(--c); opacity: .1; transition: opacity .15s; }
.lobe-node.target .halo { opacity: .4; }
.lobe-node .core { fill: color-mix(in srgb, var(--c) 30%, var(--surface)); stroke: var(--c); stroke-width: 2.5; }
.lobe-node .emoji { font-size: 30px; text-anchor: middle; stroke: none; }
.lobe-node .name { fill: var(--text); font-weight: 700; font-size: 15px; text-anchor: middle; }
.note-node { cursor: pointer; }
.note-node .glow { fill: var(--c); opacity: .22; }
.note-node .dot { fill: var(--c); stroke: var(--bg); stroke-width: 2.5; }
.note-node text { fill: var(--text); font-size: 11.5px; text-anchor: middle; opacity: .9; }
.note-node.from .dot { stroke: #fff; stroke-width: 4; }
.note-node.from .glow { opacity: .6; }
.dim { opacity: .12; }
.brain-tools { position: absolute; right: 12px; bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.tool { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.tool.on { background: var(--accent2); border-color: var(--accent2); }
.brain-hint {
  position: absolute; left: 12px; right: 76px; bottom: 14px; padding: 9px 12px; border-radius: 12px;
  font-size: 12.5px; color: var(--muted); background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border); backdrop-filter: blur(8px);
}

/* ---------- Ajustes ---------- */
.settings { padding: 6px 14px calc(var(--bot) + 30px); max-width: 640px; margin: 0 auto; }
.settings h4 { margin: 22px 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.card-s { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 4px 14px; }
.card-s.hero { padding: 18px 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 30%, var(--surface)), color-mix(in srgb, var(--accent2) 22%, var(--surface))); }
.hero-title { font-size: 20px; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stats div { background: rgba(0, 0, 0, .18); border-radius: 12px; padding: 10px; text-align: center; }
:root[data-theme="light"] .stats div { background: rgba(255, 255, 255, .55); }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 11.5px; color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row small { display: block; color: var(--muted); font-size: 12.5px; }
.row .btns { display: flex; gap: 8px; }
.note { font-size: 12.5px; color: var(--muted); margin: 6px 0 12px; }
.about { text-align: center; color: var(--muted); font-size: 12px; margin-top: 26px; }
.lobe-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 0; border-bottom: 1px solid var(--border); text-align: left; }
.lobe-row:last-child { border-bottom: 0; }
.lobe-row .sw { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.lobe-row span:nth-child(3) { flex: 1; }
.lobe-row small { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 9px 15px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0; }
.btn.danger { background: rgba(239, 68, 68, .15); color: #f87171; border-color: rgba(239, 68, 68, .35); }
.btn:active { transform: scale(.96); }

/* ---------- Editor ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.ed-top { display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 8px) 10px 8px; border-bottom: 1px solid var(--border); }
.ed-top select { flex: 1; min-width: 0; height: 40px; padding: 0 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.ed-scroll { flex: 1; overflow: auto; padding: 12px 16px calc(var(--safe-b) + 30px); }
.dots-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cdot { width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 2px solid transparent; outline: 2px solid transparent; outline-offset: 2px; font-size: 11px; color: #fff; display: grid; place-items: center; }
.cdot.sel { outline-color: var(--text); }
.cdot.auto { background: conic-gradient(#8b5cf6, #06b6d4, #22c55e, #f59e0b, #ef4444, #8b5cf6); }
#edTitle { width: 100%; padding: 6px 0; border: 0; outline: 0; background: none; font-size: 22px; font-weight: 750; }
#edBody { width: 100%; min-height: 42vh; border: 0; outline: 0; background: none; resize: none; font-size: 16px; line-height: 1.6; }
.ed-links { margin-top: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.ed-links-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 600; }
#edLinkList { display: flex; flex-wrap: wrap; gap: 8px; }
#edLinkList p { margin: 0; }
.lchip { display: inline-flex; align-items: center; border-radius: 999px; background: color-mix(in srgb, var(--c) 20%, var(--surface2)); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); font-size: 13px; overflow: hidden; }
.lchip button { padding: 6px 10px; }
.lchip button + button { padding-left: 4px; color: var(--muted); font-size: 16px; line-height: 1; }
.ed-meta { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Modales ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(5, 3, 15, .6); backdrop-filter: blur(4px); }
.modal-box { width: 100%; max-width: 520px; max-height: 85dvh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.modal-box h3 { margin: 0 0 14px; }
.field { width: 100%; padding: 12px 14px; border-radius: 12px; outline: 0; background: var(--bg); border: 1px solid var(--border); }
.field:focus { border-color: var(--accent); }
.le-row { display: flex; gap: 10px; }
.le-emoji { width: 56px; flex: none; text-align: center; font-size: 24px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); outline: 0; }
.emoji-picks { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0; }
.emoji-picks button { width: 40px; height: 40px; border-radius: 10px; font-size: 21px; }
.emoji-picks button:active { background: var(--surface2); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.spacer { flex: 1; }
.pk-list { margin-top: 10px; display: flex; flex-direction: column; }
.pk-list button { text-align: left; padding: 12px 6px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.pk-list .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Bloqueo ---------- */
.lock {
  position: fixed; inset: 0; z-index: 100; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(70% 50% at 50% 20%, color-mix(in srgb, var(--accent) 25%, transparent), transparent), var(--bg);
}
.lock-logo { width: 72px; height: 72px; filter: drop-shadow(0 8px 24px rgba(139, 92, 246, .5)); }
.lock-title { font-size: 18px; font-weight: 700; text-align: center; }
.lock-dots { display: flex; gap: 14px; height: 16px; }
.lock-dots span { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--muted); transition: .1s; }
.lock-dots span.f { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }
.keypad { display: grid; grid-template-columns: repeat(3, 74px); gap: 14px; }
.keypad button { height: 74px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); font-size: 26px; font-weight: 600; }
.keypad button:active { background: var(--surface2); transform: scale(.94); }
.link-btn { color: var(--accent2); font-size: 14px; font-weight: 600; padding: 8px; }
.modal.center { z-index: 110; align-items: center; padding: 16px; }
.modal.center .modal-box { border-radius: 22px; }
.rec-code {
  margin: 16px 0 4px; padding: 16px 10px; border-radius: 14px; text-align: center;
  font: 700 19px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .06em; word-break: break-all;
  background: var(--bg); border: 1.5px dashed var(--accent2); color: var(--text); user-select: all;
}
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* ---------- Aviso flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bot) + 16px); z-index: 200;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 11px 16px; border-radius: 14px; font-size: 14px;
  background: #2a2148; color: #fff; box-shadow: var(--shadow);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .22s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button { color: #67e8f9; font-weight: 700; }
