/* ==========================================================================
   Variables y Paletas de Color Modernas (Estilo Obsidian / Notion)
   ========================================================================== */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", "Consolas", Menlo, monospace;

  /* Tema Oscuro (Obsidian Glow) */
  --bg-app: #111216;
  --bg-sidebar: #17181f;
  --bg-surface: #1d1f27;
  --bg-surface-hover: #262936;
  --bg-active: #313545;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  
  --text-primary: #f0f2f6;
  --text-secondary: #9da3b4;
  --text-muted: #656b7c;
  
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-subtle: rgba(99, 102, 241, 0.16);
  --wikilink-color: #818cf8;
  --wikilink-bg: rgba(99, 102, 241, 0.14);
  
  --highlight-bg: rgba(234, 179, 8, 0.35);
  --code-bg: #0c0d10;
  --quote-border: #6366f1;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-width: 290px;
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-sidebar: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f3f4f6;
  --bg-active: #e2e8f0;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #4f46e5;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-subtle: rgba(79, 70, 229, 0.1);
  --wikilink-color: #4338ca;
  --wikilink-bg: rgba(79, 70, 229, 0.1);
  
  --highlight-bg: rgba(253, 224, 71, 0.6);
  --code-bg: #e2e8f0;
  --quote-border: #4f46e5;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

/* Reset y Scrollbars */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.65;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(150, 150, 150, 0.25);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 150, 150, 0.45);
}

/* ==========================================================================
   PANTALLA DE BLOQUEO / LOCK SCREEN (Zero-Knowledge)
   ========================================================================== */
.lock-screen-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at center, #1c1e28 0%, #0d0e12 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.lock-screen-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lock-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 34px 28px;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.lock-shield-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px auto;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.35);
}

.lock-brand h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.lock-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
}
.lock-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  animation: fadeIn 0.2s ease-out;
}
.lock-badge-pill.manual {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.lock-badge-pill.timeout {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.lock-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.setup-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  align-self: flex-start;
  margin-bottom: -4px;
}
.setup-badge.danger-badge {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
}
.setup-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 4px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrapper input {
  width: 100%;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.95rem;
  padding: 10px 42px 10px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.password-wrapper input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.toggle-pwd-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.toggle-pwd-btn:hover {
  color: var(--text-primary);
}

.lock-error-msg {
  font-size: 0.8rem;
  color: #ef4444;
  min-height: 18px;
  text-align: center;
  font-weight: 500;
}

.btn-lock-submit {
  background: var(--accent);
  color: #ffffff;
  border: none;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-lock-submit:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.lock-footer {
  margin-top: 22px;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Layout Principal y Sidebar
   ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 45;
}
.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.brand-icon {
  color: var(--accent);
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 8px;
  background: var(--bg-surface);
}
.sidebar-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.sidebar-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sidebar-pane {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  gap: 10px;
}

.pane-action-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.note-search-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  outline: none;
}
.note-search-input:focus {
  border-color: var(--accent);
}

.icon-btn-accent {
  background: var(--accent);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn-accent:hover {
  background: var(--accent-hover);
}

/* Lista de Notas */

.vault-note-item:hover .vault-note-del-btn {
  opacity: 1;
}
.vault-note-del-btn:hover {
  color: #ef4444;
}

/* Panel Seguridad */
.timeout-selector-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.settings-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
}
.custom-select {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.82rem;
  padding: 7px 8px;
  border-radius: 4px;
  outline: none;
}
.custom-select:focus {
  border-color: var(--accent);
}
.action-btn-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  transition: background 0.15s;
}
.action-btn-block:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
}
.action-btn-block.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.action-btn-block.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.settings-change-pwd-box {
  margin-top: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.settings-msg {
  font-size: 0.76rem;
  line-height: 1.35;
  margin-top: 8px;
  display: none;
}
.settings-msg.error {
  color: #ef4444;
  display: block;
}
.settings-msg.success {
  color: #10b981;
  display: block;
}

/* Estructura TOC */
.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.toc-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.toc-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 6px 0;
}
.toc-link {
  font-size: 0.84rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.toc-link:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.toc-h1 { font-weight: 600; color: var(--text-primary); }
.toc-h2 { padding-left: 18px; }
.toc-h3 { padding-left: 28px; font-size: 0.78rem; color: var(--text-muted); }

/* Atajos y Footer */

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Header Superior y Botones
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg-app);
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  box-sizing: border-box;
  height: 34px;
  width: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  display: block;
}

.action-btn {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-sizing: border-box;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.80rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
  vertical-align: middle;
  margin: 0;
}
.action-btn:hover {
  background: var(--bg-active);
  border-color: var(--text-muted);
}
.action-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: block;
}
.action-btn .btn-text {
  display: inline-block;
  line-height: 1;
}
.action-btn.file-input-label {
  cursor: pointer;
  margin: 0;
}
.action-btn.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.action-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}
.action-btn.lock-btn {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.08);
}
.action-btn.lock-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* ==========================================================================
   Superficie del Editor
   ========================================================================== */
.editor-scroll-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  display: flex;
  justify-content: center;
  padding: 40px 20px 80px 20px;
}

.editor-wrapper {
  width: 100%;
  max-width: 820px;
  position: relative;
}

.editor-surface {
  min-height: 80vh;
  outline: none;
  font-size: 1.05rem;
  color: var(--text-primary);
  word-break: break-word;
  padding-bottom: 250px;
  position: relative;
}

.editor-surface[placeholder]:empty:before {
  content: attr(placeholder);
  color: var(--text-muted);
  pointer-events: none;
  display: block;
  font-style: italic;
}

/* Wikilinks [[...]] */
.wikilink {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  color: var(--wikilink-color);
  background: var(--wikilink-bg);
  padding: 1px 7px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95em;
  border-bottom: 1px dashed var(--wikilink-color);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.wikilink:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Formatos de contenido */
.editor-surface h1 {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 1.4em 0 0.5em 0;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3em;
}
.editor-surface h2 {
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 1.2em 0 0.4em 0;
  color: var(--text-primary);
}
.editor-surface h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1em 0 0.3em 0;
  color: var(--text-primary);
}
.editor-surface p { margin: 0.7em 0; }
.editor-surface ul, .editor-surface ol { padding-left: 28px; margin: 0.6em 0; }
.editor-surface li { margin: 0.3em 0; }
.editor-surface blockquote {
  border-left: 4px solid var(--quote-border);
  padding: 8px 16px;
  margin: 1em 0;
  background: var(--bg-surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}
.editor-surface pre {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin: 1.2em 0;
  color: #38bdf8;
}
.editor-surface code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-surface-hover);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  color: #38bdf8;
}
.editor-surface mark {
  background-color: var(--highlight-bg);
  color: inherit;
  padding: 2px 3px;
  border-radius: 3px;
}
.editor-surface a:not(.wikilink) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}

/* Tablas Dinámicas */
.table-block-wrapper {
  margin: 1.5em 0;
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
}
.tbl-ctrl-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tbl-ctrl-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.tbl-ctrl-btn.danger:hover { background: #ef4444; border-color: #ef4444; }

.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.95rem;
}
.custom-table th, .custom-table td {
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  min-width: 90px;
  vertical-align: top;
  outline: none;
}
.custom-table th {
  background: var(--bg-sidebar);
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}
.custom-table td:focus, .custom-table th:focus {
  background: var(--bg-surface-hover);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Barra Flotante de Selección */
.floating-toolbar {
  position: absolute;
  top: 0; left: 0;
  z-index: 100;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 4px;
  display: none;
  align-items: center;
  gap: 3px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.15s ease-out;
}
.floating-toolbar.active { display: flex; }
.float-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
}
.float-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.float-btn.wikilink-btn { color: var(--wikilink-color); background: var(--wikilink-bg); }
.highlight-indicator {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #facc15;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.color-picker-wrapper {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.color-picker-wrapper:hover { background: var(--bg-surface-hover); }
.color-picker-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.color-picker-icon {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
  line-height: 1;
}

/* Menú Wikilinks */
.wikilink-suggest-menu {
  position: absolute;
  z-index: 120;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 6px;
  width: 260px;
  display: none;
  flex-direction: column;
  backdrop-filter: blur(12px);
}
.wikilink-suggest-menu.active { display: flex; animation: fadeIn 0.15s ease-out; }
.suggest-header {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 8px 6px 8px;
  border-bottom: 1px solid var(--border-color);
}
.suggest-items {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
.wikilink-search-wrapper {
  padding: 4px 4px 6px 4px;
  border-bottom: 1px solid var(--border-color);
}
.wikilink-search-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.8rem;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}
.wikilink-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-primary);
  transition: background 0.12s;
}
.suggest-item:hover { background: var(--accent-subtle); color: var(--accent); }

/* Slash menu */
.slash-menu {
  position: absolute;
  z-index: 110;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 6px;
  width: 250px;
  display: none;
  flex-direction: column;
  gap: 2px;
  backdrop-filter: blur(10px);
}
.slash-menu.active { display: flex; animation: fadeIn 0.15s ease-out; }
.slash-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 8px;
}
.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}
.slash-item:hover { background: var(--bg-surface-hover); }
.slash-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}
.slash-item strong { display: block; font-size: 0.85rem; color: var(--text-primary); }
.slash-item small { display: block; font-size: 0.72rem; color: var(--text-muted); }

.block-add-btn {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
  box-sizing: border-box;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 35;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  pointer-events: auto;
  user-select: none;
}
.block-add-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: scale(1.15);
}

/* Modal Grafo */
.graph-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(8px);
  padding: 24px;
}
.graph-modal.active { display: flex; animation: fadeIn 0.2s ease-out; }
.graph-modal-content {
  background: var(--bg-surface);
  width: 100%;
  max-width: 1100px;
  height: 85vh;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.graph-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
}
.graph-title-wrapper { display: flex; align-items: center; gap: 10px; color: var(--text-primary); }
.graph-title-wrapper svg { color: var(--accent); }
.graph-title-wrapper h3 { font-size: 1.05rem; }
.graph-actions { display: flex; align-items: center; gap: 14px; }
.graph-hint { font-size: 0.78rem; color: var(--text-muted); }
.canvas-container {
  flex: 1;
  position: relative;
  background: var(--bg-app);
  min-height: 320px;
  overflow: hidden;
}
#graphCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#graphCanvas:active {
  cursor: grabbing;
}

/* Drag & Drop */
.drag-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(19, 20, 23, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
[data-theme="light"] .drag-overlay { background: rgba(255, 255, 255, 0.85); }
.drag-overlay.active { display: flex; }
.drag-card {
  background: var(--bg-surface);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
}
.drag-card svg { color: var(--accent); }
.drag-card h3 { font-size: 1.2rem; color: var(--text-primary); }
.drag-card p { color: var(--text-muted); font-size: 0.85rem; }

/* Barra Móvil */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 52px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  z-index: 50;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
}
.mobile-tool-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  min-width: 36px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mobile-tool-btn:active { background: var(--bg-surface-hover); }
.mobile-tool-btn.danger { color: #ef4444; }

/* Modo Zen */
body.zen-mode .sidebar { margin-left: calc(-1 * var(--sidebar-width)); }
body.zen-mode .top-nav { transform: translateY(-100%); opacity: 0; pointer-events: none; }
body.zen-mode .mobile-bottom-bar { transform: translateY(100%); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Breakpoints */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    margin-left: 0 !important;
    z-index: 60;
    width: 280px;
    max-width: 85vw;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 55;
  }
  .sidebar-backdrop.active { display: block; }
  .close-sidebar-btn { display: inline-flex; }
  .mobile-bottom-bar { display: flex; z-index: 45; }
  .editor-scroll-container { padding: 18px 14px 85px 14px; }
  .btn-text { display: none; }
  .doc-title-input { width: 130px; }
  .graph-hint { display: none; }
}

@media (max-width: 600px) {
  .top-nav {
    padding: 0 8px;
    gap: 6px;
  }
  .nav-left {
    gap: 6px;
  }
  .doc-title-wrapper {
    gap: 6px;
  }
  .doc-title-input {
    max-width: 110px;
    min-width: 45px;
    font-size: 0.88rem;
  }
  .top-nav .nav-actions {
    gap: 5px;
  }
  .top-nav .file-input-label,
  .top-nav #zenModeBtn {
    display: none; /* Ocultar botones secundarios de escritorio para que Guardar, Bloquear y Tema nunca se encimen */
  }

  /* Menús flotantes (Slash y Wikilinks) estilo bottom sheet en móvil para evitar cortes de pantalla */
  .slash-menu,
  .wikilink-suggest-menu {
    position: fixed !important;
    top: auto !important;
    bottom: 58px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none !important;
    max-height: 48vh !important;
    overflow-y: auto !important;
    box-shadow: 0 -8px 26px rgba(0, 0, 0, 0.5) !important;
    border-radius: var(--radius-md) !important;
    z-index: 150 !important;
  }

  .floating-toolbar {
    max-width: 95vw;
    overflow-x: auto;
  }

  .graph-modal {
    padding: 10px;
  }
  .graph-modal-content {
    height: 92vh;
    border-radius: var(--radius-md);
  }
}

@media (min-width: 861px) {
  .close-sidebar-btn { display: none; }
  .sidebar-backdrop { display: none !important; }
}

/* ==========================================================================
   ÍNDICE GENERAL / MAPA DE CONTENIDOS FIJO
   ========================================================================== */
.vault-index-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 8px 8px 10px 8px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.vault-index-item:hover {
  background: rgba(99, 102, 241, 0.16);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.vault-index-item.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.vault-index-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.vault-index-item.active .vault-index-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}
.vault-index-badge {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
  font-weight: 700;
}

/* Superficie del Índice en el Editor */
.vault-index-surface {
  padding: 10px 0 40px;
}
.vault-index-surface .index-banner {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}
.vault-index-surface h1 {
  font-size: 1.7rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.vault-index-surface .index-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin: 0;
  line-height: 1.45;
}
.index-section {
  margin-bottom: 22px;
}
.index-section-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.index-folder-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.index-folder-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
}
.index-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text-primary);
  cursor: pointer;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-color);
  margin-bottom: 8px;
}
.index-folder-header:hover {
  color: var(--accent);
}
.index-notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.index-note-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.index-note-link:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(2px);
}
.index-note-link svg {
  color: var(--accent);
  flex-shrink: 0;
}

.switch-form-link-wrapper {
  margin-top: 10px;
  text-align: center;
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.link-btn:hover {
  color: var(--text-primary);
}
.link-btn.danger-link {
  color: var(--text-muted);
}
.link-btn.danger-link:hover {
  color: #ef4444;
}

/* ==========================================================================
   Banner Persistente de Cambios y Modal de Confirmación
   ========================================================================== */
.unsaved-changes-banner {
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.18) 0%, rgba(202, 138, 4, 0.12) 100%);
  border-bottom: 1px solid rgba(234, 179, 8, 0.35);
  color: #fef08a;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 25;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: slideDownBanner 0.2s ease-out;
}
.unsaved-changes-banner.saved-state {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.18) 0%, rgba(22, 163, 74, 0.12) 100%);
  border-bottom-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}
@keyframes slideDownBanner {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.banner-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
.banner-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.banner-save-btn {
  background: #eab308;
  color: #1a1a1a;
  border: none;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s;
}
.banner-save-btn:hover {
  background: #facc15;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.4);
}
.unsaved-changes-banner.saved-state .banner-save-btn {
  background: #22c55e;
  color: #ffffff;
}

/* Modal de Confirmación */
.confirm-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.15s ease-out;
  padding: 16px;
}
.confirm-modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.confirm-modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.confirm-modal-card h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
  font-weight: 700;
}
.confirm-modal-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.confirm-modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}
.confirm-btn-secondary {
  flex: 1;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.confirm-btn-secondary:hover {
  background: var(--bg-active);
}
.confirm-btn-danger {
  flex: 1;
  background: #ef4444;
  border: none;
  color: white;
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
}
.confirm-btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
}


/* ==========================================================================
   MEJORAS CRÍTICAS DE HEADER Y RESPONSIVIDAD (SIN TRASLAPES)
   ========================================================================== */
.top-nav {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  z-index: 20;
  position: relative;
  overflow: hidden;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.doc-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.doc-title-input {
  background: transparent;
  border: none;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-sans);
  border-bottom: 1px dashed transparent;
  padding: 2px 6px;
  border-radius: 4px;
  flex: 1 1 auto;
  min-width: 80px;
  max-width: 380px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.doc-title-input:hover, .doc-title-input:focus {
  border-bottom-color: var(--accent);
  background: var(--bg-app);
}

.save-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* En resoluciones medianas (pantallas compactas/tablets) */
@media (max-width: 1024px) {
  .doc-title-input {
    max-width: 150px;
  }
  .save-status {
    display: none; /* Se oculta para dar prioridad a los botones sin encimarse */
  }
  .action-btn .btn-text {
    display: none; /* Solo icono para máxima limpieza */
  }
  .action-btn {
    width: 34px;
    padding: 0;
    gap: 0;
    justify-content: center;
  }
}

/* ==========================================================================
   REDISEÑO PULIDO DE ATAJOS (COMPACTO, LIMPIO Y ARMÓNICO)
   ========================================================================== */
.sidebar-section-compact {
  padding: 10px 14px 8px;
  border-top: 1px solid var(--border-color);
  background: transparent;
}

.sidebar-section-compact .section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
  opacity: 0.8;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 0;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.73rem;
  color: var(--text-muted);
  padding: 3px 6px;
  background: transparent;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.12s ease;
}

.shortcut-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

.shortcut-item span:first-child {
  font-family: var(--font-mono);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 1px solid rgba(99, 102, 241, 0.18);
}

.shortcut-item span:last-child {
  color: inherit;
  font-size: 0.71rem;
  font-weight: 400;
}

/* ==========================================================================
   ÁRBOL DE CARPETAS Y NOTAS ESTILO NOTION / OBSIDIAN
   ========================================================================== */
.icon-btn-accent.secondary {
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.icon-btn-accent.secondary:hover {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--accent);
}

.vault-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 20px;
}

/* Fila de Carpeta */
.vault-folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s;
}
.vault-folder-row:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.vault-folder-left {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.folder-chevron {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}
.folder-chevron.open {
  transform: rotate(90deg);
}

.folder-icon {
  width: 16px;
  height: 16px;
  color: #facc15;
  flex-shrink: 0;
}

.vault-folder-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.vault-folder-row:hover .vault-folder-actions {
  opacity: 1;
}

.folder-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.folder-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}
.folder-action-btn.danger:hover {
  color: #ef4444;
}

/* Contenedor de Hijos de Carpeta */
.vault-folder-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vault-folder-children.collapsed {
  display: none;
}

/* Fila de Nota */
.vault-note-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.84rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.vault-note-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.vault-note-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}
.vault-note-item.active .vault-note-icon {
  color: var(--accent);
}

.vault-note-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.vault-note-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.vault-note-del-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.vault-note-item:hover .vault-note-del-btn {
  opacity: 1;
}
.vault-note-del-btn:hover {
  color: #ef4444;
}

.vault-empty-folder-msg {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 8px;
}

/* ==========================================================================
   CEREBRO SECRETO (Stealth Mode & Visual Identity)
   ========================================================================== */
#brandTextTitle {
  user-select: none;
  cursor: default !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
}
#brandTextTitle:hover,
#brandTextTitle:active,
#brandTextTitle:focus {
  color: inherit !important;
  background: transparent !important;
  text-decoration: none !important;
  box-shadow: none !important;
}

.brand-icon.secret-icon {
  color: #10b981;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.45));
}

body.secret-vault-active {
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-subtle: rgba(16, 185, 129, 0.16);
  --wikilink-color: #34d399;
  --wikilink-bg: rgba(16, 185, 129, 0.14);
  --border-focus: #10b981;
  --quote-border: #10b981;
}

.action-btn.secret-exit-btn {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
}
.action-btn.secret-exit-btn:hover {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
}

/* ==========================================================================
   OCULTAR / CERRAR NOTA CON 1 CLIC
   ========================================================================== */
.close-note-btn {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.close-note-btn:hover {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.note-closed-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62vh;
  padding: 24px;
}
.note-closed-card {
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 38px 28px;
  max-width: 440px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.2s ease-out;
}
.note-closed-card svg {
  color: var(--text-muted);
  opacity: 0.7;
}
.note-closed-card h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
  font-weight: 700;
}
.note-closed-card p {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==========================================================================
   ORGANIZACIÓN DE CARPETAS Y ARCHIVOS (Drag & Drop + Modal Mover)
   ========================================================================== */
.vault-note-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.vault-note-item:hover .vault-note-actions {
  opacity: 1;
}
.vault-note-actions .vault-note-del-btn {
  opacity: 1;
  padding: 3px;
}

@media (max-width: 860px) {
  .vault-folder-actions,
  .vault-note-actions {
    opacity: 1;
  }
}

.vault-item-dragging {
  opacity: 0.45;
  border: 1px dashed var(--accent) !important;
}

.vault-drop-target-active {
  background: var(--accent-subtle) !important;
  outline: 2px dashed var(--accent) !important;
  outline-offset: -2px;
  color: var(--text-primary) !important;
}

.vault-root-dropzone {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  user-select: none;
}
.vault-root-dropzone.vault-drop-target-active,
.vault-root-dropzone:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* Modal Mover Destinos */
.move-modal-card {
  max-width: 440px;
}
.confirm-modal-icon.move-icon {
  background: var(--accent-subtle);
  color: var(--accent);
}
.move-destinations-list {
  width: 100%;
  max-height: 270px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  margin: 6px 0;
  padding-right: 4px;
}
.move-dest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}
.move-dest-item:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}
.move-dest-item.current-parent {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}
.move-dest-badge {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--bg-surface-hover);
  color: var(--text-muted);
}

/* ==========================================================================
   BARRA FLOTANTE CON JERARQUÍAS Y BLOQUES
   ========================================================================== */
.floating-toolbar {
  flex-wrap: wrap;
  max-width: 560px;
}
.float-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 3px;
}
.float-btn.hierarchy-btn {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.82rem;
}
.float-btn.hierarchy-btn:hover {
  background: var(--accent);
  color: #ffffff;
}

/* ==========================================================================
   TUTORIAL Y GUÍA INTERACTIVA DE MARKDOWN
   ========================================================================== */
.guide-search-bar {
  margin-bottom: 4px;
}
.guide-intro {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 6px;
}
.md-guide-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 24px;
}
.md-guide-category {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.md-guide-cat-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 700;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
}
.md-cmd-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.md-cmd-card:hover {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
  transform: translateX(2px);
}
.md-cmd-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.md-cmd-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}
.md-cmd-code {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: #38bdf8;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}
.md-cmd-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Elementos adicionales de Markdown en el Editor */
.editor-surface h4 { font-size: 1.1rem; font-weight: 600; margin: 0.9em 0 0.3em; }
.editor-surface h5 { font-size: 1rem; font-weight: 600; margin: 0.8em 0 0.3em; color: var(--text-secondary); }
.editor-surface h6 { font-size: 0.9rem; font-weight: 600; margin: 0.8em 0 0.3em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.editor-surface img { max-width: 100%; border-radius: var(--radius-md); margin: 0.6em 0; display: block; }
.editor-surface s { opacity: 0.75; }
.editor-surface li.checklist-item:has(input:checked) { color: var(--text-muted); text-decoration: line-through; }
.editor-surface hr {
  border: none;
  border-top: 2px solid var(--border-color);
  margin: 1.4em 0;
}
.editor-surface ul.checklist {
  list-style: none;
  padding-left: 8px;
}
.editor-surface li.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0.35em 0;
}
.editor-surface li.checklist-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.editor-surface .callout-box {
  border-left: 4px solid var(--accent);
  background: var(--accent-subtle);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1em 0;
  color: var(--text-primary);
}

/* Leyenda del Grafo Jerárquico */
.graph-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-app);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.legend-item .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.legend-item .dot.index-dot { background: #8b5cf6; }
.legend-item .dot.folder-dot { background: #f59e0b; }
.legend-item .dot.note-dot { background: #6366f1; }
.legend-item .line.wikilink-line {
  width: 14px;
  height: 2px;
  background: #38bdf8;
  display: inline-block;
}
@media (max-width: 760px) {
  .graph-legend { display: none; }
}
