/* ── Reset & Vars ── */
:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #111113;
  --surface-3: #19191d;
  --border: #1e1e24;
  --border-light: #28282f;
  --text: #e8e8ed;
  --text-secondary: #8a8a98;
  --text-muted: #55555f;
  --accent: #4d8eff;
  --accent-dim: rgba(77, 142, 255, 0.12);
  --accent-glow: rgba(77, 142, 255, 0.25);
  --danger: #ff4d4d;
  --danger-dim: rgba(255, 77, 77, 0.12);
  --pinned: #f0c340;
  --pinned-dim: rgba(240, 195, 64, 0.1);
  --radius: 10px;
  --radius-lg: 14px;
  --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, textarea { border: 0; background: none; outline: none; }

::selection { background: var(--accent-dim); color: var(--accent); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Layout ── */
.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
  flex-shrink: 0;
}

.logo {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.logo svg { color: var(--accent); }

.btn-new {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  transition: background var(--transition), transform var(--transition);
}
.btn-new:hover { background: #5d96ff; transform: scale(1.05); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 16px 0;
  padding: 0 12px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  width: 100%;
  height: 100%;
  font-size: 0.82rem;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-muted); }

.filters {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  flex-shrink: 0;
}

.filter {
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 999px;
  transition: all var(--transition);
}
.filter:hover { color: var(--text-secondary); background: var(--surface-3); }
.filter.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Notes list ── */
.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}

.note-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
  position: relative;
}
.note-item:hover { background: var(--surface-2); }
.note-item.active {
  background: var(--accent-dim);
  border-color: rgba(77, 142, 255, 0.15);
}
.note-item.pinned::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--pinned);
  opacity: 0.7;
}

.note-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.note-item-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.note-item-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.7;
}

/* ── Sidebar footer ── */
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-clear {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition);
}
.btn-clear:hover { color: var(--danger); background: var(--danger-dim); }
.btn-clear:disabled { opacity: 0.3; pointer-events: none; }

/* ── Editor pane ── */
.editor-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}
.editor-empty-icon {
  width: 80px;
  height: 80px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin-bottom: 8px;
}
.editor-empty h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.02em;
}
.editor-empty p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Active editor ── */
.editor-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.editor-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.save-indicator {
  color: var(--accent);
  font-weight: 600;
  opacity: 0.8;
}

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

.toolbar-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: all var(--transition);
}
.toolbar-btn:hover { background: var(--surface-3); color: var(--text-secondary); }
.toolbar-btn.pinned { color: var(--pinned); background: var(--pinned-dim); }
.btn-danger:hover { color: var(--danger); background: var(--danger-dim); }

.editor-title {
  padding: 28px 32px 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
  color: var(--text);
  flex-shrink: 0;
}
.editor-title::placeholder { color: var(--border-light); }

.editor-body {
  flex: 1;
  padding: 16px 32px 32px;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-secondary);
  resize: none;
  overflow-y: auto;
}
.editor-body::placeholder { color: var(--border-light); }

/* ── Mobile ── */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: 100vh;
  }

  .editor-pane {
    position: fixed;
    inset: 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }

  .editor-pane.open {
    transform: translateX(0);
  }

  .editor-toolbar {
    padding: 14px 16px;
  }

  .editor-toolbar::before {
    content: '← Back';
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    margin-right: auto;
  }

  .editor-title { padding: 20px 16px 0; font-size: 1.4rem; }
  .editor-body { padding: 12px 16px 24px; }
}
