:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --ok: #16a34a;
  --err: #dc2626;
  --run: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

/* 顶栏 */
.topbar {
  height: 62px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.brand-wrap { display: flex; align-items: center; gap: 12px; }
.logo { display: block; border-radius: 11px; box-shadow: 0 2px 6px rgba(37,99,235,.28); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title { font-weight: 800; font-size: 17px; letter-spacing: .5px; color: #0f172a; }
.brand-tag { font-size: 11.5px; color: var(--muted); letter-spacing: .3px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.home-btn { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: #334155; background: var(--surface-2); text-decoration: none; font-size: 13px; }
.home-btn:hover { color: var(--accent-hover); border-color: #c7dbff; }
.topbar button {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.topbar button:hover { background: #eef4ff; border-color: #c7dbff; color: var(--accent-hover); }
.btn-ic { font-size: 14px; }

.layout { display: flex; height: calc(100vh - 62px); }

/* 侧栏 */
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); overflow-y: auto; padding: 14px 10px;
}
/* 可折叠层级 */
.caret {
  display: inline-block; width: 14px; text-align: center; font-size: 10px;
  color: var(--muted); transition: transform .15s ease; flex-shrink: 0;
}
.tree-node.collapsed > .toggle .caret { transform: rotate(-90deg); }
.tree-node.collapsed > .tree-children { display: none; }
.toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; border-radius: 8px; }

.tree-cat {
  font-weight: 700; margin: 12px 4px 2px; color: var(--text); font-size: 13px;
  padding: 5px 6px;
}
.tree-node:first-child > .tree-cat { margin-top: 0; }
.tree-cat:hover { background: var(--surface-2); }
.tree-children { margin-left: 12px; }
.grp-label {
  color: var(--muted); font-size: 12.5px; margin: 3px 0; padding: 5px 6px; font-weight: 600;
}
.grp-label:hover { background: var(--surface-2); }
.tree-tool {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px 7px 24px; margin: 1px 0; border-radius: 8px;
  cursor: pointer; color: #334155; text-decoration: none; font-size: 13.5px;
}
.tree-tool:hover { background: var(--surface-2); }
.tree-tool.active { background: #e0edff; color: var(--accent-hover); font-weight: 600; }
.tree-tool.locked { color: #7b8798; }
.badge-adv {
  font-size: 10px; background: #f59e0b; color: #fff; border-radius: 4px;
  padding: 1px 5px; margin-left: auto;
}
.badge-free, .badge-vip { padding: 1px 5px; margin-left: auto; border-radius: 4px; color: #fff; font-size: 10px; }
.badge-free { background: #16a34a; }.badge-vip { background: #9a6b16; }
.adv-tag {
  font-size: 12px; background: #fef3c7; color: #b45309; border-radius: 6px;
  padding: 2px 8px; margin-left: 8px; font-weight: 600; vertical-align: middle;
}

/* 工作区 */
.workspace { flex: 1; overflow-y: auto; padding: 22px 26px 60px; }
.placeholder { color: var(--muted); margin-top: 60px; text-align: center; font-size: 15px; }
.tool-title { font-size: 20px; font-weight: 700; margin: 0 0 18px; }
.tool-title small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card h3 {
  margin: 0 0 14px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); font-weight: 700;
}

/* 上部驾驶舱：左输入 / 右输出，尽量一屏 */
.cockpit {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.15fr);
  gap: 18px;
  min-height: calc(100vh - 200px);
}
@media (max-width: 820px) { .cockpit { grid-template-columns: 1fr; min-height: 0; } }

/* 表单 */
.field { margin-bottom: 13px; }
.field.hidden { display: none; }
.field label { display: block; font-size: 13px; margin-bottom: 5px; color: #334155; font-weight: 500; }
.field input[type=text], .field input[type=number], .field textarea, .field select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: var(--surface-2); color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { min-height: 110px; resize: vertical; }
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox label { margin: 0; }

button.primary {
  width: 100%; background: var(--accent); color: #fff; border: none; padding: 11px;
  border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; margin-top: 4px;
}
button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { background: #94a3b8; cursor: not-allowed; }

/* 输出面板 */
.output-pane { display: flex; flex-direction: column; gap: 14px; }
.schematic {
  display: flex; justify-content: center; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; min-height: 220px;
}
.schematic svg { width: auto; height: 300px; max-width: 100%; }

.status-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px;
  padding: 6px 12px; border-radius: 20px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); align-self: flex-start;
}
.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-chip.running { color: var(--run); background: #eff6ff; border-color: #bfdbfe; }
.status-chip.completed { color: var(--ok); background: #f0fdf4; border-color: #bbf7d0; }
.status-chip.failed, .status-chip.cancelled { color: var(--err); background: #fef2f2; border-color: #fecaca; }

table.result { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.result th, table.result td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
table.result tr td:first-child { color: var(--muted); }
table.result tr td:not(:first-child) { font-weight: 600; }
table.result th { background: var(--surface-2); font-weight: 700; color: var(--text); }
table.result th:not(:first-child) { text-align: right; }
table.result td:not(:first-child) { text-align: right; }
/* 高亮「推荐(标称)」列 */
table.result th:last-child, table.result td:last-child { color: var(--accent); }
table.result thead th:last-child { background: #eff6ff; }
pre.result { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.result-empty { color: var(--muted); font-size: 13px; }

/* 说明 / 反馈（在下方，需滚动） */
.below { margin-top: 20px; display: flex; flex-direction: column; gap: 18px; }
.md h3, .md h4, .md h5 { margin: 12px 0 6px; }
.md p { margin: 6px 0; line-height: 1.6; }
.md ul { margin: 6px 0; padding-left: 22px; line-height: 1.7; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.md pre.result { white-space: pre-wrap; }

.fb-row { display: flex; gap: 10px; align-items: flex-start; }
.fb-row textarea { flex: 1; min-height: 70px; }
.fb-row button { width: auto; padding: 9px 18px; align-self: stretch; }
#fb-msg { color: var(--muted); font-size: 12px; margin-top: 6px; display: inline-block; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 24px; max-width: 420px; box-shadow: var(--shadow); }
.modal-box p { margin: 0 0 8px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal-actions button { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 13.5px; }
.modal-actions button.primary { background: var(--accent); color: #fff; border: none; width: auto; margin: 0; }
