/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d0d0d; color: #e0e0e0; font-size: 15px; line-height: 1.6;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea { font: inherit; color: inherit; background: none; border: none; outline: none; }
a { color: #7c8cf8; text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ── Login ──────────────────────────────────────────────────── */
#login-overlay {
  position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; background: #0d0d0d; z-index: 1000;
}
.login-box { width: 320px; padding: 40px 32px; background: #161616; border: 1px solid #2a2a2a; border-radius: 8px; }
.login-box h1 { font-size: 18px; font-weight: 600; margin-bottom: 24px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 12px; color: #888; margin-bottom: 6px; letter-spacing: 0.05em; text-transform: uppercase; }
.login-field input { width: 100%; padding: 10px 12px; background: #0d0d0d; border: 1px solid #2a2a2a; border-radius: 4px; font-size: 14px; }
.login-field input:focus { border-color: #7c8cf8; }
.login-error { color: #f87171; font-size: 13px; margin-bottom: 12px; }
.btn-primary { width: 100%; padding: 10px; background: #7c8cf8; color: #fff; border-radius: 4px; font-size: 14px; font-weight: 500; transition: background 0.15s; }
.btn-primary:hover { background: #6b7ef5; }

/* ── App shell ──────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }
header {
  display: flex; align-items: center; height: 44px; min-height: 44px;
  background: #111; border-bottom: 1px solid #222; padding: 0 16px; flex-shrink: 0;
}
.logo { font-size: 14px; font-weight: 600; color: #666; margin-right: 24px; }
.tabs { display: flex; gap: 2px; }
.tab-btn { padding: 0 14px; height: 44px; font-size: 13px; color: #666; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; }
.tab-btn:hover { color: #bbb; }
.tab-btn.active { color: #e0e0e0; border-bottom-color: #7c8cf8; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.kbd-hint { font-size: 11px; color: #444; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; transition: background 0.3s; }
.online-dot.offline { background: #f87171; }
.view { flex: 1; overflow: hidden; display: flex; }

/* ── Notes sidebar ──────────────────────────────────────────── */
#notes-view { display: flex; }
.notes-sidebar { width: 220px; min-width: 220px; background: #111; border-right: 1px solid #1e1e1e; display: flex; flex-direction: column; overflow: hidden; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid #1e1e1e; }
.sidebar-header span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #555; }
.icon-btn { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: #666; font-size: 18px; line-height: 1; transition: background 0.12s, color 0.12s; }
.icon-btn:hover { background: #1e1e1e; color: #ccc; }
.notes-search { padding: 8px 10px; border-bottom: 1px solid #1a1a1a; }
.notes-search input { width: 100%; background: #1a1a1a; border-radius: 4px; padding: 5px 8px; font-size: 13px; color: #ccc; }
.notes-search input::placeholder { color: #444; }
.notes-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.note-item { padding: 8px 12px; cursor: pointer; border-left: 2px solid transparent; transition: background 0.1s; }
.note-item:hover { background: #181818; }
.note-item.active { background: #1a1a2a; border-left-color: #7c8cf8; }
.note-item-title { font-size: 13px; color: #ccc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item-date { font-size: 11px; color: #444; margin-top: 2px; }
.note-item-snippet { font-size: 11px; color: #555; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-btn-wrap { padding: 10px 12px; border-top: 1px solid #1e1e1e; }
.import-btn-wrap button { width: 100%; padding: 7px; font-size: 12px; color: #666; background: #1a1a1a; border-radius: 4px; border: 1px solid #2a2a2a; transition: color 0.12s, border-color 0.12s; }
.import-btn-wrap button:hover { color: #ccc; border-color: #444; }

/* ── Note editor ────────────────────────────────────────────── */
.note-editor-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.editor-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 16px; border-bottom: 1px solid #1a1a1a; background: #111; flex-shrink: 0; }
.note-title-input { flex: 1; font-size: 15px; font-weight: 600; color: #e0e0e0; }
.note-title-input::placeholder { color: #333; }
.del-note-btn { color: #555; font-size: 12px; padding: 3px 8px; }
.del-note-btn:hover { color: #f87171; }
.editor-body { flex: 1; display: flex; overflow: hidden; }
#note-cm-mount { flex: 1; overflow: hidden; min-width: 0; }

/* ── Table of Contents ──────────────────────────────────────── */
.note-toc {
  width: 170px; min-width: 170px; overflow-y: auto;
  padding: 14px 0; border-left: 1px solid #1a1a1a; background: #0d0d0d;
}
.toc-item {
  padding: 3px 12px; font-size: 11.5px; color: #4a4a4a; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color 0.12s; line-height: 1.6;
}
.toc-item:hover { color: #aaa; }
.toc-h1 { color: #666; font-weight: 600; padding-left: 12px; }
.toc-h2 { padding-left: 16px; }
.toc-h3 { padding-left: 24px; }
.toc-h4, .toc-h5, .toc-h6 { padding-left: 32px; font-size: 11px; }

/* ── Markdown rendered ──────────────────────────────────────── */
.md-content h1 { font-size: 1.6em; font-weight: 700; margin: 0.8em 0 0.4em; color: #fff; }
.md-content h2 { font-size: 1.3em; font-weight: 600; margin: 0.8em 0 0.3em; color: #e8e8e8; }
.md-content h3 { font-size: 1.1em; font-weight: 600; margin: 0.7em 0 0.3em; color: #d4d4d4; }
.md-content p { margin: 0.4em 0; }
.md-content hr { border: none; border-top: 1px solid #2a2a2a; margin: 1.2em 0; }
.md-content code { font-family: "JetBrains Mono","Fira Code",monospace; font-size: 0.87em; background: #1a1a1a; padding: 2px 5px; border-radius: 3px; color: #a5b4fc; }
.md-content pre { background: #161616; border: 1px solid #222; border-radius: 6px; padding: 14px 16px; overflow-x: auto; margin: 0.8em 0; }
.md-content pre code { background: none; padding: 0; color: #d4d4d4; }
.md-content ul, .md-content ol { padding-left: 1.4em; margin: 0.4em 0; }
.md-content li { margin: 0.15em 0; }
.md-content blockquote { border-left: 3px solid #3a3a5a; margin: 0.6em 0; padding: 4px 12px; color: #888; }
.md-content ul.task-list { list-style: none; padding-left: 0; }
.md-content .task-item { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; }
.md-content .task-item input[type="checkbox"] { margin-top: 4px; cursor: pointer; accent-color: #7c8cf8; width: 14px; height: 14px; flex-shrink: 0; }
.md-content .task-item.done .task-text { text-decoration: line-through; color: #555; }
.md-content .task-text { flex: 1; }

/* ── Boards bar ─────────────────────────────────────────────── */
#tasks-view { flex-direction: column; }
.boards-bar { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: #111; border-bottom: 1px solid #1e1e1e; flex-shrink: 0; overflow-x: auto; }
.board-chip-wrap { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.board-chip { padding: 4px 12px; font-size: 13px; border-radius: 20px; border: 1px solid #2a2a2a; color: #777; white-space: nowrap; transition: all 0.12s; }
.board-chip:hover { border-color: #555; color: #ccc; }
.board-chip.active { border-color: #7c8cf8; color: #a5b4fc; background: #1a1a2a; }
.board-del-btn {
  width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 1;
  color: #3a3a3a; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s; flex-shrink: 0;
}
.board-del-btn:hover { background: #2a1010; color: #f87171; }
.add-board-btn { padding: 4px 12px; font-size: 13px; border-radius: 20px; border: 1px dashed #2a2a2a; color: #555; white-space: nowrap; flex-shrink: 0; transition: all 0.12s; }
.add-board-btn:hover { border-color: #555; color: #999; }
.board-chip-wrap.dragging { opacity: 0.4; }
.board-chip-wrap.drag-over .board-chip { border-color: #7c8cf8; background: #1a1a2a; }

/* ── Bulk actions ───────────────────────────────────────────── */
.bulk-actions { display: flex; align-items: center; gap: 8px; padding: 6px 16px; background: #161616; border-bottom: 1px solid #1e1e1e; flex-shrink: 0; }
.bulk-actions span { font-size: 13px; color: #888; }
.danger-btn { padding: 4px 12px; font-size: 12px; color: #f87171; border: 1px solid #3a1a1a; border-radius: 4px; transition: background 0.12s; }
.danger-btn:hover { background: #2a1010; }
.cancel-sel-btn { padding: 4px 10px; font-size: 12px; color: #555; }
.cancel-sel-btn:hover { color: #999; }

/* ── Kanban ─────────────────────────────────────────────────── */
.kanban-board { flex: 1; overflow-x: auto; overflow-y: hidden; display: flex; gap: 12px; padding: 16px; align-items: flex-start; }
.kanban-col {
  width: 260px; min-width: 260px; background: #141414; border: 1px solid #1e1e1e;
  border-radius: 8px; display: flex; flex-direction: column; max-height: 100%; flex-shrink: 0;
  transition: opacity 0.15s;
}
.kanban-col.col-dragging { opacity: 0.35; }
.kanban-col.col-drag-over { border-color: #7c8cf8; border-style: dashed; }
.col-header { display: flex; align-items: center; padding: 10px 10px 8px; flex-shrink: 0; }
.col-drag-handle {
  color: #2a2a2a; font-size: 14px; padding: 2px 4px; margin-right: 4px;
  cursor: grab; user-select: none; flex-shrink: 0;
  transition: color 0.12s;
}
.col-drag-handle:hover { color: #666; }
.col-drag-handle:active { cursor: grabbing; }
.col-name {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: #666; flex: 1; cursor: pointer; user-select: none;
}
.col-name:hover { color: #999; }
.col-count { font-size: 11px; color: #333; margin-right: 6px; }
.add-task-btn { color: #444; font-size: 18px; line-height: 1; margin-right: 2px; }
.add-task-btn:hover { color: #888; }
.col-delete-btn { color: #2a2a2a; font-size: 13px; }
.col-delete-btn:hover { color: #f87171; }
.tasks-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.tasks-list.drop-active { background: rgba(124,140,248,0.05); border-radius: 4px; }

/* ── Task cards ─────────────────────────────────────────────── */
.task-card {
  background: #1a1a1a; border: 1px solid #252525; border-radius: 6px;
  padding: 10px 12px; cursor: default;
  transition: border-color 0.12s, background 0.12s;
}
.task-card:hover { border-color: #333; background: #1e1e1e; }
.task-card.selected { border-color: #7c8cf8; background: #1a1a2a; }
/* Done column styling */
.col-done .task-card { border-left: 2px solid #166534; }
.col-done .task-title { color: #4a4a4a; text-decoration: line-through; }
.col-done .task-done-btn { color: #4ade80; border-color: #166534; }
.col-done .task-done-btn:hover { background: rgba(74,222,128,0.1); }
.task-card-header { display: flex; align-items: flex-start; gap: 8px; }
.task-select-cb { margin-top: 3px; cursor: pointer; accent-color: #7c8cf8; flex-shrink: 0; }
.task-title { font-size: 13px; color: #ccc; flex: 1; line-height: 1.4; cursor: pointer; }
.task-title:hover { color: #e0e0e0; }
.task-done-btn {
  width: 20px; height: 20px; border-radius: 50%; font-size: 11px; line-height: 1;
  border: 1px solid #2a2a2a; color: #2a2a2a; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.task-done-btn:hover { border-color: #4ade80; color: #4ade80; background: rgba(74,222,128,0.08); }
.task-has-desc { font-size: 10px; color: #3a3a3a; margin-top: 4px; margin-left: 24px; }
.add-col-card {
  width: 260px; min-width: 260px; flex-shrink: 0; border: 1px dashed #222; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; height: 52px; color: #444;
  font-size: 13px; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.add-col-card:hover { border-color: #444; color: #888; }
.no-board-msg { flex: 1; display: flex; align-items: center; justify-content: center; color: #333; flex-direction: column; gap: 12px; }
.no-board-msg button { padding: 8px 20px; border: 1px solid #2a2a2a; border-radius: 6px; color: #666; font-size: 13px; transition: all 0.12s; }
.no-board-msg button:hover { border-color: #555; color: #ccc; }

/* ── Task modal ─────────────────────────────────────────────── */
#task-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 500; }
.modal-box { width: 580px; max-width: 95vw; max-height: 88vh; background: #161616; border: 1px solid #2a2a2a; border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid #1e1e1e; flex-shrink: 0; }
.modal-title-input { flex: 1; font-size: 15px; font-weight: 600; color: #e0e0e0; }
.modal-title-input::placeholder { color: #333; }
.modal-close-btn { color: #555; font-size: 18px; }
.modal-close-btn:hover { color: #ccc; }
.modal-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.modal-section-label { font-size: 11px; color: #555; text-transform: uppercase; letter-spacing: 0.07em; padding: 10px 16px 4px; flex-shrink: 0; }
#modal-editor-mount {
  flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column;
  background: #0d0d0d;
}
#modal-editor-mount .cm-editor { flex: 1; min-height: 200px; }
.modal-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid #1e1e1e; flex-shrink: 0; }
.save-btn { padding: 6px 16px; background: #7c8cf8; color: #fff; border-radius: 4px; font-size: 13px; font-weight: 500; transition: background 0.12s; }
.save-btn:hover { background: #6b7ef5; }
.del-task-btn { padding: 6px 12px; color: #555; font-size: 13px; }
.del-task-btn:hover { color: #f87171; }

/* ── Quick Switcher & Command Palette ───────────────────────── */
#quick-switcher, #cmd-palette {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 100px; z-index: 800;
}
.switcher-box, .palette-box {
  width: 520px; max-width: 94vw; background: #181818;
  border: 1px solid #333; border-radius: 10px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.switcher-input, .palette-input {
  width: 100%; padding: 14px 16px; font-size: 15px; color: #e0e0e0;
  background: transparent; border-bottom: 1px solid #2a2a2a;
}
.switcher-input::placeholder, .palette-input::placeholder { color: #444; }
.switcher-list, .palette-list { max-height: 340px; overflow-y: auto; }
.switcher-item, .palette-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  cursor: pointer; transition: background 0.1s;
}
.switcher-item:hover, .switcher-item.sel,
.palette-item:hover, .palette-item.sel { background: #222; }
.switcher-item-icon, .palette-item-icon { color: #555; font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.switcher-item-title, .palette-item-label { font-size: 14px; color: #ccc; flex: 1; }
.switcher-item-date { font-size: 11px; color: #444; }
.switcher-item-snippet { font-size: 11px; color: #555; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.switcher-empty { padding: 20px 16px; color: #444; font-size: 13px; text-align: center; }

/* ── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ── Toast ──────────────────────────────────────────────────── */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1e1e1e; border: 1px solid #333; color: #ccc; padding: 8px 18px; border-radius: 20px; font-size: 13px; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 999; }
#toast.show { opacity: 1; }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .notes-sidebar { width: 180px; min-width: 180px; }
  .kanban-col { width: 220px; min-width: 220px; }
  .logo, .kbd-hint { display: none; }
}
