/* ── Notes v4 ──────────────────────────────────────────────────────── */
.notes-app.notes-v4 {
  display: flex;
  height: 100%;
  background: var(--space-bg-base, #f8f8f8);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  overflow: hidden;
}

.notes-layout {
  display: grid;
  grid-template-columns: 200px 220px 1fr;
  width: 100%;
  height: 100%;
}

/* ── Sidebar cuadernos ── */
.notes-sidebar {
  background: var(--space-bg-sidebar, #1e1e2e);
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
}

.notes-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.3px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.notes-logo { font-size: 18px; }
.notes-brand { color: #fff; }

.notes-search-wrap {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.notes-search {
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.07);
  color: #fff;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}
.notes-search::placeholder { color: rgba(255,255,255,.35); }

.notes-sidebar-section { flex: 1; overflow-y: auto; padding: 8px 0; }
.notes-sidebar-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  color: rgba(255,255,255,.4); text-transform: uppercase;
}

.notes-add-btn {
  background: none; border: none; color: rgba(255,255,255,.5);
  cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px;
  transition: color .15s, background .15s;
}
.notes-add-btn:hover { color: #fff; background: rgba(255,255,255,.1); }

.notes-nb-list { list-style: none; margin: 0; padding: 0 6px; }
.notes-nb-item {
  display: flex; align-items: center;
  border-radius: 8px; margin-bottom: 2px;
  transition: background .15s;
}
.notes-nb-item:hover { background: rgba(255,255,255,.06); }
.notes-nb-item.active { background: rgba(255,255,255,.1); }

.notes-nb-btn {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: rgba(255,255,255,.8);
  padding: 7px 8px; cursor: pointer; font-size: 12.5px; text-align: left;
  border-radius: 8px; min-width: 0;
}
.notes-nb-item.active .notes-nb-btn { color: #fff; font-weight: 600; }

.notes-nb-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--nb-color, #7c3aed);
}
.notes-nb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-nb-count {
  font-size: 10px; background: rgba(255,255,255,.12);
  padding: 1px 6px; border-radius: 999px; color: rgba(255,255,255,.5);
}
.notes-nb-menu {
  background: none; border: none; color: rgba(255,255,255,.3);
  cursor: pointer; padding: 4px 6px; border-radius: 6px;
  opacity: 0; font-size: 14px; transition: opacity .15s;
}
.notes-nb-item:hover .notes-nb-menu { opacity: 1; }
.notes-nb-menu:hover { color: #fff; background: rgba(255,255,255,.12); }

/* ── Panel del medio (secciones + páginas) ── */
.notes-middle {
  display: flex; flex-direction: column;
  background: var(--space-bg-panel, #f3f4f6);
  border-right: 1px solid var(--space-border-default, #e5e7eb);
  overflow: hidden;
}
.notes-middle-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--space-border-default, #e5e7eb);
}
.notes-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--space-text-secondary, #6b7280);
}
.notes-section-list, .notes-page-list { list-style: none; margin: 0; padding: 4px 6px; overflow-y: auto; }
.notes-section-list { max-height: 120px; border-bottom: 1px solid var(--space-border-default,#e5e7eb); }
.notes-page-list { flex: 1; }

.notes-sec-item {
  display: flex; align-items: center; border-radius: 8px; margin-bottom: 2px;
}
.notes-sec-item:hover { background: var(--space-bg-hover, rgba(0,0,0,.04)); }
.notes-sec-item.active { background: var(--space-accent-light, rgba(124,58,237,.1)); }

.notes-sec-btn {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 7px 8px; cursor: pointer;
  font-size: 12px; color: var(--space-text-primary, #111); text-align: left; border-radius: 8px;
}
.notes-sec-item.active .notes-sec-btn { color: var(--space-accent, #7c3aed); font-weight: 600; }
.notes-sec-icon { font-size: 13px; }
.notes-sec-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-sec-del {
  background: none; border: none; color: var(--space-text-tertiary, #9ca3af);
  cursor: pointer; padding: 3px 6px; border-radius: 5px; font-size: 11px;
  opacity: 0; transition: opacity .15s;
}
.notes-sec-item:hover .notes-sec-del { opacity: 1; }
.notes-sec-del:hover { color: #ef4444; background: rgba(239,68,68,.08); }

.notes-page-item { margin-bottom: 3px; }
.notes-page-btn {
  width: 100%; display: flex; flex-direction: column; gap: 2px;
  background: none; border: none; padding: 8px 10px; cursor: pointer; text-align: left;
  border-radius: 9px; transition: background .12s;
}
.notes-page-item:hover .notes-page-btn { background: var(--space-bg-hover, rgba(0,0,0,.04)); }
.notes-page-item.active .notes-page-btn { background: var(--space-accent-light, rgba(124,58,237,.1)); }

.notes-page-title {
  font-size: 12.5px; font-weight: 600;
  color: var(--space-text-primary, #111);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notes-page-item.active .notes-page-title { color: var(--space-accent, #7c3aed); }
.notes-page-preview {
  font-size: 11px; color: var(--space-text-tertiary, #9ca3af);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notes-page-date {
  font-size: 10px; color: var(--space-text-tertiary, #9ca3af); margin-top: 2px;
}
.notes-page-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.notes-empty-page { padding: 16px; text-align: center; color: var(--space-text-tertiary, #9ca3af); font-size: 12px; }

/* ── Editor ── */
.notes-editor-area {
  display: flex; flex-direction: column; height: 100%; min-width: 0;
  background: var(--space-bg-base, #fff);
}
.notes-editor-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; gap: 4px;
  border-bottom: 1px solid var(--space-border-default, #e5e7eb);
  background: var(--space-bg-panel, #f9fafb);
  flex-wrap: wrap;
}
.notes-format-btns, .notes-toolbar-right {
  display: flex; align-items: center; gap: 2px;
}
.notes-tb-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; font-size: 12px;
  color: var(--space-text-secondary, #6b7280);
  transition: background .12s, color .12s;
}
.notes-tb-btn:hover { background: var(--space-bg-hover, rgba(0,0,0,.06)); color: var(--space-text-primary, #111); }
.notes-tb-btn.notes-tb-danger:hover { background: rgba(239,68,68,.1); color: #ef4444; }
.notes-tb-sep { width: 1px; height: 16px; background: var(--space-border-default,#e5e7eb); margin: 0 2px; }

.notes-save-status { font-size: 11px; margin-left: 6px; transition: color .3s; }
.notes-save-status.saving { color: #f59e0b; }
.notes-save-status.saved  { color: #10b981; }

.notes-editor-body {
  display: flex; flex-direction: column; flex: 1; overflow: hidden;
  padding: 16px 20px 8px;
}
.notes-title-input {
  border: none; outline: none; background: transparent;
  font-size: 22px; font-weight: 700; color: var(--space-text-primary, #111);
  width: 100%; padding: 0 0 8px; margin-bottom: 6px;
  border-bottom: 2px solid var(--space-border-default, #e5e7eb);
  font-family: inherit;
}
.notes-title-input::placeholder { color: var(--space-text-tertiary, #9ca3af); }

.notes-tags-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid var(--space-border-default, #e5e7eb);
}
.notes-tag-label { font-size: 11px; color: var(--space-text-tertiary,#9ca3af); }
.notes-tags-list { display: flex; gap: 4px; flex-wrap: wrap; }
.notes-tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--space-accent-light, rgba(124,58,237,.1));
  color: var(--space-accent, #7c3aed);
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
}
.notes-tag-remove {
  background: none; border: none; cursor: pointer;
  color: var(--space-accent, #7c3aed); font-size: 10px; padding: 0 0 0 2px;
  line-height: 1;
}
.notes-add-tag-btn {
  background: none; border: 1px dashed var(--space-border-default, #d1d5db);
  border-radius: 999px; padding: 2px 8px; font-size: 11px;
  color: var(--space-text-tertiary, #9ca3af); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.notes-add-tag-btn:hover { border-color: var(--space-accent, #7c3aed); color: var(--space-accent, #7c3aed); }

.notes-textarea {
  flex: 1; border: none; outline: none; resize: none;
  font-size: 13.5px; line-height: 1.75;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Cascadia Code', monospace;
  color: var(--space-text-primary, #111); background: transparent;
  padding: 4px 0; min-height: 0;
}
.notes-textarea::placeholder { color: var(--space-text-tertiary, #9ca3af); }

.notes-preview-pane {
  flex: 1; overflow-y: auto; padding: 4px 0;
  font-size: 14px; line-height: 1.75;
  color: var(--space-text-primary, #111);
}
.notes-preview-body h1 { font-size: 22px; font-weight: 700; margin: 0 0 12px; border-bottom: 2px solid var(--space-border-default,#e5e7eb); padding-bottom: 6px; }
.notes-preview-body h2 { font-size: 17px; font-weight: 700; margin: 16px 0 8px; }
.notes-preview-body h3 { font-size: 14px; font-weight: 700; margin: 12px 0 6px; color: var(--space-accent,#7c3aed); }
.notes-preview-body strong { font-weight: 700; }
.notes-preview-body em { font-style: italic; }
.notes-preview-body del { text-decoration: line-through; color: var(--space-text-tertiary,#9ca3af); }
.notes-preview-body code { background: var(--space-bg-panel,#f3f4f6); border-radius: 4px; padding: 1px 5px; font-family: monospace; font-size: 12.5px; }
.notes-preview-body ul { padding-left: 18px; margin: 8px 0; }
.notes-preview-body li.done { list-style: none; }
.notes-preview-body li.todo { list-style: none; }
.notes-preview-body p { margin: 8px 0; }
.notes-empty-hint { color: var(--space-text-tertiary,#9ca3af); }

.notes-editor-footer {
  display: flex; justify-content: space-between;
  padding-top: 6px; font-size: 11px;
  color: var(--space-text-tertiary, #9ca3af);
  border-top: 1px solid var(--space-border-default, #e5e7eb);
}

/* ── Responsive móvil ── */
@media (max-width: 680px) {
  .notes-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .notes-sidebar { max-height: 120px; overflow-y: auto; }
  .notes-middle  { max-height: 140px; overflow-y: auto; }
}
