/* ============================================================
   设计系统：中性灰 + 靛蓝品牌色，专业写作工具风格
   ============================================================ */
:root {
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-light: #eef2ff;
  --success: #059669;
  --success-hover: #047857;
  --danger: #dc2626;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --bg: #f7f7f8;
  --card: #ffffff;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.16);
}

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

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

svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ============ 加载页 ============ */
.loading-screen {
  height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; color: var(--text-3);
}
.loading-spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 登录页 ============ */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #312e81 0%, #4338ca 55%, #4f46e5 100%);
  padding: 24px;
}
.auth-layout {
  display: flex; width: 860px; max-width: 100%; min-height: 520px;
  background: var(--card); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.auth-brand {
  flex: 1.1; padding: 56px 48px; color: #fff;
  background:
    radial-gradient(800px 400px at -10% -10%, rgba(255,255,255,0.14), transparent 60%),
    linear-gradient(160deg, #3730a3, #4f46e5);
  display: flex; flex-direction: column; justify-content: center;
}
.brand-logo {
  width: 48px; height: 48px; border-radius: 12px;
  background: rgba(255,255,255,0.15); display: flex;
  align-items: center; justify-content: center; margin-bottom: 24px;
}
.brand-logo svg { width: 26px; height: 26px; }
.auth-brand h1 { font-size: 28px; font-weight: 700; letter-spacing: 1px; }
.brand-tagline { margin-top: 12px; font-size: 15px; opacity: 0.9; line-height: 1.7; }
.brand-features { margin-top: 32px; list-style: none; }
.brand-features li {
  position: relative; padding-left: 22px; margin-bottom: 14px;
  font-size: 13.5px; opacity: 0.85; line-height: 1.6;
}
.brand-features li::before {
  content: ''; position: absolute; left: 0; top: 7px;
  width: 12px; height: 6px; border-left: 2px solid #a5b4fc;
  border-bottom: 2px solid #a5b4fc; transform: rotate(-45deg);
}
.auth-card {
  flex: 1; padding: 56px 48px; display: flex; flex-direction: column;
  justify-content: center; gap: 18px;
}
.auth-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.auth-tabs button {
  background: none; border: none; padding: 10px 2px; font-size: 15px;
  cursor: pointer; color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.auth-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.auth-error {
  color: var(--danger); font-size: 13px; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: 6px; padding: 8px 12px;
}

/* ============ 表单控件 ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field input, .field textarea, .field select {
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 70px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-success { background: var(--success); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }
.btn-ghost {
  background: #fff; color: var(--text-2);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { background: #f9fafb; color: var(--text); }
.btn-danger-text { color: var(--danger); }
.btn-block { width: 100%; height: 38px; }
.btn-lg { height: 42px; font-size: 14px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; }
.btn-half { flex: 1; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--text-3); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.mini-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 5px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--text-2);
  transition: all .15s;
}
.mini-btn:hover { background: #f9fafb; border-color: var(--border-strong); }
.mini-btn.on { color: var(--brand); border-color: #c7d2fe; background: var(--brand-light); font-weight: 600; }
.mini-btn-danger { color: var(--danger); border-color: #fecaca; }
.mini-btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }

/* ============ 主界面布局 ============ */
.main-screen { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.logo-mark svg { width: 18px; height: 18px; }
.logo-text { font-size: 15px; font-weight: 600; letter-spacing: 0.5px; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); }
.more-wrap { position: relative; }
.more-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 180px; padding: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.more-item {
  text-align: left; background: none; border: none; border-radius: 6px;
  padding: 8px 10px; font-size: 13px; color: var(--text-2);
  cursor: pointer; transition: all .12s; white-space: nowrap;
}
.more-item:hover { background: #f3f4f6; color: var(--text); }
.more-label {
  padding: 6px 10px 4px; font-size: 11px; font-weight: 600;
  color: var(--text-3); letter-spacing: .04em;
}
.more-sep { height: 1px; margin: 5px 6px; background: var(--border); }
.save-status { font-size: 12px; color: var(--success); }
.save-status.dirty { color: #d97706; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 999px; background: #f3f4f6;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand);
  color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-size: 13px; color: var(--text-2); }

/* 作品切换器 */
.work-switch { position: relative; display: flex; align-items: center; }
.work-switch-btn {
  width: 24px; height: 28px; border: none; background: none; padding: 0;
  color: var(--text-3); cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.work-switch-btn:hover { background: #f3f4f6; color: var(--text); }
.work-switch-btn svg { width: 16px; height: 16px; }
.work-menu { left: 0; right: auto; min-width: 300px; max-height: 70vh; overflow-y: auto; }
.work-menu-row {
  display: flex; align-items: center; gap: 2px;
  border-radius: 6px; padding-right: 4px;
}
.work-menu-row:hover { background: #f3f4f6; }
.work-menu-row.active { background: var(--brand-light); }
.work-menu-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px;
  border: none; background: none; padding: 7px 10px;
  text-align: left; font-family: inherit; cursor: pointer;
}
.wmr-title {
  font-size: 13px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.work-menu-row.active .wmr-title { color: var(--brand); font-weight: 600; }
.wmr-meta { font-size: 11px; color: var(--text-3); }
.work-menu-sub {
  display: flex; flex-direction: column; margin: 0 6px 6px 10px;
  padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}

/* 用户菜单 */
.user-wrap { position: relative; }
.user-chip-btn {
  border: none; font-family: inherit; cursor: pointer;
  padding: 4px 8px 4px 4px; color: inherit;
}
.user-chip-btn:hover { background: #e9eaee; }
.user-caret { width: 14px; height: 14px; color: var(--text-3); }
.user-menu { right: 0; min-width: 150px; }

.workspace {
  flex: 1; display: flex; gap: 16px; padding: 16px 20px; overflow: hidden;
}
.left-panel {
  width: 308px; flex-shrink: 0; display: flex; flex-direction: column;
  gap: 14px; overflow-y: auto; padding-right: 2px;
}
.right-panel {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  overflow: hidden; min-width: 0; position: relative;
  --drawer-w: min(560px, 56%);
}
/* 抽屉展开时，写作建议区让出右侧宽度，避免被抽屉盖住 */
.right-panel.has-drawer .bottom-dock { margin-right: calc(var(--drawer-w) + 14px); }

/* ============ 左侧区块 ============ */
.panel-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-sm);
}
.section-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.section-header svg { width: 16px; height: 16px; color: var(--text-3); }

/* 创作工具折叠区 */
.panel-tools { padding: 0; gap: 0; }
.section-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 14px 16px; cursor: pointer;
  background: none; border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; color: var(--text-2); font-family: inherit;
  transition: background .12s;
}
.section-toggle:hover { background: #f9fafb; color: var(--text); }
.toggle-arrow { font-size: 12px; color: var(--text-3); }
.panel-tools .tools-grid { padding: 0 16px 16px; }
.count-pill {
  margin-left: auto; font-size: 11px; font-weight: 500; color: var(--text-3);
  background: #f3f4f6; border-radius: 999px; padding: 1px 8px;
}
.empty-tip { color: var(--text-3); font-size: 12px; text-align: center; padding: 14px 0; }

.outline-input {
  width: 100%; min-height: 108px; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 10px 12px; font-size: 13px; line-height: 1.7;
  font-family: inherit; resize: vertical; background: #fafafa;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.outline-input:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.character-list {
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px;
  display: flex; flex-direction: column;
}
/* 平铺章节列表：唯一滚动区是左栏本身，列表内部不再套滚动 */
.chapter-list-flat {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 6px;
}
.chapter-row {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid #f3f4f6; transition: background .12s;
}
.chapter-row:last-child { border-bottom: none; }
.chapter-row:hover { background: var(--brand-light); }
.chapter-row.active {
  background: var(--brand-light);
  box-shadow: inset 2px 0 0 var(--brand);
}
.chapter-index {
  width: 20px; flex-shrink: 0; text-align: right;
  font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums;
}
.chapter-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #d1d5db; flex-shrink: 0;
}
.chapter-dot.filled { background: var(--success); }
.chapter-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text-2);
}
.chapter-row.active .chapter-title { color: var(--text); font-weight: 500; }
.chapter-words {
  font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums;
}
.chapter-filter {
  width: 100%; padding: 6px 10px; margin-top: -4px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: inherit; color: var(--text-2);
  background: #fff; outline: none; transition: border-color .15s;
}
.chapter-filter:focus { border-color: var(--brand); }
.chapter-rename-input {
  flex: 1; min-width: 0; padding: 2px 6px;
  font-size: 13px; font-family: inherit; color: var(--text);
  border: 1px solid var(--brand); border-radius: 4px;
  background: #fff; outline: none;
}
.chapter-row-menu { position: relative; flex-shrink: 0; }
.chapter-more {
  opacity: 0; background: none; border: none; border-radius: 4px;
  padding: 2px 5px; font-size: 14px; line-height: 1; color: var(--text-3);
  cursor: pointer; transition: opacity .12s, background .12s;
}
.chapter-row:hover .chapter-more,
.chapter-row.active .chapter-more { opacity: 1; }
.chapter-more:hover { background: #e9eaf0; color: var(--text); }
.row-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 25;
  width: 116px; padding: 4px; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lg);
}
.row-menu.up { top: auto; bottom: calc(100% + 4px); }
.row-menu-item {
  text-align: left; background: none; border: none; border-radius: 5px;
  padding: 6px 9px; font-size: 12.5px; font-family: inherit;
  color: var(--text-2); cursor: pointer;
}
.row-menu-item:hover { background: #f3f4f6; color: var(--text); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item:disabled { opacity: .35; cursor: default; background: none; }

.character-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  font-size: 13px; border-bottom: 1px solid #f3f4f6; transition: background .12s;
}
.character-item:last-child { border-bottom: none; }
.character-item:hover { background: var(--brand-light); }
.character-item.selected {
  background: var(--brand-light);
  box-shadow: inset 2px 0 0 var(--brand);
}
.character-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-light); color: var(--brand);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.character-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 角色管理弹窗 */
.char-manage-list {
  max-height: 340px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px;
  display: flex; flex-direction: column;
}
.char-manage-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  font-size: 13px; border-bottom: 1px solid #f3f4f6;
}
.char-manage-row:last-child { border-bottom: none; }
.char-manage-name {
  flex-shrink: 0; max-width: 90px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.char-manage-identity {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.char-manage-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ============ 右侧：编辑器 ============ */
.editor-card {
  flex: 1; min-height: 0; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.editor-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: #fcfcfd; flex-wrap: wrap;
  flex-shrink: 0; /* 防止被下方正文区挤压，导致标题被裁切 */
}
.chapter-tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chapter-tab {
  font-size: 12.5px; padding: 4px 12px; border-radius: 999px;
  color: var(--text-2); cursor: pointer; transition: all .12s;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chapter-tab:hover { background: #f3f4f6; }
.chapter-tab.active { background: var(--brand); color: #fff; }
.chapter-tab-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; color: var(--text-3);
  border: 1px dashed var(--border-strong); border-radius: 50%;
}
.chapter-tab-add:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-light); }
.chapter-tab-add svg { width: 13px; height: 13px; }
.editor-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.word-count {
  font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chapter-title-input {
  flex: 1; min-width: 0; max-width: 420px; height: 32px;
  border: 1px solid transparent; border-radius: 6px;
  font-size: 14px; font-weight: 600; padding: 6px 10px;
  line-height: 1.4; background: transparent; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.chapter-title-input:hover { border-color: var(--border); }
.chapter-title-input:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.summary-input {
  width: 100%; border: none; border-bottom: 1px solid var(--border);
  padding: 10px 40px; font-size: 13px; line-height: 1.7;
  font-family: inherit; resize: none; flex-shrink: 0;
  min-height: 52px; max-height: 90px;
  background: #fafbfc; color: var(--text-2);
}
.summary-input:focus { outline: none; background: #fff; }
.summary-input::placeholder { color: var(--text-3); }

.editor-input {
  flex: 1; width: 100%; border: none; resize: none;
  padding: 26px 48px; font-size: 16px; line-height: 1.95;
  font-family: Georgia, "Songti SC", "SimSun", "STSong", serif;
  background: #fffdf9; color: #1f2937;
  caret-color: var(--brand);
}
.editor-input:focus { outline: none; }
.editor-input::placeholder { color: #c4c9d4; font-family: inherit; }

/* ============ 欢迎页（还没有作品时） ============ */
.library-screen { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.library-body {
  width: 100%;
  padding: 32px 40px 60px;
}
.welcome-btns { display: flex; gap: 10px; justify-content: center; }

/* 左栏页签：章节 / 设定 */
.left-tabs {
  display: flex; gap: 4px; flex-shrink: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow-sm);
}
.left-tab {
  flex: 1; height: 32px; border: none; border-radius: 6px; background: none;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-3);
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .12s;
}
.left-tab:hover { color: var(--text); }
.left-tab.active { background: var(--brand-light); color: var(--brand); }
.left-tab-count {
  font-size: 11px; font-weight: 500; padding: 0 6px;
  border-radius: 999px; background: #f3f4f6; color: var(--text-3);
}
.left-tab.active .left-tab-count { background: #fff; color: var(--brand); }

/* 设定入口 */
.setting-entry {
  display: flex; flex-direction: column; gap: 3px; width: 100%;
  text-align: left; font-family: inherit; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fcfcfd; transition: all .12s;
}
.setting-entry:hover { border-color: var(--brand); background: #fff; }
.se-name {
  display: flex; align-items: center;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.se-count {
  margin-left: 6px; font-size: 11px; font-weight: 500; color: var(--text-3);
  background: #f3f4f6; border-radius: 999px; padding: 0 6px;
}
.se-desc {
  font-size: 11.5px; color: var(--text-3); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.setting-foot { font-size: 11.5px; color: var(--text-3); text-align: center; }

.empty-state { text-align: center; padding: 70px 0; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.empty-desc { font-size: 13px; color: var(--text-3); margin: 0 0 18px; }

.work-title-input {
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  font-size: 14.5px; font-weight: 650; color: var(--text);
  padding: 5px 9px; width: 170px; min-width: 80px;
}
.work-title-input:hover { border-color: var(--border); background: #fff; }
.work-title-input:focus { outline: none; border-color: var(--brand); background: #fff; }
.genre-select {
  height: 30px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 12.5px; color: var(--text-2); padding: 0 6px;
}
.hidden-input { display: none; }

/* ============ 角色定位标签 ============ */
.role-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: #f4f4f5; color: var(--text-3); flex-shrink: 0;
}

/* ============ 表单两列 ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ============ AI 面板风格行 ============ */
.ai-style-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  background: #fafaff; flex-shrink: 0;
}
.ai-style-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.style-select {
  height: 28px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 12.5px; color: var(--text); padding: 0 6px;
}
.ai-style-state { font-size: 12px; color: var(--brand); font-weight: 500; }
.ai-context-hint { font-size: 11.5px; color: var(--text-3); margin-left: auto; }
.preset-card.active { border-color: var(--brand); background: var(--brand-light); }
.dot-on {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); display: inline-block;
  margin-left: 2px; vertical-align: middle;
}
.preset-row { display: flex; gap: 10px; margin-bottom: 14px; }
.preset-card {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  padding: 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; transition: all .15s;
}
.preset-card:hover {
  border-color: var(--brand); background: var(--brand-light);
  box-shadow: var(--shadow-sm);
}
.preset-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.preset-desc { font-size: 11.5px; color: var(--text-3); }
.style-input {
  width: 100%; min-height: 190px; resize: vertical;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 13px; line-height: 1.8;
  font-family: inherit; color: var(--text); background: #fff;
}
.style-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ============ 底部停靠区：AI 写作 / 对话 / 建议（合并页签） ============ */
.bottom-dock {
  flex-shrink: 0; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
  display: flex; flex-direction: column;
  height: 180px; min-height: 0;
  transition: height .18s ease;
}
.bottom-dock.collapsed { height: 44px; }

.dock-head {
  display: flex; align-items: center; gap: 8px;
  height: 44px; flex-shrink: 0; padding: 6px 12px;
  border-bottom: 1px solid var(--border); background: #fcfcfd;
}
.dock-title { font-size: 13px; font-weight: 600; color: var(--text); }
.live-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 3px 9px; font-size: 11.5px; color: var(--text-3); cursor: pointer;
  transition: all .15s;
}
.live-chip:hover { border-color: var(--border-strong); color: var(--text-2); }
.live-chip.on { color: var(--brand); border-color: #c7d2fe; background: var(--brand-light); }
.live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
}
.live-chip.on .live-dot { background: var(--brand); animation: livePulse 1.8s infinite; }
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
  50% { opacity: .6; box-shadow: 0 0 0 4px rgba(79, 70, 229, 0); }
}
.assist-time { font-size: 11px; color: var(--text-3); }
.meta-count {
  font-size: 10.5px; font-weight: 600; color: #fff; background: var(--brand);
  border-radius: 999px; padding: 0 5px; line-height: 15px; margin-left: 4px;
}
.dock-count {
  font-size: 11px; font-weight: 600; color: #fff; background: var(--brand);
  border-radius: 999px; padding: 0 6px; line-height: 16px;
}
.dock-spacer { flex: 1; }
.dock-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.dock-pane {
  flex: 1; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
}

.generating-badge { font-size: 12px; font-weight: 500; color: var(--brand); }
.generating-badge .dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0%{content:'';} 25%{content:'.';} 50%{content:'..';} 75%{content:'...';} }

.btn-danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.ai-output { flex: 1; overflow-y: auto; padding: 14px 18px; background: #fcfcff; }
.ai-output pre {
  white-space: pre-wrap; word-break: break-word;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 14px; line-height: 1.9; color: #374151;
}

.ai-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-top: 1px solid var(--border);
  background: #fcfcfd; flex-shrink: 0;
}
.ai-footer-hint {
  font-size: 12px; color: var(--text-3); margin-right: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============ 右侧 AI 写作抽屉 ============ */
.ai-drawer {
  position: absolute; top: 0; right: 0; bottom: 16px;
  width: var(--drawer-w);
  z-index: 30; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: drawerIn .18s ease;
}
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}
.ai-drawer-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--border); background: #fcfcfd;
}
.drawer-tab {
  background: none; border: none; border-radius: 6px;
  padding: 6px 12px; font-size: 13px; color: var(--text-3);
  cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.drawer-tab:hover { color: var(--text); background: #f3f4f6; }
.drawer-tab.active { color: var(--brand); background: var(--brand-light); font-weight: 600; }
.drawer-pane {
  flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.ai-drawer-style {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; flex-shrink: 0;
  border-bottom: 1px solid #f3f4f6;
}
.ai-drawer-context {
  padding: 6px 12px; flex-shrink: 0;
  font-size: 11.5px; color: var(--text-3);
  border-bottom: 1px solid #f3f4f6;
}
.ai-drawer .ai-output { padding: 16px 20px; }
.ai-drawer .ai-output pre { font-size: 15px; line-height: 2; }

.statusbar {
  font-size: 12px; color: var(--text-3); padding: 0 4px; flex-shrink: 0;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: fadeIn .15s ease;
}
/* 需要盖在新建向导之上的弹窗 */
.modal-mask.modal-top { z-index: 130; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 12px; padding: 28px;
  width: 440px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .18s ease;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ============ 管理员面板 ============ */
.modal-wide { width: 700px; }
.modal-sync { max-height: 82vh; display: flex; flex-direction: column; }
.sync-preview-body { overflow-y: auto; padding: 4px 2px 8px; flex: 1; }
.sync-section { margin-bottom: 14px; }
.sync-section-head {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.sync-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.sync-check input { cursor: pointer; }
.sync-item {
  display: flex; gap: 6px; align-items: center;
  padding: 5px 0; border-bottom: 1px solid var(--border-soft);
}
.sync-item:last-child { border-bottom: none; }
.sync-input {
  padding: 5px 8px; font-size: 13px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg); color: var(--text);
  min-width: 80px;
}
.sync-input-sm { width: 70px; min-width: 70px; }
.sync-input.sync-flex { flex: 1; min-width: 120px; }
.sync-input:disabled, .sync-textarea:disabled {
  background: var(--panel); color: var(--text-soft); cursor: not-allowed;
}
.sync-textarea {
  width: 100%; box-sizing: border-box; padding: 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); resize: vertical;
  font-family: inherit; line-height: 1.6;
}
.sync-badge {
  flex-shrink: 0; padding: 2px 7px; border-radius: 10px;
  font-size: 10.5px; font-weight: 600; color: #b45309;
  background: #fef3c7; border: 1px solid #fde68a;
}
.sync-mode-select {
  flex-shrink: 0; padding: 4px 6px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); cursor: pointer;
  font-family: inherit;
}
.sync-mode-select:focus { outline: none; border-color: var(--brand); }

.admin-badge {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  font-size: 11px; font-weight: 500; border-radius: 999px;
  background: var(--brand-light); color: var(--brand);
}
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 8px; text-align: center;
}
.stat-num {
  font-size: 24px; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.admin-section {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.admin-section-title { font-size: 14px; font-weight: 600; }
.apikey-row { display: flex; gap: 8px; align-items: center; }
.apikey-input {
  flex: 1; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 8px 12px; font-size: 13px; font-family: Consolas, monospace;
}
.apikey-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.api-config-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.api-config-label { width: 70px; flex-shrink: 0; font-size: 12.5px; color: var(--text-2); }
.admin-hint { font-size: 12px; color: var(--text-3); line-height: 1.6; }

.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th, .user-table td {
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border);
}
.user-table th {
  color: var(--text-3); font-weight: 500; font-size: 12px; background: #f9fafb;
}
.user-table tbody tr:hover { background: #f9fafb; }
.user-table td .mini-btn { margin-right: 6px; }
.admin-msg { text-align: center; color: var(--success); font-size: 13px; }

/* ============ 一句话生成 / 创作工具 ============ */
.head-btns { display: flex; gap: 8px; }
.tools-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.tool-btn {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 10px; text-align: left; cursor: pointer;
  background: #fafafa; border: 1px solid var(--border);
  border-radius: 6px; transition: all .15s;
}
.tool-btn:hover {
  background: var(--brand-light); border-color: var(--brand);
}
.tool-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.tool-desc { font-size: 11px; color: var(--text-3); }

/* 作品设定卡片（作品简介 / 章节大纲） */
.setting-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.setting-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 9px 10px; text-align: left; cursor: pointer;
  background: #fafafa; border: 1px solid var(--border);
  border-radius: 6px; transition: all .15s; min-width: 0;
}
.setting-card:hover { background: var(--brand-light); border-color: var(--brand); }
.sc-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.sc-desc {
  font-size: 11px; color: var(--text-3); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}
.synopsis-modal-input { min-height: 220px; }
.oneshot-input {
  width: 100%; min-height: 84px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 10px 12px; font-size: 13.5px; line-height: 1.7;
  font-family: inherit; background: #fafafa;
}
.oneshot-input:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ============ 设定集 ============ */
.setting-section {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.setting-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.setting-head .mini-btn { margin-left: auto; }
.setting-row {
  display: flex; align-items: center; gap: 8px;
}
.setting-name {
  width: 128px; flex-shrink: 0;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 10px; font-size: 13px; font-family: inherit;
}
.setting-desc {
  flex: 1; min-width: 0;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 10px; font-size: 13px; font-family: inherit;
}
.setting-status {
  width: 86px; flex-shrink: 0;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 6px; font-size: 12.5px; background: #fff;
}
.setting-name:focus, .setting-desc:focus, .setting-status:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.setting-textarea {
  width: 100%; min-height: 92px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 10px 12px; font-size: 13px; line-height: 1.7;
  font-family: inherit; background: #fafafa;
}
.setting-textarea:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ============ 大纲视图 ============ */
.modal-outline { width: 860px; }
.outline-scroll {
  max-height: 58vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding-right: 4px;
}
.outline-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px; background: #fafafa;
  border: 1px solid var(--border); border-radius: 6px;
}
.outline-row-head { display: flex; align-items: center; gap: 8px; }
.outline-index {
  width: 22px; flex-shrink: 0; text-align: right;
  font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums;
}
.outline-row-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 13.5px; font-weight: 600; color: var(--text);
}
.outline-words { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.outline-summary-input {
  width: 100%; min-height: 54px; resize: vertical;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 12.5px; line-height: 1.7;
  font-family: inherit; color: var(--text-2); background: #fff;
}
.outline-summary-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ============ 生成历史 ============ */
.modal-history { width: 920px; }
.history-layout {
  display: grid; grid-template-columns: 264px 1fr; gap: 14px;
  min-height: 300px;
}
.history-list {
  max-height: 56vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px;
  display: flex; flex-direction: column;
}
.history-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; cursor: pointer;
  border-bottom: 1px solid #f3f4f6; transition: background .12s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--brand-light); }
.history-item.active {
  background: var(--brand-light);
  box-shadow: inset 2px 0 0 var(--brand);
}
.history-action { font-size: 12.5px; font-weight: 600; color: var(--text); }
.history-chapter { font-size: 11.5px; color: var(--text-2); }
.history-time { font-size: 11px; color: var(--text-3); }
.history-detail { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.history-detail-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.history-detail-head .btn { margin-left: auto; }
.history-compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 0;
}
.compare-col {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: #fcfcff;
}
.compare-title {
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  background: #f9fafb;
}
.compare-col pre {
  flex: 1; max-height: 48vh; overflow-y: auto;
  margin: 0; padding: 10px;
  white-space: pre-wrap; word-break: break-word;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 13px; line-height: 1.85; color: #374151;
}

/* ============ 一致性报告 ============ */
.report-box {
  border: 1px solid var(--border); border-radius: 6px;
  background: #fcfcff; min-height: 260px; max-height: 56vh;
  overflow-y: auto; padding: 14px 16px;
}
.report-box pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 13px; line-height: 1.8; color: #374151;
}
.report-loading {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-3);
}
.report-error { font-size: 13px; color: var(--danger); line-height: 1.7; }
.loading-spinner.small { width: 18px; height: 18px; border-width: 2px; }

/* ============ 导入分析 ============ */
.import-sum-list { display: flex; flex-direction: column; gap: 6px; }
.import-sum-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12.5px; background: #fafafa;
}
.import-sum-item.done { background: #fff; }
.import-sum-item .loading-spinner { margin-top: 2px; }
.import-sum-title {
  flex-shrink: 0; max-width: 170px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500; color: var(--text);
}
.import-sum-text { color: var(--text-2); line-height: 1.6; }
.import-stage { margin-top: 12px; }
.import-synopsis { font-size: 13px; line-height: 1.8; color: var(--text-2); }
.import-char-row {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 13px; padding: 2px 0;
}
.import-char-name {
  flex-shrink: 0; font-weight: 600; color: var(--text);
}
.import-char-name em { font-style: normal; font-weight: 400; color: var(--brand); font-size: 12px; }
.import-char-desc { color: var(--text-2); line-height: 1.6; }
.suggest-list {
  padding-left: 18px; display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--text-2); line-height: 1.7;
}

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============ 响应式 ============ */
@media (max-height: 700px) {
  .bottom-dock { height: 150px; }
  .bottom-dock.collapsed { height: 44px; }
}

@media (max-width: 900px) {
  .auth-brand { display: none; }
  .library-body { padding: 24px 16px 48px; }
  .auth-card { padding: 40px 32px; }
  .workspace { flex-direction: column; overflow-y: auto; }
  .left-panel { width: 100%; }
  .right-panel { overflow: visible; --drawer-w: 100%; }
  .right-panel.has-drawer .bottom-dock { margin-right: 0; }
  .ai-drawer { width: 100%; }
  .bottom-dock { height: 260px; }
  .bottom-dock.collapsed { height: 44px; }
  .dock-head { flex-wrap: wrap; height: auto; min-height: 44px; }
  .action-bar { flex-wrap: wrap; }
  .action-bar .summary-input { flex-basis: 100%; }
  .editor-card { min-height: 340px; }
  .topbar { padding: 0 12px; }
  .topbar .btn { padding: 0 10px; }
  .btn .btn-label { display: none; }
}

/* ============ AI 助手（底部停靠区） ============ */
.assist-list {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.assist-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; background: #fafafa;
  display: flex; flex-direction: column; gap: 8px;
}
.assist-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assist-type {
  font-size: 11px; font-weight: 600; border-radius: 4px; padding: 1px 7px;
  color: var(--brand); background: var(--brand-light); flex-shrink: 0;
}
.assist-type.t-文字 { color: #b45309; background: #fffbeb; }
.assist-type.t-错别字 { color: var(--danger); background: #fef2f2; }
.assist-type.t-一致性 { color: #0369a1; background: #f0f9ff; }
.assist-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.assist-text { font-size: 13px; line-height: 1.75; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.assist-ops { display: flex; justify-content: flex-end; gap: 6px; }

/* ============ 选中片段改写 ============ */
.rewrite-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--brand); border-radius: 8px;
  background: var(--brand-light); flex-shrink: 0;
}
.rewrite-info { font-size: 12px; font-weight: 600; color: var(--brand); margin-right: 2px; }
.rewrite-custom-input {
  flex: 1; min-width: 160px; border: 1px solid var(--border-strong);
  border-radius: 5px; padding: 4px 8px; font-size: 12px;
}
.rewrite-custom-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.rewrite-panel {
  border: 1px solid var(--border); border-radius: 8px;
  background: #fcfcff; flex-shrink: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.rewrite-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--text);
  background: #f9fafb; flex-wrap: wrap;
}
.rewrite-panel-ops { display: flex; align-items: center; gap: 6px; }
.rewrite-output {
  margin: 0; padding: 12px 14px; max-height: 220px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 13px; line-height: 1.85; color: #374151;
}

/* ============ 全书搜索 ============ */
.modal-search { width: 640px; }
.search-input {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 10px 14px; font-size: 14px;
}
.search-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.search-results {
  max-height: 52vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column;
}
.search-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid #f3f4f6; transition: background .12s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--brand-light); }
.search-type {
  flex-shrink: 0; margin-top: 1px; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: #f3f4f6; color: var(--text-2);
}
.search-type.st-content { background: var(--brand-light); color: var(--brand); }
.search-type.st-character { background: #ecfdf5; color: var(--success); }
.search-type.st-setting { background: #fff7ed; color: #d97706; }
.search-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-label { font-size: 13px; font-weight: 600; color: var(--text); }
.search-snippet {
  font-size: 12px; color: var(--text-2); line-height: 1.6;
  word-break: break-all;
}
.search-snippet mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }

/* ============ 手稿版本快照 ============ */
.history-tabs { display: flex; gap: 4px; }
.snapshot-filter {
  margin: 8px; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 8px; font-size: 12.5px; background: #fff; color: var(--text);
}
.snapshot-filter:focus { outline: none; border-color: var(--brand); }
.snap-kind {
  font-style: normal; font-size: 10.5px; font-weight: 500;
  padding: 0 6px; border-radius: 999px; margin-right: 6px;
  background: #f3f4f6; color: var(--text-3);
}
.snap-kind.manual { background: var(--brand-light); color: var(--brand); }
.snap-preview {
  font-size: 11.5px; color: var(--text-3); line-height: 1.5;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ============ 对话成果落地 ============ */
.chat-actions { display: flex; gap: 10px; margin-top: 4px; padding-left: 4px; }
.chat-act {
  background: none; border: none; padding: 0; cursor: pointer;
  font-size: 11.5px; color: var(--text-3); transition: color .15s;
}
.chat-act:hover { color: var(--brand); text-decoration: underline; }

/* ============ 三步开始写作引导条 ============ */
.guide-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; border: 1px dashed var(--border-strong); border-radius: 8px;
  background: #fffbeb; font-size: 12.5px; flex-shrink: 0;
}
.guide-title { font-weight: 700; color: #92400e; }
.guide-step { color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.guide-step i {
  font-style: normal; width: 17px; height: 17px; border-radius: 50%;
  background: #fde68a; color: #92400e; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.guide-step.done { color: var(--text-3); }
.guide-step.done i { background: var(--success); color: #fff; }

/* ============ 正文动作栏（提要 + 帮我想 + 生成本章） ============ */
.action-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: #fcfcfd; flex-shrink: 0;
}
.action-bar .summary-input {
  flex: 1; min-width: 0; height: 48px; min-height: 48px; max-height: 48px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 12.5px; line-height: 18px; overflow-y: auto;
}
.action-bar .summary-input:focus { outline: none; border-color: var(--brand); background: #fff; }
.action-main {
  flex-shrink: 0; height: 34px; padding: 0 18px;
  font-weight: 600; font-size: 13px;
}
.action-main svg { width: 14px; height: 14px; }
.idea-btn {
  position: static; height: 34px; flex-shrink: 0;
  background: var(--brand-light); border-color: var(--brand);
  color: var(--brand); font-weight: 600;
}
.idea-btn:hover { background: #e0e7ff; }
.idea-btn:disabled { opacity: .6; }

/* ============ 新建作品向导 ============ */
.modal-wizard { width: 480px; }
.modal-wizard.review { width: 780px; }
.wizard-review {
  max-height: 54vh; overflow-y: auto; padding-right: 4px;
  display: flex; flex-direction: column; gap: 18px;
}
.review-section { display: flex; flex-direction: column; gap: 8px; }
.review-section-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.review-section-head .mini-btn { margin-left: auto; }
.review-char-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px;
}
.review-char-name { font-size: 13px; font-weight: 500; flex-shrink: 0; }
.review-char-desc {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.review-chapter {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.review-chapter-head { display: flex; align-items: center; gap: 8px; }
.review-chapter-index {
  width: 18px; flex-shrink: 0; text-align: right;
  font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums;
}
.review-chapter-title {
  flex: 1; min-width: 0; padding: 2px 6px; font-size: 13px; font-weight: 500;
  font-family: inherit; color: var(--text); border: 1px solid transparent;
  border-radius: 4px; background: transparent;
}
.review-chapter-title:focus {
  outline: none; border-color: var(--brand); background: #fff;
}
.review-chapter textarea {
  width: 100%; min-height: 52px; resize: vertical;
  border: 1px solid var(--border); border-radius: 5px;
  padding: 6px 8px; font-size: 12.5px; line-height: 1.6;
  font-family: inherit; color: var(--text-2);
}
.review-chapter textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.wizard-loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; }
.wizard-steps {
  display: flex; gap: 6px; align-items: center;
  font-size: 12px; color: var(--text-3);
}
.wizard-steps span {
  padding: 3px 12px; border-radius: 999px; background: #f3f4f6;
}
.wizard-steps span.on { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.wizard-styles { display: flex; flex-direction: column; gap: 8px; }
.wizard-style-card {
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 10px 14px; cursor: pointer; transition: all .15s; background: #fff;
}
.wizard-style-card:hover { border-color: var(--border-strong); }
.wizard-style-card.active {
  border-color: var(--brand); background: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.ws-name { font-size: 14px; font-weight: 600; color: var(--text); }
.ws-desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.wizard-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer; line-height: 1.5;
}
.wizard-check input { margin-top: 2px; }

/* 方式选择卡片（AI 创建 / 导入书稿） */
.wizard-modes { display: flex; gap: 12px; }
.wizard-mode-card {
  flex: 1; border: 1.5px solid var(--border); border-radius: 12px;
  background: #fff; padding: 22px 14px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; transition: all .15s;
}
.wizard-mode-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(79, 70, 229, 0.12); transform: translateY(-2px); }
.wm-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.wm-icon svg { width: 24px; height: 24px; }
.wm-title { font-size: 15px; font-weight: 700; color: var(--text); }
.wm-desc { font-size: 12px; color: var(--text-2); line-height: 1.6; }

/* 导入文件选择区（label 内嵌透明 file input，点击即原生选文件） */
.wizard-import-drop {
  position: relative; display: block;
  border: 2px dashed var(--border-strong); border-radius: 12px;
  background: #fafafa; padding: 24px 14px; cursor: pointer;
  text-align: center; transition: all .15s; margin-bottom: 12px;
}
.wizard-import-drop:hover { border-color: var(--brand); background: var(--brand-light); }
.wizard-import-drop.loading { cursor: wait; opacity: .7; }
.wizard-import-native {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; font-size: 0;
}
.wid-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 0 0 4px; }
.wid-sub { font-size: 12px; color: var(--text-2); margin: 0; }

/* ============ 模型配置人话档位 ============ */
.level-row { display: flex; gap: 8px; }
.level-btn {
  flex: 1; border: 1.5px solid var(--border); border-radius: 8px;
  background: #fff; padding: 10px 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  transition: all .15s;
}
.level-btn:hover { border-color: var(--border-strong); }
.level-btn.active {
  border-color: var(--brand); background: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.level-btn b { font-size: 13px; color: var(--text); }
.level-btn span { font-size: 11px; color: var(--text-3); }
.adv-config { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.adv-config summary {
  font-size: 12.5px; color: var(--text-3); cursor: pointer; user-select: none;
}
.adv-config .field { margin-top: 10px; }
.assist-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px; border-top: 1px solid var(--border); flex-shrink: 0;
  font-size: 11px; color: var(--text-3);
}
.assist-foot:empty { display: none; }
.assist-error { color: var(--danger); }

.chat-list {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-empty { color: var(--text-3); font-size: 13px; line-height: 1.8; padding: 8px 2px; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chat-chip {
  border: 1px solid var(--border-strong); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 12px; color: var(--text-2); cursor: pointer;
  transition: all .15s;
}
.chat-chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble {
  max-width: 88%; padding: 9px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: var(--brand); color: #fff; border-bottom-right-radius: 3px;
}
.chat-msg.assistant .chat-bubble {
  background: #f3f4f6; color: var(--text); border-bottom-left-radius: 3px;
}
.chat-cursor { color: var(--brand); animation: chat-blink 0.9s steps(2) infinite; }
@keyframes chat-blink { 50% { opacity: 0; } }

.chat-err { margin: 0 14px 8px; flex-shrink: 0; }
.chat-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 14px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.chat-input {
  flex: 1; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  resize: none; line-height: 1.6;
  min-height: 40px; max-height: 160px;
  overflow-y: auto; box-sizing: border-box;
}
.chat-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
