/* 作家助手 —— 手机优先，白底 + 招行红 + 加粗标题 */
:root {
  --red: #C7000B;
  --red-dark: #A00009;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #888;
  --border: #e5e5ea;
  --green: #1a7f37;
  --yellow: #b58900;
  --ok: #e8f5e9;
  --warn: #fff8e1;
  --danger: #fdecea;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 15px; line-height: 1.6;
}
h1, h2, h3 { font-weight: 700; }
h2 { font-size: 19px; margin: 18px 0 10px; border-left: 4px solid var(--red); padding-left: 9px; }
h3 { font-size: 16px; margin: 14px 0 8px; }
a { color: var(--red); }
small, .muted { color: var(--muted); font-size: 12.5px; }
.container { max-width: 640px; margin: 0 auto; padding: 12px 14px 90px; }

/* 顶栏 */
.topbar {
  background: var(--red); color: #fff; padding: 12px 14px;
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .title { font-weight: 700; font-size: 17px; }
.topbar button { background: rgba(255,255,255,.15); color: #fff; border: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; }

/* 卡片 */
.card { background: var(--card); border-radius: 10px; padding: 14px; margin: 10px 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card.grey { background: #f0f0f2; color: #999; }

/* 表单 */
label { display: block; font-size: 13px; color: #555; margin: 10px 0 4px; font-weight: 600; }
label .req { color: var(--red); }
input, textarea, select {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
textarea.big { min-height: 200px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--red); border-color: var(--red); }
/* checkbox/radio 不吃文本框的 width:100%，恢复原生尺寸（修副类型标签/等级体系勾选错位） */
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; padding: 0; margin: 0 4px 0 0;
  flex-shrink: 0; accent-color: var(--red); vertical-align: middle;
}
/* 包含勾选框的行内 label：正常行内排版、文字不必加粗（与表单标题区分） */
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
  display: inline-flex; align-items: flex-start; font-weight: 400;
  line-height: 1.5; cursor: pointer;
}
/* 下拉多选（details/summary 实现）：收起时仿 select 外观，展开后两列勾选网格 */
.multi-select { position: relative; }
.multi-select summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-size: 15px; color: var(--text); cursor: pointer; min-height: 20px;
}
.multi-select summary::-webkit-details-marker { display: none; }
.multi-select summary::after { content: '▾'; color: #999; font-size: 13px; margin-left: 8px; flex-shrink: 0; }
.multi-select[open] summary::after { content: '▴'; }
.multi-select[open] summary { outline: 2px solid var(--red); outline-offset: -1px; border-color: var(--red); }
.ms-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px;
  border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px;
  padding: 8px 10px; background: #fff;
}
.ms-item {
  display: inline-flex; align-items: center; font-weight: 400;
  font-size: 15px; color: var(--text); padding: 8px 0; cursor: pointer;
  border-bottom: 1px solid #f2f2f2; white-space: nowrap;
}
.ms-item input { accent-color: var(--red); }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* 按钮 */
button { font-family: inherit; }
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; margin: 6px 6px 0 0;
  background: #eee; color: var(--text);
}
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: var(--red-dark); }
.btn.small { padding: 5px 10px; font-size: 12.5px; margin: 3px 4px 0 0; }
.btn.full { width: 100%; margin: 8px 0 0; }

/* 步骤条 */
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.steps .step {
  flex: 1 1 12%; min-width: 72px; text-align: center; padding: 8px 2px;
  background: #fff; border-radius: 8px; font-size: 12.5px; color: #666;
  border: 1px solid var(--border); cursor: pointer; user-select: none;
}
.steps .step.active { background: var(--red); color: #fff; font-weight: 700; border-color: var(--red); }
.steps .step.locked { opacity: .4; }
.steps .step.done { border-color: var(--green); color: var(--green); }

/* 标签 */
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.tag.draft { background: var(--warn); color: var(--yellow); }
.tag.final { background: var(--ok); color: var(--green); }
.tag.pov { background: var(--warn); color: var(--yellow); font-weight: 700; }
.tag.review { background: var(--danger); color: var(--red-dark); font-weight: 700; }
.tag.pass { background: var(--ok); color: var(--green); }
.tag.red { background: var(--red); color: #fff; font-weight: 700; }

/* 提示条 */
.banner { border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 13.5px; }
.banner.warn { background: var(--warn); color: #7a5c00; }
.banner.danger { background: var(--danger); color: var(--red-dark); font-weight: 600; }
.banner.info { background: #e8f0fe; color: #174ea6; }
.banner.ok { background: var(--ok); color: var(--green); }

/* 进度条 */
.progress-wrap { margin: 10px 0; }
.progress-bar { background: #eee; border-radius: 8px; height: 12px; overflow: hidden; }
.progress-bar > div { background: var(--red); height: 100%; transition: width .3s; }
.progress-text { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* AI 产出草稿区 */
.ai-draft { border: 1px dashed var(--yellow); background: #fffdf5; border-radius: 8px; padding: 10px; margin: 8px 0; white-space: pre-wrap; font-size: 14px; }
.ai-draft .draft-head { font-size: 12px; color: var(--yellow); font-weight: 700; margin-bottom: 6px; }
.ai-error { background: var(--danger); color: var(--red-dark); border-radius: 8px; padding: 10px; margin: 8px 0; font-size: 13.5px; }

/* 审校结果 */
.review-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 8px 0; font-size: 13.5px; }
.review-item .sev { font-weight: 700; }
.sev-高 { color: var(--red); } .sev-中 { color: var(--yellow); } .sev-低 { color: var(--green); }

/* 钩子建议条 */
.hook-suggestion { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
.hook-suggestion .type { font-weight: 700; color: var(--red); }

/* 第十八节 章末钩引擎：自检卡 / 批量审校条 / 候选列表 */
.hook-batch-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hook-check-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hook-list { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 6px; }
.hook-list .row-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.hook-cand { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
.hook-cand .row-desc { margin: 0; flex: 1 1 100%; }
.hook-verdict { display: flex; gap: 4px; margin-left: auto; }

/* 折叠卡片 */
details.fold { background: #fff; border-radius: 8px; border: 1px solid var(--border); margin: 10px 0; }
details.fold summary { padding: 10px 12px; font-weight: 700; cursor: pointer; font-size: 14px; }
details.fold .fold-body { padding: 0 12px 12px; font-size: 13.5px; white-space: pre-wrap; }

/* 抽屉（查看本次上下文） */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
.drawer {
  position: fixed; bottom: 0; left: 0; right: 0; max-height: 85vh; overflow-y: auto;
  background: #fff; border-radius: 16px 16px 0 0; z-index: 91; padding: 16px 14px 30px;
}
.drawer h3 { margin-top: 6px; }
.ctx-step { border-left: 3px solid var(--red); padding: 6px 10px; margin: 10px 0; background: #fafafa; border-radius: 0 8px 8px 0; font-size: 13px; }
.ctx-step .ctx-label { font-weight: 700; font-size: 12.5px; }
.ctx-step pre { white-space: pre-wrap; word-break: break-all; font-family: inherit; margin: 4px 0 0; font-size: 12.5px; color: #444; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 12px; max-width: 480px; width: 100%; max-height: 80vh; overflow-y: auto; padding: 18px; }
.modal pre { white-space: pre-wrap; word-break: break-all; font-family: inherit; font-size: 13px; background: #f7f7f7; padding: 10px; border-radius: 8px; max-height: 45vh; overflow-y: auto; }

/* Toast */
#toast-root { position: fixed; top: 14px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; z-index: 200; pointer-events: none; }
.toast { background: rgba(20,20,20,.85); color: #fff; border-radius: 20px; padding: 8px 18px; margin-top: 6px; font-size: 13.5px; max-width: 86%; }
.toast.err { background: var(--red-dark); }

/* 列表行 */
.row-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding: 10px 0; }
.row-item:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 14.5px; }
.row-desc { font-size: 13px; color: #555; margin-top: 2px; white-space: pre-wrap; }
.row-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

/* 徽标角标 */
.badge { display: inline-block; background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; margin-left: 6px; font-weight: 700; }

/* 底部导航（项目内） */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border); display: flex; z-index: 60; max-width: 640px; margin: 0 auto; }
.bottom-nav a { flex: 1; text-align: center; padding: 9px 0 10px; font-size: 12px; color: #666; text-decoration: none; }
.bottom-nav a.active { color: var(--red); font-weight: 700; }

.loading { color: var(--muted); font-size: 13px; padding: 6px 0; }
.chip { display: inline-block; background: #f0f0f2; border-radius: 12px; padding: 2px 10px; font-size: 12px; margin: 0 6px 6px 0; }
.checkline { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; font-size: 14px; }
.checkline input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.cliff-line { background: #f7f7f7; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13.5px; }
textarea.fs-editor { position: fixed; inset: 0; z-index: 150; min-height: 100vh; border-radius: 0; background: #fff; }

/* 推理模块：标签页 / 时间线行 / 筛选行 */
.tabs { display: flex; gap: 8px; margin: 14px 0 0; }
.tabs .tab { flex: 1; padding: 9px 0; border: 1px solid var(--border); border-radius: 8px 8px 0 0; background: #fff; font-size: 14px; font-weight: 600; color: #666; cursor: pointer; }
.tabs .tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.tl-row { display: flex; gap: 6px; margin: 6px 0; }
.tl-row input { flex: 2; padding: 8px; font-size: 13px; }
.tl-row input[data-tl-time] { flex: 1; }
.tl-row input[data-tl-who] { flex: 1; }
.tl-row .btn { flex-shrink: 0; padding: 8px 10px; margin: 0; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.filter-row select, .filter-row input { flex: 1 1 100px; min-width: 90px; padding: 7px; font-size: 13px; }
.card.warn-card { border: 1px solid var(--red); }

/* 类型模块（PRD 十四节） */
.canon-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .canon-compare { grid-template-columns: 1fr; } }
.canon-compare h4 { margin: 4px 0; font-size: 14px; }

/* 15章增强模块：模拟试读读者口吻卡片 / 弃书点高亮 */
.reader-card { border-left: 3px solid var(--red); }
.sim-line { font-size: 13.5px; margin: 6px 0; }
.sim-text { white-space: pre-wrap; font-size: 13.5px; background: #f7f7f7; border-radius: 8px; padding: 10px; max-height: 45vh; overflow-y: auto; line-height: 1.8; }
.sim-text mark { background: #ffe08a; padding: 0 2px; border-radius: 3px; font-weight: 700; }

/* 等级体系（PRD 十六节） */
.power-check-box { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.benefit-list input, .benefit-list select { padding: 4px 6px; }

/* 版本历史与合规（PRD 十七节） */
.ver-diff { white-space: pre-wrap; max-height: 380px; overflow: auto; background: var(--bg, #fff); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 14px; line-height: 1.7; }
.ver-diff ins { background: #e6f7e6; color: #1a7a1a; text-decoration: none; }
.ver-diff del { background: #fde8e8; color: #b03030; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-grid .card { padding: 10px; }
.stat-grid .big-num { font-size: 26px; font-weight: 700; margin: 2px 0; }
.warn-text { color: #c88a00; }

/* ========== 19章 成本统计 ========== */
.cost-bar { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin: 10px 0; font-size: 13px; }
.cost-bar summary { cursor: pointer; color: var(--ink); }
.cost-fold .fold-body { padding: 6px 0; }
.cost-line { font-size: 12.5px; color: var(--muted, #666); background: #fafafa; border: 1px dashed var(--border); border-radius: 6px; padding: 4px 8px; margin: 6px 0; }
.cost-tag { font-size: 12px; margin-top: 4px; color: var(--muted, #666); }
.cost-tag summary { cursor: pointer; display: inline-block; background: #f5f0f0; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; }
.cost-tag-body { padding: 4px 8px; }
.cost-missing { color: #c0392b; font-weight: 700; }
.cost-est { display: inline-block; margin-left: 4px; background: #fff3cd; color: #856404; border-radius: 4px; padding: 0 5px; font-size: 11px; }
.cost-chip { font-size: 11.5px; color: var(--muted, #666); background: #f7f2f2; border-radius: 999px; padding: 1px 8px; }
.warn-num { color: #c0392b; }
.mini-bar-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.mini-bar-label { width: 72px; font-size: 12px; color: var(--muted, #666); flex-shrink: 0; }
.mini-bar { flex: 1; height: 8px; background: #f0e8e8; border-radius: 4px; overflow: hidden; min-width: 40px; }
.mini-bar-fill { height: 100%; background: var(--red, #c0392b); border-radius: 4px; }
.mini-bar-num { font-size: 12px; color: var(--muted, #666); flex-shrink: 0; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
.cost-table th, .cost-table td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; }
.cost-table th { background: #faf5f5; }
.cost-calls details.fold { margin: 3px 0; }
.price-custom-row { margin: 4px 0; display: flex; gap: 6px; align-items: center; }
