/* ============ 基础 ============ */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2329;
  --ink2: #5f6672;
  --ink3: #9ca3af;
  --line: #e5e7eb;
  --brand: #c0392b;
  --brand2: #e8590c;
  --brand-soft: #fdf0ee;
  --ok: #1e8e5a;
  --ok-bg: #eaf7f0;
  --warn: #b7791f;
  --warn-bg: #fdf6e7;
  --fail: #c0392b;
  --fail-bg: #fdecea;
  --blue: #2b6cb0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 16px -6px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; }

a { color: var(--brand); text-decoration: none; }

/* ============ 布局 ============ */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: #1e2228;
  color: #e6e8eb;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.brand {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #e8590c, #c0392b);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.brand-txt b { display: block; font-size: 14.5px; }
.brand-txt small { display: block; font-size: 11.5px; color: #8b949e; font-weight: 400; }

.nav { padding: 10px 8px; flex: 1; }
.nav-grp { font-size: 11.5px; color: #6b7280; padding: 10px 12px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  cursor: pointer; color: #c9cdd4; font-size: 13.5px;
  transition: .15s; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.on { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item .ic { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.nav-foot { padding: 10px 8px 14px; border-top: 1px solid rgba(255, 255, 255, .07); }

.side-stat {
  margin: 8px 12px 0; padding: 10px 12px;
  background: rgba(255, 255, 255, .05); border-radius: 9px;
  font-size: 12px; color: #9ca3af; line-height: 1.9;
}
.side-stat b { color: #e6e8eb; font-size: 13px; }
.side-stat.clk { cursor: pointer; transition: .15s; }
.side-stat.clk:hover { background: rgba(255, 255, 255, .1); }

/* 状态条三行：模型通道 / 检索 / 图源，左边小圆点表示通不通 */
.sd-row {
  display: flex; align-items: center; gap: 6px;
  padding: 1px 0; overflow: hidden;
}
.sd-row span:nth-child(2) { color: #8b949e; flex-shrink: 0; }
.sd-row b {
  margin-left: auto; font-size: 12px; font-weight: 600;
  max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: right;
}
.sd-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: #6b7280;
}
.sd-dot.on { background: #34d399; box-shadow: 0 0 5px rgba(52, 211, 153, .7); }
.sd-dot.off { background: #f87171; }
.sd-hint { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .07); }

.main { flex: 1; overflow-y: auto; position: relative; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 11px 22px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

.topbar .sp { flex: 1; }
.top-title { font-size: 15px; font-weight: 700; }

/* ============ 通用组件 ============ */
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 22px 80px; }
.wrap-narrow { max-width: 780px; margin: 0 auto; padding: 20px 22px 80px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card.pad0 { padding: 0; }

.card h2 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .tag {
  font-size: 11px; font-weight: 400; color: var(--ink2);
  background: #f2f3f5; padding: 2px 8px; border-radius: 20px;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--card);
  border-radius: 9px; padding: 8px 15px; font-size: 13.5px;
  color: var(--ink); cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #c9cdd4; background: #fafbfc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.p {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(192, 57, 43, .22);
}
.btn.p:hover:not(:disabled) { background: #a93226; border-color: #a93226; }
.btn.p2 {
  background: linear-gradient(135deg, #e8590c, #c0392b); border: 0; color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(232, 89, 12, .28);
}
.btn.p2:hover:not(:disabled) { filter: brightness(1.06); }
.btn.s { background: #f2f3f5; border-color: transparent; color: var(--ink2); }
.btn.danger { color: var(--fail); border-color: #f5c2bd; }
.btn.wide { width: 100%; padding: 11px; font-size: 14.5px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.mt { margin-top: 14px; }

label.lab { display: block; font-size: 13px; color: var(--ink2); margin: 14px 0 6px; font-weight: 500; }
label.lab b { color: var(--ink); }
label.lab:first-child { margin-top: 0; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 13px; font-size: 14px; background: #fafbfc;
  transition: .15s; color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); background: #fff;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
select { cursor: pointer; }

.hint { font-size: 12.5px; color: var(--ink3); margin-top: 7px; line-height: 1.8; }
.hint.warn { color: var(--warn); }
.hint.err { color: var(--fail); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  font-size: 12.5px; padding: 5px 12px; border-radius: 20px;
  background: #f2f3f5; color: var(--ink2); cursor: pointer; border: 1px solid transparent;
}
.chip:hover { background: var(--brand-soft); color: var(--brand); }
.chip.on { background: var(--brand); color: #fff; }

.radios { display: flex; gap: 18px; align-items: center; margin-top: 6px; }
.radios label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }

.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: #f2f3f5; color: var(--ink2); font-weight: 500;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.badge.blue { background: #eef4ff; color: var(--blue); }

/* ============ 步骤条 ============ */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.step {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; color: var(--ink2); transition: .2s;
}
.step .n {
  width: 20px; height: 20px; border-radius: 50%; background: #eef0f3;
  color: var(--ink2); display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
}
.step.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.step.active .n { background: var(--brand); color: #fff; }
.step.done { color: var(--ok); }
.step.done .n { background: var(--ok); color: #fff; }
.step.clk { cursor: pointer; }
.step.clk:hover { border-color: #c9cdd4; }

/* ============ 角度卡片 ============ */
.angle {
  border: 1px solid var(--line); border-radius: 11px; padding: 15px 16px;
  margin-bottom: 11px; background: #fff; transition: .15s; cursor: pointer;
}
.angle:hover { border-color: #c9cdd4; box-shadow: var(--shadow); }
.angle.on { border-color: var(--brand); background: var(--brand-soft); }
.angle-t {
  font-size: 16.5px; font-weight: 700; line-height: 1.55; margin-bottom: 10px;
  display: flex; gap: 9px; align-items: flex-start;
}
.angle-t .no {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px;
  background: var(--brand); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center; margin-top: 3px;
}
.angle-meta { font-size: 12.5px; color: var(--ink2); line-height: 2; }
.angle-meta b { color: var(--ink); font-weight: 600; }
.angle-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

/* ============ 文章区 ============ */
.article-box {
  background: #fafbfc; border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; font-size: 15.5px; line-height: 2; white-space: pre-wrap;
  word-break: break-word; max-height: 620px; overflow-y: auto;
}
.article-box h3 {
  font-size: 16px; font-weight: 700; text-align: center;
  margin: 22px 0 12px; line-height: 1.8;
}
.article-box p { margin-bottom: 14px; }

.preview-box {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 22px; max-height: 700px; overflow-y: auto;
}
.preview-box img { max-width: 100%; border-radius: 8px; display: block; margin: 0 auto; }

.fig-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  background: #fafbfc; text-align: center;
}
.fig-card img { max-width: 100%; max-height: 200px; border-radius: 8px; display: block; margin: 0 auto 8px; }
.fig-card .cap { font-size: 12px; color: var(--ink3); line-height: 1.7; }
.fig-card.fail { border-style: dashed; border-color: #dd3333; padding: 22px 10px; color: var(--fail); font-size: 12.5px; }
.figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }

/* ============ 流式状态 ============ */
.status {
  display: flex; align-items: center; gap: 9px; padding: 10px 14px;
  background: #eef4ff; border: 1px solid #dbe7ff; border-radius: 9px;
  font-size: 13px; color: var(--blue); margin-bottom: 12px; font-weight: 500;
}
.status.err { background: var(--fail-bg); border-color: #f5c2bd; color: var(--fail); }
.status.ok { background: var(--ok-bg); border-color: #c6ead8; color: var(--ok); }
.status.warn { background: var(--warn-bg); border-color: #f0e0b8; color: var(--warn); }

.spin {
  width: 14px; height: 14px; border: 2px solid rgba(43, 108, 176, .25);
  border-top-color: var(--blue); border-radius: 50%;
  animation: sp .7s linear infinite; flex-shrink: 0;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ============ 任务进度条（裂变/写作/配图/降AI 共用） ============ */
/* 为什么要统一成一块：以前每个环节各写各的提示，有的连秒数都没有，
   界面十几秒不动用户就以为死机了，反复点按钮反而更慢。
   这块固定给出「在做什么 + 已经跑了多久 + 大概到哪了 + 别乱点」四件事。 */
.job {
  background: linear-gradient(180deg, #f7faff, #eef4ff);
  border: 1px solid #dbe7ff; border-radius: 11px;
  padding: 13px 15px; margin-bottom: 12px;
}
.job.done { background: var(--ok-bg); border-color: #c6ead8; }
.job.fail { background: var(--fail-bg); border-color: #f5c2bd; }
.job-head { display: flex; align-items: center; gap: 9px; }
.job-title { font-size: 13.5px; font-weight: 600; color: var(--blue); flex: 1; }
.job.done .job-title { color: var(--ok); }
.job.fail .job-title { color: var(--fail); }
.job-time {
  font-size: 12.5px; color: var(--ink2); font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, .8); border-radius: 20px; padding: 2px 10px;
  font-family: ui-monospace, Consolas, monospace;
}
.job-bar {
  height: 5px; border-radius: 4px; background: rgba(43, 108, 176, .14);
  margin: 10px 0 8px; overflow: hidden;
}
.job-bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #4c8fe0, #2b6cb0);
  border-radius: 4px; transition: width .45s ease;
}
.job.done .job-bar > i { background: var(--ok); }
.job.fail .job-bar > i { background: var(--fail); }
.job-msg { font-size: 13px; color: var(--ink); line-height: 1.75; }
.job-tip { font-size: 12px; color: var(--ink3); margin-top: 5px; line-height: 1.7; }

/* ============ 草稿保存 ============ */
.draft-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--warn-bg); border: 1px solid #f0e0b8; border-radius: 10px;
  padding: 11px 14px; margin-bottom: 14px; font-size: 13px; color: var(--warn);
}
.draft-bar .grow { flex: 1; min-width: 160px; }
.save-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); margin-right: 5px; vertical-align: middle;
}

/* ============ 表格 ============ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--ink2); font-weight: 600; background: #fafbfc; font-size: 12.5px; }
.tbl tbody tr:hover { background: #fafbfc; }

/* ============ 设置面板 ============ */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.ch-box {
  border: 1px solid var(--line); border-radius: 11px; padding: 16px;
  background: #fff; margin-bottom: 14px;
}
.ch-box h3 {
  font-size: 14px; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.ch-box h3 > span:first-child { margin-right: auto; }
.ch-box .chk { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink2); margin: 6px 0 10px; cursor: pointer; }
.ch-box .chk input { width: auto; margin: 0; cursor: pointer; }
.ch-box .own-cfg { padding: 12px; border-radius: 9px; background: var(--bg); margin-bottom: 4px; }
.ch-box .own-cfg.hide { display: none; }

.pwd-wrap { position: relative; }
.pwd-wrap .eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--ink3); cursor: pointer; background: none; border: 0;
}

.check-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.check-item:last-child { border-bottom: 0; }
.check-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.check-dot.ok { background: var(--ok); }
.check-dot.fail { background: var(--fail); }
.check-body b { display: block; font-size: 13.5px; }
.check-body .m { color: var(--ink2); font-size: 12.5px; }
.check-body .h { color: var(--warn); font-size: 12px; margin-top: 3px; }

/* ============ 提示条 ============ */
.toast-wrap {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 13.5px; box-shadow: 0 6px 22px rgba(0, 0, 0, .22);
  animation: tin .22s; max-width: 82vw;
}
.toast.err { background: #c0392b; }
.toast.ok { background: #1e8e5a; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }

/* ============ 弹窗 ============ */
.mask {
  position: fixed; inset: 0; background: rgba(15, 20, 28, .48);
  z-index: 9000; display: none; align-items: center; justify-content: center; padding: 24px;
}
.mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 860px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.modal-h {
  position: sticky; top: 0; background: #fff; z-index: 2;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-h b { font-size: 15.5px; }
.modal-b { padding: 20px; }
.modal-x {
  border: 0; background: none; font-size: 22px; color: var(--ink3);
  cursor: pointer; line-height: 1; padding: 0 4px;
}

/* ============ 空态 ============ */
.empty { text-align: center; padding: 46px 20px; color: var(--ink3); }
.empty .e-ic { font-size: 38px; margin-bottom: 10px; opacity: .5; }
.empty .e-tx { font-size: 13.5px; line-height: 1.9; }

/* ============ 工具 ============ */
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.mb0 { margin-bottom: 0; } .mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.fs12 { font-size: 12px; } .fs13 { font-size: 13px; } .fs15 { font-size: 15px; }
.dim { color: var(--ink2); } .dim3 { color: var(--ink3); }
.bold { font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.scroll-y { max-height: 460px; overflow-y: auto; }
.kv { display: flex; gap: 8px; font-size: 13px; line-height: 2.1; }
.kv .k { color: var(--ink2); min-width: 96px; flex-shrink: 0; }
.kv .v { color: var(--ink); word-break: break-all; }
.pointer { cursor: pointer; }

/* ============ 赛道下拉框 ============ */
.track-sel {
  width: 100%; max-width: 340px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; background: #fafbfc;
  color: var(--ink); cursor: pointer;
}
.track-sel:focus { outline: none; border-color: var(--brand); background: #fff; }

/* ============ 撞库提示 ============ */
.collide-note {
  font-size: 12px; color: var(--warn); background: var(--warn-bg);
  border-radius: 7px; padding: 6px 10px; margin: 6px 0 8px; line-height: 1.7;
}

/* ============ 降AI / 正文 带格式预览 ============ */
.hu-out { white-space: normal; }
.hu-out .hu-title {
  text-align: center; font-size: 17px; font-weight: 700;
  line-height: 1.9; margin: 4px 0 18px;
}
.hu-out .hu-h {
  font-size: 16px; font-weight: 700; margin: 22px 0 10px; line-height: 1.8;
}
.hu-out .hu-p { margin-bottom: 14px; }
.hu-out .gap { height: 8px; }
.hu-out .hu-fig { margin: 16px 0; text-align: center; }
.hu-out .hu-fig img {
  max-width: 100%; border-radius: 8px; display: block; margin: 0 auto;
}
.hu-out .hu-fig .cap { font-size: 12.5px; color: var(--ink3); margin-top: 6px; line-height: 1.7; }
.hu-out .hu-fig-ph {
  margin: 14px 0; padding: 16px; text-align: center;
  border: 1px dashed #d5d9e0; border-radius: 8px;
  font-size: 12.5px; color: var(--ink2); background: #fafbfc;
}
.hu-out .hu-fig-ph .dim3 { margin-left: 6px; }

/* ============ 内容库 ============ */
.lib-title { font-size: 14px; font-weight: 600; line-height: 1.6; }
.lib-prev { font-size: 12.5px; color: var(--ink2); line-height: 1.7; margin-top: 4px; }
.lib-stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.lib-stats b { font-size: 19px; color: var(--brand); }
