/* ============================================================
 * 笔记页样式：三栏（笔记本 / 列表 / 编辑器）+ Markdown 预览
 * ============================================================ */
body { background: #f3f4f7; }

.notes-shell {
  display: flex;
  height: calc(100vh - 57px);
  overflow: hidden;
  background: #fff;
}

/* ---------------- 左：笔记本 / 标签 ---------------- */
.notes-side {
  width: 236px; flex: none; min-width: 170px; max-width: 560px; display: flex; flex-direction: column;
  background: #fbfbfd; border-right: 1px solid var(--cal-border, #e6e8ee);
}
.ns-top { padding: 14px 12px 8px; }
.ns-new { width: 100%; }
.ns-scroll { flex: 1; overflow: auto; padding: 4px 8px 20px; }
.ns-item {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px;
  border-radius: 8px; font-size: 13.5px; color: #334155; cursor: pointer;
}
.ns-item:hover { background: rgba(37, 99, 235, .06); }
.ns-item.active { background: rgba(37, 99, 235, .1); color: var(--primary-dark); font-weight: 600; }
.ns-item .icon { width: 16px; height: 16px; color: #64748b; }
.ns-item.active .icon { color: var(--primary); }
.ns-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ns-count { font-size: 11px; color: #94a3b8; }
.ns-sec {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 9px 5px; font-size: 11px; font-weight: 600;
  color: #94a3b8; text-transform: uppercase; letter-spacing: .04em;
}
.ns-add {
  border: none; background: transparent; color: #94a3b8; cursor: pointer;
  font-size: 14px; line-height: 1; border-radius: 5px; padding: 1px 6px;
}
.ns-add:hover { background: rgba(0, 0, 0, .06); color: var(--primary); }
.ns-empty { font-size: 12px; color: #9ca3af; padding: 3px 9px; }
.ns-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 7px; }
.ns-tag {
  border: 1px solid #e2e8f0; background: #fff; border-radius: 12px;
  padding: 2px 9px; font-size: 11.5px; color: #475569; cursor: pointer;
}
.ns-tag i { font-style: normal; color: #94a3b8; margin-left: 3px; font-size: 10.5px; }
.ns-tag:hover { border-color: #bfdbfe; background: #f8fbff; }
.ns-tag.active { background: rgba(37, 99, 235, .1); border-color: var(--primary); color: var(--primary-dark); }
.ns-share { margin: 10px 8px 0; padding: 9px 10px; background: #fff; border: 1px solid #e6e8ee; border-radius: 9px; }
.ns-share-label { font-size: 11px; color: #94a3b8; margin-bottom: 3px; }
.ns-share-url { font-size: 11px; color: #475569; word-break: break-all; }

/* 笔记本树 */
.nt-level { display: block; }
.notes-resizer { width: 5px; flex:none; cursor:col-resize; background:transparent; position:relative; z-index:2; }
.notes-resizer:hover, body.notes-resizing .notes-resizer { background:#bfdbfe; }
body.notes-resizing { cursor:col-resize; user-select:none; }
.nt-node .nt-level { margin-left: 8px; border-left: 1px dashed #dbe7f7; }
.nt-row { min-height: 27px; }
.nt-ico { flex: none; }
.nt-count { flex: none; }
.nt-row {
  display: flex; align-items: center; gap: 4px; padding: 5px 7px 5px 4px;
  border-radius: 7px; font-size: 13px; color: #334155; cursor: pointer;
}
.nt-row:hover { background: rgba(37, 99, 235, .06); }
.nt-row.active { background: rgba(37, 99, 235, .1); color: var(--primary-dark); font-weight: 600; }
.nt-arrow { width: 14px; flex: none; text-align: center; font-size: 10px; color: #94a3b8; cursor: pointer; }
.nt-ico { width: 15px; height: 15px; color: #eab308; fill: rgba(234, 179, 8, .15); }
.nt-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-count { font-size: 10.5px; color: #94a3b8; }
.nt-ops { display: flex; gap: 2px; opacity: 0; }
.nt-row:hover .nt-ops { opacity: 1; }
.nt-ops i {
  font-style: normal; font-size: 11px; color: #64748b; cursor: pointer;
  padding: 1px 3px; border-radius: 4px;
}
.nt-ops i:hover { background: rgba(0, 0, 0, .07); color: var(--primary); }
.nt-ops i.danger:hover { color: var(--danger); }

/* ---------------- 中：笔记列表 ---------------- */
.notes-list {
  width: 336px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid #e6e8ee; background: #fff;
}
.nl-head { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.nl-search { position: relative; display: flex; align-items: center; }
.nl-search .icon {
  position: absolute; left: 10px; width: 15px; height: 15px; color: #94a3b8;
}
.nl-search input {
  width: 100%; padding: 8px 28px 8px 32px; border: 1px solid #e2e8f0;
  border-radius: 9px; font-size: 13px; background: #f8fafc; outline: none;
}
.nl-search input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.nl-clear { position: absolute; right: 7px; border: none; background: transparent; cursor: pointer; color: #94a3b8; }
.nl-tools { display: flex; gap: 6px; align-items: center; }
.nl-sort { width: auto; padding: 5px 8px; font-size: 12px; }
.nl-caption {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px 8px; font-size: 12px; color: #64748b;
  border-bottom: 1px solid #f1f5f9;
}
.link-btn { border: none; background: none; color: var(--primary); cursor: pointer; font-size: 12px; padding: 0; }
.link-btn.danger { color: var(--danger); }
.nl-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 20px; }
.note-item {
  padding: 9px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent;
}
.note-item:hover { background: #f8fafc; }
.note-item.active { background: #eff6ff; border-color: #bfdbfe; }
.ni-row { display: flex; align-items: center; gap: 6px; }
.ni-title {
  font-size: 13.5px; font-weight: 600; color: #1f2937; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ni-pin { font-size: 10px; color: #d97706; background: #fffbeb; border-radius: 4px; padding: 0 4px; }
.ni-vis { display: inline-flex; color: #64748b; }
.ni-vis .icon { width: 13px; height: 13px; }
.ni-excerpt {
  font-size: 12px; color: #64748b; margin-top: 3px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.ni-meta {
  display: flex; align-items: center; gap: 7px; margin-top: 5px;
  font-size: 10.5px; color: #94a3b8; overflow: hidden;
}
.ni-meta .spacer { flex: 1; }
.ni-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nl-more { width: 100%; margin-top: 10px; font-size: 12px; }

/* ---------------- 右：编辑器 ---------------- */
.notes-editor { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.ne-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 8px; border-bottom: 1px solid #f1f5f9;
}
.ne-title {
  flex: 1; min-width: 0; border: none; outline: none;
  font-size: 20px; font-weight: 650; color: #0f172a; padding: 4px 2px;
}
.ne-title::placeholder { color: #cbd5e1; }
.ne-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.ne-state { font-size: 11.5px; color: #94a3b8; margin-right: 4px; white-space: nowrap; }
.ne-state.dirty { color: #d97706; }
.ne-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid #e2e8f0; background: #fff; color: #475569;
  padding: 4px 9px; border-radius: 7px; font-size: 12px; cursor: pointer;
}
.ne-btn:hover { background: #f8fafc; color: var(--primary); }
.ne-btn.active { background: rgba(37, 99, 235, .09); border-color: #bfdbfe; color: var(--primary-dark); }
.ne-btn.danger:hover { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.ne-btn .icon { width: 14px; height: 14px; }

.ne-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 14px; border-bottom: 1px solid #f1f5f9; background: #fcfdff;
}
.ne-folder { width: 130px; padding: 5px 7px; font-size: 12px; }
.ne-tags { width: 150px; padding: 5px 8px; font-size: 12px; }
.ne-format { width: 108px; padding: 5px 7px; font-size: 12px; }
.ne-btn.pin { padding: 4px 7px; }
.ne-btn.pin.active { color: #d97706; background: #fffbeb; border-color: #fde68a; }
.ne-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.md-btn {
  border: none; background: transparent; color: #475569; cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px; display: inline-flex;
  align-items: center; justify-content: center;
}
.md-btn:hover { background: #eef2f7; color: var(--primary); }
.md-btn .icon { width: 15px; height: 15px; }
.md-sep { width: 1px; height: 15px; background: #e2e8f0; margin: 0 3px; }

.ne-body { flex: 1; min-height: 0; display: flex; }
.ne-edit-pane { flex: 1; min-width: 0; display: flex; }
.ne-textarea {
  flex: 1; width: 100%; border: none; outline: none; resize: none;
  padding: 18px 22px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "PingFang SC", monospace;
  font-size: 13.5px; line-height: 1.75; color: #1f2937; background: #fff;
}
.ne-preview-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 18px 26px 40px; }
.mode-edit .ne-preview-pane { display: none; }
.mode-split .ne-edit-pane { border-right: 1px solid #f1f5f9; }
.mode-split .ne-edit-pane, .mode-split .ne-preview-pane { width: 50%; flex: none; }
.mode-preview .ne-edit-pane { display: none; }
.mode-preview .ne-preview-pane { max-width: 860px; margin: 0 auto; width: 100%; }

.ne-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 16px; border-top: 1px solid #f1f5f9;
  font-size: 11.5px; color: #94a3b8; min-height: 30px;
}
.ne-foot .spacer { flex: 1; }
.ne-error { color: var(--danger); }
.ne-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; color: #94a3b8; font-size: 14px;
}
.ne-empty .icon { width: 46px; height: 46px; opacity: .35; }

/* ---------------- Markdown 预览 ---------------- */
.md-body { font-size: 14.5px; line-height: 1.75; color: #1f2937; word-wrap: break-word; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 {
  margin: 1.15em 0 .5em; line-height: 1.35; color: #0f172a;
}
.md-body h1 { font-size: 25px; border-bottom: 1px solid #e2e8f0; padding-bottom: .28em; }
.md-body h2 { font-size: 20px; border-bottom: 1px solid #eef2f7; padding-bottom: .22em; }
.md-body h3 { font-size: 17px; }
.md-body p { margin: .55em 0; }
.md-body a { color: var(--primary); }
.md-body code {
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 5px;
  padding: .08em .34em; font-size: 87%;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.md-body pre {
  background: #0f172a; color: #e2e8f0; border-radius: 10px;
  padding: 13px 17px; overflow: auto; margin: .8em 0;
}
.md-body pre code { background: none; border: none; color: inherit; padding: 0; font-size: 12.5px; }
.md-body blockquote {
  border-left: 4px solid #c7d2fe; background: #f8faff;
  margin: .8em 0; padding: 6px 16px; color: #475569; border-radius: 0 8px 8px 0;
}
.md-body ul, .md-body ol { padding-left: 1.55em; margin: .55em 0; }
.md-body li { margin: .16em 0; }
.md-body li.task { list-style: none; margin-left: -1.25em; }
.md-body .task-box {
  display: inline-block; width: 13px; height: 13px; border: 1.5px solid #94a3b8;
  border-radius: 3px; margin-right: 7px; vertical-align: -2px; background: #fff;
}
.md-body .task-box.done { background: var(--primary); border-color: var(--primary); position: relative; }
.md-body .task-box.done::after {
  content: ''; position: absolute; left: 3px; top: 0; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.md-body hr { border: none; border-top: 1px solid #e2e8f0; margin: 1.5em 0; }
.md-body img { max-width: 100%; border-radius: 8px; margin: .3em 0; }
.md-body table { border-collapse: collapse; margin: .7em 0; display: block; overflow-x: auto; max-width: 100%; }
.md-body th { background: #f8fafc; }
.md-body th, .md-body td { border: 1px solid #e2e8f0; padding: 5px 11px; }
.md-body .plain-text {
  white-space: pre-wrap; background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 16px; font-size: 13px;
}

/* ---------------- 分享弹窗 ---------------- */
.share-modal { max-width: 540px; }
.share-vis { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.share-opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px;
  border: 1px solid #e2e8f0; border-radius: 10px; cursor: pointer; background: #fff;
}
.share-opt input { display: none; }
.share-opt .icon { width: 17px; height: 17px; color: #64748b; flex: none; }
.share-opt div { display: flex; flex-direction: column; }
.share-opt b { font-size: 13px; font-weight: 600; }
.share-opt span { font-size: 11.5px; color: #94a3b8; }
.share-opt:hover { border-color: #bfdbfe; }
.share-opt.active { border-color: var(--primary); background: #eff6ff; box-shadow: 0 0 0 1px var(--primary) inset; }
.share-slug { display: flex; align-items: center; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.share-slug-prefix { padding: 9px 8px 9px 12px; font-size: 12px; color: #64748b; background: #f8fafc; white-space: nowrap; }
.share-slug .input { border: none; border-radius: 0; box-shadow: none; }
.share-url-row { display: flex; gap: 6px; }
.share-url-row .input { flex: 1; }

/* ---------------- 图床弹窗 ---------------- */
.images-modal { max-width: 760px; }
.images-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.image-card { border: 1px solid #e6e8ee; border-radius: 10px; overflow: hidden; background: #fff; }
.image-card img { width: 100%; height: 110px; object-fit: cover; display: block; background: #f8fafc; }
.image-ops { display: flex; gap: 4px; padding: 6px; flex-wrap: wrap; }
.image-ops .btn { flex: 1; padding: 3px 5px; font-size: 11px; }
.images-foot { margin-top: 14px; text-align: center; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .notes-side { width: 200px; }
  .notes-list { width: 288px; }
  .ne-tags { width: 110px; }
}
@media (max-width: 860px) {
  .notes-side { display: none; }
  .notes-list { width: 250px; }
  .ne-title { font-size: 17px; }
  .mode-split .ne-edit-pane, .mode-split .ne-preview-pane { width: 100%; flex: 1; }
  .mode-split .ne-preview-pane { display: none; }
}
@media (max-width: 640px) {
  .notes-shell { flex-direction: column; height: auto; }
  .notes-list { width: 100%; max-height: 32vh; border-right: none; border-bottom: 1px solid #e6e8ee; }
  .notes-editor { min-height: 70vh; }
  .ne-toolbar { overflow-x: auto; flex-wrap: nowrap; }
  .ne-tools { margin-left: 0; }
}
