:root {
  --bg: #0a0a0c;
  --panel: #141417;
  --panel-2: #1b1b20;
  --border: #2b2b31;
  --ink: #ece8dc;
  --muted: #9a9384;
  --accent: #d4af37;
  --accent-dark: #b8942a;
  --accent-bright: #e8c55a;
  --accent-soft: rgba(212, 175, 55, 0.12);
  --good: #34c17b;
  --danger: #e06a5f;
  --radius: 12px;
  --font-ui: "PingFang SC", -apple-system, "Segoe UI", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-prose: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(212, 175, 55, 0.06), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- 三栏骨架 ---------- */
.cols { display: flex; height: 100vh; overflow: hidden; }
/* 可拖拽分隔条 */
.resizer { flex: none; width: 5px; cursor: col-resize; background: transparent; transition: background 0.15s; position: relative; z-index: 5; }
.resizer:hover, .resizer.active { background: var(--accent); }
.resizer-v { height: 5px; cursor: row-resize; background: transparent; transition: background 0.15s; border-radius: 4px; }
.resizer-v:hover, .resizer-v.active { background: var(--accent); }

/* ---------- 左栏：书稿管理 ---------- */
.col-left {
  width: 240px;
  flex: none;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 12px;
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 2px 4px; }
.brand-logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-dark));
  color: #0a0a0c; font-size: 16px; font-weight: 800;
  border-radius: 9px;
  font-family: Georgia, serif;
}
.brand-text b { display: block; font-size: 14.5px; color: var(--accent-bright); }
.brand-text span { font-size: 11px; color: var(--muted); }

.btn-new {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-dark));
  color: #0a0a0c;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  transition: filter 0.15s;
}
.btn-new:hover { filter: brightness(1.08); }
.btn-library {
  width: 100%;
  padding: 9px;
  background: transparent;
  color: var(--accent-bright);
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
  transition: all 0.15s;
}
.btn-library:hover { background: var(--accent-soft); border-color: var(--accent); }

.search {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: var(--panel-2);
  color: var(--ink);
}
.search::placeholder { color: var(--muted); }
.search:focus { border-color: var(--accent); }

.book-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.book-item {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  cursor: pointer;
  background: var(--panel-2);
  transition: border-color 0.12s, background 0.12s;
}
.book-item { position: relative; }
.book-item:hover { border-color: var(--accent); }
.book-item.active { border-color: var(--accent); background: var(--accent-soft); }
.book-item .bi-title { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 22px; }
/* 书稿卡片右上角的「改书名/作者」铅笔：平时淡出，悬停或聚焦时显形 */
.book-item .bi-edit {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; cursor: pointer;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted); opacity: 0; transition: opacity .12s, color .12s, background .12s;
}
.book-item:hover .bi-edit, .book-item .bi-edit:focus { opacity: 1; }
.book-item .bi-edit:hover { color: var(--accent-bright); background: rgba(184,148,42,.14); border-color: var(--accent); }
.book-item .bi-meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; align-items: center; }
.book-item .bi-score { color: var(--accent-bright); font-weight: 700; }
.book-item .bi-score.bad { color: var(--danger); }
.bi-progress { height: 3px; background: #2b2b31; border-radius: 3px; margin-top: 7px; overflow: hidden; }
.bi-progress .fill { height: 100%; background: linear-gradient(90deg, var(--accent-dark), var(--accent-bright)); border-radius: 3px; transition: width 0.3s ease; }
.bi-status { font-size: 10px; color: var(--muted); }
.bi-status.running { color: var(--accent-bright); }
.bi-status.done { color: var(--good); }
.bi-status.interrupted { color: var(--accent); }
.bi-status.error { color: var(--danger); }
.book-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px 4px; }

.lang-badge { display: inline-block; margin-left: 6px; padding: 1px 5px; font-size: 9px; line-height: 1.4; border-radius: 3px; vertical-align: 1px; font-weight: 700; letter-spacing: 0.5px; }
.lang-badge.en { color: #7fb3ff; border: 1px solid #3b5d8f; background: rgba(63, 114, 201, 0.12); }
.lang-badge.zh { color: var(--accent-bright); border: 1px solid var(--accent-dark); background: rgba(212, 175, 55, 0.1); }
.lang-badge.tr { color: #6ee7b7; border: 1px solid #2f8f6b; background: rgba(52, 211, 153, 0.1); }

.user {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #2b2b31; color: var(--accent-bright);
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.user-text { flex: 1; }
.user-text b { display: block; font-size: 12.5px; }
.user-text span { font-size: 10.5px; color: var(--muted); }
.icon-btn { border: none; background: transparent; font-size: 15px; color: var(--muted); border-radius: 6px; padding: 4px 8px; }
.icon-btn:hover { background: var(--panel-2); color: var(--accent-bright); }

/* ---------- 中栏：创作区 ---------- */
.col-center { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.chat-title { font-size: 14.5px; font-weight: 700; letter-spacing: 0.3px; color: var(--accent-bright); }
.chat-title span { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: #3a3a42; }
.conn.on .dot { background: var(--good); box-shadow: 0 0 0 3px rgba(52, 193, 123, 0.15); }
.conn.off .dot { background: var(--danger); }

/* 各 Agent 阶段进度条（中间区域） */
.stepper {
  list-style: none;
  display: flex;
  margin: 0;
  padding: 12px 18px 10px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.stepper .step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; gap: 5px; min-width: 0; }
.stepper .step::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.stepper .step:first-child::before { display: none; }
.stepper .step .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 2px solid var(--border); font-size: 12px; position: relative; z-index: 1; filter: grayscale(1); opacity: 0.55; transition: all 0.2s; }
.stepper .step .name { font-size: 10.5px; color: var(--muted); text-align: center; white-space: nowrap; }
.stepper .step.active .dot { border-color: var(--accent); filter: none; opacity: 1; box-shadow: 0 0 0 4px var(--accent-soft); animation: pulse 1.4s infinite; }
.stepper .step.active .name { color: var(--accent-bright); font-weight: 650; }
.stepper .step.done .dot { border-color: var(--good); background: var(--good); color: #0a0a0c; filter: none; opacity: 1; }
.stepper .step.done .name { color: var(--good); }
.stepper .step.done::before, .stepper .step.active::before { background: var(--good); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); } 50% { box-shadow: 0 0 0 7px rgba(212, 175, 55, 0.12); } }

.chat-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.agent { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble { background: var(--accent-soft); color: var(--ink); border: 1px solid rgba(212, 175, 55, 0.35); border-bottom-right-radius: 4px; }
.msg.agent .bubble { background: var(--panel-2); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble .progress-list { margin: 2px 0; }
.bubble .pl-item { display: flex; gap: 6px; align-items: center; }
.bubble .pl-item .pl-ico { width: 16px; text-align: center; }
.bubble .pl-done { color: var(--good); }
.bubble .pl-active { color: var(--accent-bright); font-weight: 600; }
.bubble .pl-pending { color: #4a4a52; }
.bubble .score-line { font-weight: 700; }
.bubble .score-line.good { color: var(--good); }
.bubble .score-line.bad { color: var(--danger); }

/* 风格倾向选择（聊天内两个按钮） */
.tendencies { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.tendency-btn {
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: var(--ink);
  border-radius: 9px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s;
}
.tendency-btn:hover { background: rgba(212, 175, 55, 0.16); border-color: var(--accent); }
.tendency-btn .t-name { font-weight: 700; color: var(--accent-bright); display: block; margin-bottom: 3px; font-size: 13.5px; }
.tendency-btn .t-desc { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* 每章完成后的交互检查点 */
.checkpoint-box { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.checkpoint-box .btn { width: 100%; justify-content: center; }
.checkpoint-input {
  width: 100%;
  min-height: 64px;
  padding: 9px 11px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 8px;
  background: #0f0f12;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  font-family: inherit;
}
.checkpoint-input:focus { border-color: var(--accent); }

.chat-input {
  flex: none;
  border-top: 1px solid var(--border);
  padding: 12px 18px 14px;
  background: var(--panel);
}
.input-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; gap: 10px; }
.input-title { font-size: 12.5px; font-weight: 650; color: var(--accent-bright); white-space: nowrap; }
.input-controls { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; margin-bottom: 8px; }
.model-select {
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  padding: 4px 8px;
  background: var(--panel-2);
  color: var(--ink);
  max-width: 200px;
  outline: none;
}
.model-select:focus { border-color: var(--accent); }
.chat-input textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.6;
  resize: none;
  outline: none;
  background: var(--panel-2);
  color: var(--ink);
}
.chat-input textarea::placeholder { color: var(--muted); }
.chat-input textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.08); }
.input-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.hint { font-size: 11.5px; color: var(--muted); }
.btn-send {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent-dark));
  color: #0a0a0c;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 700;
  transition: filter 0.15s;
}
.btn-send:hover { filter: brightness(1.08); }
.btn-send:disabled { background: #3a3a42; color: var(--muted); cursor: not-allowed; }

/* ---------- 右栏：辅助与导出 ---------- */
.col-right {
  width: 300px;
  flex: none;
  border-left: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
}
.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card h3 { font-size: 14px; margin-bottom: 10px; color: var(--accent-bright); }
/* 写作进展卡片：高度可拖拽调整，内部 live-stream 自动填满 */
#progressCard { display: flex; flex-direction: column; height: 340px; flex: none; }
#progressCard .live-stream { flex: 1; height: auto; min-height: 80px; }
#exportCard { flex: 1; min-height: 160px; display: flex; flex-direction: column; }
.live-stream {
  height: 300px;
  overflow-y: auto;
  background: #0f0f12;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.8;
  color: #d8d3c6;
  white-space: pre-wrap;
  word-break: break-word;
}
.live-stream .ls-head { font-weight: 650; color: var(--accent-bright); margin-bottom: 6px; }
.ls-empty { color: var(--muted); font-size: 12.5px; line-height: 1.7; text-align: center; padding: 20px 6px; }

.sub { font-size: 11.5px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.menu.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; }
.menu-item {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
  color: var(--ink);
  transition: all 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 6px;
  font-size: 12px;
  text-align: center;
  line-height: 1.3;
}
.menu-item:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
.mi-ico { font-size: 16px; line-height: 1; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); width: min(860px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; color: var(--accent-bright); }
.modal-body { padding: 18px 20px; overflow-y: auto; }

.model-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.model-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel-2); }
.model-item .mi-name { font-weight: 650; font-size: 13.5px; }
.model-item .mi-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.model-item .mi-actions { display: flex; gap: 6px; }
.mi-actions .btn { padding: 5px 9px; font-size: 12px; }
.model-form { border-top: 1px dashed var(--border); padding-top: 14px; }
.model-form h4 { font-size: 13px; margin-bottom: 10px; }

/* 书库 */
.lib-stats { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.lib-list { display: flex; flex-direction: column; gap: 10px; }
.lib-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--panel-2); display: flex; gap: 12px; }
.lib-item.active { border-color: var(--accent); }
/* 封面缩略图 */
.lib-cover { flex: none; width: 56px; height: 76px; border-radius: 5px; overflow: hidden; background: #1b1b20; border: 1px solid var(--border); align-self: flex-start; }
.lib-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-cover-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #555; }
.lib-main { flex: 1; min-width: 0; }
.lib-title { font-weight: 650; font-size: 14px; color: var(--ink); }
.lib-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
/* 进度与操作按钮同行：进度在左、按钮水平排列在右 */
.lib-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; flex-wrap: wrap; }
.lib-progress { flex: 1 1 140px; min-width: 140px; }
.lib-status { font-size: 11px; margin-top: 6px; }
.lib-status.done { color: var(--good); }
.lib-status.running { color: var(--accent-bright); }
.lib-status.interrupted { color: var(--accent); }
.lib-status.error { color: var(--danger); }
.lib-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.lib-actions .btn { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.lib-actions .btn-translate { border-color: rgba(212, 175, 55, 0.45); color: var(--accent-bright); }
.lib-actions .btn.danger { border-color: var(--danger); color: var(--danger); font-weight: 700; }

/* 自定义删除确认弹窗 */
.confirm-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.confirm-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; max-width: 340px; width: 90%; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); }
.confirm-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--ink); }
.confirm-text { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.7; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-danger { background: var(--danger); border: 1px solid var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.12); }

/* 书籍封面 */
.cover-area { min-height: 240px; display: flex; align-items: center; justify-content: center; background: #141418; border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.cover-hint { color: var(--muted); font-size: 12.5px; text-align: center; line-height: 1.8; padding: 20px; }
.cover-img { max-width: 100%; max-height: 420px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55); }
.cover-actions { display: flex; justify-content: center; gap: 10px; }

/* ---------- 阅读视图 ---------- */
.read-prose { font-family: var(--font-prose); font-size: 16px; line-height: 2; color: #e3ded2; }
.read-prose h1 { text-align: center; font-size: 1.7em; margin: 0.3em 0; color: var(--accent-bright); }
.read-prose h2 { margin: 1.4em 0 0.4em; font-size: 1.2em; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; color: var(--accent-bright); }
.read-prose p { text-indent: 2em; margin: 0.5em 0; }
.read-prose blockquote { color: var(--muted); border-left: 3px solid rgba(212, 175, 55, 0.4); margin: 0.8em 0; padding: 0.1em 1em; background: var(--panel-2); }
.read-prose hr { border: none; border-top: 1px solid var(--border); margin: 1.4em auto; width: 40%; }
.outline-list { display: flex; flex-direction: column; gap: 10px; }
.outline-item { border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; background: var(--panel-2); }
.outline-item .oi-title { font-weight: 650; font-size: 14px; color: var(--accent-bright); }
.outline-item .oi-words { color: var(--accent); font-size: 12px; margin-left: 8px; }
.outline-item .oi-sum { font-size: 13px; color: #cfc9bb; margin-top: 4px; line-height: 1.7; }
.oi-points { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.oi-point { font-size: 12.5px; color: #cfc9bb; line-height: 1.6; padding-left: 2px; }
.oi-point b { color: var(--accent-bright); margin-right: 5px; }
.oi-hook { margin-top: 8px; font-size: 12.5px; color: var(--accent-bright); }
.oi-hook span { display: inline-block; font-size: 10.5px; border: 1px solid rgba(212, 175, 55, 0.4); color: var(--accent-bright); border-radius: 4px; padding: 0 5px; margin-right: 6px; }
.bp-subhead { font-size: 13px; color: var(--accent-bright); margin: 16px 0 8px; }
.blueprint-grid { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; font-size: 13.5px; }
.blueprint-grid .bp-k { color: var(--accent-bright); }
.blueprint-grid .bp-v { line-height: 1.7; color: #d8d3c6; }

/* ---------- 表单/按钮（弹窗内复用） ---------- */
.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 550; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--panel-2);
  outline: none;
}
.input:focus { border-color: var(--accent); }
.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.btn-primary { background: linear-gradient(135deg, var(--accent-bright), var(--accent-dark)); color: #0a0a0c; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-bright); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--accent-bright); background: var(--panel-2); }
.action-row { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--accent);
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 200;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .col-right { display: none; }
  .col-left { width: 200px; }
}
@media (max-width: 640px) {
  .col-left { display: none; }
  .bubble { max-width: 92%; }
}

/* ---------- 智能配图 ---------- */
.opt-inline {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}
.opt-inline input { accent-color: #c8a86b; cursor: pointer; }
.ls-figs { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 14px 16px; }
.ls-figs:empty { display: none; }
.ls-fig {
  margin: 0; flex: 1 1 240px; max-width: 320px;
  background: #fff; border: 1px solid var(--line, #2a2a2a); border-radius: 4px; padding: 6px;
}
.ls-fig img { width: 100%; height: 180px; object-fit: cover; border-radius: 2px; display: block; background: #111; }
.ls-fig figcaption { font-size: 11px; line-height: 1.6; color: var(--muted); margin-top: 6px; }
.ls-fig .fig-src { display: block; margin-top: 2px; font-size: 10px; color: #8a8a8a; }
.ls-fig .fig-src a { color: #c8a86b; text-decoration: none; }

/* ---------- 右栏：书籍配图（预览 + 下载） ---------- */
#illusCard { display: flex; flex-direction: column; height: 260px; flex: none; min-height: 120px; }
#illusCard h3 { display: flex; align-items: center; gap: 8px; }
.count-badge {
  display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 10px;
  background: #2b2b31; color: #c8a86b; font-size: 11px; font-weight: 600; text-align: center;
}
.h3-actions { margin-left: auto; display: inline-flex; gap: 6px; }
.mini-btn {
  background: transparent; border: 1px solid var(--line, #2a2a2a); color: var(--muted, #9a9384);
  border-radius: 5px; font-size: 11px; padding: 2px 8px; cursor: pointer; white-space: nowrap;
}
.mini-btn:hover { border-color: #c8a86b; color: #e8c55a; }

.illus-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  overflow-y: auto; padding: 2px; margin-top: 4px; min-height: 60px; flex: 1;
}
.illus-empty { grid-column: 1 / -1; color: var(--muted, #9a9384); font-size: 12px; line-height: 1.7; padding: 10px 4px; text-align: center; }
.illus-thumb {
  position: relative; border: 1px solid var(--line, #2a2a2a); border-radius: 5px;
  overflow: hidden; cursor: zoom-in; background: #111; aspect-ratio: 4 / 3;
}
.illus-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.illus-thumb:hover img { transform: scale(1.06); }
.illus-thumb .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 6px 4px;
  font-size: 10px; line-height: 1.4; color: #f0ece2; max-height: 3.2em; overflow: hidden;
  background: linear-gradient(transparent, rgba(0,0,0,.82));
}
.illus-thumb .no {
  position: absolute; top: 4px; left: 4px; padding: 1px 6px; border-radius: 8px;
  background: rgba(0,0,0,.62); color: #e8c55a; font-size: 10px;
}
.illus-thumb .dl {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; line-height: 20px;
  border-radius: 50%; background: rgba(0,0,0,.62); color: #f0ece2; font-size: 12px;
  text-align: center; text-decoration: none; opacity: 0; transition: opacity .2s;
}
.illus-thumb:hover .dl { opacity: 1; }
.illus-thumb .dl:hover { background: #c8a86b; color: #17171a; }

/* 预览弹窗 */
.modal-img .modal-card, .modal-card.modal-img { width: min(920px, 92vw); }
.img-stage {
  display: flex; align-items: center; justify-content: center;
  background: #111114; border: 1px solid var(--line, #2a2a2a); border-radius: 6px; padding: 10px;
  max-height: 62vh; overflow: hidden;
}
.img-stage img { max-width: 100%; max-height: 58vh; object-fit: contain; display: block; }
.img-meta { margin: 12px 2px; font-size: 12px; line-height: 1.9; color: var(--muted, #9a9384); }
.img-meta b { color: #e8c55a; }
.img-meta a { color: #c8a86b; }

/* ---------- 封面风格选择 ---------- */
.cover-style-bar { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; }
.cs-label { font-size: 12px; color: var(--muted, #9a9384); white-space: nowrap; padding-top: 4px; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.cs-chip {
  border: 1px solid var(--line, #2a2a2a); background: transparent; color: var(--muted, #9a9384);
  border-radius: 14px; padding: 3px 11px; font-size: 12px; cursor: pointer; transition: all .15s;
}
.cs-chip:hover { border-color: #c8a86b; color: #e8c55a; }
.cs-chip.on { background: linear-gradient(135deg, #b8942a, #e8c55a); border-color: #e8c55a; color: #17171a; font-weight: 600; }
.cs-chip .cs-desc { display: none; }
.cover-tip { margin-top: 10px; font-size: 11.5px; line-height: 1.7; color: #8a8a8a; }
.cover-tip b { color: #c8a86b; }

/* 封面生成信息（风格/模型/自检结果） */
.cover-info {
  margin-top: 10px; font-size: 11.5px; line-height: 1.8; color: #8a8a8a;
  border-top: 1px solid var(--line, #2a2a2a); padding-top: 8px; text-align: center;
}
.cover-info b { color: #c8a86b; }

/* ---------- 研究档案（史料 / 论断 / 场景防火墙） ---------- */
.rs-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.rs-stat { flex: 1 1 90px; background: var(--panel-2, #1c1c20); border: 1px solid var(--line, #2a2a2a); border-radius: 8px; padding: 10px 12px; text-align: center; }
.rs-stat b { display: block; font-size: 20px; color: #e8c55a; }
.rs-stat span { font-size: 11.5px; color: var(--muted, #9a9384); }
.rs-h { margin: 18px 0 8px; font-size: 13px; color: var(--accent-bright, #e8c55a); border-left: 3px solid #c8a86b; padding-left: 8px; }
.rs-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.rs-row { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; line-height: 1.65; padding: 6px 8px; background: var(--panel-2, #1c1c20); border-radius: 5px; }
.rs-id { color: #c8a86b; font-family: ui-monospace, monospace; font-size: 11.5px; flex: none; }
.rs-tag { flex: none; font-size: 11px; padding: 1px 7px; border-radius: 9px; border: 1px solid #3a3a42; color: #b9b2a4; }
.rs-tag.ok { border-color: #3f7d52; color: #74d18d; }
.rs-tag.warn { border-color: #8a6d2f; color: #e8c55a; }
.rs-tag.bad { border-color: #8a3a3a; color: #ff8a8a; }
.rs-tag.info { border-color: #3a5a8a; color: #8ab4ff; }
.rs-main { flex: 1; color: #ddd8cd; }
.rs-meta { color: #8a8a8a; font-size: 11.5px; flex: none; max-width: 46%; text-align: right; }
.rs-empty { color: var(--muted, #9a9384); font-size: 12px; padding: 6px 2px; }

/* ---------- 对话命令列表 ---------- */
.cmd-list { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.cmd-row { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; }
.cmd-row code {
  flex: none; min-width: 150px; color: #e8c55a; background: #1c1c20;
  border: 1px solid var(--line, #2a2a2a); border-radius: 4px; padding: 1px 6px;
  font-size: 11.5px; font-family: ui-monospace, monospace;
}
.cmd-row span { color: var(--muted, #9a9384); }

/* ---------- 账号：登录 / 注册弹窗 ---------- */
.auth-mask {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 12, .78); backdrop-filter: blur(3px); padding: 20px;
}
.auth-mask.hidden { display: none; }
.auth-card {
  position: relative; width: min(94vw, 400px); max-height: 92vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px 24px 20px; box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.auth-close {
  position: absolute; top: 10px; right: 12px; border: 0; background: transparent;
  color: var(--muted); font-size: 15px; cursor: pointer;
}
.auth-close:hover { color: var(--ink); }
.auth-logo { text-align: center; font-size: 26px; }
.auth-title { margin: 8px 0 4px; font-size: 17px; text-align: center; color: var(--ink); }
.auth-sub { margin: 0 0 16px; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.6; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.auth-tab {
  flex: 1; padding: 8px 0; font-size: 13px; cursor: pointer;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); border-radius: 9px;
}
.auth-tab.on { color: var(--accent-bright); border-color: var(--accent); background: var(--accent-soft); }
.auth-form { display: flex; flex-direction: column; }
.auth-form.hidden { display: none; }
.auth-form label { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.auth-form input {
  width: 100%; padding: 10px 12px; font-size: 14px; border-radius: 9px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--border);
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-btn {
  margin-top: 16px; padding: 11px 14px; border: 0; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: #fff; background: linear-gradient(180deg, #b8942a, #96771f);
}
.auth-btn:disabled { opacity: .6; cursor: default; }
.auth-steps { display: flex; flex-direction: column; }
.auth-steps.hidden { display: none; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.auth-links a { color: var(--accent-bright); text-decoration: none; }
.auth-note { min-height: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.auth-note.err { color: var(--danger); }
.auth-note.ok { color: var(--accent-bright); }
.auth-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); line-height: 1.6; }

/* 顶栏用户信息 */
.user-box { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.user-box .u-name { color: var(--ink); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box .u-role { color: var(--accent-bright); font-size: 11px; }
.user-box button {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
  border-radius: 7px; padding: 3px 8px; font-size: 11px; cursor: pointer;
}
.user-box button:hover { color: var(--ink); border-color: var(--accent); }
.chat-input.locked textarea { opacity: .55; }
.chat-head-right { display: flex; align-items: center; gap: 14px; }
.user-box button { white-space: nowrap; }

/* 邮件通道区块（模型配置弹窗内） */
.mail-box { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.mail-box h4 { margin: 0 0 10px; font-size: 13px; color: var(--ink); }
.mail-status { font-size: 12px; color: var(--muted); line-height: 1.7; margin-bottom: 12px; }
.mail-status .warn { color: var(--accent-bright); }
.mail-hint { margin-top: 10px; font-size: 11px; color: var(--muted); line-height: 1.7; }
.mail-hint code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; }
.mail-box .field-row { align-items: flex-end; }

/* 用量日报 */
.modal-card.wide { width: min(94vw, 860px); }
.report-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.report-toolbar .input { width: 150px; }
.report-note { font-size: 12px; color: var(--muted); }
.report-body { font-size: 13px; color: var(--ink); line-height: 1.7; }
.report-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.report-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.report-card .k { font-size: 11px; color: var(--muted); }
.report-card .v { font-size: 17px; font-weight: 600; margin-top: 3px; }
.report-body h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.report-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.report-table th, .report-table td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.report-table th { color: var(--muted); font-weight: 500; }
.report-table td.num, .report-table th.num { text-align: right; }
.report-dim { color: var(--muted); }
