/* ============================================
   orOS Notes — Styles v4.4
   Fixes from v4.3:
   - Sidebar collapse now frees space (width:0 instead of transform)
   - Added .view-toggle-small / .view-btn-small styles (footer view buttons)
   - Removed broken .notes-main.view-editor-only .notes-sidebar rule
   - First note spacing fix (sidebar-tree padding-top)
   - Editor tabs kept (HTML/JS still reference them)
   - Zen mode layout preserved
   - All focus mode remnants removed
   ============================================ */

/* ===== PAGE LAYOUT ===== */
.notes-page {
  background: var(--bg-dark, #1a1814);
  color: var(--text-primary, #e8e2d4);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  overflow: hidden;
  height: 100vh;
}

/* ===== TOOLBAR ===== */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-toolbar, #232019);
  border-bottom: 1px solid var(--border-color, #3a3528);
  position: sticky;
  top: 56px;
  z-index: 100;
  gap: 12px;
  flex-shrink: 0;
  height: 52px;
  box-sizing: border-box;
}

.notes-toolbar-left,
.notes-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.notes-toolbar-center {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
  max-width: 400px;
}

/* ===== CONTAINER ===== */
.notes-container {
  display: flex;
  height: calc(100vh - 108px);
  overflow: hidden;
}

/* ===== SIDEBAR (FIX: width-based collapse) ===== */
.notes-sidebar {
  width: 280px;
  min-width: 240px;
  max-width: 360px;
  background: var(--bg-panel, #2a2620);
  border-right: 1px solid var(--border-color, #3a3528);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease, border 0.2s ease;
  flex-shrink: 0;
}

.notes-sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-content::-webkit-scrollbar { width: 5px; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--border-color, #3a3528); border-radius: 3px; }

/* ===== ROOT DROP ZONE ===== */
.sidebar-root-dropzone {
  margin: 4px 8px 8px;
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted, #8a8474);
  border: 1px dashed var(--border-color, #3a3528);
  border-radius: var(--radius-sm, 6px);
  opacity: 0.4;
  transition: all 0.2s;
  flex-shrink: 0;
}
.sidebar-root-dropzone.drag-over {
  opacity: 1;
  border-color: var(--accent-gold, #c8a96e);
  background: rgba(200, 169, 110, 0.1);
}

/* ===== TREE VIEW (FIX: first note spacing) ===== */
.sidebar-tree {
  padding: 12px 4px 4px;
  flex: 1;
}
.tree-node { user-select: none; }

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin: 2px 0;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  transition: background var(--transition, 0.2s);
  position: relative;
}

.tree-item:hover { background: var(--bg-hover, #332e26); }
.tree-item.active {
  background: rgba(200, 169, 110, 0.2);
  border-left: 3px solid var(--accent-gold, #c8a96e);
}

.tree-item.dragging { opacity: 0.4; }
.tree-item.drag-over {
  background: rgba(200, 169, 110, 0.25);
  border-left: 3px solid var(--accent-gold, #c8a96e);
  outline: 1px dashed var(--accent-gold, #c8a96e);
  outline-offset: -2px;
}

.tree-item.pinned .tree-title::before {
  content: '\f08d';
  font-family: 'ForkAwesome';
  font-size: 9px;
  color: var(--accent-gold, #c8a96e);
  margin-right: 4px;
}

.tree-item .tree-tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold, #c8a96e);
  margin-left: 4px;
  flex-shrink: 0;
}

.tree-item.folder .tree-expand { opacity: 1; }
.tree-item.file .tree-expand { opacity: 0; pointer-events: none; }

.tree-expand {
  font-size: 10px;
  color: var(--text-muted, #8a8474);
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition, 0.2s);
  flex-shrink: 0;
}

.tree-item.tree-expanded .tree-expand { transform: rotate(90deg); }

.tree-icon {
  font-size: 14px;
  color: var(--text-muted, #8a8474);
  width: 16px;
  flex-shrink: 0;
}

.tree-item.folder .tree-icon { color: var(--accent-gold, #c8a96e); }

.tree-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-children { padding-left: 20px; display: none; }
.tree-item.tree-expanded + .tree-children { display: block; }

/* ===== TAGS PANEL ===== */
.sidebar-tags-panel {
  padding: 4px 8px 8px;
  border-top: 1px solid var(--border-color, #3a3528);
  margin-top: 4px;
  flex-shrink: 0;
}

.tags-panel-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #8a8474);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tags-panel-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tags-panel-list .tag-badge { cursor: pointer; font-size: 10px; padding: 2px 6px; }
.tags-panel-list .tag-badge:hover { background: rgba(200, 169, 110, 0.3); }
.tags-panel-empty { font-size: 11px; color: var(--text-muted, #8a8474); font-style: italic; }

/* ===== OUTLINE PANEL ===== */
.sidebar-outline-panel {
  padding: 4px 8px 8px;
  border-top: 1px solid var(--border-color, #3a3528);
  margin-top: 4px;
  flex-shrink: 0;
}

.outline-list { display: flex; flex-direction: column; gap: 2px; }
.outline-item {
  font-size: 12px;
  color: var(--text-secondary, #b8b0a0);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-item:hover { background: var(--bg-hover, #332e26); color: var(--accent-gold, #c8a96e); }
.outline-item.h1 { font-weight: 700; padding-left: 4px; }
.outline-item.h2 { font-weight: 600; padding-left: 12px; }
.outline-item.h3 { font-weight: 500; padding-left: 20px; }
.outline-item.h4 { padding-left: 28px; }
.outline-item.h5 { padding-left: 36px; }
.outline-item.h6 { padding-left: 44px; }
.outline-empty { font-size: 11px; color: var(--text-muted, #8a8474); font-style: italic; }

/* ===== MAIN EDITOR AREA (FIX: removed broken sidebar selector) ===== */
.notes-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* ===== EDITOR PANEL ===== */
.notes-editor-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color, #3a3528);
  flex-shrink: 0;
}

.note-title-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary, #e8e2d4);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 18px;
  font-weight: 700;
  outline: none;
  padding: 4px 0;
}

.note-title-input::placeholder { color: var(--text-muted, #8a8474); }

.editor-actions { display: flex; gap: 4px; }

.editor-action-btn {
  background: none;
  border: none;
  color: var(--text-muted, #8a8474);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 14px;
  border-radius: var(--radius-sm, 6px);
  transition: all var(--transition, 0.2s);
}

.editor-action-btn:hover {
  background: var(--bg-hover, #332e26);
  color: var(--text-primary, #e8e2d4);
}

.editor-action-btn.active {
  color: var(--accent-gold, #c8a96e);
  background: rgba(200, 169, 110, 0.15);
}

.editor-action-btn.delete:hover { color: var(--danger, #f44336); }

/* Editor Tabs (still present in HTML/JS) */
.editor-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-dark, #1a1814);
  border-bottom: 1px solid var(--border-color, #3a3528);
  flex-shrink: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted, #8a8474);
  padding: 8px 20px;
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition, 0.2s);
}

.tab-btn:hover { color: var(--text-primary, #e8e2d4); }
.tab-btn.active {
  color: var(--accent-gold, #c8a96e);
  border-bottom-color: var(--accent-gold, #c8a96e);
}

/* ===== EDITOR BODY ===== */
.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.editor-pane-left { flex: 1; align-items: stretch; }
.editor-pane-right { flex: 1; }

.editor-divider {
  width: 1px;
  background: var(--border-color, #3a3528);
  flex-shrink: 0;
  cursor: col-resize;
  transition: background 0.2s;
}

.editor-divider:hover { background: var(--accent-gold, #c8a96e); }

.notes-main.view-editor-only .editor-divider,
.notes-main.view-editor-only .editor-pane-right { display: none; }

.notes-main.view-preview-only .editor-divider,
.notes-main.view-preview-only .editor-pane-left { display: none; }

.note-editor {
  flex: 1;
  width: 100%;
  background: var(--bg-dark, #1a1814);
  border: none;
  color: var(--text-primary, #e8e2d4);
  padding: 16px;
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  resize: none;
  box-sizing: border-box;
}

.note-editor:focus { outline: none; }

.note-preview {
  flex: 1;
  width: 100%;
  background: var(--bg-dark, #1a1814);
  padding: 16px;
  overflow-y: auto;
  box-sizing: border-box;
  display: none;
}

.note-preview.visible { display: block; }

.editor-body.full-width .note-editor,
.editor-body.full-width .note-preview { width: 100%; }
.editor-body.full-width .note-preview.visible { flex: 1; }

/* ===== AUTOCOMPLETE DROPDOWN ===== */
.autocomplete-dropdown {
  position: fixed;
  z-index: 5500;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--accent-gold, #c8a96e);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  max-height: 200px;
  overflow-y: auto;
  min-width: 220px;
  max-width: 340px;
  display: none;
}

.autocomplete-list { padding: 4px; }

.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary, #e8e2d4);
  cursor: pointer;
  border-radius: var(--radius-sm, 6px);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--bg-hover, #332e26);
}

.autocomplete-item .fa {
  font-size: 11px;
  color: var(--accent-gold, #c8a96e);
}

.autocomplete-item .ac-tag-list {
  margin-left: auto;
  display: flex;
  gap: 2px;
}

.autocomplete-item .ac-tag {
  font-size: 9px;
  background: rgba(200, 169, 110, 0.15);
  color: var(--accent-gold, #c8a96e);
  padding: 1px 4px;
  border-radius: 3px;
}

.autocomplete-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted, #8a8474);
  font-style: italic;
}

/* ===== MARKDOWN PREVIEW STYLES ===== */
.note-preview h1, .note-preview h2, .note-preview h3,
.note-preview h4, .note-preview h5, .note-preview h6 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 700;
  color: var(--text-primary, #e8e2d4);
}

.note-preview h1 { font-size: 1.8em; border-bottom: 1px solid var(--border-color, #3a3528); padding-bottom: 0.3em; }
.note-preview h2 { font-size: 1.5em; }
.note-preview h3 { font-size: 1.2em; }

.note-preview p { margin: 0.8em 0; line-height: 1.6; }
.note-preview strong { font-weight: 700; color: var(--accent-gold, #c8a96e); }
.note-preview em { font-style: italic; }
.note-preview del { color: var(--text-muted, #8a8474); }

.note-preview code {
  background: var(--bg-panel, #2a2620);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #ffd700;
}

.note-preview pre {
  background: var(--bg-panel, #2a2620);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.8em 0;
}

.note-preview pre code { background: none; padding: 0; }

.note-preview ul, .note-preview ol { margin: 0.5em 0; padding-left: 2em; }

/* Task list checkboxes */
.note-preview ul.task-list {
  list-style: none;
  padding-left: 1em;
  margin: 0.5em 0;
}

.note-preview ul.task-list li {
  margin: 6px 0;
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.note-preview ul.task-list li input[type="checkbox"] {
  margin-right: 10px;
  margin-top: 4px;
  accent-color: var(--accent-gold, #c8a96e);
  cursor: pointer;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.note-preview ul.task-list li.checked {
  color: var(--text-muted, #8a8474);
  text-decoration: line-through;
}

.note-preview blockquote {
  border-left: 3px solid var(--accent-gold, #c8a96e);
  margin: 0.8em 0;
  padding: 4px 0 4px 16px;
  color: var(--text-muted, #8a8474);
}

.note-preview a {
  color: var(--accent-gold, #c8a96e);
  text-decoration: underline;
}

.note-preview a:hover { color: var(--accent-gold-light, #dcc088); }

.note-preview hr {
  border: none;
  border-top: 1px solid var(--border-color, #3a3528);
  margin: 1.5em 0;
}

/* GFM Tables */
.note-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
}

.note-preview th, .note-preview td {
  border: 1px solid var(--border-color, #3a3528);
  padding: 8px;
  text-align: left;
}

.note-preview th { background: var(--bg-panel, #2a2620); font-weight: 600; }

/* Wikilinks */
.wikilink {
  color: var(--accent-gold, #c8a96e);
  text-decoration: none;
  cursor: pointer;
  position: relative;
}

.wikilink:hover { text-decoration: underline; color: var(--accent-gold-light, #dcc088); }

.wikilink.broken::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  border-bottom: 1px dashed var(--danger, #f44336);
}

/* ===== BACKLINKS PANEL ===== */
.backlinks-panel {
  border-top: 1px solid var(--border-color, #3a3528);
  flex-shrink: 0;
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.backlinks-panel.collapsed { max-height: 36px; }

.backlinks-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #8a8474);
  transition: background 0.2s;
}

.backlinks-header:hover { background: var(--bg-hover, #332e26); }

.backlinks-header .fa-link { font-size: 11px; }
.backlinks-title { flex: 1; }

.backlinks-count {
  background: var(--bg-dark, #1a1814);
  color: var(--accent-gold, #c8a96e);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.backlinks-chevron {
  font-size: 10px;
  transition: transform 0.2s;
}

.backlinks-panel:not(.collapsed) .backlinks-chevron { transform: rotate(180deg); }

.backlinks-body {
  padding: 0 16px 8px;
  overflow-y: auto;
  max-height: 160px;
}

.backlinks-section { margin-bottom: 8px; }
.backlinks-section:last-child { margin-bottom: 0; }

.backlinks-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #8a8474);
  margin-bottom: 4px;
}

.backlinks-list, .related-list { display: flex; flex-direction: column; gap: 2px; }

.backlink-item, .related-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary, #b8b0a0);
  transition: all 0.2s;
}

.backlink-item:hover, .related-item:hover {
  background: var(--bg-hover, #332e26);
  color: var(--accent-gold, #c8a96e);
}

.backlink-item .fa, .related-item .fa { font-size: 10px; color: var(--text-muted, #8a8474); }

.related-score {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted, #8a8474);
  background: var(--bg-dark, #1a1814);
  padding: 1px 5px;
  border-radius: 3px;
}

.backlinks-empty {
  font-size: 11px;
  color: var(--text-muted, #8a8474);
  font-style: italic;
  padding: 4px 8px;
}

/* ===== EDITOR FOOTER (FIX: added view-toggle-small styles) ===== */
.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-dark, #1a1814);
  border-top: 1px solid var(--border-color, #3a3528);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.note-meta { display: flex; gap: 16px; font-size: 11px; color: var(--text-muted, #8a8474); }
.meta-item { display: flex; align-items: center; gap: 4px; }
.meta-item .fa { font-size: 10px; }

/* Tags Section */
.note-tags-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.note-tags-display { display: flex; flex-wrap: wrap; gap: 4px; }

.tag-badge {
  background: rgba(200, 169, 110, 0.15);
  color: var(--accent-gold, #c8a96e);
  padding: 2px 8px;
  border-radius: var(--radius-sm, 6px);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag-badge .tag-remove { cursor: pointer; opacity: 0.6; transition: opacity 0.2s; }
.tag-badge .tag-remove:hover { opacity: 1; }

.note-tags-input {
  background: transparent;
  border: 1px solid var(--border-color, #3a3528);
  color: var(--text-primary, #e8e2d4);
  padding: 2px 8px;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 11px;
  outline: none;
  min-width: 80px;
  transition: border-color var(--transition, 0.2s);
}

.note-tags-input:focus { border-color: var(--accent-gold, #c8a96e); }
.note-tags-input::placeholder { color: var(--text-muted, #8a8474); }

/* ===== NEW: View Toggle Small (in footer) ===== */
.view-toggle-small {
  display: flex;
  gap: 2px;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  border-radius: var(--radius-sm, 6px);
  padding: 2px;
  margin-left: auto;
  flex-shrink: 0;
}

.view-btn-small {
  background: none;
  border: none;
  color: var(--text-muted, #8a8474);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  border-radius: var(--radius-sm, 6px);
  transition: all var(--transition, 0.2s);
}

.view-btn-small:hover { color: var(--text-primary, #e8e2d4); }
.view-btn-small.active {
  background: var(--accent-gold, #c8a96e);
  color: #1b1a18;
}

/* ===== EMPTY STATE ===== */
.notes-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
}

.notes-empty-state .empty-icon {
  font-size: 64px;
  color: var(--text-muted, #8a8474);
  margin-bottom: 16px;
  opacity: 0.3;
}

.notes-empty-state h2 { font-size: 22px; font-weight: 700; color: var(--text-primary, #e8e2d4); margin-bottom: 8px; }
.notes-empty-state p { font-size: 14px; color: var(--text-muted, #8a8474); margin-bottom: 20px; }

.btn-create-first-note {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-gold, #c8a96e);
  color: #1b1a18;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition, 0.2s);
}

.btn-create-first-note:hover { opacity: 0.9; transform: translateY(-1px); }

/* ===== TOGGLE & ACTION BUTTONS ===== */
.notes-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary, #b8b0a0);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
  transition: all var(--transition, 0.2s);
}

.notes-toggle-btn:hover { background: var(--bg-hover, #332e26); color: var(--text-primary, #e8e2d4); }

.notes-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  color: var(--text-secondary, #b8b0a0);
  padding: 6px 12px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition, 0.2s);
  white-space: nowrap;
}

.notes-action-btn:hover {
  background: var(--bg-hover, #332e26);
  border-color: var(--accent-gold, #c8a96e);
  color: var(--accent-gold, #c8a96e);
}

/* Legacy view buttons (toolbar — kept for backward compat) */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-dark, #1a1814);
  border: 1px solid var(--border-color, #3a3528);
  border-radius: var(--radius-sm, 6px);
  padding: 2px;
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-muted, #8a8474);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  border-radius: var(--radius-sm, 6px);
  transition: all var(--transition, 0.2s);
}

.view-btn:hover { color: var(--text-primary, #e8e2d4); }
.view-btn.active { background: var(--accent-gold, #c8a96e); color: #1b1a18; }

/* ===== SEARCH BOX ===== */
.notes-search-box { position: relative; width: 100%; max-width: 320px; }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted, #8a8474);
  font-size: 13px;
  pointer-events: none;
}

.notes-search-input {
  width: 100%;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  color: var(--text-primary, #e8e2d4);
  padding: 6px 30px 6px 30px;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition, 0.2s);
  box-sizing: border-box;
}

.notes-search-input:focus { border-color: var(--accent-gold, #c8a96e); }

.notes-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted, #8a8474);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
}

.notes-search-clear:hover { color: var(--text-primary, #e8e2d4); }

/* ===== EXPORT DROPDOWN ===== */
.export-dropdown-wrapper { position: relative; }

.export-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  min-width: 240px;
  z-index: 1500;
  padding: 4px 0;
  display: none;
}

.export-dropdown.visible { display: block; }

.export-group-label {
  padding: 6px 14px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #8a8474);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color, #3a3528);
}

.export-group-label:first-child { padding-top: 8px; }

.export-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #e8e2d4);
  transition: background 0.2s;
}

.export-item:hover { background: var(--bg-hover, #332e26); }
.export-item .fa { font-size: 12px; color: var(--accent-gold, #c8a96e); width: 16px; text-align: center; }

.export-divider {
  height: 1px;
  background: var(--border-color, #3a3528);
  margin: 4px 0;
}

/* ===== CONTEXT MENU ===== */
.context-menu {
  position: fixed;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  min-width: 180px;
  z-index: 2000;
  display: none;
  padding: 4px 0;
}

.context-menu.visible { display: block; }

.context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #e8e2d4);
  transition: background var(--transition, 0.2s);
}

.context-item:hover { background: var(--bg-hover, #332e26); }
.context-item .fa { font-size: 12px; color: var(--text-muted, #8a8474); }
.context-item.disabled { opacity: 0.4; cursor: not-allowed; }
.context-item.disabled:hover { background: none; }

.context-divider { height: 1px; background: var(--border-color, #3a3528); margin: 4px 0; }

.editor-context-menu { min-width: 160px; }
.editor-context-menu .context-item { padding: 6px 14px; font-size: 12px; }
.editor-context-menu .context-item .fa { width: 14px; font-size: 12px; }

/* ===== COMMAND PALETTE (no blur) ===== */
.command-palette-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5000;
  display: none;
  align-items: flex-start;
  justify-content: center;
}

.command-palette-modal.visible { display: flex; }

.command-palette-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
}

.command-palette-content {
  position: relative;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--accent-gold, #c8a96e);
  border-radius: var(--radius-lg, 12px);
  width: 90%;
  max-width: 560px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  overflow: hidden;
  margin-top: 12vh;
}

.command-palette-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color, #3a3528);
}

.command-palette-input-wrapper .fa { font-size: 14px; color: var(--accent-gold, #c8a96e); }

.command-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary, #e8e2d4);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 15px;
  outline: none;
}

.command-palette-input::placeholder { color: var(--text-muted, #8a8474); }

.command-palette-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 0;
}

.command-palette-results::-webkit-scrollbar { width: 5px; }
.command-palette-results::-webkit-scrollbar-thumb { background: var(--border-color, #3a3528); border-radius: 3px; }

.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #e8e2d4);
  transition: background 0.15s;
}

.cmd-item:hover, .cmd-item.selected {
  background: var(--bg-hover, #332e26);
}

.cmd-item.selected { border-left: 3px solid var(--accent-gold, #c8a96e); }

.cmd-item .fa { font-size: 12px; color: var(--accent-gold, #c8a96e); width: 16px; text-align: center; }

.cmd-item-type {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #8a8474);
}

.command-palette-footer {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border-color, #3a3528);
  font-size: 11px;
  color: var(--text-muted, #8a8474);
}

.command-palette-footer kbd {
  background: var(--bg-dark, #1a1814);
  border: 1px solid var(--border-color, #3a3528);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
  margin-right: 4px;
}

/* ===== GRAPH MODAL ===== */
.graph-modal .modal-content { display: flex; flex-direction: column; }

.graph-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted, #8a8474);
  background: rgba(26, 24, 20, 0.8);
  padding: 6px 12px;
  border-radius: var(--radius-sm, 6px);
}

.graph-legend-item { display: flex; align-items: center; gap: 4px; }
.graph-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.graph-dot.active-dot { background: var(--accent-gold, #c8a96e); }
.graph-dot.linked-dot { background: #5a5345; }
.graph-line { width: 16px; height: 1px; background: rgba(200, 169, 110, 0.3); display: inline-block; }

/* ===== MODALS ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.visible { display: flex; }

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  border-radius: var(--radius-lg, 12px);
  width: 90%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #3a3528);
}

.modal-header h3 { font-size: 16px; font-weight: 700; margin: 0; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted, #8a8474);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
  transition: all var(--transition, 0.2s);
}

.modal-close:hover { background: var(--bg-hover, #332e26); color: var(--text-primary, #e8e2d4); }

.modal-body { padding: 20px; }

.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #8a8474);
  margin-bottom: 8px;
}

.modal-input {
  width: 100%;
  background: var(--bg-dark, #1a1814);
  border: 1px solid var(--border-color, #3a3528);
  color: var(--text-primary, #e8e2d4);
  padding: 10px 12px;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}

.modal-input:focus { border-color: var(--accent-gold, #c8a96e); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color, #3a3528);
}

.btn-cancel, .btn-confirm {
  padding: 8px 16px;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition, 0.2s);
}

.btn-cancel {
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  color: var(--text-secondary, #b8b0a0);
}

.btn-cancel:hover { background: var(--bg-hover, #332e26); }

.btn-confirm {
  background: var(--accent-gold, #c8a96e);
  border: none;
  color: #1b1a18;
}

.btn-confirm:hover { opacity: 0.9; }

.note-list-results {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 12px;
  border: 1px solid var(--border-color, #3a3528);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-dark, #1a1814);
}

.note-result-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition, 0.2s);
}

.note-result-item:hover, .note-result-item.active { background: var(--bg-hover, #332e26); }

/* ===== SETTINGS MODAL ===== */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1500;
  display: none;
  align-items: center;
  justify-content: center;
}

.settings-modal.visible { display: flex; }

.settings-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.settings-modal-content {
  position: relative;
  background: var(--bg-panel, #2a2620);
  border: 1px solid var(--border-color, #3a3528);
  border-radius: var(--radius-lg, 12px);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #3a3528);
}

.settings-header h2 { font-size: 18px; font-weight: 700; margin: 0; }

.settings-close {
  background: none;
  border: none;
  color: var(--text-muted, #8a8474);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
}

.settings-close:hover { background: var(--bg-hover, #332e26); color: var(--text-primary, #e8e2d4); }

.settings-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color, #3a3528);
}

.settings-nav .tab-btn { padding: 10px 20px; }

.settings-body { padding: 20px; overflow-y: auto; }
.toggles-container { display: flex; flex-direction: column; gap: 8px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.toggle-label { font-size: 13px; color: var(--text-primary, #e8e2d4); }

.setting-select {
  background: var(--bg-dark, #1a1814);
  border: 1px solid var(--border-color, #3a3528);
  color: var(--text-primary, #e8e2d4);
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
  font-family: var(--font-primary, 'Nunito', sans-serif);
  font-size: 12px;
  outline: none;
}

.setting-select:focus { border-color: var(--accent-gold, #c8a96e); }

.settings-divider { height: 1px; background: var(--border-color, #3a3528); margin: 8px 0; }

.shortcut-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.shortcut-table th { text-align: left; font-size: 11px; color: var(--text-muted, #8a8474); text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 8px; border-bottom: 1px solid var(--border-color, #3a3528); }
.shortcut-table td { padding: 6px 8px; font-size: 12px; color: var(--text-primary, #e8e2d4); border-bottom: 1px solid var(--border-color, #3a3528); }
.shortcut-table kbd { background: var(--bg-dark, #1a1814); border: 1px solid var(--border-color, #3a3528); border-radius: 3px; padding: 1px 5px; font-size: 10px; font-family: monospace; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border-color, #3a3528); transition: 0.3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background: var(--text-muted, #8a8474); transition: 0.3s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--accent-gold, #c8a96e); }
.switch input:checked + .slider:before { transform: translateX(16px); background: #1b1a18; }

.btn-install { background: var(--bg-dark, #1a1814); border: 1px solid var(--border-color, #3a3528); color: var(--text-secondary, #b8b0a0); padding: 4px 12px; border-radius: var(--radius-sm, 6px); font-size: 12px; cursor: pointer; }
.btn-install:hover:not(:disabled) { border-color: var(--accent-gold, #c8a96e); color: var(--accent-gold, #c8a96e); }
.btn-install:disabled { opacity: 0.4; cursor: not-allowed; }

.beta-section { margin-top: 8px; }
.beta-header { font-size: 13px; font-weight: 700; color: var(--text-primary, #e8e2d4); margin-bottom: 4px; }
.beta-warning { font-size: 12px; color: var(--text-muted, #8a8474); margin-bottom: 8px; }
.beta-links { display: flex; gap: 8px; }
.beta-btn { display: inline-block; background: var(--bg-dark, #1a1814); border: 1px solid var(--border-color, #3a3528); color: var(--text-secondary, #b8b0a0); padding: 6px 12px; border-radius: var(--radius-sm, 6px); font-size: 12px; text-decoration: none; transition: all 0.2s; }
.beta-btn:hover { border-color: var(--accent-gold, #c8a96e); color: var(--accent-gold, #c8a96e); }

/* ===== ZEN MODE ===== */
[data-zen="true"] .notes-toolbar { display: none !important; }
[data-zen="true"] .notes-container {
  height: 100vh;
  margin-top: 0;
}
[data-zen="true"] .notes-sidebar {
  display: none !important;
}
[data-zen="true"] .notes-main {
  width: 100%;
  flex: 1;
}
[data-zen="true"] .notes-editor-panel {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
[data-zen="true"] .note-editor,
[data-zen="true"] .note-preview {
  padding: 48px 64px;
}
[data-zen="true"] .editor-header,
[data-zen="true"] .editor-tabs,
[data-zen="true"] .editor-footer,
[data-zen="true"] .backlinks-panel {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* ===== PRINT STYLES ===== */
@media print {
  body * { visibility: hidden; }
  #print-frame, #print-frame * { visibility: visible; }
  #print-frame {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    border: none !important;
    display: block !important;
  }
  @page { margin: 2cm; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .notes-toolbar { flex-wrap: wrap; height: auto; padding: 6px 10px; gap: 6px; }
  .notes-toolbar-left, .notes-toolbar-right { order: 1; }
  .notes-toolbar-center { order: 3; width: 100%; max-width: none; }
  .notes-action-btn span { display: none; }
  .notes-container { flex-direction: column; }
  .notes-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    max-width: none !important;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color, #3a3528);
  }
  .notes-sidebar.collapsed {
    max-height: 0;
    border-bottom: none;
  }
  .notes-toolbar { top: 56px; }
  .note-editor, .note-preview { width: 100%; }
  .editor-header { flex-wrap: wrap; }
  .note-title-input { order: 1; width: 100%; }
  .editor-actions { order: 2; margin-left: auto; }
  .editor-divider { display: none; }
  .editor-pane { width: 100%; }
  .command-palette-content { max-width: 95%; margin-top: 5vh; }
  .backlinks-panel { max-height: 120px; }
  .editor-footer { flex-direction: column; align-items: stretch; gap: 6px; }
  .note-meta { justify-content: center; flex-wrap: wrap; }
  .view-toggle-small { margin-left: 0; justify-content: center; }
  [data-zen="true"] .notes-editor-panel { max-width: 100%; }
  [data-zen="true"] .note-editor,
  [data-zen="true"] .note-preview { padding: 24px 20px; }
  [data-zen="true"] .editor-header,
  [data-zen="true"] .editor-tabs,
  [data-zen="true"] .editor-footer,
  [data-zen="true"] .backlinks-panel { max-width: 100%; }
}

@media (max-width: 480px) {
  .notes-action-btn { padding: 6px 8px; }
  .editor-tabs { overflow-x: auto; }
  .tab-btn { padding: 8px 14px; flex-shrink: 0; }
  .export-dropdown { right: -40px; min-width: 200px; }
  .note-meta { gap: 8px; }
}