:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c2230;
  --line: #2a3140;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #ff5c8a;
  --accent-2: #4cc2ff;
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #11151c, #161b22);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: 1px; }
.topbar p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.mode-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(210,153,34,.15); color: var(--warn); border: 1px solid rgba(210,153,34,.4);
}
.mode-tag.live { background: rgba(63,185,80,.15); color: var(--ok); border-color: rgba(63,185,80,.4); }

.layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 65px); }
.sidebar { border-right: 1px solid var(--line); padding: 16px 12px; background: var(--panel); }
.nav-btn {
  width: 100%; text-align: left; display: flex; gap: 10px; align-items: center;
  padding: 12px 12px; margin-bottom: 8px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--text); font-size: 14px;
  transition: .15s;
}
.nav-btn:hover { background: var(--panel-2); }
.nav-btn.active { background: var(--panel-2); border-color: var(--accent); }
.nav-btn .ico { font-size: 18px; }
.nav-btn.war { border-color: rgba(255,92,138,.5); background: rgba(255,92,138,.08); font-weight: 600; }
.nav-btn.war.active { border-color: var(--accent); background: rgba(255,92,138,.16); }
.nav-sep { font-size: 11px; color: var(--muted); margin: 14px 4px 8px; letter-spacing: 1px; }

.workspace { padding: 22px 26px; max-width: 1040px; width: 100%; }
.module-head h2 { margin: 0 0 4px; font-size: 22px; }
.module-head p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.view.hidden { display: none; }

.io { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.input-card, .output-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
textarea, input, select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
.input-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); }
.primary-btn {
  background: linear-gradient(135deg, var(--accent), #ff8a5c); color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.primary-btn:disabled { opacity: .6; cursor: not-allowed; }
.ghost-btn {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-size: 13px;
}
.ghost-btn.small { padding: 5px 10px; font-size: 12px; }
.ghost-btn:hover { border-color: var(--accent-2); }

.output-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.output-body {
  font-size: 14px; line-height: 1.7; max-height: 520px; overflow: auto; white-space: normal;
}
.output-body .placeholder { color: var(--muted); }
.output-body h3 { color: var(--accent-2); margin: 14px 0 6px; font-size: 15px; }
.output-body h4 { color: var(--text); margin: 10px 0 4px; font-size: 14px; }
.output-body ul { margin: 6px 0; padding-left: 20px; }
.output-body li { margin: 3px 0; }
.output-body strong { color: #ffd479; }
.output-body table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.output-body th, .output-body td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.output-body th { background: var(--panel-2); }
.output-body code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; color: #ff9eb5; }
.output-body .tag { display: inline-block; background: rgba(76,194,255,.15); color: var(--accent-2); border:1px solid rgba(76,194,255,.35); border-radius: 6px; padding: 1px 8px; font-size: 12px; margin: 2px 3px 2px 0; }
.placeholder.small { font-size: 12px; }

/* ===== 一键作战视图 ===== */
.goal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.campaign-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.step-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.step-card.running { border-color: var(--accent-2); }
.step-card.done { border-color: rgba(63,185,80,.45); }
.step-card-head { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.step-no { font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; color: var(--muted); }
.step-icon { font-size: 17px; }
.step-spin { color: var(--accent-2); font-size: 12px; }
.step-ok { color: var(--ok); font-size: 12px; margin-left: auto; }
.step-preview { margin-top: 6px; font-size: 12px; color: var(--muted); }

.result-card { background: var(--panel); }
.goal-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }

/* 汇总作战方案（aggregateCampaign 输出） */
.step-block { border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; overflow: hidden; }
.step-head { background: var(--panel-2); padding: 9px 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.step-body { padding: 12px 16px; }
.final-advice { background: rgba(255,92,138,.08); border: 1px solid rgba(255,92,138,.35); border-radius: 12px; padding: 14px 18px; margin-top: 14px; }
.final-advice h3 { color: var(--accent); margin: 0 0 6px; }

/* 工具徽章 */
.tool-badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tool-badge { font-size: 11px; background: rgba(76,194,255,.15); color: var(--accent-2); border: 1px solid rgba(76,194,255,.35); border-radius: 6px; padding: 1px 8px; }
.demo-badge { font-size: 11px; background: rgba(210,153,34,.15); color: var(--warn); border: 1px solid rgba(210,153,34,.4); border-radius: 6px; padding: 1px 8px; }

/* 记忆面板 */
.memory-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 18px; }
.memory-head { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.memory-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow: auto; }
.hist-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; }
.hist-q { font-size: 13px; color: var(--text); }
.hist-a { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: 440px; max-width: 92vw; }
.modal-box h3 { margin: 0 0 6px; }
.modal-sub { font-size: 12px; color: var(--muted); margin: 0 0 14px; }
.modal-box label { margin-top: 12px; }
.modal-note { font-size: 12px; color: var(--muted); margin: 10px 0; min-height: 16px; }
.modal-note.ok { color: var(--ok); }
.modal-note.warn { color: var(--warn); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin-top: 14px; }
.check-row input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 60;
}
.toast.hidden { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .nav-btn { width: auto; white-space: nowrap; }
  .nav-sep { display: none; }
  .io { grid-template-columns: 1fr; }
}
