:root {
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --success: #16a34a;
  --danger: #ef4444;
  --radius-card: 14px;
  --radius-btn: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI","Microsoft YaHei",sans-serif;
}

.app { display: flex; min-height: 100vh; position: relative; }

.aside {
  width: 280px;
  min-width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  transition: width .25s ease,min-width .25s ease,padding .25s ease;
  z-index: 2;
}
.aside.collapsed { width: 0; min-width: 0; padding: 0; overflow: hidden; }

.aside-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.title { margin: 0; font-size: 18px; font-weight: 700; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.btn {
  border: none; cursor: pointer; font-weight: 600; transition: all .2s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary {
  background: var(--accent); color: #fff; padding: 10px 14px;
  border-radius: var(--radius-btn); box-shadow: 0 10px 20px rgba(37,99,235,.25);
}
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn-ghost {
  background: #f8fafc; border: 1px solid var(--border); color: var(--ink);
  padding: 9px 12px; border-radius: var(--radius-btn);
}
.btn-ghost:hover { background: #eef2ff; }
.btn-icon {
  width: 34px; height: 34px; border-radius: 8px; background: #f8fafc;
  border: 1px solid var(--border); color: var(--muted); display: grid; place-items: center;
}
.btn-icon:hover { background: #e2e8f0; color: var(--ink); }

.tree-wrap { flex: 1; overflow-y: auto; padding-top: 6px; }
.tree-wrap::-webkit-scrollbar, .content::-webkit-scrollbar { width: 8px; }
.tree-wrap::-webkit-scrollbar-thumb, .content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
.tree { list-style: none; padding: 0; margin: 0; }
.node { margin: 2px 0; }
.node-line {
  display: grid; grid-template-columns: 16px 18px 1fr auto; gap: 8px;
  align-items: center; padding: 6px 10px; border-radius: 10px; cursor: pointer;
}
.node-line:hover { background: #e8f0ff; }
.node-line.active { background: #e0e7ff; border: 1px solid #c7d2fe; }
.caret { font-size: 10px; color: var(--muted); display: grid; place-items: center; }
.caret::before { content: "\f105"; font-family: "Font Awesome 6 Free"; font-weight: 900; transition: transform .2s ease; }
.node.open > .node-line .caret::before { transform: rotate(90deg); }
.caret.empty::before { content: ""; }
.icon-folder { color: #f59e0b; width: 18px; text-align: center; }
.icon-file { color: #475569; width: 18px; text-align: center; }
.node-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.node-actions { display: inline-flex; gap: 6px; }
.node-btn {
  width: 26px; height: 26px; border-radius: 6px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.node-btn:hover { background: #e2e8f0; color: var(--ink); }
.branch { list-style: none; margin: 0 0 0 5px; padding-left: 5px; border-left: 1px dashed var(--border); }

.content { flex: 1; min-width: 0; padding: 26px; overflow-y: auto; }
.placeholder { text-align: center; color: var(--muted); max-width: 520px; margin: 40px auto; }
.placeholder i { font-size: 52px; color: #cbd5e1; margin-bottom: 12px; }
.markdown-body {
  background: var(--card) !important; padding: 28px !important; border-radius: var(--radius-card);
  box-shadow: var(--shadow); max-width: 1200px; margin: 0 auto;
}
.markdown-body pre, .markdown-body code { background: #e2e8f0 !important; color: #0f172a !important; }

.toggle-nav {
  position: fixed; top: 20px; left: 310px; transform: translateX(-30%);
  width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--accent); color: #fff;
  box-shadow: 0 10px 20px rgba(37,99,235,.25); display: grid; place-items: center; cursor: pointer;
  transition: left .25s ease, transform .2s ease;
}
.toggle-nav:hover { transform: translateX(-30%) scale(1.03); }
.toggle-nav.collapsed { left: 14px; transform: none; }

.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: center; justify-content: center; z-index: 10;
}
.modal.show { display: flex; }
.dialog {
  width: 420px; max-width: 92vw; background: var(--card); border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: 18px 20px 10px;
}
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dialog-title { margin: 0; font-size: 18px; font-weight: 700; }
.field { margin: 12px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid rgba(37,99,235,.25); }
.error { color: var(--danger); font-size: 12px; min-height: 16px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin: 14px 0; }

.select { position: relative; }
.select button { width: 100%; justify-content: space-between; }
.select-panel {
  position: absolute; left: 0; top: calc(100% + 6px); width: 100%; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); max-height: 220px; overflow-y: auto; display: none; z-index: 11;
}
.select-panel.show { display: block; }
.parent-item { padding: 10px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.parent-item:hover { background: #f1f5f9; }
.parent-item.disabled { color: #cbd5e1; cursor: not-allowed; }

.toast {
  position: fixed; right: 16px; top: 16px; padding: 12px 16px; border-radius: 10px; color: #fff;
  background: #1e293b; box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); transition: all .2s ease; z-index: 15;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.loading { display: grid; place-items: center; gap: 10px; color: var(--muted); padding: 16px 8px; font-size: 14px; }
.spinner { width: 34px; height: 34px; border: 4px solid #e2e8f0; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 悬停显示完整名称 */
.name-tooltip {
  position: fixed;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 320px;
  z-index: 30;
  pointer-events: none;
  display: none;
  white-space: nowrap;
}
