/* ====== 通用 ====== */
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ====== Toolbar 按钮 ====== */
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  color: #4b5563;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.tb-btn:hover { background: #f3f4f6; color: #111827; }
.dark .tb-btn { color: #d1d5db; }
.dark .tb-btn:hover { background: #374151; color: #f9fafb; }
.tb-btn.active { background: #dbeafe; color: #1d4ed8; }
.dark .tb-btn.active { background: #1e3a8a; color: #93c5fd; }

/* ====== 编辑区样式 (Notion-like) ====== */
.editor-area {
  font-size: 15px;
  line-height: 1.7;
  color: #1f2937;
}
.dark .editor-area { color: #e5e7eb; }

.editor-area:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

.editor-area h1 { font-size: 1.875rem; font-weight: 700; margin: 1.2em 0 0.5em; line-height: 1.3; }
.editor-area h2 { font-size: 1.5rem; font-weight: 600; margin: 1em 0 0.4em; line-height: 1.3; }
.editor-area h3 { font-size: 1.25rem; font-weight: 600; margin: 0.8em 0 0.4em; line-height: 1.3; }
.editor-area p { margin: 0.5em 0; }
.editor-area ul, .editor-area ol { padding-left: 1.5em; margin: 0.5em 0; }
.editor-area ul { list-style: disc; }
.editor-area ol { list-style: decimal; }
.editor-area li { margin: 0.2em 0; }
.editor-area blockquote {
  border-left: 3px solid #d1d5db;
  padding-left: 1em;
  color: #6b7280;
  font-style: italic;
  margin: 0.8em 0;
}
.dark .editor-area blockquote { border-left-color: #4b5563; color: #9ca3af; }
.editor-area pre {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 0.8em 1em;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 13px;
  overflow-x: auto;
  margin: 0.8em 0;
  line-height: 1.5;
}
.dark .editor-area pre { background: #1f2937; color: #e5e7eb; }
.editor-area code {
  background: #f3f4f6;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.9em;
}
.dark .editor-area code { background: #1f2937; }
.editor-area a {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-color: #93c5fd;
  text-underline-offset: 2px;
}
.dark .editor-area a { color: #60a5fa; text-decoration-color: #1e40af; }
.editor-area img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.8em 0;
}
.editor-area hr {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 1.5em 0;
}
.dark .editor-area hr { border-top-color: #374151; }

/* ====== 笔记列表卡片 ====== */
.note-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.1s;
}
.dark .note-item { border-bottom-color: #1f2937; }
.note-item:hover { background: #f9fafb; }
.dark .note-item:hover { background: #111827; }
.note-item.active { background: #eff6ff; border-left: 3px solid #2563eb; padding-left: 13px; }
.dark .note-item.active { background: #1e3a8a33; border-left-color: #60a5fa; }

.note-item-title {
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dark .note-item-title { color: #f9fafb; }

.note-item-preview {
  font-size: 12px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
  min-height: 2.8em;
}
.dark .note-item-preview { color: #9ca3af; }

.note-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: #9ca3af;
}

.note-item-tag {
  display: inline-block;
  padding: 1px 6px;
  background: #e0effe;
  color: #1d4ed8;
  border-radius: 3px;
  font-size: 10px;
}
.dark .note-item-tag { background: #1e3a8a40; color: #93c5fd; }

/* ====== 侧边栏项 ====== */
.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  font-size: 13px;
  color: #4b5563;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.nav-item:hover { background: #f3f4f6; }
.dark .nav-item { color: #d1d5db; }
.dark .nav-item:hover { background: #1f2937; }
.nav-item.active { background: #eff6ff; color: #1d4ed8; font-weight: 500; }
.dark .nav-item.active { background: #1e3a8a40; color: #93c5fd; }

.nav-item-count {
  margin-left: auto;
  font-size: 11px;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 0 6px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}
.dark .nav-item-count { background: #1f2937; }

.nav-item-children { margin-left: 12px; border-left: 1px solid #f3f4f6; padding-left: 4px; }
.dark .nav-item-children { border-left-color: #1f2937; }

.nav-item-actions {
  margin-left: auto;
  display: none;
  gap: 2px;
}
.nav-item:hover .nav-item-actions { display: flex; }
.nav-item:hover .nav-item-count { display: none; }

.nav-action-btn {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #6b7280;
  border-radius: 3px;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.nav-action-btn:hover { background: #e5e7eb; color: #111827; }
.dark .nav-action-btn:hover { background: #374151; color: #f9fafb; }

/* ====== 附件缩略图 ====== */
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
  max-width: 200px;
}
.dark .attachment-chip { background: #1f2937; border-color: #374151; }

.attachment-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}
.attachment-thumb.file {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #6b7280;
}

.attachment-info { display: flex; flex-direction: column; min-width: 0; }
.attachment-name { font-size: 12px; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dark .attachment-name { color: #e5e7eb; }
.attachment-size { font-size: 10px; color: #9ca3af; }

.attachment-remove {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.attachment-remove:hover { background: #fee2e2; color: #dc2626; }

/* ====== Toast ====== */
#toast {
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ====== 滚动条 ====== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
.dark ::-webkit-scrollbar-thumb { background: #374151; }
.dark ::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ====== 暗色模式调整 ====== */
.dark body { background: #0f172a; }
.dark header { background: #0f172a; }
.dark aside { background: #0f172a; }
.dark section { background: #0f172a; }

/* ====== 响应式 ====== */
@media (max-width: 768px) {
  main { flex-direction: column; }
  aside { width: 100%; max-height: 30vh; }
  section { width: 100%; }
}
