/* ============================================================
   织字工坊 v0.5 —— 设计系统
   深色专业工作台风格：层次化表面、克制的紫蓝强调色、统一的圆角与动效。
   注意：本文件与 app.js 动态生成的类名严格对应，改类名需同步改 JS。
   ============================================================ */

:root {
  /* 表面层次：从底到顶逐级提亮 */
  --bg: #0a0e17;
  --bg-soft: #0d1220;
  --surface: #121a2b;
  --surface-2: #172033;
  --surface-3: #1d2740;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .13);

  /* 文字 */
  --text: #e7eaf3;
  --text-dim: #a5adc2;
  --muted: #7b8499;

  /* 语义色 */
  --accent: #6366f1;
  --accent-hi: #818cf8;
  --accent-soft: rgba(99, 102, 241, .14);
  --purple: #a855f7;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow: 0 8px 24px rgba(0, 0, 0, .34);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);

  --ease: cubic-bezier(.4, 0, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(99, 102, 241, .16), transparent 60%),
    radial-gradient(900px 520px at 88% 4%, rgba(168, 85, 247, .11), transparent 62%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-hi); }

.hidden { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; }
.mb6 { margin-bottom: 6px; } .mb8 { margin-bottom: 8px; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 99px; border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .18); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= 按钮 ================= */
button {
  font: inherit; cursor: pointer; border-radius: var(--r-sm);
  border: 1px solid transparent; padding: 8px 14px;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              transform .12s var(--ease), box-shadow .16s var(--ease), color .16s var(--ease);
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }

.primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(99, 102, 241, .34);
}
.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #93a0fb, #6d70f3);
  box-shadow: 0 4px 16px rgba(99, 102, 241, .46);
}

.ghost {
  background: var(--surface-2); color: var(--text-dim);
  border-color: var(--line-strong);
}
.ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); border-color: rgba(255, 255, 255, .22); }

.sm { padding: 6px 11px; font-size: 13px; }
.block { width: 100%; justify-content: center; }

.linkbtn {
  background: none; border: none; color: var(--accent-hi);
  padding: 4px 2px; font-size: 13px;
}
.linkbtn:hover { text-decoration: underline; }

/* ================= 表单控件 ================= */
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 12px; width: 100%;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
input::placeholder, textarea::placeholder { color: #5f6779; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
textarea { resize: vertical; line-height: 1.7; }
select.sel { width: auto; min-width: 190px; cursor: pointer; }
select option { background: var(--surface); color: var(--text); }

/* ================= 登录 / 注册 ================= */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(99, 102, 241, .22), transparent 60%),
    radial-gradient(700px 420px at 80% 100%, rgba(168, 85, 247, .14), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 396px;
  background: linear-gradient(180deg, rgba(23, 32, 51, .96), rgba(18, 26, 43, .96));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  padding: 32px 30px 26px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  animation: rise .32s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.auth-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 17px; font-weight: 700; letter-spacing: .02em; margin-bottom: 6px;
}
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-hi), var(--purple));
  box-shadow: 0 0 12px rgba(129, 140, 248, .7);
  display: inline-block; flex: none;
}

.seg {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 16px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; width: 100%;
}
.chipbtn {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 7px 12px; border-radius: 7px; font-size: 13px; font-weight: 600;
}
.chipbtn.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

#authForm { display: grid; gap: 10px; }
#authForm input { padding: 11px 13px; }
#authForm .primary { margin-top: 4px; padding: 11px; }
#authTitle { margin: 4px 0 2px; }
#authSubtitle { font-size: 13px; margin-bottom: 16px; }
#btnAuthSwitch { display: block; margin: 14px auto 0; }

/* ================= 顶栏 ================= */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px; height: 58px;
  background: rgba(13, 18, 32, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; letter-spacing: .01em; white-space: nowrap;
}
.ver {
  font-size: 11px; font-weight: 500; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 99px; padding: 1px 7px;
}

.nav { display: flex; gap: 2px; }
.nav-btn {
  background: none; border: none; color: var(--muted);
  padding: 7px 13px; border-radius: 9px; font-size: 13.5px; font-weight: 550;
}
.nav-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-btn.active {
  color: var(--text); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .3);
}

.userbox { display: flex; align-items: center; gap: 10px; }
#userName { font-size: 13.5px; font-weight: 600; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent-hi), var(--purple));
  box-shadow: 0 2px 8px rgba(99, 102, 241, .4);
}

.tag {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-3); color: var(--text-dim);
  border: 1px solid var(--line-strong); white-space: nowrap;
}
.tag-admin { background: rgba(168, 85, 247, .16); color: #d8b4fe; border-color: rgba(168, 85, 247, .4); }
.tag-user { background: rgba(52, 211, 153, .13); color: #6ee7b7; border-color: rgba(52, 211, 153, .32); }
.tag.open, .tag.doing { background: rgba(251, 191, 36, .14); color: #fcd34d; border-color: rgba(251, 191, 36, .34); }
.tag.done { background: rgba(52, 211, 153, .13); color: #6ee7b7; border-color: rgba(52, 211, 153, .32); }
.tag.ok { background: rgba(52, 211, 153, .13); color: #6ee7b7; border-color: rgba(52, 211, 153, .32); }
.tag.err { background: rgba(248, 113, 113, .14); color: #fca5a5; border-color: rgba(248, 113, 113, .36); }

/* ================= 页面骨架 ================= */
.view { padding: 24px 22px 34px; animation: fade .22s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex; align-items: flex-end; gap: 14px;
  margin-bottom: 20px;
}
.page-head .muted { font-size: 13px; margin-top: 3px; }

/* ================= 统计卡 ================= */
.stat-row {
  display: grid; gap: 12px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}
.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.stat::after {
  content: ''; position: absolute; inset: 0 auto auto 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: .55;
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.stat-v {
  font-size: 27px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 7px;
}
.stat-i { font-size: 16px; opacity: .9; }
.stat-l { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ================= 项目卡 ================= */
.dash-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}
.book-card {
  display: flex; flex-direction: column; gap: 11px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.book-card:hover {
  transform: translateY(-3px);
  border-color: rgba(129, 140, 248, .38);
  box-shadow: var(--shadow);
}
.bc-head { display: flex; align-items: flex-start; gap: 10px; }
.bc-title {
  font-size: 15.5px; font-weight: 650; line-height: 1.35; flex: 1;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px; flex: none;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--line-strong);
}
.badge.ok { background: rgba(52, 211, 153, .13); color: #6ee7b7; border-color: rgba(52, 211, 153, .32); }
.bc-meta { font-size: 12.5px; color: var(--muted); }

.prog { display: flex; align-items: center; gap: 10px; }
.prog-bar {
  flex: 1; height: 6px; border-radius: 99px;
  background: var(--bg-soft); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .4);
}
.prog-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  transition: width .5s var(--ease);
}
.prog-t { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

.bc-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.score {
  font-weight: 700; font-size: 12.5px; padding: 2px 9px; border-radius: 99px;
  border: 1px solid var(--line-strong);
}
.score.ok { background: rgba(52, 211, 153, .13); color: #6ee7b7; border-color: rgba(52, 211, 153, .3); }
.score.warn { background: rgba(251, 191, 36, .13); color: #fcd34d; border-color: rgba(251, 191, 36, .3); }
.score.err { background: rgba(248, 113, 113, .13); color: #fca5a5; border-color: rgba(248, 113, 113, .3); }
.score.muted { color: var(--muted); }

.next {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm); padding: 10px 12px;
}
.next b { font-size: 12.5px; color: var(--accent-hi); }
.next p { font-size: 12.5px; color: var(--text-dim); margin: 3px 0 0; }

.bc-actions { display: flex; gap: 8px; margin-top: 2px; }

/* ================= 工作室 ================= */
.studio-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.studio {
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1.32fr) minmax(320px, .88fr);
  align-items: start;
}
@media (max-width: 1080px) { .studio { grid-template-columns: 1fr; } }

.col {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}
.col-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.col-head b { font-size: 14px; }
.col-head .muted { font-size: 12px; }

.chat-col { display: flex; flex-direction: column; height: calc(100vh - 178px); min-height: 520px; }
.chat-log {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 14px;
}

.chat-empty { padding: 34px 24px; text-align: center; }
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .9; }
.chat-empty h3 { margin-bottom: 6px; }
.chat-empty p { color: var(--muted); font-size: 13px; max-width: 380px; margin: 0 auto 16px; }

.msg { max-width: 84%; animation: fade .2s var(--ease); }
.msg.user {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #fff; padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 3px 12px rgba(99, 102, 241, .3);
}
/* v0.14.10：兼容性别名。历史遗留数据 / 其他入口若把模型回复写成 .msg.assistant，
   也按 agent 气泡渲染（前端 JS 已做归一化，此处是纵深防御，避免旧数据再次裸奔）。 */
.msg.agent, .msg.assistant {
  align-self: flex-start;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 11px 15px; border-radius: 16px 16px 16px 4px;
}
.msg.agent .txt, .msg.assistant .txt { white-space: pre-wrap; word-break: break-word; }
.msg .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.msg .actions:empty { display: none; }

/* v0.14.9：agent 回复的 Markdown 渲染样式（发送时与刷新后共用同一渲染器）。
   注意：父级 .txt 是 pre-wrap（为纯文本兜底），Markdown 渲染后由 JS 打上
   .md 标记类并重置 white-space，否则块级元素间会多出空白行。 */
.msg.agent .txt.md, .msg.assistant .txt.md { white-space: normal; }
.msg.agent .txt > .md-p, .msg.assistant .txt > .md-p { margin: 0 0 8px; }
.msg.agent .txt > .md-p:last-child, .msg.assistant .txt > .md-p:last-child { margin-bottom: 0; }
.msg.agent .txt .md-h, .msg.assistant .txt .md-h { 
  margin: 12px 0 6px; font-size: 14px; font-weight: 700; line-height: 1.4;
  color: var(--text); border-left: 3px solid var(--accent); padding-left: 8px;
}
.msg.agent .txt .md-h:first-child, .msg.assistant .txt .md-h:first-child { margin-top: 0; }
.msg.agent .txt .md-ul, .msg.assistant .txt .md-ul, .msg.agent .txt .md-ol, .msg.assistant .txt .md-ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.agent .txt .md-ul li, .msg.assistant .txt .md-ul li, .msg.agent .txt .md-ol li, .msg.assistant .txt .md-ol li { margin: 2px 0; line-height: 1.6; }
.msg.agent .txt .md-quote, .msg.assistant .txt .md-quote { 
  margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--line);
  background: var(--bg-soft); color: var(--text-dim); border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.msg.agent .txt .md-hr, .msg.assistant .txt .md-hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.msg.agent .txt .md-code, .msg.assistant .txt .md-code { 
  margin: 6px 0; padding: 9px 11px; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55; white-space: pre;
}
.msg.agent .txt code, .msg.assistant .txt code { 
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.msg.agent .txt .md-code code, .msg.assistant .txt .md-code code { border: none; background: none; padding: 0; font-size: inherit; }
/* 表格：Markdown 表格是可读性最大的收益点（审计报告大量用表） */
.msg.agent .txt .md-table, .msg.assistant .txt .md-table { 
  border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 12px;
  display: block; overflow-x: auto;
}
.msg.agent .txt .md-table th, .msg.assistant .txt .md-table th, .msg.agent .txt .md-table td, .msg.assistant .txt .md-table td { 
  border: 1px solid var(--line); padding: 5px 9px; text-align: left;
  vertical-align: top; line-height: 1.5;
}
.msg.agent .txt .md-table th, .msg.assistant .txt .md-table th { background: var(--surface-2); font-weight: 600; }
.msg.agent .txt .md-table tr:nth-child(even) td, .msg.assistant .txt .md-table tr:nth-child(even) td { background: var(--bg-soft); }
.msg.agent .txt .md-gap, .msg.assistant .txt .md-gap { height: 6px; }

/* v0.9.1：对话框内「过程活动流」——agent 自动调用工具/技能时，
   不再只有底部"思考中"循环文案，而是把每一步（翻设定集→代笔第N章→质检X分→精修）
   逐条实时列出来。可折叠，默认展开。 */
.process { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
           overflow: hidden; background: var(--bg-soft); }
.process-head { display: flex; align-items: center; gap: 8px; padding: 8px 11px;
                cursor: pointer; font-size: 12px; color: var(--muted);
                background: var(--surface-2); user-select: none; }
.process-head .p-icon { font-size: 13px; }
.process-head .p-count { margin-left: auto; font-size: 11px; }
.process-head.p-running .p-status { color: var(--warn); }
.process-head.p-done .p-status { color: var(--ok); }
.process-head.p-error .p-status { color: var(--err); }
.process-body { padding: 4px 0; max-height: 240px; overflow-y: auto; }
.process.collapsed .process-body { display: none; }
.p-item { display: flex; align-items: flex-start; gap: 8px; padding: 5px 12px;
          font-size: 12px; line-height: 1.5; color: var(--text-dim); }
.p-item .p-dot { flex: none; width: 7px; height: 7px; border-radius: 50%;
                 margin-top: 6px; background: var(--muted); }
.p-item.p-ok .p-dot { background: var(--ok); }
.p-item.p-warn .p-dot { background: var(--warn); }
.p-item.p-error .p-dot { background: var(--err); }
.p-item.p-active .p-dot { background: var(--accent); animation: pdot 1s infinite; }
.p-item .p-time { margin-left: auto; color: var(--muted); font-size: 11px;
                  white-space: nowrap; }
.p-item.p-active { color: var(--text); }

/* v0.9.1：刷新后恢复未完成任务的横幅（"上次的代笔任务还在/中断了"） */
.task-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
               margin: 8px 4px; padding: 9px 12px; border-radius: var(--r-sm);
               font-size: 12px; border: 1px solid var(--line); }
.task-banner.tb-running { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.task-banner.tb-abandoned { background: rgba(248,113,113,.1); border-color: var(--err); }
.task-banner.tb-done { background: rgba(52,211,153,.1); border-color: var(--ok); }
.task-banner .tb-title { font-weight: 600; }
.task-banner .tb-prog { color: var(--text-dim); }
.task-banner button { margin-left: auto; }
.task-banner:empty { display: none; }

/* v0.14.10：对话区常驻草稿提示条。
   背景：主编答完「已起草第 N 章」后，草稿其实还没入库、正文里看不到，
   入口只在"正文"tab 顶部。用户刷新或滚走就彻底找不到，误以为系统空喊。
   这里把入口搬到对话区底部常驻，一键直达待审区。 */
.draft-hint { display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
              margin: 8px 4px; padding: 9px 12px; border-radius: var(--r-sm);
              font-size: 12px; border: 1px solid var(--warn, #d99a2b);
              background: rgba(217, 154, 43, .10); color: var(--text); }
.draft-hint .dh-icon { font-size: 14px; }
.draft-hint .dh-text { flex: 1; line-height: 1.5; }
.draft-hint button { margin-left: auto; flex: none; }
.draft-hint.hidden { display: none; }

/* ---- 章节历史版本对比 ---- */
.chap-hist { margin-left: auto; opacity: 0; transition: opacity .15s; }
.chap-row:hover .chap-hist { opacity: 1; }
@media (hover: none) { .chap-hist { opacity: 1; } }

.hist-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.hist-head .inp { flex: 1; min-width: 180px; max-width: 42%; }
.hist-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.diff-out { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-sm);
            max-height: 56vh; overflow: auto; background: var(--bg-soft);
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-size: 12px; line-height: 1.65; }
.d-line { display: flex; gap: 8px; padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.d-sign { flex: none; width: 10px; color: var(--muted); user-select: none; }
.d-text { flex: 1; }
.d-add { background: rgba(52,211,153,.14); }
.d-add .d-sign { color: var(--ok); }
.d-del { background: rgba(248,113,113,.14); }
.d-del .d-sign { color: var(--err); }
.d-skip { padding: 3px 10px; color: var(--muted); font-size: 11px;
          background: var(--surface-2); border-top: 1px solid var(--line);
          border-bottom: 1px solid var(--line); }

.chat-input {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 14px; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.chat-input textarea { max-height: 160px; }
#btnSend { flex: none; min-width: 84px; }
/* v0.14.8：发送按钮在任务执行期间保持禁用并给出明确的"进行中"观感，
   让用户一眼看出"命令已收到、还在跑"，而不是疑惑能不能再点。 */
#btnSend:disabled { cursor: not-allowed; opacity: .85; }
#btnSend .spinner { display: inline-block; vertical-align: -1px; }

/* v0.14.8：任务执行过程列表——非活跃行静止不闪，只有当前执行行有呼吸动画。
   之前所有 active 行共用 pdot 动画导致整列蓝点齐闪。 */
.p-item:not(.p-active) .p-dot { animation: none; }
.p-item.p-ok .p-dot { opacity: .9; }

/* 草稿卡（代笔产出） */
.card {
  background: var(--bg-soft); border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 12px 14px; margin-top: 10px;
}
.draft-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.draft-head b { font-size: 13px; }
.draft-body {
  font-size: 13px; color: var(--text-dim); white-space: pre-wrap;
  max-height: 260px; overflow-y: auto; line-height: 1.75;
}
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.diag { margin-top: 10px; display: grid; gap: 6px; }
.diag-title { font-size: 12px; font-weight: 600; color: var(--warn); }
.diag-item {
  font-size: 12px; color: var(--text-dim);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 10px;
}
.sev { font-weight: 700; }

/* 设定集（右栏） */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 550;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .28); }

.bible-col { display: flex; flex-direction: column; max-height: calc(100vh - 178px); }
.bible-col .tabs {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.bpane { padding: 14px; overflow-y: auto; display: grid; gap: 10px; }

.item {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 13px;
}
.item b { font-size: 13.5px; }
.item p { font-size: 12.5px; color: var(--text-dim); margin: 5px 0 0; }
.cat-h {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin: 4px 0 2px;
}
.kv { display: flex; gap: 8px; font-size: 12.5px; }
.kv span:first-child { color: var(--muted); min-width: 62px; flex: none; }
.pre {
  white-space: pre-wrap; font-family: var(--mono); font-size: 12px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 11px; color: var(--text-dim);
  margin-top: 6px; max-height: 220px; overflow-y: auto;
}

.chap-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-soft);
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.chap-row:hover { background: var(--surface-3); border-color: var(--line-strong); }
.chap-row .t { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chap-row .w { font-size: 11.5px; color: var(--muted); flex: none; }

/* ================= 管理后台 ================= */
#adminBody .user-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px;
}
.user-row b { font-size: 13.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ================= 空状态 / 加载 ================= */
.empty {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 22px 16px;
  background: var(--bg-soft); border: 1px dashed var(--line-strong);
  border-radius: var(--r);
}
.empty.lg { padding: 44px 20px; }
.empty.lg h3 { margin-bottom: 6px; color: var(--text); }
.empty.lg p { max-width: 420px; margin: 0 auto 16px; }

.loading { text-align: center; color: var(--muted); padding: 28px; font-size: 13px; }

.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 弹层 ================= */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 7, 14, .68);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 22px;
  animation: fade .18s var(--ease);
}
.modal-box {
  width: 100%; max-width: 720px; max-height: 88vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise .24s var(--ease);
}
.modal-box.sm { max-width: 440px; }
.modal-box.lg { max-width: 900px; }
.modal-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
}
.mtab {
  background: none; border: none; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 550;
}
.mtab.active { color: var(--text); background: var(--accent-soft); }
.mpane { padding: 16px; overflow-y: auto; display: grid; gap: 12px; }
.pane { padding: 16px; overflow-y: auto; display: grid; gap: 12px; }
.skill-body {
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  min-height: 240px;
}

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 90;
  transform: translate(-50%, 20px);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 99px; padding: 10px 20px;
  font-size: 13px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  max-width: 78vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52, 211, 153, .5); background: rgba(20, 45, 38, .96); color: #a7f3d0; }
.toast.err { border-color: rgba(248, 113, 113, .5); background: rgba(52, 22, 24, .96); color: #fecaca; }

/* ================= 等待指示（v0.6） ================= */
/* 模型还没吐字时的「正在想」信号：三点跳动 + 阶段文案轮播 */
.typing {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 13px 8px 11px; margin-top: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px;
  font-size: 12.5px; color: var(--text-dim);
  animation: fade .18s var(--ease);
  max-width: 100%;
}
.typing .tdots { display: inline-flex; gap: 4px; align-items: center; }
.typing .tdots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-hi);
  animation: tdot 1.25s var(--ease) infinite;
}
.typing .tdots i:nth-child(2) { animation-delay: .16s; }
.typing .tdots i:nth-child(3) { animation-delay: .32s; }
@keyframes tdot {
  0%, 60%, 100% { transform: translateY(0); opacity: .38; }
  30%           { transform: translateY(-5px); opacity: 1; }
}
@keyframes pdot { 0%, 100% { opacity: .3; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) {
  .p-item.p-active .p-dot { animation: none; opacity: .8; }
}
.typing .tlabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  .typing .tdots i { animation: none; opacity: .7; }
}

/* 写作过程自动补入的人物，和人工设计的人物要能一眼分开 */
.tag.auto {
  background: rgba(99, 102, 241, .14); color: var(--accent-hi);
  border-color: rgba(99, 102, 241, .34);
}

/* ================= 纪年表 / 度量衡 / 审计（v0.6） ================= */
.pane-actions { display: flex; gap: 6px; margin-bottom: 10px; }

.tl-item { border-left: 2px solid rgba(99, 102, 241, .45); padding-left: 10px; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-t {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--accent-hi);
  background: var(--accent-soft);
  padding: 1px 7px; border-radius: var(--r-sm);
}

.item.bal {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-2);
}
.bal-v {
  margin-left: auto; font-family: var(--mono); font-size: 14px; font-weight: 700;
  color: var(--ok);
}
.item.lg { background: var(--surface-2); }
.lg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lg-head .delta {
  font-family: var(--mono); font-size: 12.5px; font-weight: 700;
  padding: 0 6px; border-radius: var(--r-sm);
}
.lg-head .delta.ok { color: #fca5a5; background: rgba(248, 113, 113, .12); }   /* 涨：红 */
.lg-head .delta.err { color: #6ee7b7; background: rgba(52, 211, 153, .12); }  /* 跌：绿 */

.audit-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.audit-sum {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface-2);
}
.audit-sum.ok { border-color: rgba(52, 211, 153, .38); background: rgba(52, 211, 153, .08); }
.audit-sum.warn { border-color: rgba(251, 191, 36, .38); background: rgba(251, 191, 36, .08); }
.audit-sum.err { border-color: rgba(248, 113, 113, .38); background: rgba(248, 113, 113, .08); }
.as-n { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.audit-sum.ok .as-n { color: #6ee7b7; }
.audit-sum.warn .as-n { color: #fcd34d; }
.audit-sum.err .as-n { color: #fca5a5; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }

/* 9 个 tab 小屏放不下时优雅换行（而非横向滚动+截断错位），每个 tab 内文字不换行 */
.bible-col .tabs { flex-wrap: wrap; row-gap: 2px; overflow: visible; }
.bible-col .tab { flex: 0 0 auto; white-space: nowrap; }

/* ================= 正文标签醒目化（v0.7） ================= */
/* 正文是创作最关心的一栏，默认就给它一抹强调色 + 章节数徽标，一眼能看到。 */
.tab.body-tab {
  color: var(--accent-hi);
  border: 1px solid rgba(129, 140, 248, .42);
  background: var(--accent-soft);
}
.tab.body-tab.active {
  color: #fff;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .42);
}
.tab-badge {
  display: inline-block; min-width: 18px; text-align: center;
  font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 99px;
  background: rgba(255, 255, 255, .18); margin-left: 2px;
}
.tab.body-tab:not(.active) .tab-badge { background: rgba(129, 140, 248, .3); color: #c7cdff; }

/* ================= 对话历史栏（v0.7） ================= */
.conv-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.conv-bar .sel { min-width: 168px; }
#convMeta { font-size: 12px; }

/* 表单字段块（系统设置等） */
.field { display: block; }
.field > span {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px;
}
.field-inline { align-items: center; }
.switch {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-dim);
}
.switch input { width: auto; }

/* 对话历史为空时的引导卡片，比纯文字更有呼吸感 */
.chat-empty {
  background:
    radial-gradient(420px 240px at 50% 0%, rgba(99, 102, 241, .12), transparent 70%),
    var(--bg-soft);
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  margin: 14px 16px;
}

/* ================= 顶栏品牌（v0.7） ================= */
.brand #brandText { font-weight: 700; }

/* ================= 响应式 ================= */
/* 中等屏（≤1100px）：顶栏元素开始紧张——让右侧用户区可换行、品牌收缩，
   避免"配置中心/退出"被挤出可视区。固定 58px 顶栏在此段改为可增高。 */
@media (max-width: 1100px) {
  .topbar { gap: 12px; height: auto; min-height: 58px; padding: 8px 16px; }
  .userbox { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
  #userName { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* 中等屏（≤1100px）：工作室顶部条同样让"字数进度 + 导出"可换行，不再挤压书名选择框 */
@media (max-width: 1100px) {
  .studio-bar { row-gap: 8px; }
  .studio-bar #progress { order: 5; }
}

@media (max-width: 720px) {
  .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .view { padding: 16px 14px 28px; }
  .chat-col, .bible-col { height: auto; max-height: none; min-height: 420px; }
  .msg { max-width: 94%; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .bible-col .tabs { padding: 8px 10px; }
  .conv-bar { padding: 8px 10px; row-gap: 6px; }
}

/* ============================================================
   v0.10.0 —— 浅色「设计工作室」主题
   ------------------------------------------------------------
   做法说明（改之前先看）：
   上面那一整套 v0.5 深色设计里散落着几十处 rgba(255,255,255,xx) /
   #6ee7b7 / #fcd34d 这类「为深底调好的」硬编码色值。逐个改既慢又容易
   漏，所以这里采用两层策略：
     1) 重定义 :root 变量 —— 覆盖所有走变量的规则（占绝大多数）；
     2) 末尾补丁块 —— 只针对那批硬编码色值做定点覆盖。
   放在文件末尾是因为同优先级下后写的赢，不用去改 784 行里的原始规则。
   ============================================================ */

:root {
  /* 表面层次：暖白纸感，从底到顶逐级提亮 */
  --bg: #f7f4ef;
  --bg-soft: #fdfbf7;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --surface-3: #eae5db;
  --line: rgba(58, 46, 32, .10);
  --line-strong: rgba(58, 46, 32, .20);

  /* 文字：墨色，不用纯黑 */
  --text: #241f1a;
  --text-dim: #5c5349;
  --muted: #8a8073;

  /* 语义色：降饱和、提高明度以适配浅底 */
  --accent: #d95f34;
  --accent-hi: #c14a22;
  --accent-soft: rgba(217, 95, 52, .11);
  --purple: #7a5ea8;
  --ok: #1f8a5b;
  --warn: #b07808;
  --err: #c0392b;

  --shadow-sm: 0 1px 2px rgba(58, 46, 32, .07);
  --shadow: 0 8px 24px rgba(58, 46, 32, .10);
  --shadow-lg: 0 24px 60px rgba(58, 46, 32, .16);

  /* 设计工作室点缀色 */
  --ink: #241f1a;
  --teal: #1f7a72;
  --clay: #d95f34;
}

/* ---- 页面底：纸纹 + 工作室色块 ---- */
body {
  background:
    radial-gradient(1100px 620px at 10% -10%, rgba(217, 95, 52, .13), transparent 62%),
    radial-gradient(900px 520px at 90% 2%, rgba(31, 122, 114, .10), transparent 64%),
    radial-gradient(700px 460px at 55% 100%, rgba(122, 94, 168, .08), transparent 66%),
    var(--bg);
  background-attachment: fixed;
}

/* ---- 硬编码色值定点覆盖（深底专属 → 浅底适配） ---- */
::-webkit-scrollbar-thumb { background: rgba(58, 46, 32, .16); }
::-webkit-scrollbar-thumb:hover { background: rgba(58, 46, 32, .28); background-clip: content-box; }

button.primary {
  background: linear-gradient(180deg, #e2703f, #d2562c);
  color: #fff;
  box-shadow: 0 1px 2px rgba(142, 68, 30, .28);
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #d9622f, #c14a22); }

.ghost:hover:not(:disabled) {
  background: var(--surface-3); color: var(--ink);
  border-color: rgba(58, 46, 32, .30);
}

input::placeholder, textarea::placeholder { color: #a49a8b; }

.tag-admin { background: rgba(122, 94, 168, .12); color: #5d458a; border-color: rgba(122, 94, 168, .32); }
.tag-user  { background: rgba(31, 138, 91, .11);  color: #14674a; border-color: rgba(31, 138, 91, .28); }
.tag.open, .tag.doing { background: rgba(176, 120, 8, .12); color: #8a5c04; border-color: rgba(176, 120, 8, .30); }
.tag.done  { background: rgba(31, 138, 91, .11); color: #14674a; border-color: rgba(31, 138, 91, .28); }

.badge.ok { background: rgba(31, 138, 91, .11); color: #14674a; border-color: rgba(31, 138, 91, .28); }
.badge.warn { background: rgba(176, 120, 8, .12); color: #8a5c04; border-color: rgba(176, 120, 8, .30); }

.score.ok   { background: rgba(31, 138, 91, .11); color: #14674a; border-color: rgba(31, 138, 91, .26); }
.score.warn { background: rgba(176, 120, 8, .12); color: #8a5c04; border-color: rgba(176, 120, 8, .28); }
.score.err  { background: rgba(192, 57, 43, .10); color: #9e2c1f; border-color: rgba(192, 57, 43, .26); }

/* toast：浅底 + 深字 */
.toast { background: rgba(255, 255, 255, .98); color: var(--ink); box-shadow: var(--shadow); }
.toast.ok  { border-color: rgba(31, 138, 91, .45); background: rgba(240, 251, 245, .98); color: #14674a; }
.toast.err { border-color: rgba(192, 57, 43, .45); background: rgba(253, 244, 242, .98); color: #9e2c1f; }

/* 涨跌配色沿用中式约定：涨红跌绿，但改成浅底可读的深色 */
.lg-head .delta.ok { color: #9e2c1f; background: rgba(192, 57, 43, .10); }
.lg-head .delta.err { color: #14674a; background: rgba(31, 138, 91, .10); }

.audit-sum.ok   .as-n { color: #14674a; }
.audit-sum.warn .as-n { color: #8a5c04; }
.audit-sum.err  .as-n { color: #9e2c1f; }

/* diff 高亮在浅底上需要更实的底色 */
.d-add { background: rgba(31, 138, 91, .13); }
.d-add .d-sign { color: #14674a; }
.d-del { background: rgba(192, 57, 43, .11); }
.d-del .d-sign { color: #9e2c1f; }

/* 头像圆环 */
.avatar, .brand-mark { border-color: rgba(255, 255, 255, .55); }

/* ---- 设计工作室风格点缀 ----
   1) 卡片左上角的「批注条」：像样稿上用胶带贴住标签的感觉；
   2) 顶部细网格背景：设计工作室的桌面/制图板肌理；
   3) 卡片 hover 时轻微上浮 + 暖色描边，强调「这是可操作的稿件」。 */
.card, .book-card, .cat {
  position: relative;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              border-color .18s var(--ease);
}
.book-card:hover, .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(217, 95, 52, .34);
}

.brand-mark {
  background: linear-gradient(135deg, var(--clay), var(--teal));
  color: #fff;
}

/* 顶栏：磨砂玻璃 + 底部细描边，像铺在桌面上的一张硫酸纸 */
.topbar {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset;
}

/* 选中态：像荧光笔划过的一行 */
.nav .nav-btn.active, .tab.active {
  color: var(--clay);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--clay);
}

/* 过程流：把「正在做的事」做成一张工单贴纸 */
.process { box-shadow: var(--shadow-sm); }
.process.collapsed .process-body { display: none; }
.p-item.p-active { background: var(--accent-soft); }

/* 任务横幅 */
.task-banner.tb-running { background: var(--accent-soft); border-color: var(--clay); }
.task-banner.tb-done    { background: rgba(31, 138, 91, .10); }
.task-banner.tb-abandoned { background: rgba(192, 57, 43, .08); }

/* 输入框聚焦：暖色描边 + 柔光，别用冷蓝 */
input:focus, textarea:focus, select:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(217, 95, 52, .14);
}

/* 空态引导：虚线像铅笔稿纸边 */
.chat-empty {
  background:
    radial-gradient(420px 240px at 50% 0%, rgba(217, 95, 52, .09), transparent 70%),
    var(--bg-soft);
}

/* 深色遗留的 inset 阴影（输入框等）在浅底会显脏，统一去掉 */
input, textarea, select { box-shadow: none; }

/* ---- v0.10.2 低质量草稿预警（采纳前就把问题摊开） ---- */
.draft-warn {
  margin: 10px 12px 0; padding: 9px 11px;
  border: 1px solid rgba(192, 57, 43, .38); border-left-width: 3px;
  border-radius: var(--r-sm); background: rgba(192, 57, 43, .07);
  font-size: 12px; line-height: 1.6; color: var(--text);
}
.draft-warn b { color: #9e2c1f; display: block; margin-bottom: 4px; }
.draft-warn ul { margin: 4px 0 0; padding-left: 18px; }
.draft-warn li { margin: 2px 0; color: var(--text-dim); }

/* ============ 短剧工坊（v0.12，v0.13.10 三栏化） ============ */
/* 三栏：分集选择（左，窄）| 当前集分镜/媒体（中，主）| 资产/剧本/风格/模型（右）。
 * minmax(0, …) 是关键：无它时 grid 子项按内容 intrinsic 宽度扩张，
 * ep-title(220px)+徽章+按钮会把列撑出视口——其他栏被推出屏幕。 */
.drama-studio { grid-template-columns: minmax(230px, 300px) minmax(0, 1fr) minmax(280px, 340px); }
.drama-ep-col, .drama-main-col, .drama-side-col { display: flex; flex-direction: column; min-width: 0; max-height: calc(100vh - 210px); }
.drama-episodes {
  overflow-y: auto; flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 6px; padding: 10px; align-content: start;
}
.ep-card { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line, #d8d8e0);
  border-radius: 10px; cursor: pointer; background: var(--card, #fff); font-size: 13px; min-width: 0; flex-wrap: wrap; }
.ep-card:hover { border-color: var(--accent, #7c5cff); }
.ep-card.active { border-color: var(--accent, #7c5cff); box-shadow: 0 0 0 2px rgba(124, 92, 255, .15); }
.ep-card.rendered { border-color: #2fa36b; }
.ep-no { font-weight: 700; white-space: nowrap; }
.ep-title { flex: 1 1 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; order: 3; }
.ep-src { font-size: 11.5px; white-space: nowrap; }
.drama-scenes { padding: 12px; overflow-y: auto; flex: 1; min-height: 0; }
.scene-card { border: 1px solid var(--line, #d8d8e0); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
  background: var(--card, #fff); }
.scene-card.done { border-color: #2fa36b; }
.scene-card.error { border-color: #d9534f; }
.scene-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scene-desc { font-size: 13px; line-height: 1.55; margin-top: 6px; color: var(--fg, #222); }
.scene-utt { font-size: 12.5px; color: #667; margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--line, #ddd); }
.scene-img { display: block; max-width: 320px; max-height: 240px; border-radius: 8px; margin-top: 8px; object-fit: cover; }
.scene-img:has(src$=".mp4") { max-width: 360px; }
.scene-audio { display: block; width: 100%; max-width: 380px; height: 34px; margin-top: 8px; }
.scene-err { color: #d9534f; font-size: 12.5px; margin-top: 6px; }
@media (max-width: 1280px) {
  /* 中屏：右栏收窄 */
  .drama-studio { grid-template-columns: minmax(210px, 250px) minmax(0, 1fr) minmax(250px, 300px); }
}
@media (max-width: 1080px) {
  /* 小屏：退化为上下两栏（分集+分镜），资产栏换行到底部 */
  .drama-studio { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .drama-side-col { grid-column: 1 / -1; max-height: 420px; }
}
.asset-row { border-bottom: 1px dashed var(--line, #e2e2e8); padding: 8px 2px; }
.asset-row b { margin-right: 8px; }
.asset-row p { margin: 4px 0 0; font-size: 12.5px; color: #667; line-height: 1.5; }
/* v0.13.11：资产定妆图（缩略图 + 生图按钮） */
.asset-row { display: flex; gap: 8px; align-items: flex-start; }
.asset-thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex: 0 0 auto;
  border: 1px solid var(--line, #e2e2e8); }
.asset-main { flex: 1; min-width: 0; }
.asset-head { display: flex; align-items: center; gap: 6px; }
.asset-head b { margin-right: 0; }
.asset-main .ghost.sm { margin-top: 4px; padding: 2px 8px; font-size: 11.5px; }
/* v0.13.11：分集卡批量生成按钮区与进度 */
.ep-row { display: flex; align-items: center; gap: 6px; flex: 1 1 100%; }
.ep-row .ep-no { order: 0; }
.ep-title { order: 3; }
.ep-batch { display: flex; gap: 6px; flex: 1 1 100%; margin-top: 4px; }
.ep-batch .ghost.sm { padding: 2px 8px; font-size: 11.5px; }
.ep-batch-progress { flex: 1 1 100%; font-size: 11.5px; min-height: 14px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-card.batching { border-color: var(--accent, #7c5cff); }
.script-scene summary { cursor: pointer; font-size: 13px; padding: 4px 0; }
.script-scene pre { font-size: 11.5px; background: var(--bg2, #f6f6fa); border-radius: 8px; padding: 8px;
  overflow-x: auto; white-space: pre-wrap; }
/* v0.13.16 C4：导出面板（宫格图预览 + 剪映草稿导出） */
.export-actions { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.export-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.export-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--line, #e2e2e8); border-radius: 8px; }
.export-row .muted { flex: 1; font-size: 12px; }
.export-row a { text-decoration: none; }

/* ============================================================
   v0.13.17 —— 商业化平台布局：侧边栏 + 顶栏面包屑
   放在文件末尾：同优先级后写赢，定点覆盖旧顶栏/视图骨架规则。
   ============================================================ */

/* ---- 应用骨架：左侧固定导航 + 右侧主列 ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex: none;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
  z-index: 50;
}

.side-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 16px 14px;
  font-weight: 700; font-size: 15px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.side-brand .ver { margin-left: auto; font-size: 10px; }

.side-nav {
  flex: 1; overflow-y: auto; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-group {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: var(--muted); text-transform: uppercase;
  padding: 12px 8px 5px;
}
.side-nav .nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: none; border: none; border-radius: var(--r-sm);
  color: var(--text-dim); font-size: 13.5px; font-weight: 550;
  padding: 9px 12px;
}
.side-nav .nav-btn:hover { color: var(--text); background: var(--surface-2); }
.side-nav .nav-btn.active {
  color: var(--clay);
  background: var(--accent-soft);
  font-weight: 650;
  box-shadow: inset 2px 0 0 var(--clay);
}
.nav-ico { width: 18px; text-align: center; font-size: 14px; flex: none; }

.side-user {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.side-user-row { display: flex; align-items: center; gap: 9px; min-width: 0; }
.side-user-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.side-user-meta #userName {
  font-size: 13px; font-weight: 650;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-user-meta .tag { align-self: flex-start; }
.side-user-actions { display: flex; gap: 6px; }
.side-user-actions .ghost { flex: 1; padding: 6px 4px; font-size: 12px; }

/* ---- 主列：顶栏（面包屑）+ 内容区 ---- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 24px;
  background: rgba(253, 251, 247, .86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.crumb-root { color: var(--muted); font-weight: 550; }
.crumb-sep { color: var(--muted); opacity: .6; }
.crumbs b { font-weight: 650; color: var(--text); }

.content { flex: 1; min-width: 0; }
.content .view { max-width: 1280px; margin: 0 auto; width: 100%; }

/* 旧顶栏里的 .brand / .userbox 已移入侧栏；保留兼容性兜底 */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.userbox { display: none; }

/* ---- 工作台快捷入口 ---- */
.quick-row {
  display: grid; gap: 12px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.quick-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  text-align: left;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 14px 16px;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease),
              border-color .16s var(--ease);
}
.quick-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(217, 95, 52, .34);
}
.q-ico { font-size: 20px; line-height: 1; }
.q-t { font-weight: 650; font-size: 14px; color: var(--text); }
.q-d { font-size: 12px; color: var(--muted); }

/* ---- 响应式：窄屏侧栏收成图标条 → 移动端顶部横排 ---- */
@media (max-width: 1080px) {
  .sidebar { width: 64px; }
  .side-brand #brandText, .side-brand .ver,
  .nav-group, .side-nav .nav-btn .nav-label { display: none; }
  .side-nav .nav-btn { justify-content: center; padding: 10px 0; }
  .side-user { align-items: center; }
  .side-user-meta, .side-user-actions { display: none; }
}
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; }
  .side-brand { border-bottom: none; padding: 0; }
  .side-brand .ver { display: none; }
  .side-nav { flex-direction: row; padding: 0; overflow-x: auto; }
  .side-nav .nav-btn { padding: 8px 10px; white-space: nowrap; }
  .side-user { border-top: none; margin-left: auto; padding: 0; flex-direction: row; }
  .topbar { padding: 0 14px; }
}

/* ---- v0.13.18 待审草稿区（正文 tab 顶部常驻） ---- */
.pd-wrap {
  margin-bottom: 14px; padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--clay);
  border-radius: var(--r);
}
.pd-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.pd-head b { font-size: 13.5px; }
.pd-head .muted { font-size: 12px; }
.pd-item {
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.pd-item:last-child { margin-bottom: 0; }
.pd-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.pd-meta b { font-size: 13.5px; }
.pd-body {
  margin: 8px 0; font-size: 12.5px; line-height: 1.7;
  color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.pd-actions { display: flex; gap: 8px; }

/* ============================================================
   v0.13.19 —— 主题换血：冷灰中性 + 靛蓝主色（专业 SaaS 风）
   设计语言：Linear / Notion 式的克制配色——
     · 中性色全部换冷灰（slate 系），去掉暖棕/米纸的「工作室手作感」；
     · 主色从暖陶土橙 #d95f34 换成靛蓝 #4f46e5（indigo-600），
       更冷静、更专业，对比度也更稳（白字 4.6:1）；
     · 语义色升级为现代浅底版（emerald / amber / red-600 系）；
     · --clay 别名直接换血为靛蓝：侧边栏 active、荧光笔选中态、
       待审草稿区边框、输入框聚焦等 10 处引用自动跟随，零漏网。
   依旧沿用「末尾覆盖层」策略：重定义 :root + 定点覆盖硬编码。
   ============================================================ */

:root {
  /* 表面层次：冷灰中性，从底到顶逐级提亮 */
  --bg: #fafafa;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef1;
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .16);

  /* 文字：slate 墨色 */
  --text: #0f172a;
  --text-dim: #475569;
  --muted: #94a3b8;

  /* 语义色：现代浅底版 */
  --accent: #4f46e5;
  --accent-hi: #4338ca;
  --accent-soft: rgba(79, 70, 229, .10);
  --purple: #7c3aed;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;

  /* 阴影：暖棕 → 冷 slate */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 8px 24px rgba(15, 23, 42, .09);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .14);

  /* 点缀色换血：clay 别名改为靛蓝（老引用自动跟随） */
  --ink: #0f172a;
  --teal: #0d9488;
  --clay: #4f46e5;
}

/* ---- 页面底：去掉暖色光斑，换成极淡冷调层次 ---- */
body {
  background:
    radial-gradient(1100px 620px at 10% -10%, rgba(79, 70, 229, .05), transparent 62%),
    radial-gradient(900px 520px at 90% 2%, rgba(13, 148, 136, .04), transparent 64%),
    var(--bg);
  background-attachment: fixed;
}

/* ---- 硬编码定点覆盖 ---- */
::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, .15); }
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, .25); background-clip: content-box; }

/* 主按钮：靛蓝渐变 */
button.primary {
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 1px 2px rgba(67, 56, 202, .30);
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #4f46e5, #4338ca); }

.ghost:hover:not(:disabled) {
  background: var(--surface-3); color: var(--ink);
  border-color: rgba(15, 23, 42, .28);
}

input::placeholder, textarea::placeholder { color: #94a3b8; }

/* 徽章 / 标签：现代语义色 */
.tag-admin { background: rgba(124, 58, 237, .10); color: #6d28d9; border-color: rgba(124, 58, 237, .30); }
.tag-user  { background: rgba(5, 150, 105, .10);  color: #047857; border-color: rgba(5, 150, 105, .28); }
.tag.open, .tag.doing { background: rgba(217, 119, 6, .10); color: #b45309; border-color: rgba(217, 119, 6, .30); }
.tag.done  { background: rgba(5, 150, 105, .10); color: #047857; border-color: rgba(5, 150, 105, .28); }

.badge.ok { background: rgba(5, 150, 105, .10); color: #047857; border-color: rgba(5, 150, 105, .28); }
.badge.warn { background: rgba(217, 119, 6, .10); color: #b45309; border-color: rgba(217, 119, 6, .30); }

.score.ok   { background: rgba(5, 150, 105, .10); color: #047857; border-color: rgba(5, 150, 105, .26); }
.score.warn { background: rgba(217, 119, 6, .10); color: #b45309; border-color: rgba(217, 119, 6, .28); }
.score.err  { background: rgba(220, 38, 38, .09); color: #b91c1c; border-color: rgba(220, 38, 38, .26); }

/* toast */
.toast { background: rgba(255, 255, 255, .98); color: var(--ink); box-shadow: var(--shadow); }
.toast.ok  { border-color: rgba(5, 150, 105, .45); background: rgba(236, 253, 245, .98); color: #047857; }
.toast.err { border-color: rgba(220, 38, 38, .45); background: rgba(254, 242, 242, .98); color: #b91c1c; }

/* 涨跌配色沿用中式约定：涨红跌绿 */
.lg-head .delta.ok { color: #b91c1c; background: rgba(220, 38, 38, .09); }
.lg-head .delta.err { color: #047857; background: rgba(5, 150, 105, .10); }

.audit-sum.ok   .as-n { color: #047857; }
.audit-sum.warn .as-n { color: #b45309; }
.audit-sum.err  .as-n { color: #b91c1c; }

/* diff 高亮 */
.d-add { background: rgba(5, 150, 105, .12); }
.d-add .d-sign { color: #047857; }
.d-del { background: rgba(220, 38, 38, .10); }
.d-del .d-sign { color: #b91c1c; }

/* 卡片 hover：暖橙描边 → 靛蓝描边 */
.book-card:hover, .card:hover { border-color: rgba(79, 70, 229, .35); }
.quick-card:hover { border-color: rgba(79, 70, 229, .35); }

/* 任务横幅：完成/放弃态换新语义色 */
.task-banner.tb-done    { background: rgba(5, 150, 105, .09); }
.task-banner.tb-abandoned { background: rgba(220, 38, 38, .07); }

/* 输入聚焦光圈：暖橙 → 靛蓝 */
input:focus, textarea:focus, select:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}

/* 空态引导光晕 */
.chat-empty {
  background:
    radial-gradient(420px 240px at 50% 0%, rgba(79, 70, 229, .06), transparent 70%),
    var(--bg-soft);
}

/* 低质量草稿预警 */
.draft-warn {
  border: 1px solid rgba(220, 38, 38, .35); border-left-width: 3px;
  background: rgba(220, 38, 38, .06);
}
.draft-warn b { color: #b91c1c; }

/* 短剧工坊：状态边框统一到新语义色 */
.ep-card.rendered { border-color: #059669; }
.scene-card.done { border-color: #059669; }
.scene-card.error { border-color: #dc2626; }
.scene-err { color: #dc2626; }
.ep-card.active { box-shadow: 0 0 0 2px rgba(79, 70, 229, .14); }

/* 顶栏玻璃：暖纸底 → 纯白磨砂 */
.topbar {
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset;
}

/* ============ 题材包管理（v0.15 G8）============ */
.cfg-note {
  font-size: 12px; color: var(--text-dim); line-height: 1.6;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 11px; margin-bottom: 10px;
}
.cfg-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.genre-card {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; margin-bottom: 9px; background: var(--surface);
}
.genre-card.builtin { border-left: 3px solid var(--accent); }
.gc-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
.gc-meta { font-size: 12px; line-height: 1.65; }
.genre-card.danger, .ghost.sm.danger { color: var(--err); }
.ghost.sm.danger:hover { border-color: var(--err); }

/* 题材编辑浮层 */
.genre-editor { position: fixed; inset: 0; z-index: 60; display: flex;
                align-items: center; justify-content: center; }
.ge-mask { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.ge-box { position: relative; background: var(--surface); border-radius: var(--r);
          border: 1px solid var(--line); width: min(560px, 92vw); max-height: 86vh;
          overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.ge-head { display: flex; align-items: center; gap: 8px; padding: 12px 15px;
           border-bottom: 1px solid var(--line); position: sticky; top: 0;
           background: var(--surface); }
.ge-box .pane { padding: 13px 15px; }
.ge-box label { display: block; font-size: 12px; color: var(--text-dim); margin: 9px 0 4px; }
.ge-box input { width: 100%; }

/* ============ 题材选择浮层（v0.15 G9）============ */
.tp-opts { display: flex; flex-direction: column; gap: 5px; margin-top: 5px; }
.tp-opt {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px; transition: background .12s;
}
.tp-opt:hover { background: var(--bg-soft); }
.tp-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.tp-opt input { margin: 0; }
.tp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.tp-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-size: 12px; transition: background .12s;
}
.tp-tag:hover { background: var(--bg-soft); }
.tp-tag.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ============ 登录页错误提示（v0.21.1）============
   bug 实录：登录失败只弹 toast，3 秒后消失，用户来不及看清，
   感觉"点了没反应"。加行内常驻提示区。 */
.auth-error {
  margin: 10px 0 0; padding: 9px 12px; border-radius: var(--r-sm);
  background: rgba(224, 72, 72, .1); border: 1px solid rgba(224, 72, 72, .35);
  color: #e05c5c; font-size: 13px; line-height: 1.5; word-break: break-all;
}
.auth-tip { margin-top: 14px; font-size: 12px; line-height: 1.7; }
.auth-tip a { color: var(--accent); }
