/* ============================================================
   读书笔记 · 知识树（思维导图）+ 封面选择器
   与 book.css 分层：book.css 管书架/表单，本文件管画布与选择器
   ============================================================ */

/* ---------- 视图切换（大纲 / 画布） ---------- */
.mind-tabs {
  display: flex; gap: 3px; padding: 3px; margin: 2px 16px 10px;
  background: rgba(255, 255, 255, .68); border: 1px solid var(--line); border-radius: 10px;
}
.mind-tabs button {
  flex: 1; height: 31px; border: 0; border-radius: 8px; background: none;
  font-size: 12px; color: var(--ink-500); display: inline-flex; align-items: center;
  justify-content: center; gap: 5px; padding: 0; transition: color .16s;
}
.mind-tabs button .ic { width: 13px; height: 13px; }
.mind-tabs button.on { background: #fff; color: var(--wood-900); font-weight: 600; box-shadow: var(--shadow-card); }

/* ============================================================
   大纲视图
   ============================================================ */
.outline { padding: 2px 14px 24px; }

.ol-row {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 7px 6px; border-radius: 9px; cursor: pointer;
  transition: background .14s;
}
.ol-row:hover { background: rgba(255, 255, 255, .78); }
.ol-row.sel { background: var(--wood-100); box-shadow: inset 0 0 0 1px var(--wood-200); }
.ol-row.sel .ol-title { color: var(--wood-900); }

/* 折叠箭头 */
.ol-toggle {
  flex: 0 0 16px; width: 16px; height: 20px; border: 0; background: none; padding: 0;
  color: var(--ink-300); display: flex; align-items: center; justify-content: center;
  transition: transform .18s cubic-bezier(.3, .8, .3, 1), color .16s;
}
.ol-toggle .ic { width: 10px; height: 10px; stroke-width: 2.2; }
.ol-toggle.open { transform: rotate(90deg); color: var(--ink-500); }
.ol-toggle:hover { color: var(--wood-700); }
.ol-toggle.leaf { opacity: 0; pointer-events: none; }

/* 类型图标块：取代原来的小圆点 */
.ol-icon {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--tint, #F6EBDC); color: var(--accent, #7A5533);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05);
}
.ol-icon .ic { width: 13px; height: 13px; stroke-width: 1.8; }
.ol-row[data-type="root"] .ol-icon { width: 26px; height: 26px; border-radius: 8px; }
.ol-row[data-type="root"] .ol-icon .ic { width: 14px; height: 14px; }
.ol-row[data-type="book"] .ol-icon { border-radius: 3px 5px 5px 3px; }
.ol-row[data-type="remark"] .ol-icon { opacity: .82; }

.ol-main { min-width: 0; flex: 1; }

/* 标题：按类型分层 */
.ol-title {
  font-size: 13px; line-height: 1.5; color: var(--ink-800);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ol-row[data-type="root"] .ol-title {
  font-family: var(--serif); font-size: 15.5px; font-weight: 650; letter-spacing: -.1px;
}
.ol-row[data-type="category"] .ol-title { font-size: 14px; font-weight: 600; }
.ol-row[data-type="book"] .ol-title { font-family: var(--serif); font-size: 14px; font-weight: 600; }
.ol-row[data-type="note"] .ol-title { font-size: 13px; font-weight: 500; }
.ol-row[data-type="remark"] .ol-title {
  font-size: 12.5px; color: var(--ink-600); font-weight: 400;
}

/* 元信息行 */
.ol-meta {
  margin-top: 2px; font-size: 10.5px; color: var(--ink-400);
  display: flex; align-items: center; gap: 6px; line-height: 1.4;
}
.ol-meta .badge {
  font-size: 9.5px; padding: 0 5px; border-radius: 4px; line-height: 15px;
  background: var(--tint, #F6EBDC); color: var(--accent, #7A5533);
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.ol-meta .kind {
  font-size: 9.5px; letter-spacing: .02em; color: var(--accent, #7A5533); opacity: .78;
}

.ol-go {
  flex: 0 0 auto; align-self: center; border: 0; background: none;
  color: var(--wood-700); padding: 4px; display: flex; align-items: center;
  opacity: .34; transition: opacity .15s, color .15s;
}
.ol-row:hover .ol-go { opacity: .85; }
.ol-row.sel .ol-go { opacity: .75; }
.ol-go:hover { opacity: 1 !important; color: var(--wood-900); }
.ol-go .ic { width: 13px; height: 13px; stroke-width: 2; }

/* 层级：引导线对齐箭头中线，子层用更浅的线 */
.ol-kids {
  margin-left: 8px; padding-left: 14px;
  border-left: 1px solid var(--line-strong);
  position: relative;
}
.ol-kids[hidden] { display: none; }
.ol-kids > .ol-row::before {
  /* 每行左侧短横线，接上父级竖线 */
  content: ""; position: absolute; left: -14px; top: 50%;
  width: 9px; height: 1px; background: var(--line-strong);
}

/* 顶层分类之间留呼吸：展开的子层与下一个分类之间多留一点 */
.outline > .ol-kids > .ol-kids + .ol-row { margin-top: 7px; }
.outline > .ol-kids > .ol-row + .ol-row { margin-top: 3px; }

/* 折叠后给父行加一点"还有内容"的暗示 */
.ol-row.has-hidden-kids .ol-title::after {
  content: ""; display: inline-block; width: 4px; height: 4px; margin-left: 6px;
  border-radius: 50%; background: var(--accent, #8E6438); opacity: .5;
  vertical-align: middle;
}

/* ============================================================
   画布视图
   ============================================================ */
.canvas-wrap {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(140, 116, 88, .16) 1px, transparent 0) 0 0 / 20px 20px,
    radial-gradient(80% 60% at 50% 0%, rgba(255, 252, 246, .96), rgba(243, 236, 224, .9));
  cursor: grab; touch-action: none;
}
.canvas-wrap.dragging { cursor: grabbing; }

.canvas-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.canvas-links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.canvas-links path {
  fill: none; stroke: var(--line-strong); stroke-width: 1.5;
  stroke-linecap: round;
  transition: stroke .18s, stroke-width .18s, opacity .18s;
}
/* 连线按父节点类型着色：整棵树从木色 → 红 → 绿 → 蓝有方向感 */
.canvas-links path { stroke: rgba(168, 124, 74, .34); }
.canvas-links path[data-l="category"] { stroke: rgba(142, 100, 56, .36); }
.canvas-links path[data-l="book"] { stroke: rgba(158, 68, 51, .34); }
.canvas-links path[data-l="note"] { stroke: rgba(76, 99, 80, .34); }
.canvas-links path[data-l="remark"] { stroke: rgba(51, 71, 91, .3); }
.canvas-links path.faded { opacity: .28; }
.canvas-links path.on {
  stroke: var(--wood-600); stroke-width: 2.2; opacity: 1;
}

/* ---------- 节点 ---------- */
.mnode {
  position: absolute; box-sizing: border-box;
  display: flex; align-items: center; gap: 9px; padding: 0 11px 0 9px;
  border-radius: 10px; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(74, 53, 32, .06), 0 4px 10px -6px rgba(74, 53, 32, .22);
  cursor: pointer; user-select: none;
  transition: box-shadow .16s, border-color .16s, opacity .16s;
}
.mnode:hover {
  border-color: var(--wood-300);
  box-shadow: 0 2px 4px rgba(74, 53, 32, .08), 0 8px 18px -8px rgba(74, 53, 32, .35);
}
.mnode.sel {
  border-color: var(--wood-600);
  box-shadow: 0 0 0 2.5px rgba(142, 100, 56, .16), 0 8px 20px -8px rgba(74, 53, 32, .38);
}
.mnode.on-path { border-color: var(--wood-300); }
.mnode.dim { opacity: .34; }

/* 类型图标 */
.mnode .mi {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--tint, #F6EBDC); color: var(--accent, #7A5533);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05);
}
.mnode .mi .ic { width: 13px; height: 13px; stroke-width: 1.8; }

.mnode .txt { min-width: 0; flex: 1; }
.mnode .tt {
  font-size: 12.5px; font-weight: 600; line-height: 1.3; color: var(--ink-800);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mnode .tm {
  margin-top: 1px; font-size: 9.5px; color: var(--ink-400);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4;
}

/* 按类型做视觉分层 */
.mnode[data-type="root"] {
  background: linear-gradient(150deg, #7A5533 0%, #5C3F27 100%);
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(92, 63, 39, .28), 0 10px 24px -12px rgba(92, 63, 39, .55);
}
.mnode[data-type="root"] .tt { color: #fff; font-family: var(--serif); font-size: 14px; }
.mnode[data-type="root"] .tm { color: rgba(255, 255, 255, .68); }
.mnode[data-type="root"] .mi { background: rgba(255, 255, 255, .16); color: #FBEFE7; box-shadow: none; }
.mnode[data-type="root"]:hover { border-color: transparent; box-shadow: 0 2px 6px rgba(92, 63, 39, .3), 0 12px 28px -12px rgba(92, 63, 39, .6); }
.mnode[data-type="root"].sel { box-shadow: 0 0 0 2.5px rgba(92, 63, 39, .22), 0 12px 28px -12px rgba(92, 63, 39, .6); }

.mnode[data-type="category"] { background: #FFFCF6; }
.mnode[data-type="category"] .tt { font-size: 13.5px; font-weight: 650; }

.mnode[data-type="book"] .tt { font-family: var(--serif); font-size: 13px; }
.mnode[data-type="book"] .mi { border-radius: 3px 5px 5px 3px; }

.mnode[data-type="note"] { background: #FCFDFB; }
.mnode[data-type="note"] .tt { font-size: 12.5px; font-weight: 600; }

.mnode[data-type="remark"] { background: #FBFCFD; }
.mnode[data-type="remark"] .tt { font-size: 11.5px; font-weight: 450; color: var(--ink-600); line-height: 1.35; }
.mnode[data-type="remark"] .mi { opacity: .85; }

/* 展开/折叠圆钮 */
.mn-toggle {
  position: absolute; right: -10px; top: 50%; transform: translateY(-50%);
  min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
  border-radius: 9px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; line-height: 1; z-index: 2;
  font-variant-numeric: tabular-nums; font-weight: 600;
  box-shadow: 0 1px 3px rgba(74, 53, 32, .14);
  transition: border-color .16s, color .16s, background .16s;
}
.mn-toggle:hover { border-color: var(--wood-600); color: var(--wood-900); background: var(--wood-100); }
.mnode[data-type="root"] .mn-toggle {
  background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .38); color: #fff;
  box-shadow: none;
}
.mnode[data-type="root"] .mn-toggle:hover { background: rgba(255, 255, 255, .34); border-color: #fff; }

/* ---------- 画布工具条 ---------- */
.canvas-tools {
  position: absolute; right: 12px; bottom: 14px; z-index: 12;
  display: flex; flex-direction: column; gap: 6px;
}
.canvas-tools button {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .95); color: var(--ink-600);
  display: flex; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 2px 6px rgba(74, 53, 32, .1);
  transition: color .15s, border-color .15s;
}
.canvas-tools button:hover { color: var(--wood-900); border-color: var(--wood-500); }
.canvas-tools button .ic { width: 15px; height: 15px; }

.canvas-zoom {
  position: absolute; left: 12px; bottom: 14px; z-index: 12;
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 5px 10px; font-size: 10.5px; color: var(--ink-500);
  box-shadow: 0 2px 6px rgba(74, 53, 32, .1);
}
.canvas-zoom b { color: var(--ink-800); font-variant-numeric: tabular-nums; font-size: 11.5px; }

.canvas-hint {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 11;
  font-size: 10px; color: var(--ink-400); background: rgba(255, 255, 255, .84);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px;
  white-space: nowrap; pointer-events: none;
  backdrop-filter: blur(4px);
}

/* ---------- 选中节点动作条 ---------- */
.node-bar {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 15;
  display: flex; align-items: center; gap: 9px;
  background: rgba(251, 248, 241, .98); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 9px 10px;
  box-shadow: 0 8px 24px -10px rgba(74, 53, 32, .45);
  transform: translateY(140%); transition: transform .24s cubic-bezier(.3, .8, .3, 1);
}
.node-bar.on { transform: translateY(0); }
.node-bar .nb-ic {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--tint, #F6EBDC); color: var(--accent, #7A5533);
}
.node-bar .nb-ic .ic { width: 14px; height: 14px; }
.node-bar .nb-main { min-width: 0; flex: 1; }
.node-bar .nb-t {
  font-size: 12px; font-weight: 650; color: var(--ink-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node-bar .nb-m {
  font-size: 10px; color: var(--ink-400); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node-bar .nb-go {
  flex: 0 0 auto; height: 30px; padding: 0 13px; border-radius: 999px; border: 0;
  background: var(--wood-700); color: #fff; font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.node-bar .nb-go:active { transform: scale(.97); }
.node-bar .nb-go .ic { width: 12px; height: 12px; stroke-width: 2.2; }


/* ============================================================
   封面：图案层（封面绘制 / 缩略图共用）
   ============================================================ */
.cover-frame { position: relative; width: 100%; aspect-ratio: 2 / 3; overflow: hidden; }
.cover-face {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  justify-content: space-between; padding: 11px 8px 9px 15px;
}
.cover-art { position: absolute; inset: 0; pointer-events: none; }
.cover-face .cf-title, .cover-face .cf-author { position: relative; z-index: 1; }
.cover-face .cf-title {
  font-family: var(--serif); font-size: 13px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.cover-face .cf-author { font-size: 9px; opacity: .84; letter-spacing: .03em; }

.cover-big, .cover-preview, .mini-cover { position: relative; }
.cover-big .cover-face { padding: 14px 9px 11px 18px; }
.cover-big .cover-face .cf-title { font-size: 15px; }
.cover-preview .cover-face { padding: 8px 6px 7px 11px; }
.cover-preview .cover-face .cf-title { font-size: 9.5px; -webkit-line-clamp: 3; }
.cover-preview .cover-face .cf-author { font-size: 7px; }
.mini-cover .cover-face { padding: 10px 6px 9px 13px; }
.mini-cover .cover-face .cf-title { font-size: 11px; }
.mini-cover .cover-face .cf-author { font-size: 8px; }

/* ============================================================
   查找面板：书本列表 / 分类配图网格
   ============================================================ */
.fd-sheet { max-height: 90%; }

/* 搜索框 */
.fd-search { display: flex; gap: 8px; margin-bottom: 9px; }
.fd-search .input { flex: 1; min-width: 0; height: 40px; }
.fd-search .btn { flex: 0 0 auto; width: auto; min-height: 40px; padding: 0 16px; }

/* 关键词建议 */
.fd-words { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.fd-words::-webkit-scrollbar { display: none; }
.fd-words button {
  flex: 0 0 auto; height: 25px; padding: 0 10px; border-radius: 999px;
  border: 1px dashed var(--line-strong); background: #fff;
  color: var(--ink-500); font-size: 11px;
}
.fd-words button:hover { border-style: solid; border-color: var(--wood-500); color: var(--wood-900); }

/* 数据源 */
.fd-sources { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.fd-sources button {
  height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-500); font-size: 11px;
  display: inline-flex; align-items: center; gap: 4px;
}
.fd-sources button i { font-style: normal; font-size: 9px; color: var(--ink-300); }
.fd-sources button.on {
  border-color: var(--wood-600); background: var(--wood-100);
  color: var(--wood-900); font-weight: 600;
}
.fd-sources button.on i { color: var(--wood-600); }

.fd-status { font-size: 10.5px; color: var(--ink-400); margin-bottom: 9px; line-height: 1.5; }
.fd-status b { color: var(--ink-700); }
.fd-status span { color: var(--ink-300); }

/* ---------- 书本结果：一行一条，带完整书目 ---------- */
.fd-list { display: flex; flex-direction: column; gap: 9px; }

.fd-row {
  display: flex; gap: 11px; align-items: stretch;
  padding: 9px; border: 1px solid var(--line); border-radius: 11px;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.fd-row:hover { border-color: var(--wood-300); box-shadow: 0 3px 12px -6px rgba(74, 53, 32, .3); }

.fd-thumb {
  position: relative; flex: 0 0 52px; width: 52px; aspect-ratio: 2 / 3;
  border-radius: 2px 4px 4px 2px; overflow: hidden; background: var(--wood-200);
  box-shadow: 0 2px 6px -2px rgba(74, 53, 32, .4);
}
.fd-thumb::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; z-index: 3;
  background: linear-gradient(90deg, rgba(0, 0, 0, .26), rgba(0, 0, 0, .04) 60%, rgba(255, 255, 255, .14));
}
.fd-thumb .cover-face { padding: 6px 4px 5px 9px; }
.fd-thumb .cover-face .cf-title { font-size: 7.5px; -webkit-line-clamp: 3; }
.fd-thumb .cover-face .cf-author { display: none; }

.fd-info { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.fd-t {
  font-size: 12.5px; font-weight: 650; color: var(--ink-800); line-height: 1.35;
  display: flex; align-items: center; gap: 6px;
}
.fd-t .fd-ed {
  flex: 0 0 auto; font-size: 9px; font-weight: 500; padding: 1px 5px; border-radius: 3px;
  background: var(--wood-100); color: var(--wood-800); letter-spacing: .02em;
}
.fd-a { font-size: 11px; color: var(--ink-600); }
.fd-p { font-size: 10px; color: var(--ink-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd-x { display: flex; align-items: center; gap: 9px; margin-top: 2px; font-size: 9.5px; color: var(--ink-400); }
.fd-star { color: var(--amber-700); font-weight: 600; }

.fd-acts { flex: 0 0 auto; display: flex; flex-direction: column; gap: 5px; justify-content: center; }
.fd-use {
  height: 27px; padding: 0 10px; border-radius: 999px; border: 0;
  background: var(--wood-700); color: #fff; font-size: 10.5px; font-weight: 600;
  white-space: nowrap;
}
.fd-use:active { transform: scale(.97); }
.fd-cover {
  height: 24px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: #fff;
  color: var(--ink-500); font-size: 9.5px; white-space: nowrap;
}
.fd-cover:hover { border-color: var(--wood-500); color: var(--wood-900); }

/* ---------- 分类配图：三列网格 ---------- */
.fd-list.fd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 9px; }

.fd-theme {
  border: 0; background: none; padding: 0; display: flex; flex-direction: column;
  gap: 3px; text-align: left;
}
.fd-theme-img {
  position: relative; width: 100%; aspect-ratio: 2 / 3; border-radius: 5px;
  overflow: hidden; box-shadow: var(--shadow-book); background: var(--wood-200);
  transition: outline .12s;
}
.fd-theme:hover .fd-theme-img { outline: 2px solid var(--wood-500); outline-offset: 1px; }
.fd-theme-img .cover-face { padding: 0; }
.fd-theme-n {
  font-size: 10px; color: var(--ink-600); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fd-theme-k {
  font-size: 9px; color: var(--ink-300);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 查找回填后的字段高亮 */
.input.filled, .textarea.filled, .select.filled {
  animation: fillFlash 1.2s ease;
}
@keyframes fillFlash {
  0%   { border-color: var(--wood-600); background: #FFF9EF; box-shadow: 0 0 0 3px rgba(142, 100, 56, .14); }
  100% { border-color: var(--line-strong); background: #fff; box-shadow: none; }
}

/* 查找面板可以叠在其它抽屉之上，因此层级要高于普通 sheet */
#finderSheet { position: absolute; inset: 0; z-index: 70; pointer-events: none; }
#finderSheet .overlay { z-index: 71; pointer-events: auto; }
#finderSheet .fd-sheet { z-index: 72; pointer-events: auto; }
#finderSheet .overlay:not(.on),
#finderSheet .fd-sheet:not(.on) { pointer-events: none; }
