/* === 极简白底笔记 === */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-hover: #f3f3f3;
  --bg-active: #ececec;
  --border: #ececec;
  --border-soft: #f3f3f3;
  --text: #222;
  --text-soft: #666;
  --text-muted: #999;
  --accent: #222;
  --danger: #d33;
  --warn: #e07a00;
  --pin: #f0a30a;
  --green: #1f9c4a;
  --shadow: 0 2px 12px rgba(0,0,0,.04);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
input, textarea, select { background: transparent; border: 0; outline: none; }

/* 顶部条 */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 18px; height: 50px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 600; font-size: 15px; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 14px; background: transparent; border: 0; cursor: pointer;
  border-radius: 6px; color: var(--text-soft); font-size: 13px;
}
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.badge {
  display: inline-block; min-width: 16px; padding: 0 5px; height: 16px; line-height: 16px;
  font-size: 11px; background: var(--danger); color: #fff; border-radius: 8px; margin-left: 4px;
}
.badge:empty { display: none; }
.search-wrap { flex: 1; max-width: 480px; margin: 0 auto; }
#searchInput {
  width: 100%; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg-soft);
}
#searchInput:focus { background: #fff; border-color: #ccc; }
.actions { display: flex; gap: 8px; }
.btn-link { background: transparent; border: 0; color: var(--text-soft); cursor: pointer; font-size: 13px; padding: 6px 8px; }
.btn-link:hover { color: var(--text); }

/* 视图 */
.view { display: none; height: calc(100vh - 50px); }
.view.active { display: flex; }

/* 笔记三栏 */
.view-notes { display: none; }
.view-notes.active { display: flex; }
.sidebar {
  width: 220px; min-width: 200px;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  overflow-y: auto;
  padding: 12px 0;
}
.side-section { padding: 8px 14px 14px; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 6px; padding: 0 6px;
}
.icon-btn {
  background: transparent; border: 0; cursor: pointer; color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 4px; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.danger:hover { background: #fee; color: var(--danger); }

.nb-list li, .tag-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text-soft);
}
.nb-list li:hover, .tag-list li:hover { background: var(--bg-hover); color: var(--text); }
.nb-list li.active, .tag-list li.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.nb-list .count, .tag-list .count {
  font-size: 11px; color: var(--text-muted); background: rgba(0,0,0,.04);
  padding: 1px 6px; border-radius: 8px;
}
.nb-list li.active .count, .tag-list li.active .count { background: rgba(0,0,0,.08); }

/* 中栏：笔记列表 */
.list-pane {
  width: 300px; min-width: 280px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--bg);
}
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
}
.list-title { font-size: 13px; font-weight: 600; color: var(--text); }
.btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.btn-primary:hover { background: #000; }
.note-list { flex: 1; overflow-y: auto; padding: 4px; }
.note-list .item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 2px;
}
.note-list .item:hover { background: var(--bg-soft); }
.note-list .item.active { background: var(--bg-active); border-color: var(--border); }
.note-list .item-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.note-list .item-snippet {
  font-size: 12px; color: var(--text-muted); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-list .item-foot {
  display: flex; gap: 8px; align-items: center; margin-top: 6px;
  font-size: 11px; color: var(--text-muted);
}
.note-list .item-tag {
  background: rgba(0,0,0,.04); padding: 1px 6px; border-radius: 4px; color: var(--text-soft);
}
.pin-mark { color: var(--pin); font-size: 11px; }

/* 右栏：编辑器 */
.editor-pane {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg); min-width: 0;
}
.empty-hint {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
}
.editor { flex: 1; display: flex; flex-direction: column; }
.editor-head {
  padding: 18px 28px 8px;
  border-bottom: 1px solid var(--border-soft);
}
.title-input {
  width: 100%; font-size: 22px; font-weight: 600; color: var(--text);
  margin-bottom: 10px; padding: 2px 0;
}
.title-input::placeholder { color: var(--text-muted); }
.meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-select, .meta-input {
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px;
  font-size: 12px; color: var(--text-soft); background: var(--bg-soft);
  max-width: 180px;
}
.meta-input { flex: 1; min-width: 160px; }
.save-status {
  font-size: 11px; color: var(--text-muted); margin-left: auto;
}
.save-status.dirty { color: var(--warn); }
.save-status.saved { color: var(--green); }

.editor-body {
  flex: 1; display: flex; min-height: 0;
}
.content-input {
  flex: 1; padding: 18px 28px; resize: none; line-height: 1.7;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px; background: var(--bg);
  border-right: 1px solid var(--border-soft);
}
.preview-pane {
  flex: 1; padding: 18px 28px; overflow-y: auto; line-height: 1.7;
  background: var(--bg);
}
.preview-pane h1 { font-size: 1.8em; margin: .5em 0; border-bottom: 1px solid var(--border); padding-bottom: .2em; }
.preview-pane h2 { font-size: 1.5em; margin: .6em 0; }
.preview-pane h3 { font-size: 1.25em; margin: .6em 0; }
.preview-pane p { margin: .5em 0; }
.preview-pane ul, .preview-pane ol { padding-left: 1.6em; margin: .4em 0; }
.preview-pane li { margin: .15em 0; }
.preview-pane code {
  background: var(--bg-active); padding: 2px 5px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .92em;
}
.preview-pane pre {
  background: #f6f6f6; padding: 12px; border-radius: 8px; overflow-x: auto;
  margin: .5em 0;
}
.preview-pane pre code { background: transparent; padding: 0; }
.preview-pane blockquote {
  border-left: 3px solid #ddd; padding: 2px 12px; color: var(--text-soft);
  margin: .5em 0;
}
.preview-pane img { max-width: 100%; border-radius: 6px; margin: .5em 0; }
.preview-pane a { color: #0a66c2; text-decoration: underline; }
.preview-pane table { border-collapse: collapse; margin: .5em 0; }
.preview-pane th, .preview-pane td { border: 1px solid var(--border); padding: 6px 10px; }
.preview-pane hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }

/* 编辑器底部 */
.editor-foot {
  padding: 8px 28px; font-size: 11px; color: var(--text-muted);
  border-top: 1px solid var(--border-soft);
}

/* 待办视图 */
.view-todos { display: none; }
.view-todos.active { display: flex; }
.todo-pane {
  flex: 1; max-width: 720px; margin: 0 auto;
  width: 100%; padding: 28px 24px;
  overflow-y: auto;
}
.todo-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.todo-head h2 { font-size: 22px; font-weight: 600; }
.todo-filters { display: flex; gap: 6px; }
.chip {
  background: transparent; border: 1px solid var(--border); cursor: pointer;
  padding: 4px 12px; font-size: 12px; border-radius: 14px; color: var(--text-soft);
}
.chip:hover { background: var(--bg-hover); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.todo-add {
  display: flex; gap: 8px; margin-bottom: 18px;
  padding: 12px; background: var(--bg-soft); border-radius: 10px;
  border: 1px solid var(--border);
}
.todo-add input[type="text"], .todo-add input[type="datetime-local"], .todo-add #todoTitle {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff;
}
.todo-add #todoDue { flex: 0 0 200px; }
.todo-add button {
  background: var(--accent); color: #fff; border: 0; padding: 0 18px;
  border-radius: 6px; cursor: pointer;
}
.todo-add button:hover { background: #000; }

.todo-list { display: flex; flex-direction: column; gap: 4px; }
.todo-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 8px; transition: background .15s;
}
.todo-item:hover { background: var(--bg-soft); }
.todo-item.done .todo-text { color: var(--text-muted); text-decoration: line-through; }
.todo-check {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
}
.todo-text { flex: 1; cursor: pointer; }
.todo-text:focus { outline: 1px solid #ccc; outline-offset: 2px; border-radius: 3px; }
.todo-due {
  font-size: 11px; color: var(--text-muted); padding: 2px 8px;
  background: var(--bg-active); border-radius: 4px; white-space: nowrap;
}
.todo-due.overdue { background: #fee; color: var(--danger); }
.todo-due.today { background: #fff4e0; color: var(--warn); }
.todo-edit-due {
  background: transparent; border: 0; cursor: pointer; color: var(--text-muted); font-size: 13px;
}
.todo-edit-due:hover { color: var(--text); }
.todo-del {
  background: transparent; border: 0; cursor: pointer; color: var(--text-muted);
  padding: 4px 6px; border-radius: 4px;
}
.todo-del:hover { background: #fee; color: var(--danger); }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 100;
}
#toast.show { opacity: 1; }

/* 响应式 */
@media (max-width: 900px) {
  .sidebar { width: 180px; min-width: 160px; }
  .list-pane { width: 240px; min-width: 220px; }
  .topbar { gap: 8px; padding: 0 12px; }
  .search-wrap { max-width: none; }
}
@media (max-width: 700px) {
  .sidebar { display: none; }
  .list-pane { width: 100%; }
  .editor-pane.show-mobile { position: fixed; inset: 50px 0 0; background: #fff; z-index: 30; }
  .editor-body { flex-direction: column; }
  .preview-pane { display: none; }
  .preview-pane.show { display: block; }
  .content-input { border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .todo-add { flex-direction: column; }
  .todo-add #todoDue { flex: none; }
}
