/* 书册工坊 BookPress — 前端样式（纸质书卷美学） */

:root {
  --paper: #f4f0e6;
  --panel: #fffdf7;
  --panel2: #faf6ec;
  --ink: #2b2723;
  --muted: #8a8177;
  --faint: #b3a996;
  --accent: #9a3b2e;
  --accent-dark: #7e2f24;
  --line: #e4dccb;
  --line2: #d5cdb8;
  --ok: #3d7a4f;
  --shadow: 0 1px 3px rgba(60, 50, 30, .08), 0 6px 24px -8px rgba(60, 50, 30, .14);
  --radius: 10px;
  --serif: Georgia, "Times New Roman", "SimSun", serif;
  --ui: "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  background-image: radial-gradient(rgba(120, 100, 60, .045) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  min-width: 980px;
}
button { font-family: var(--ui); cursor: pointer; }
input, select, textarea { font-family: var(--ui); }

.boot-loading { text-align: center; padding: 120px 0; color: var(--muted); font-size: 15px; letter-spacing: 2px; }

/* ============ 顶栏 ============ */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px; height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand .seal {
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--accent); color: #fffdf5;
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1.5px rgba(255, 253, 245, .5);
}
.brand h1 { font-size: 18px; margin: 0; font-family: var(--serif); font-weight: 700; letter-spacing: 3px; }
.brand .sub { font-size: 11.5px; color: var(--muted); letter-spacing: 1px; margin-top: 1px; }
.topbar .spacer { flex: 1; }

.btn {
  border: 1px solid var(--line2); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 8px 16px; font-size: 13.5px;
  transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn.active { border-color: var(--accent); color: var(--accent); background: var(--panel2); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fffdf5; font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(154, 59, 46, .5);
}
.btn-primary:hover { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--accent); background: rgba(154, 59, 46, .06); }
.btn-danger:hover { border-color: #b23a2a; color: #b23a2a; background: rgba(178, 58, 42, .06); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }

/* ============ 书架 ============ */
.shelf-wrap { max-width: 1180px; margin: 0 auto; padding: 34px 28px 60px; }
.shelf-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; }
.shelf-head h2 { font-family: var(--serif); font-size: 22px; margin: 0; letter-spacing: 2px; }
.shelf-head .hint { color: var(--muted); font-size: 12.5px; }

.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 22px; }

.book-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s;
  display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(60,50,30,.08), 0 14px 32px -8px rgba(60,50,30,.2); }
.cover-thumb { height: 205px; overflow: hidden; position: relative; background: #efe9da; border-bottom: 1px solid var(--line); }
.cover-thumb iframe { border: 0; pointer-events: none; position: absolute; top: 0; left: 0; }
.book-meta { padding: 12px 14px 10px; flex: 1; }
.book-meta h3 { margin: 0 0 4px; font-size: 15px; font-family: var(--serif); letter-spacing: .5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta p { margin: 0; font-size: 12px; color: var(--muted); }
.book-meta .stats { margin-top: 6px; font-size: 11.5px; color: var(--faint); }
.book-actions { display: flex; border-top: 1px solid var(--line); }
.book-actions button {
  flex: 1; border: 0; background: transparent; padding: 9px 0; font-size: 12.5px; color: var(--muted);
  border-right: 1px solid var(--line);
}
.book-actions button:last-child { border-right: 0; }
.book-actions button:hover { background: rgba(154, 59, 46, .06); color: var(--accent); }
.book-actions button.main { color: var(--accent); font-weight: 600; }

.new-card {
  border: 1.5px dashed var(--line2); border-radius: var(--radius); background: transparent;
  min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--muted); cursor: pointer; transition: all .15s;
}
.new-card:hover { border-color: var(--accent); color: var(--accent); background: rgba(154, 59, 46, .03); }
.new-card .plus { font-size: 34px; line-height: 1; }
.new-card.dragover { border-color: var(--accent); background: rgba(154,59,46,.07); color: var(--accent); }

.empty-shelf { text-align: center; padding: 80px 0; color: var(--muted); }
.empty-shelf .big { font-size: 42px; margin-bottom: 12px; }

/* ============ 编辑器 ============ */
.editor { display: flex; flex-direction: column; height: calc(100vh - 60px); }
.editor-top {
  display: flex; align-items: center; gap: 12px; padding: 10px 22px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.editor-top .back { font-size: 13px; color: var(--muted); }
.editor-top .back:hover { color: var(--accent); }
.title-input {
  font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: 1px;
  border: 1px solid transparent; background: transparent; border-radius: 6px;
  padding: 5px 8px; color: var(--ink); min-width: 120px; flex: 0 1 320px;
}
.author-input { width: 130px; font-size: 13px; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 8px; color: var(--muted); }
.title-input:hover, .author-input:hover { border-color: var(--line2); }
.title-input:focus, .author-input:focus { outline: none; border-color: var(--accent); background: #fff; }
.save-status { font-size: 12px; color: var(--faint); min-width: 88px; text-align: right; }
.save-status.saving { color: #b08a3e; }
.save-status.saved { color: var(--ok); }
.save-status.dirty { color: #b0532b; font-weight: 600; }

/* 保存按钮：有未保存改动才亮起 */
.save-btn { flex: none; }
.save-btn:disabled { opacity: .38; }
.save-btn.is-dirty {
  background: var(--accent); border-color: var(--accent); color: #fffdf5; font-weight: 600;
  animation: dirtyPulse 1.9s ease-in-out infinite;
}
.save-btn.is-dirty:hover { color: #fffdf5; }
@keyframes dirtyPulse { 50% { box-shadow: 0 0 0 4px rgba(160, 44, 33, .15); } }

/* 未保存提醒要盖在导出/导入弹窗之上 */
.modal-mask.stacked { z-index: 130; }

.editor-body { display: flex; flex: 1; min-height: 0; }

/* 章节侧栏 */
.chapter-side {
  width: 268px; background: var(--panel2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.side-head { padding: 12px 14px 8px; display: flex; align-items: center; justify-content: space-between; }
.side-head span { font-size: 12.5px; color: var(--muted); letter-spacing: 2px; }
.chapter-list { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.ch-item {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 3px;
  display: flex; align-items: center; gap: 8px; border: 1px solid transparent;
}
.ch-item:hover { background: rgba(154, 59, 46, .05); }
.ch-item.active { background: #fff; border-color: var(--line); box-shadow: 0 1px 4px rgba(60,50,30,.08); }
.ch-item .idx { font-size: 11px; color: var(--faint); font-family: var(--serif); min-width: 18px; }
.ch-item .ch-title { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-item .ch-words { font-size: 11px; color: var(--faint); }
.ch-item .ch-ops { display: none; gap: 2px; }
.ch-item:hover .ch-ops, .ch-item.active .ch-ops { display: flex; }
.ch-item .ch-ops button {
  border: 0; background: transparent; color: var(--faint); font-size: 12px; padding: 2px 4px; border-radius: 4px;
}
.ch-item .ch-ops button:hover { color: var(--accent); background: rgba(154,59,46,.08); }
.side-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.side-foot .btn { flex: 1; justify-content: center; }

/* 主区与标签页 */
.editor-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 22px 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs button {
  border: 0; background: transparent; padding: 9px 18px 11px; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; letter-spacing: 1px; position: relative;
}
.tabs button.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
.tabs button.tab-dirty::after {
  content: ''; position: absolute; top: 9px; right: 10px; width: 6px; height: 6px;
  border-radius: 50%; background: #c8862d; box-shadow: 0 0 0 2px var(--panel);
}
.tab-pane { flex: 1; min-height: 0; display: none; }
.tab-pane.active { display: flex; }

/* 编辑标签页 */
.pane-edit { flex-direction: column; padding: 18px 26px; overflow-y: auto; }
.pane-edit .ch-title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pane-edit .ch-title-input {
  flex: 1; font-family: var(--serif); font-size: 17px; font-weight: 700; padding: 8px 12px;
  border: 1px solid var(--line2); border-radius: 8px; background: #fff;
}
.pane-edit .ch-title-input:focus { outline: none; border-color: var(--accent); }
.genre-select {
  flex: none; font-family: var(--serif); font-size: 13.5px; color: var(--ink); padding: 8px 8px;
  border: 1px solid var(--line2); border-radius: 8px; background: #fff; cursor: pointer;
}
.genre-select:focus { outline: none; border-color: var(--accent); }
.ch-editor {
  flex: 1; min-height: 320px; width: 100%; resize: vertical;
  font-family: var(--serif); font-size: 15.5px; line-height: 2.1; color: var(--ink);
  padding: 18px 22px; border: 1px solid var(--line2); border-radius: 10px; background: #fffef9;
}
.ch-editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(154,59,46,.08); }
.edit-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--faint); }
.empty-edit { margin: auto; text-align: center; color: var(--muted); }
.empty-edit .btn { margin-top: 14px; }

/* 更改日志标签页 */
.pane-history { flex-direction: column; overflow: hidden; }
.history-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 30px 50px; }
.history-list { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.history-empty { text-align: center; color: var(--faint); font-size: 13px; padding: 46px 0; }
.hs-item {
  display: flex; flex-direction: column; gap: 5px; padding: 10px 14px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.hs-item.hs-current { border-color: var(--accent); background: #fff7ef; }
.hs-top { display: flex; align-items: center; gap: 14px; }
.hs-top .spacer { flex: 1; }
.hs-when { font-family: var(--serif); min-width: 158px; }
.hs-what { color: var(--muted); flex: none; }
.hs-stats { color: var(--faint); font-size: 12px; }
.hs-restore { flex: none; }
.hs-desc { font-size: 12.5px; color: var(--muted); line-height: 1.7; padding-left: 2px; border-left: 3px solid var(--line2); margin-left: 2px; padding: 2px 0 2px 10px; }

/* 版式标签页 */
.pane-style { flex-direction: column; overflow: hidden; }
.pane-bar {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 26px;
  border-bottom: 1px solid var(--line); background: var(--panel2);
  font-size: 12px; color: var(--faint);
}
.pane-bar .spacer { flex: 1; }
.style-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 30px 50px; }
.style-cols { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.style-group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; box-shadow: var(--shadow); }
.style-group h3 { margin: 0 0 4px; font-size: 14.5px; font-family: var(--serif); letter-spacing: 1px; }
.style-group .g-desc { font-size: 11.5px; color: var(--faint); margin: 0 0 12px; }
.style-group.full { grid-column: 1 / -1; }

.frow { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.frow > label { width: 76px; flex: none; font-size: 12.5px; color: var(--muted); }
.frow .fval { font-size: 12px; color: var(--accent); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.frow select, .frow input[type="number"] {
  flex: 1; border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; font-size: 13px; background: #fff; color: var(--ink);
}
.frow select:focus, .frow input[type="number"]:focus { outline: none; border-color: var(--accent); }
.frow input[type="range"] { flex: 1; accent-color: var(--accent); }
.margins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; flex: 1; }
.margins-grid .mm { position: relative; }
.margins-grid input { width: 100%; }
.margins-grid .unit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 10.5px; color: var(--faint); }

.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #d8d0bd; border-radius: 21px; transition: .18s; cursor: pointer; }
.switch .track::after { content: ''; position: absolute; top: 2.5px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }

.cover-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: 1; }
.cover-pick { border: 1.5px solid var(--line2); border-radius: 8px; overflow: hidden; cursor: pointer; background: #fff; position: relative; }
.cover-pick.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(154,59,46,.2); }
.cover-pick .thumb { height: 108px; overflow: hidden; position: relative; background: #f0ead9; }
.cover-pick .thumb iframe { border: 0; pointer-events: none; position: absolute; top: 0; left: 0; }
.cover-pick .name { text-align: center; font-size: 11.5px; padding: 5px 0; color: var(--muted); }
.theme-dots { display: flex; gap: 10px; }
.theme-dot { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; position: relative; }
.theme-dot.active { border-color: var(--ink); }
.theme-dot.active::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; }
.td-ink { background: linear-gradient(135deg, #f8f3e7 50%, #2c2820 50%); }
.td-red { background: linear-gradient(135deg, #fbf1e6 50%, #a02c21 50%); }
.td-navy { background: linear-gradient(135deg, #f1f3f1 50%, #22334d 50%); }
.td-green { background: linear-gradient(135deg, #f2f5ea 50%, #2e4030 50%); }

/* 预览标签页 */
.pane-preview { flex-direction: column; }
.preview-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 22px;
  border-bottom: 1px solid var(--line); background: var(--panel2);
}
.preview-bar .hint { font-size: 12px; color: var(--faint); }
.preview-bar .spacer { flex: 1; }
.preview-scroll { flex: 1; overflow: auto; background: #ded7c5; }
.preview-scroll iframe { border: 0; width: 100%; height: 100%; display: block; }

/* 导出弹窗 */
.export-steps { margin: 0 0 16px; padding: 0; list-style: none; }
.export-steps li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13.5px; color: var(--muted); }
.export-steps li .ic { color: var(--ok); }
.export-steps li.off { opacity: .38; text-decoration: line-through; }
.export-result { text-align: center; padding: 8px 0 2px; }
.export-result .pages { font-size: 15px; margin-bottom: 4px; }
.export-result .file { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 14px; }
.export-loading { text-align: center; padding: 18px 0; color: var(--muted); }
.export-loading .bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 14px 30px; }
.export-loading .bar i { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(40, 33, 24, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.modal {
  background: var(--panel); border-radius: 14px; width: 560px; max-width: 94vw;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px -10px rgba(30, 20, 10, .4);
  border: 1px solid var(--line);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px 0; }
.modal-head h3 { margin: 0; font-family: var(--serif); font-size: 17px; letter-spacing: 1px; }
.modal-head .close { border: 0; background: transparent; font-size: 20px; color: var(--faint); line-height: 1; }
.modal-head .close:hover { color: var(--accent); }
.modal-body { padding: 16px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }

.form-row { margin-bottom: 13px; }
.form-row > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.form-row input[type="text"], .form-row select, .form-row textarea {
  width: 100%; border: 1px solid var(--line2); border-radius: 8px; padding: 9px 11px; font-size: 13.5px; background: #fff;
}
.form-row textarea { font-family: var(--serif); font-size: 14px; line-height: 1.9; resize: vertical; min-height: 120px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--accent); }
.form-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); margin: 8px 0; cursor: pointer; }
.check-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.check-row .tip { color: var(--faint); font-size: 11.5px; }

.dropzone {
  border: 1.5px dashed var(--line2); border-radius: 10px; padding: 22px; text-align: center;
  color: var(--muted); cursor: pointer; transition: .15s; margin-bottom: 12px;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); color: var(--accent); background: rgba(154,59,46,.04); }
.dropzone .big { font-size: 26px; margin-bottom: 6px; }
.dropzone input[type="file"] { display: none; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 11.5px; margin: 14px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
/* 紧凑容器里的分隔条变体 */
.gallery-drawer .divider { flex: none; margin: 2px 12px 4px; font-size: 11px; }
.gallery-drawer .gal-search { padding: 6px 12px 4px; }
.gallery-drawer .gal-search input { width: 100%; box-sizing: border-box; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-size: 11px; }
.pane-history > .divider { flex: none; margin: 0 26px; font-size: 11.5px; }
.lx-card .divider, .insp-el .divider { margin: 9px 0 7px; font-size: 11px; }
.zoom-label { font-size: 12px; color: var(--muted); min-width: 42px; text-align: center; cursor: pointer; user-select: none; }

/* ============ Toast ============ */
#toast-wrap { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #33302a; color: #f5f1e8; padding: 10px 20px; border-radius: 8px; font-size: 13.5px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: toastIn .25s ease; max-width: 70vw;
}
.toast.err { background: #8c2f22; }
.toast.ok { background: #2e5940; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* 后端未启动横幅 */
.offline-banner {
  background: #8c2f22; color: #fff; text-align: center; padding: 9px; font-size: 13px;
}
.offline-banner b { cursor: pointer; text-decoration: underline; }

/* ============ v2：侧栏章节树 ============ */
.btn-new-chapter { width: 100%; justify-content: center; letter-spacing: 2px; padding: 10px 0; font-size: 14px; }
.side-foot { flex-direction: column; gap: 6px !important; }
.sec-list { margin: 0 0 4px 26px; border-left: 1px dashed var(--line2); padding-left: 4px; }
.sec-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px;
  cursor: pointer; font-size: 12.5px; color: var(--muted);
}
.sec-item:hover { background: rgba(154, 59, 46, .05); color: var(--ink); }
.sec-item.active { background: #fff7ef; color: var(--accent); }
.sec-item .sec-no { font-size: 10.5px; color: var(--faint); min-width: 18px; font-family: var(--serif); }
.sec-item .sec-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-item .sec-words { font-size: 10.5px; color: var(--faint); }
.sec-item .sec-genre {
  flex: none; font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 4px;
  border: 1px solid var(--line2); color: var(--faint); letter-spacing: 1px;
}
.sec-item .sec-genre.g-poem { color: #3f6a5a; border-color: #b9cfc4; background: #eef5f1; }
.sec-item .sec-genre.g-gushi { color: #8a5a2a; border-color: #dcc5a2; background: #f8f1e4; }
.sec-item .sec-genre.g-prose { color: #6b6a5e; border-color: #d8d4c6; background: #f5f4ec; }
.sec-item .sec-ops { display: none; }
.sec-item:hover .sec-ops { display: inline; }
.sec-item .sec-ops button { border: 0; background: transparent; color: var(--faint); font-size: 11px; padding: 0 3px; }
.sec-item .sec-ops button:hover { color: #b23a2a; }
.ch-item .ch-ops button[data-op="work"] { font-size: 10.5px; padding: 2px 5px; border: 1px solid var(--line2); border-radius: 4px; }

/* 编辑页 */
.row-tag { flex: none; font-size: 11px; color: var(--faint); border: 1px solid var(--line2); border-radius: 4px; padding: 2px 7px; letter-spacing: 2px; }
.ch-title-input.work { font-size: 15px; font-weight: 600; }
.edit-nav { display: flex; gap: 6px; }
.edit-nav .btn:disabled { opacity: .4; }
.empty-btns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

/* 分段按钮组 */
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 6px 13px; font-size: 12.5px; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--accent); }
.seg button.active { background: var(--accent); color: #fffdf5; font-weight: 600; }

/* ============ v2：封面工坊 ============ */
.pane-cover { flex-direction: column; }
.cover-studio { display: flex; flex: 1; min-height: 0; }
.cs-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cs-bar { display: flex; align-items: center; gap: 12px; padding: 8px 18px; border-bottom: 1px solid var(--line); background: var(--panel2); flex-wrap: wrap; }
.cs-bar .spacer { flex: 1; }
.cs-tip { font-size: 12px; color: var(--faint); }
.cs-stage-wrap {
  flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center;
  background: #ded7c5;
  background-image: radial-gradient(rgba(90, 75, 45, .12) 1px, transparent 1px);
  background-size: 22px 22px;
}
.cs-frame { position: relative; background: #fff; box-shadow: 0 4px 22px rgba(40, 30, 10, .3); }
.cs-frame iframe { border: 0; display: block; }
.cover-stage {
  position: relative; overflow: hidden; flex: none;
  box-shadow: 0 4px 22px rgba(40, 30, 10, .3);
}
.ace { position: absolute; cursor: move; outline: 1px solid transparent; }
.ace:hover { outline: 1px dashed rgba(154, 59, 46, .55); }
.ace.sel { outline: 1.5px solid var(--accent); box-shadow: 0 0 0 1px rgba(154, 59, 46, .25), 0 2px 10px rgba(154, 59, 46, .25); }
.ace-rh {
  position: absolute; right: -6px; bottom: -6px; width: 11px; height: 11px;
  background: #fff; border: 2px solid var(--accent); border-radius: 3px; cursor: nwse-resize; z-index: 40;
}
.ace-seal { display: flex; align-items: center; justify-content: center; color: #fffdf5; font-family: KaiTi, 'SimSun', serif; }
.ace-text, .ace-title { user-select: none; }
.ce-menu {
  position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line2);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(40, 30, 10, .28); padding: 5px; display: flex; flex-direction: column; min-width: 128px;
}
.ce-menu button { border: 0; background: transparent; text-align: left; padding: 7px 10px; font-size: 12.5px; border-radius: 6px; color: var(--ink); }
.ce-menu button:hover { background: rgba(154, 59, 46, .08); color: var(--accent); }

.cs-inspector { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 18px; max-height: 30vh; overflow-y: auto; display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.insp-sec { min-width: 240px; flex: 1; }
.insp-sec h4 { margin: 0 0 8px; font-size: 13px; font-family: var(--serif); letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.insp-id { font-size: 10px; color: var(--faint); font-family: monospace; font-weight: 400; }
.insp-ops { margin-left: auto; display: flex; gap: 6px; }
.insp-ops button { border: 1px solid var(--line2); background: var(--panel); border-radius: 5px; font-size: 11.5px; padding: 2px 8px; color: var(--muted); }
.insp-ops button:hover { color: #b23a2a; border-color: #b23a2a; }
.insp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.insp-row > label { width: 62px; flex: none; font-size: 12px; color: var(--muted); }
.insp-in { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.insp-in input[type="range"] { flex: 1; accent-color: var(--accent); }
.insp-in input[type="text"], .insp-in select { flex: 1; border: 1px solid var(--line2); border-radius: 6px; padding: 4px 7px; font-size: 12.5px; background: #fff; min-width: 0; }
.insp-in input[type="color"] { width: 34px; height: 24px; border: 1px solid var(--line2); border-radius: 5px; padding: 1px; background: #fff; }
.insp-in output { font-size: 11px; color: var(--accent); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.insp-in .unit { font-size: 11px; color: var(--faint); }
.insp-hint { font-size: 11.5px; color: var(--faint); line-height: 1.9; }
.insp-sec textarea, .insp-sec input[type="number"] { border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; font-size: 12.5px; width: 100%; background: #fff; font-family: var(--ui); }

/* AI 聊天面板 */
.cs-ai { width: 320px; flex: none; border-left: 1px solid var(--line); background: var(--panel2); display: flex; flex-direction: column; min-height: 0; }
.ai-head { padding: 12px 14px 8px; font-size: 13.5px; font-weight: 600; letter-spacing: 1px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ai-state { font-size: 11px; font-weight: 400; color: #b23a2a; }
.ai-state.ok { color: var(--ok); }
.ai-key { display: flex; gap: 6px; padding: 0 12px 10px; }
.ai-key input { flex: 1; border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; font-size: 12px; background: #fff; min-width: 0; }
.ai-log { flex: 1; overflow-y: auto; padding: 4px 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-msg { max-width: 92%; padding: 8px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.ai-msg.ai { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 3px; }
.ai-msg.me { background: var(--accent); color: #fffdf5; align-self: flex-end; border-bottom-right-radius: 3px; }
.ai-quick { display: flex; gap: 6px; padding: 8px 12px 0; }
.ai-input-row { display: flex; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.ai-input-row textarea { flex: 1; resize: none; border: 1px solid var(--line2); border-radius: 8px; padding: 7px 9px; font-size: 12.5px; background: #fff; font-family: var(--ui); }
.ai-input-row .btn { flex: none; width: 38px; justify-content: center; }

/* ============ v2：排版模块 ============ */
.pane-layout { flex-direction: column; }
.layout-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.layout-bar { flex-wrap: wrap; }
.lx-hint { font-size: 12px; color: var(--muted); background: rgba(154, 59, 46, .06); border-radius: 6px; padding: 4px 10px; }
.layout-main { display: flex; flex: 1; min-height: 0; }
.layout-scroll { flex: 1; overflow: auto; background: #ded7c5; }
.layout-scroll iframe { border: 0; width: 100%; height: 100%; display: block; }
.lx-note-editor {
  width: 286px; flex: none; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-left: 1px solid var(--line);
  background: var(--panel); box-sizing: border-box;
}
.lx-note-editor[hidden] { display: none; }
.lx-note-head { display: flex; align-items: center; gap: 8px; }
.lx-note-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.lx-note-close {
  margin-left: auto; border: 0; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.lx-note-close:hover { color: var(--accent); }
.lx-note-tip {
  font-size: 11.5px; line-height: 1.65; color: var(--muted);
  padding: 8px 9px; border-radius: 7px; background: rgba(176, 138, 62, .1);
}
.lx-note-editor textarea {
  width: 100%; min-height: 150px; resize: vertical; box-sizing: border-box;
  border: 1px solid var(--line2); border-radius: 7px; padding: 8px 9px;
  font-size: 13px; line-height: 1.7; font-family: var(--serif);
  background: #fffdf8; color: var(--ink); outline: none;
}
.lx-note-editor textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(154, 59, 46, .12); }
.lx-note-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: auto; }
.lx-note-delete { margin-right: auto; color: #b23a2a; border-color: rgba(178, 58, 42, .35); }
.lx-note-delete:hover { color: #fff; background: #b23a2a; border-color: #b23a2a; }
.gallery-drawer { width: 250px; flex: none; border-left: 1px solid var(--line); background: var(--panel2); display: flex; flex-direction: column; min-height: 0; }
.material-search { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; padding: 10px; flex-shrink: 0; }
.material-search label { display: grid; gap: 5px; flex: 1 1 180px; color: var(--muted); font-size: 12px; }
.material-search input, .material-search select { width: 100%; min-width: 0; box-sizing: border-box; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; }
.material-search p { margin: 0; width: 100%; font-size: 12px; color: var(--muted); }
.material-search a { font-size: 11px; color: var(--accent); }
.gitem[hidden] { display: none !important; }
.gal-head { padding: 10px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.gal-head .seg { flex: 1; }
.gal-head .seg button { padding: 5px 8px; font-size: 11.5px; }
.gal-drop {
  flex: none; margin: 8px 10px 0; padding: 11px 8px; text-align: center; font-size: 11.5px; color: var(--faint);
  border: 1.5px dashed var(--line2); border-radius: 8px; background: rgba(255, 255, 255, .55); transition: all .15s;
}
.gal-drop.over { border-color: var(--accent); color: var(--accent); background: #fff3ea; }
.ci-drop {
  padding: 26px 12px; text-align: center; font-size: 13px; color: var(--muted);
  border: 2px dashed var(--line2); border-radius: 10px; background: rgba(255, 255, 255, .55); transition: all .15s;
}
.ci-drop.over { border-color: var(--accent); color: var(--accent); background: #fff3ea; }
.ci-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.ci-stage { display: flex; flex-direction: column; gap: 10px; }
.ci-stage canvas { width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; border: 1px solid var(--line2); border-radius: 8px; background: #111; }
.ci-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.ci-tools .btn.active { border-color: var(--accent); color: var(--accent); background: #fff3ea; }
.ci-tip { font-size: 12px; color: var(--muted); line-height: 1.8; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; }
.ci-galrow { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ci-galrow .ci-galhint { font-size: 12px; color: var(--faint); }
.ci-galpanel { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); overflow: hidden; }
.ci-galpanel .gal-grid { max-height: 300px; grid-template-columns: repeat(4, 1fr); }
.ci-galpanel .gitem { height: 96px; }
.ci-galpanel .ci-galsec { font-size: 11.5px; color: var(--muted); padding: 8px 12px 0; letter-spacing: .04em; }
.gal-grid { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; align-content: start; }
.gal-empty { grid-column: 1 / -1; font-size: 11.5px; color: var(--faint); text-align: center; padding: 18px 6px; line-height: 1.9; }
.gitem { position: relative; height: 138px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); cursor: pointer; background: #efe9da; box-shadow: 0 1px 2px rgba(40, 30, 20, .06); transition: box-shadow .12s, border-color .12s; }
.gitem img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.gitem:hover { border-color: var(--line2); box-shadow: 0 3px 9px rgba(40, 30, 20, .16); }
.gitem.pending { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(154, 59, 46, .25); }
.gitem.pending::after { content: '✓ 待插入'; position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); color: #fff; font-size: 10.5px; text-align: center; padding: 2px 0; }
.gal-grid.st-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 7px; }
.sitem { height: 52px; background: repeating-conic-gradient(#eae6dc 0% 25%, #f8f6f0 0% 50%) 50% / 12px 12px; cursor: grab; touch-action: none; }
.sitem img { object-fit: contain; padding: 6px; box-sizing: border-box; pointer-events: none; }
.sitem.pending::after { font-size: 9px; padding: 1px 0; }
.sitem.dragging { opacity: .35; }
.st-ghost { position: fixed; width: 58px; height: 58px; transform: translate(-50%, -50%); pointer-events: none; z-index: 999; opacity: .92; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3)); }
.st-ghost img { width: 100%; height: 100%; object-fit: contain; }
.gdel { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border: 0; border-radius: 5px; background: rgba(30, 25, 20, .55); color: #fff; font-size: 11px; display: none; z-index: 5; }
.gitem:hover .gdel { display: block; }
.ggrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ggrid .gitem { height: 150px; }

.lx-card {
  position: absolute; right: 268px; bottom: 18px; width: 268px; z-index: 40;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: 0 12px 34px rgba(40, 30, 10, .25); padding: 12px 14px;
}
.lx-card textarea { border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; font-size: 12.5px; font-family: var(--serif); resize: vertical; }
.lxc-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; }
.lxc-ops { margin-left: auto; display: flex; gap: 6px; }
.lxc-ops button { border: 1px solid var(--line2); background: var(--panel); border-radius: 5px; font-size: 11.5px; padding: 2px 8px; color: var(--muted); }
.lxc-ops #lxc-del:hover { color: #b23a2a; border-color: #b23a2a; }
.lxc-hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 2px; }
.lxc-hint b { color: #9a3b2e; font-weight: 600; }
.lxc-cropwrap { margin-bottom: 6px; }
.lxc-croplabel { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.lxc-lock { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.lxc-lock input { accent-color: var(--accent); }
.lxc-crops { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 10px; width: 100%; min-width: 0; }
.lxc-crop { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.lxc-crop input[type=range] { flex: 1; min-width: 0; }
.lxc-crop output { width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.lxc-crops #lxc-nocrop { grid-column: 1 / -1; margin-top: 2px; }

/* ============ v2：导出弹窗书脊 ============ */
.spine-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 12.5px; color: var(--muted);
}
.spine-row input[type="number"] { width: 68px; border: 1px solid var(--line2); border-radius: 6px; padding: 4px 6px; font-size: 12.5px; background: #fff; }
.spine-info { color: var(--ink); }
.spine-info b { color: var(--accent); font-size: 14px; }

@media (max-width: 1100px) {
  .style-cols { grid-template-columns: 1fr; }
  body { min-width: 760px; }
}
