/* ── Notes ───────────────────────────────────────────────── */
.notes-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}
.notes-layout.has-editor {
  grid-template-columns: 320px 1fr;
  gap: var(--space-5);
}

/* Notes list */
.notes-list-panel { display: flex; flex-direction: column; gap: var(--space-3); }

.notes-grid {
  columns: 2;
  column-gap: var(--space-4);
}
.notes-grid .empty-state {
  column-span: all;
}
.notes-grid .note-card {
  break-inside: avoid;
  margin-bottom: var(--space-4);
  display: inline-block;
  width: 100%;
}

.note-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  position: relative;
  animation: scaleIn 0.2s ease;
}
.note-card:hover,
.note-card:focus-within,
.note-card:focus-visible { border-color: var(--bg-hover); transform: translateY(-1px); }
.note-card.active { border-color: var(--accent); }
.note-card.pinned { border-top: 3px solid var(--warning); }

.note-card-accent { position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

.note-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.note-card-title { font-size: var(--text-sm); font-weight: 600; line-height: 1.4; flex: 1; }
.note-card-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--transition-fast); }
.note-card:hover .note-card-actions,
.note-card:focus-within .note-card-actions,
.note-card:focus-visible .note-card-actions { opacity: 1; }

.note-card-preview {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  margin-bottom: var(--space-3);
}
.note-card-footer { display: flex; align-items: center; justify-content: space-between; }
.note-date { font-size: 11px; color: var(--text-muted); }
.note-pin-icon { color: var(--warning); }
.linked-bookmarks-count { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); }

/* Editor */
.note-editor-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: 500px;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg-tertiary);
}
.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar-btn.active { background: var(--accent-light); color: var(--accent); }
.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.editor-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.editor-title-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  padding: 0;
}
.editor-title-input::placeholder { color: var(--text-muted); }
.editor-save-status { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
.editor-save-status.saving { color: var(--warning); }
.editor-save-status.saved  { color: var(--success); }

.note-body {
  flex: 1;
  padding: var(--space-5);
  outline: none;
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-primary);
  min-height: 300px;
  overflow-y: auto;
  word-break: break-word;
}
.note-body[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.note-body h1, .note-body h2, .note-body h3 { margin: var(--space-4) 0 var(--space-2); }
.note-body p { margin-bottom: var(--space-3); }
.note-body ul, .note-body ol { margin: var(--space-2) 0 var(--space-3) var(--space-6); }
.note-body li { margin-bottom: var(--space-1); }
.note-body code { background: var(--bg-hover); padding: 2px 6px; border-radius: var(--radius-sm); font-family: var(--font-mono); }
.note-body blockquote { border-left: 3px solid var(--accent); padding-left: var(--space-4); color: var(--text-secondary); font-style: italic; margin: var(--space-3) 0; }

/* Markdown preview */
.note-body.preview-mode { background: var(--bg-secondary); }

/* Linked bookmarks section */
.editor-linked {
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
}
.linked-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.linked-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.linked-chip { display: flex; align-items: center; gap: var(--space-1); padding: 3px var(--space-2); background: var(--bg-hover); border: 1px solid var(--border); border-radius: var(--radius-full); font-size: var(--text-xs); color: var(--text-secondary); text-decoration: none; transition: all var(--transition-fast); max-width: 100%; min-width: 0; }
.linked-chip span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-chip:hover { border-color: var(--accent); color: var(--accent); }
.linked-chip img { width: 12px; height: 12px; border-radius: 1px; }
.linked-chip-remove { color: var(--text-muted); cursor: pointer; }
.linked-chip-remove:hover { color: var(--danger); }

/* Note color picker */
.color-picker { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.color-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform var(--transition-fast), border-color var(--transition-fast); }
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--text-primary); }

@media (max-width: 1024px) {
  .notes-layout.has-editor { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .notes-grid { columns: 1; }
  .note-editor-panel { min-height: 420px; }
  .notes-layout.has-editor { gap: var(--space-4); }
  .editor-toolbar { gap: var(--space-1); overflow-x: auto; flex-wrap: nowrap; }
  .toolbar-sep { display: none; }
  .editor-meta { align-items: stretch; flex-direction: column; gap: var(--space-2); }
  .editor-title-input { font-size: var(--text-lg); }
  .note-body { padding: var(--space-4); min-height: 260px; }
  .linked-chips { align-items: flex-start; }
  .note-card-actions { opacity: 1; }
}

@media (hover: none), (pointer: coarse) {
  .note-card-actions { opacity: 1; }
  .note-card:hover { transform: none; }
  .toolbar-btn,
  .color-swatch {
    min-width: 44px;
    min-height: 44px;
  }
}
