:root {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #1f2933;
  --muted: #69707d;
  --primary: #3b82f6;
  --primary-d: #2563eb;
  --primary-soft: #eff6ff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 28px; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 700; }
.brand .sub { margin: 0; font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 按钮 */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px;
  font-weight: 600; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #c7cfdb; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: #fff; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* 布局 */
.layout {
  display: grid; grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 16px; padding: 16px; align-items: start;
  height: calc(100vh - 64px);
}
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
}

/* 配置面板 */
.section-nav {
  display: flex; gap: 4px; padding: 10px 10px 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.section-nav button {
  border: none; background: transparent; color: var(--muted);
  padding: 7px 11px; border-radius: 8px 8px 0 0; cursor: pointer; font-size: 12.5px; font-weight: 600;
}
.section-nav button.active { color: var(--primary-d); background: var(--primary-soft); }
.config-body { padding: 16px; overflow: auto; flex: 1; }

/* 表单 */
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=color] { width: 42px; height: 36px; padding: 2px; border-radius: 8px; border: 1px solid var(--border); }

/* 卡片列表（nav/sidebar/social/features） */
.list-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fbfcfe; }
.list-card .lc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.list-card .lc-title { font-weight: 700; font-size: 12.5px; color: var(--muted); }
.lc-remove { border: none; background: #fee2e2; color: var(--err); border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 12px; font-weight: 700; }
.lc-remove:hover { background: #fecaca; }
.add-btn { width: 100%; border: 1px dashed var(--border); background: #fff; color: var(--primary-d); padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.add-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.sub-item { border-left: 2px solid var(--border); padding-left: 8px; margin: 8px 0; }

.section-title { font-size: 15px; font-weight: 800; margin: 4px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.section-desc { color: var(--muted); font-size: 12px; margin: -8px 0 16px; }
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 26px 16px; text-align: center;
  color: var(--muted); cursor: pointer; transition: .15s; background: #fbfcfe; margin-bottom: 14px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-d); }
.logo-drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px; }
.logo-drop-text { font-size: 13px; }
.logo-preview { max-width: 120px; max-height: 64px; border-radius: 8px; background: #fff; padding: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.12); }

/* 文档目录树（可视化） */
.doc-tree-wrap { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 4px 0 14px; background: #fbfcfe; }
.doc-tree-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.doc-tree, .doc-tree ul { list-style: none; margin: 0; padding-left: 16px; }
.doc-tree { padding-left: 4px; }
.doc-tree li { line-height: 1.9; font-size: 13px; }
.doc-tree .dt-ico { margin-right: 6px; }
.doc-tree .dt-folder > b { color: var(--primary-d); }
.doc-tree .dt-file { color: var(--muted); }

/* 预览面板 */
.tabs { display: flex; gap: 2px; padding: 10px 10px 0; border-bottom: 1px solid var(--border); }
.tab { border: none; background: transparent; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-radius: 8px 8px 0 0; font-size: 13px; }
.tab.active { color: var(--primary-d); background: var(--primary-soft); }
.tab-pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tab-pane.active { display: flex; }
.preview-toolbar, .files-toolbar { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.preview-toolbar .hint { color: var(--muted); font-size: 12px; }
.preview-frame { flex: 1; width: 100%; border: none; background: #fff; }
.files-toolbar .file-select { flex: 1; }
.code-view { flex: 1; margin: 0; overflow: auto; padding: 14px 16px; background: #0f172a; color: #e2e8f0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; white-space: pre; }

/* 部署表单 */
.deploy-form { padding: 16px; overflow: auto; flex: 1; }
.deploy-log { border-top: 1px solid var(--border); padding: 12px 16px; max-height: 220px; overflow: auto; font-family: ui-monospace, monospace; font-size: 12px; background: #0f172a; color: #cbd5e1; }
.deploy-log .ok { color: #4ade80; }
.deploy-log .err { color: #f87171; }
.deploy-log .info { color: #93c5fd; }
.security-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1f2933; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

/* 响应式 */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .panel { height: 70vh; }
}

/* 文档目录树：可交互 */
.doc-tree .dt-file { display: flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 6px; padding: 0 4px; }
.doc-tree .dt-file:hover { background: var(--primary-soft); color: var(--primary-d); }
.doc-tree .dt-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-tree .dt-badge { font-size: 11px; color: var(--muted); background: #eef2f7; border-radius: 999px; padding: 0 7px; margin-left: 2px; }
.doc-tree .dt-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1; padding: 2px 5px; border-radius: 5px; opacity: 0; }
.doc-tree .dt-file:hover .dt-del { opacity: 1; }
.doc-tree .dt-del:hover { background: #fee2e2; color: var(--err); }

/* 上传区：文件 + 文件夹并排 */
.upload-row { display: flex; gap: 10px; align-items: stretch; margin-bottom: 14px; flex-wrap: wrap; }
.upload-row .dropzone-inline { flex: 1; min-width: 220px; margin-bottom: 0; padding: 16px; }
.upload-row #btn-folder { align-self: center; }

/* 编辑卡片高亮（目录树点击定位） */
.list-card.flash { animation: cardFlash 1.2s ease; }
@keyframes cardFlash {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 3px var(--primary); border-color: var(--primary); }
}

/* 配置同步区块 */
.sync-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 6px 0 12px; background: #f8fafc; }
.sync-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.sync-box .hint { margin-bottom: 8px; }
.sync-btns { display: flex; gap: 8px; flex-wrap: wrap; }
