/* ============================================================
 * 幕布克隆版 — 样式
 * ============================================================ */
:root {
  --bg: #ffffff;
  --bg-side: #fcfbfb;
  --line: #dedee1;
  --text: #1d1d1f;
  --text-dim: #86868b;
  --accent: #5856d5;
  --accent-soft: rgba(88, 86, 213, .1);
  --hover: #f5f5f7;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", "Source Han Sans SC", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: 240px;
  flex: none;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 12px;
}

.brand { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px 4px 10px; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 5px;
  background: linear-gradient(135deg, #5856d5, #7d7bfb);
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: .4px; }

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background .12s;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); color: #fff; text-align: center; font-weight: 500; }
.btn-primary:hover { background: #4b49c9; }
.btn-ghost { border-color: var(--line); text-align: center; font-size: 12px; padding: 6px 8px; }

.doclist { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.doc-item {
  padding: 7px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.doc-item:hover { background: var(--hover); }
.doc-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.doc-item .doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item .doc-del {
  opacity: 0; border: none; background: none; cursor: pointer;
  color: var(--text-dim); font-size: 14px; line-height: 1; padding: 0 2px;
}
.doc-item:hover .doc-del { opacity: 1; }
.doc-item .doc-del:hover { color: #e0413e; }

.sidebar-foot { display: flex; flex-direction: column; gap: 6px; }
.foot-note {
  margin-top: 4px; font-size: 11px; color: var(--text-dim);
  line-height: 1.5; text-align: center;
}

/* ---------------- 主区 ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 52px; flex: none;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
}
.doc-title {
  flex: 1; min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  font-size: 15px; font-weight: 600; font-family: inherit;
  color: var(--text);
  padding: 6px 8px; border-radius: var(--radius);
  outline: none;
}
.doc-title:hover { background: var(--hover); }
.doc-title:focus { background: #fff; border-color: var(--accent); }

.tabs { display: flex; gap: 2px; background: var(--hover); padding: 3px; border-radius: 8px; }
.tab {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--text-dim);
  padding: 5px 14px; border-radius: 6px;
}
.tab.is-active { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.stat { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

.view { flex: 1; min-height: 0; position: relative; overflow: hidden; }

/* ---------------- 大纲视图 ---------------- */
.outliner { height: 100%; display: flex; flex-direction: column; position: relative; }
.outliner-head {
  flex: none;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  padding: 16px 16px 4px;
  display: flex; flex-direction: column; gap: 6px;
}
/* 下钻 / 返回面包屑 */
.breadcrumb {
  font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; flex-wrap: wrap;
  line-height: 1.6; min-height: 20px;
}
.bc-wrap { display: inline-flex; align-items: center; }
.bc-seg { padding: 1px 4px; border-radius: 4px; color: #6f6f74; }
.bc-wrap:not([data-cur]) .bc-seg { cursor: pointer; }
.bc-wrap:not([data-cur]) .bc-seg:hover { background: var(--hover); color: var(--text); }
.bc-seg.bc-cur { color: var(--text-dim); font-weight: 500; }
.bc-sep { margin: 0 3px; color: #c5c5cb; }
.hint { font-size: 11px; color: #b0b0b6; }

/* 下钻标题（对齐幕布页内大标题：34px/600/#16181a） */
.drill-title {
  flex: none;
  max-width: 820px; margin: 0 auto; width: 100%;
  padding: 48px 16px 6px;
  font-size: 34px; font-weight: 600; color: #16181a;
  line-height: 1.6;
}

.outliner-body {
  flex: 1; overflow-y: auto;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  padding: 6px 16px 120px;
}

.row {
  display: flex; align-items: flex-start; gap: 0;
  flex-wrap: wrap;
  padding: 3px 8px 3px 0;
  border-radius: 4px;
  position: relative;
  --gl-color: #dedee1;
  background-color: transparent;
}
.row.is-active { background-color: transparent; --gl-color: #c9c9cf; }
/* 多选高亮（浅紫底，参考幕布多选） */
.row.is-sel { background-color: rgba(101, 87, 222, .13); --gl-color: #c9c4ee; }
.row.is-sel.is-active { background-color: rgba(101, 87, 222, .18); }
/* 层级引导线 —— 由 JS 在 .has-line 上设置 background-image（每层一根 1px），位置与对应 level 的「•」圆心对齐 */
.row.has-line { background-repeat: no-repeat; }

/* 每行控件条：⋯ ▾ •  (+ 待办勾选框)；宽度由 JS 内联设置；
   内部控件用 absolute 定位到对应 level 的 x 位置（MIN_PAD + (level+2)*INDENT，右侧 2 级留给 -1/-2 级） */
.row-ctrl {
  position: relative;
  flex: none;
  height: 28px;
}

.more {
  position: absolute; top: 50%;
  width: 18px; height: 18px;
  border: none; background: none; cursor: pointer;
  font-size: 16px; line-height: 18px; color: #b2b3b4;
  padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transform: translate(-50%, -50%);
  opacity: 0; pointer-events: none;
  transition: opacity .1s, background .1s, color .1s;
}
.row:hover .more, .row.is-active .more { opacity: 1; pointer-events: auto; }
.more.is-on { opacity: 1; pointer-events: auto; }   /* 菜单打开时强制显示 */
.more:hover { background: #ececef; color: #3a3a3c; }

.toggle {
  position: absolute; top: 50%;
  width: 18px; height: 18px;
  border: none; background: none; cursor: pointer;
  color: #b2b3b4; font-size: 18px; line-height: 18px;
  padding: 0; text-align: center;
  transform: translate(-50%, -50%);
  opacity: 0; pointer-events: none;
  transition: opacity .1s, color .1s;
}
.row:hover .toggle, .row.is-active .toggle { opacity: 1; pointer-events: auto; }
.toggle.has-children:hover { color: var(--text); }
.toggle:not(.has-children) { color: transparent; cursor: default; }

.bullet {
  position: absolute; top: 50%;
  width: 18px; height: 24px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  transform: translate(-50%, -50%);
}
.bullet .b-dot {
  width: 6px; height: 6px; border-radius: 3px;
  background: #66666d; display: block;
  transition: background .1s, transform .1s;
}
.row:hover .bullet .b-dot, .row.is-active .bullet .b-dot { background: #6f6f74; transform: scale(1.15); }
.bullet:hover { background: #f0f0f2; }

/* 待办勾选框：放在 • 右侧（自然 flex 流） */
.todo-check {
  flex: none; width: 14px; height: 14px;
  border: 1.6px solid #a9aab0; border-radius: 3px;
  background: transparent; cursor: pointer; padding: 0;
  position: relative; box-sizing: border-box;
  margin: 7px 0 0 4px;
}
.todo-check:hover { border-color: #6f6f74; }
.todo-check .tc-mark {
  position: absolute; left: 3px; top: -2px; width: 4px; height: 8px;
  border-right: 1.8px solid #fff; border-bottom: 1.8px solid #fff;
  transform: rotate(45deg); display: none; box-sizing: border-box;
}
.todo-check.is-done { background: #4e83fd; border-color: #4e83fd; }
.todo-check.is-done .tc-mark { display: block; }

.text {
  flex: 1; min-width: 0;
  font-size: 16px; line-height: 25.6px;
  padding: 0 2px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.text.is-empty::before {
  content: '输入内容…';
  color: #c7c7cc;
  pointer-events: none;
}

/* 段落 / 标题 */
.text.h1 { font-size: 22px; font-weight: 700; line-height: 1.35; }
.text.h2 { font-size: 18px; font-weight: 600; line-height: 1.4; }
.text.h3 { font-size: 16px; font-weight: 600; }

/* 行内描述（对齐幕布 note：14px / #75757d，左侧跟随引导线） */
.row-note {
  flex-basis: 100%;
  font-size: 14px; color: #75757d; line-height: 1.7;
  padding: 4px 0 2px; white-space: pre-wrap; outline: none;
  border-top: none; border-left: 1px solid #dedee1; margin-top: 4px;
  padding-left: 10px; margin-left: 11px;
}
.row-note.is-empty::before { content: '添加描述…'; color: #c7c7cc; pointer-events: none; }

/* 节点设置菜单（浅色卡片） */
.outline-menu {
  position: absolute; width: 224px; z-index: 80;
  background: #fff; border: 1px solid #e7e7eb; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.14);
  opacity: 0; pointer-events: none; transform: scale(.97);
  transition: opacity .1s, transform .1s;
  overflow: hidden;
}
.outline-menu.is-open { opacity: 1; pointer-events: auto; transform: scale(1); }
.om-head { padding: 8px 12px; border-bottom: 1px solid #f0f0f2; }
.om-row { display: flex; align-items: center; gap: 4px; }
.om-f { width: 34px; height: 30px; border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 14px; font-family: inherit; color: #3a3a3c; font-weight: 600; }
.om-f:hover { background: #f2f2f4; }
.om-f.is-on { background: #eef0ff; color: #6557de; }
.om-b { font-weight: 800; }
.om-i { font-style: italic; }
.om-u { text-decoration: underline; }
.om-s { text-decoration: line-through; }
.om-vsep { width: 1px; height: 20px; background: #ececf0; margin: 0 5px; }
.om-palette { display: none; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-bottom: 1px solid #f0f0f2; }
.om-palette.is-open { display: flex; }
.om-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 1px solid rgba(0,0,0,.1); position: relative; transition: transform .1s; }
.om-swatch:hover { transform: scale(1.12); }
.om-swatch.clear { background: #fff; }
.om-swatch.clear::after { content: '×'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #a0a0a6; }
.om-list { padding: 6px; display: flex; flex-direction: column; }
.om-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 14px; color: #1d1d1f; text-align: left; font-family: inherit; }
.om-item:hover { background: #f5f5f7; }
.om-item > span:nth-child(2) { flex: 1; }
.om-ic { width: 20px; text-align: center; font-size: 15px; flex: none; }
.om-a { font-weight: 700; color: #e0353a; text-decoration: underline; }
.om-chev { color: #c5c5cb; font-style: normal; flex: none; }
.om-danger { color: #e23c3c; }
.om-danger:hover { background: #fdeeee; }
.om-foot { padding: 10px 14px 12px; border-top: 1px solid #f0f0f2; color: #a0a0a6; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }

/* 多选统计工具条 */
.outline-selbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 70; display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #e7e7eb; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.14);
  padding: 6px 9px; white-space: nowrap;
}
.outline-selbar[hidden] { display: none; }
.os-stats { font-size: 12px; color: #4a4a4f; }
.os-stats b { color: #6557de; font-weight: 700; }
.os-vsep { width: 1px; height: 18px; background: #ececf0; }
.os-btn { border: none; background: transparent; cursor: pointer; font-size: 13px; color: #1d1d1f; padding: 5px 9px; border-radius: 7px; font-family: inherit; }
.os-btn:hover { background: #f2f2f4; }
.os-btn.os-danger { color: #e23c3c; }
.os-btn.os-danger:hover { background: #fdeeee; }
.os-btn.os-done { background: #6557de; color: #fff; }
.os-btn.os-done:hover { background: #5647c9; }

.outline-toast {
  position: fixed; left: 50%; bottom: 36px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(29,29,31,.92); color: #fff;
  padding: 9px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s; z-index: 999;
}
.outline-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 思维导图视图 ---------------- */
.minder { height: 100%; display: flex; flex-direction: column; }

.minder-toolbar {
  flex: none; height: 44px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px; border-bottom: 1px solid var(--line);
  background: #fff;
}
.minder-toolbar button {
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  border-radius: 5px; padding: 4px 10px; font-size: 12px;
  font-family: inherit; color: var(--text);
}
.minder-toolbar button:hover { background: var(--hover); }
.minder-zoom { font-size: 12px; color: var(--text-dim); min-width: 42px; text-align: center; }
.toolbar-spacer { margin-left: auto; }
.minder-toolbar .tool-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 4px; width: 30px; height: 30px;
}
.minder-toolbar .tool-btn svg { width: 18px; height: 18px; }
.minder-toolbar .tool-btn:hover { border-color: var(--accent); }

.minder-canvas {
  flex: 1; position: relative; overflow: hidden;
  cursor: grab;
  background-size: 20px 20px;
  background-image: radial-gradient(circle, #d8d8dd 1px, transparent 1px);
}
.minder-canvas.is-panning { cursor: grabbing; }

.minder-world { position: absolute; transform-origin: 0 0; top: 0; left: 0; }
.minder-links { position: absolute; top: 0; left: 0; overflow: visible; }
.minder-nodes { position: absolute; top: 0; left: 0; }

.mnode {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  word-break: break-word;
  white-space: pre-wrap;
}
.mnode:hover { outline: 2px solid var(--hov, rgba(88, 86, 213, .4)); outline-offset: 1px; z-index: 2; }
.mnode.is-selected { outline: 2px solid var(--sel, #4e83fd); outline-offset: 1px; }
.mnode.is-root { text-align: center; }
.mnode .mtext { display: block; }
.mnode .mtext[contenteditable="true"] { outline: none; cursor: text; }

/* 折叠/展开按钮（对齐幕布：圆形白底、hover 或折叠时出现、按分支方向贴边） */
.mbadge {
  position: absolute; right: -10px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px; line-height: 16px;
  border-radius: 50%;
  background: var(--c-bg, #fff); border: 1px solid var(--c-bd, #c7c7cc);
  color: var(--c-fg, #58585c); font-size: 13px; text-align: center;
  box-sizing: border-box;
  cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity .1s;
  z-index: 3;
}
.mnode:hover .mbadge, .mnode.is-collapsed .mbadge { opacity: 1; pointer-events: auto; }
.mnode.is-left .mbadge { right: auto; left: -10px; }
.mbadge:hover { filter: brightness(.95); }
.mbadge:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- 思维导图工具栏按钮 & 点击弹出面板 ---------------- */
.mind-wrap { display: flex; height: 100%; }
.minder { flex: 1; min-width: 0; position: relative; }

/* 弹出面板 */
.mind-popup {
  position: absolute; right: 16px; top: 52px;
  width: 240px; max-height: calc(100% - 80px);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  z-index: 25;
  opacity: 0; pointer-events: none; transform: translateX(8px);
  transition: opacity .15s, transform .15s;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.mind-popup.is-open { opacity: 1; pointer-events: auto; transform: translateX(0); }

.popup-head {
  flex: none; height: 44px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
}
.popup-close {
  width: 24px; height: 24px; border-radius: 6px;
  border: none; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--text-dim);
}
.popup-close:hover { background: var(--hover); }

.popup-body {
  flex: 1; overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}

/* 结构面板 */
#mind-structures {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.struc-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 10px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text); transition: border .12s, background .12s;
}
.struc-btn:hover { background: var(--hover); border-color: var(--accent); }
.struc-btn.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.struc-icon { width: 44px; height: 30px; display: block; }
.struc-icon svg { width: 100%; height: 100%; }
.struc-label { text-align: center; line-height: 1.25; }

/* 配色面板 */
.theme-group { display: flex; flex-direction: column; gap: 8px; }
.theme-group-title { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.theme-group-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-btn {
  position: relative; height: 52px; border-radius: 6px;
  border: 1px solid rgba(0,0,0,.08); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; padding: 0 4px; text-align: center; word-break: break-all;
  transition: transform .1s, box-shadow .1s;
}
.theme-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.theme-btn.is-active { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------- 节点右键菜单 ---------------- */
.mnode-menu {
  position: absolute;
  min-width: 180px;
  background: #2c2c2e;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  z-index: 60;
  padding: 6px 0;
  color: #f2f2f7;
  font-size: 13px;
  opacity: 0; pointer-events: none; transform: scale(.96);
  transition: opacity .08s, transform .08s;
  user-select: none;
}
.mnode-menu.is-open { opacity: 1; pointer-events: auto; transform: scale(1); }

.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; cursor: pointer; gap: 24px;
}
.menu-item:hover { background: #3a3a3c; }
.menu-item.is-disabled { opacity: .4; pointer-events: none; }
.menu-label { white-space: nowrap; }
.menu-key { font-size: 11px; color: #8e8e93; white-space: nowrap; }

.menu-sep { height: 1px; background: #48484a; margin: 6px 0; }

/* ---------------- 底部编辑条（选中节点后弹出） ---------------- */
.minder-editorbar {
  position: absolute; left: 50%; bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  display: flex; align-items: center; gap: 2px;
  background: #2c2c2e;
  border-radius: 10px; padding: 5px 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.minder-editorbar.is-visible { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }

.eb-icon {
  width: 32px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  color: #d1d1d6; border-radius: 6px;
}
.eb-icon:hover { background: #3a3a3c; color: #fff; }
.eb-icon svg { width: 20px; height: 20px; }
.eb-more { color: #fff; }
.eb-sep { width: 1px; height: 18px; background: #48484a; margin: 0 4px; }

.minder-toast {
  position: fixed; left: 50%; bottom: 72px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(29, 29, 31, .92); color: #fff;
  padding: 7px 16px; border-radius: 7px;
  font-size: 12px; z-index: 999;
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.minder-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 32px;
  transform: translateX(-50%);
  background: rgba(29, 29, 31, .92); color: #fff;
  padding: 9px 18px; border-radius: 8px;
  font-size: 13px; z-index: 999;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
