/* =====================================================================
   文学创作工坊 · 后台服务 UI
   设计基调：纸感底色 + 墨色文字 + 单一赭石强调色，细线分隔，极少阴影。
   ===================================================================== */

:root {
  --paper: #f7f5f0;
  --paper-deep: #efeade;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --line: #e6e0d4;
  --line-soft: #efeae0;
  --ink: #241f1a;
  --ink-2: #4a423a;
  --muted: #8c8175;
  --muted-2: #a99e90;
  --accent: #8a5a3b;
  --accent-soft: #f2e8df;
  --accent-deep: #6d452b;
  --sage: #5d6f5c;
  --sage-soft: #e8eee6;
  --danger: #a6402d;
  --danger-soft: #f7e7e2;
  --warn: #a4762a;
  --warn-soft: #f7efdd;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(36, 31, 26, 0.04);
  --shadow-md: 0 10px 30px rgba(36, 31, 26, 0.08);
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------------------ 布局 */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 212px;
  flex: 0 0 212px;
  background: var(--surface-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px 16px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--ink); color: #f7f3ea;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 17px; line-height: 1;
  letter-spacing: -2px; padding-right: 2px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-family: var(--serif); font-size: 15px; letter-spacing: 0.04em; }
.brand-sub { font-size: 10px; color: var(--muted-2); letter-spacing: 0.12em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10px; letter-spacing: 0.14em; color: var(--muted-2);
  padding: 14px 10px 6px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 13px; cursor: pointer;
  border: 1px solid transparent; transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 15px; height: 15px; opacity: 0.7; }
.nav-item:hover { background: #f3efe7; color: var(--ink); }
.nav-item.active { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-sm); }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-item .badge {
  margin-left: auto; font-size: 10px; background: var(--danger-soft); color: var(--danger);
  border-radius: 20px; padding: 0 6px; min-width: 17px; text-align: center; line-height: 16px;
}

.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--muted-2); }
.sidebar-foot .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); margin-right: 6px; }
.sidebar-foot .dot.off { background: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px; flex: 0 0 62px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 240, 0.86);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-family: var(--serif); font-size: 15px; letter-spacing: 0.03em; }
.topbar .spacer { flex: 1; }

.book-select {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 5px 12px 5px 6px; font-size: 12px;
}
.book-select .swatch { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }
.book-select select { border: 0; background: transparent; font-size: 12.5px; color: var(--ink); outline: none; max-width: 180px; }

.content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; }

/* ------------------------------------------------------------ 基础组件 */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-soft); border-color: #d8d0c0; color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fbf8f1; }
.btn.primary:hover { background: #38302a; border-color: #38302a; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f0ebe1; }
.btn.sm { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; }
.btn.danger { color: var(--danger); border-color: #ead6d0; }
.btn.danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: #f0ebe1; color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; line-height: 18px;
  background: var(--paper-deep); color: var(--ink-2);
  border: 1px solid transparent; white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-deep); }
.chip.sage { background: var(--sage-soft); color: #46573f; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.line { background: transparent; border-color: var(--line); color: var(--muted); }
/* chip 当按钮用（素材的出处 / 引用跳转） */
button.chip { font-family: inherit; font-size: 11px; line-height: 18px; cursor: pointer; }
button.chip:hover { border-color: var(--accent); color: var(--accent-deep); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-title { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.card-sub { font-size: 11.5px; color: var(--muted); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-family: var(--serif); font-size: 25px; font-weight: 500; margin: 0 0 4px; letter-spacing: 0.02em; }
.page-head .desc { font-size: 12.5px; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 16px; }

.mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }
.field .hint { font-size: 10.5px; color: var(--muted-2); }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); padding: 8px 10px; font-size: 13px; color: var(--ink);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: #c9b8a4; box-shadow: 0 0 0 3px rgba(138, 90, 59, 0.08); }
textarea { resize: vertical; min-height: 76px; line-height: 1.7; }
.search-input { position: relative; }
.search-input input { padding-left: 32px; height: 34px; border-radius: 999px; background: var(--surface); }
.search-input svg { position: absolute; left: 11px; top: 10px; width: 14px; height: 14px; color: var(--muted-2); }

.switch-group { display: inline-flex; background: var(--paper-deep); border-radius: 999px; padding: 2px; gap: 2px; }
.switch-group button {
  border: 0; background: transparent; border-radius: 999px; padding: 4px 12px;
  font-size: 11.5px; color: var(--muted); cursor: pointer;
}
.switch-group button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* 统计卡 */
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.stat .k { font-size: 11px; color: var(--muted); letter-spacing: 0.05em; }
.stat .v { font-family: var(--serif); font-size: 26px; line-height: 1.1; letter-spacing: -0.01em; }
.stat .v small { font-size: 12px; color: var(--muted); margin-left: 4px; font-family: var(--sans); }
.stat .d { font-size: 11px; color: var(--muted-2); }
/* 可点击统计卡：整块跳转，hover 才提示方向 */
a.stat.link {
  text-decoration: none; color: inherit; position: relative; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
a.stat.link:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
a.stat.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.stat.link .go {
  position: absolute; top: 14px; right: 14px; font-size: 13px; line-height: 1;
  color: var(--accent); opacity: 0; transform: translateX(-3px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
a.stat.link:hover .go, a.stat.link:focus-visible .go { opacity: 1; transform: translateX(0); }

/* 列表 */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--line-soft);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-soft); }
.list-row .idx { font-family: var(--mono); font-size: 11px; color: var(--muted-2); width: 34px; }
.list-row .ttl { font-family: var(--serif); font-size: 14px; }
.list-row .meta { font-size: 11px; color: var(--muted); }

.empty {
  padding: 54px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface-soft);
}
.empty .t { font-family: var(--serif); font-size: 15px; color: var(--ink-2); margin-bottom: 6px; }

.skeleton { background: linear-gradient(90deg, #f2eee6 25%, #f8f5ef 37%, #f2eee6 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 抽屉 / 弹层 */
.drawer-mask, .modal-mask {
  position: fixed; inset: 0; background: rgba(36, 31, 26, 0.28);
  opacity: 0; pointer-events: none; transition: opacity 0.22s; z-index: 60;
}
.drawer-mask.open, .modal-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 92vw);
  background: var(--surface); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 61; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px; }
.drawer-head h2 { font-family: var(--serif); font-size: 17px; font-weight: 500; margin: 0; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-soft); }

.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -46%) scale(0.98);
  width: min(520px, 92vw); background: var(--surface); border-radius: 16px;
  border: 1px solid var(--line); box-shadow: var(--shadow-md); z-index: 61;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  max-height: 86vh; display: flex; flex-direction: column;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-head { padding: 18px 22px 10px; }
.modal-head h2 { font-family: var(--serif); font-size: 18px; font-weight: 500; margin: 0; }
.modal-body { padding: 8px 22px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 8px; }

.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #f8f4ec; font-size: 12.5px;
  padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow-md);
  animation: toast-in 0.22s ease;
}
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------ 总览 */
.hero {
  display: flex; gap: 26px; align-items: flex-start;
  padding: 24px 26px; border-radius: var(--radius);
  background:
    radial-gradient(120% 160% at 100% 0%, #f4ece0 0%, transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.hero-cover { width: 92px; flex: 0 0 92px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.hero-cover img { width: 100%; display: block; }
.hero h2 { font-family: var(--serif); font-size: 24px; font-weight: 500; margin: 0 0 6px; }
.hero .logline { color: var(--ink-2); font-size: 13px; max-width: 620px; line-height: 1.8; }
.hero .meta { display: flex; gap: 14px; margin-top: 12px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.progress-bar { height: 4px; border-radius: 4px; background: var(--paper-deep); overflow: hidden; margin-top: 14px; }
.progress-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.spark { width: 100%; height: 74px; display: block; }
.spark-legend { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted-2); margin-top: 4px; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline .item { display: flex; gap: 10px; padding: 8px 0; }
.timeline .item .t { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); width: 62px; flex: 0 0 62px; }
.timeline .item .b { font-size: 12px; color: var(--ink-2); }
.timeline .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); margin-top: 7px; flex: 0 0 6px; }
.timeline .item.hot .dot { background: var(--accent); }

/* ------------------------------------------------------------ 章节 */
.volume-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 16px 4px 8px; border-bottom: 1px solid var(--line);
}
.volume-head .v { font-family: var(--serif); font-size: 15px; }
.volume-head .s { font-size: 11px; color: var(--muted); }

.chapter-row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) 92px 62px 72px 92px 118px;
  align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.chapter-row:hover { background: var(--surface-soft); }
.chapter-row .no { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.chapter-row .name { font-family: var(--serif); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-row .num { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); text-align: right; }
.chapter-row .acts { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity 0.15s; }
.chapter-row:hover .acts { opacity: 1; }
.scorebar { display: flex; gap: 3px; }
.scorebar i { width: 4px; height: 12px; border-radius: 2px; background: var(--paper-deep); display: block; }
.scorebar i.on { background: var(--accent); }

/* ------------------------------------------------------------ 素材 */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px; }
.asset-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.asset-card:hover { border-color: #d5c9b8; transform: translateY(-1px); }
.asset-thumb { aspect-ratio: 4 / 3; background: var(--paper-deep); display: grid; place-items: center; overflow: hidden; position: relative; }
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-thumb .ph { font-family: var(--serif); font-size: 30px; color: #c3b7a5; }
.asset-thumb .cat { position: absolute; left: 8px; top: 8px; }
.asset-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.asset-body .nm { font-family: var(--serif); font-size: 14px; }
.asset-body .cd { font-family: var(--mono); font-size: 10.5px; color: var(--muted); word-break: break-all; }
.asset-body .pr { font-size: 11px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 元素树：父子缩进 + 归档别名行 */
.asset-tree { display: flex; flex-direction: column; gap: 6px; }
.asset-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.asset-row:hover { border-color: #d5c9b8; background: #fffdf8; }
.asset-row.alias { background: var(--paper-deep); border-style: dashed; cursor: default; padding: 5px 12px; }
.asset-row .nm { font-family: var(--serif); font-size: 14px; }
.asset-thumb.sm { width: 44px; height: 44px; aspect-ratio: auto; border-radius: 8px; flex: 0 0 44px; }
.asset-thumb.sm .ph { font-size: 18px; }
.clamp1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 元素详情：折叠段 */
.asset-sec { border-top: 1px solid var(--line-soft); padding: 10px 0 4px; margin-top: 8px; }
.asset-sec > summary {
  cursor: pointer; font-family: var(--serif); font-size: 13.5px; padding: 4px 0;
  list-style: none;
}
.asset-sec > summary::before { content: "▸ "; color: var(--muted); }
.asset-sec[open] > summary::before { content: "▾ "; }
.prompt-row { padding: 7px 0; border-bottom: 1px dashed var(--line-soft); }
.prompt-row:last-of-type { border-bottom: 0; }

/* 项目 / 二创 / 分层摘要 */
.pub-row { align-items: center; }
.pub-row .ttl { font-family: var(--serif); font-size: 14px; }
.brief {
  font-family: var(--mono); font-size: 12px; line-height: 1.7; white-space: pre-wrap;
  background: var(--paper-deep); border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 12px; max-height: 52vh; overflow: auto;
}
.dg-volume + .dg-volume { margin-top: 4px; }
.dg-window { cursor: pointer; padding: 8px 4px; }
.dg-window:hover { background: var(--paper-deep); }
.dg-chapters { overflow: auto; padding-right: 4px; }

/* 附件库：按批次分组的缩略格 */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.file-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  text-decoration: none; color: inherit; min-width: 0;
}
.file-tile:hover { border-color: #d5c9b8; }
.file-tile img, .file-tile video {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px;
  background: var(--paper-deep); display: block;
}
.file-tile .ph {
  width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center;
  background: var(--paper-deep); border-radius: 6px; font-family: var(--serif); color: #c3b7a5;
}
.file-tile .mono { word-break: break-all; }

/* 资产：事物元素卡片 + 附件卡片（全部 / 项目资产 / 附件 三页签共用） */
.element-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.element-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.element-card:hover { border-color: #d5c9b8; transform: translateY(-1px); }
.element-card-cover {
  aspect-ratio: 4 / 3; background: var(--paper-deep); display: grid; place-items: center;
  overflow: hidden; position: relative;
}
.element-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.element-card-cover .ph { font-family: var(--serif); font-size: 34px; color: #c3b7a5; }
.element-card-status { position: absolute; left: 8px; top: 8px; }
.element-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; }
.element-card-body .nm { font-family: var(--serif); font-size: 14px; }
.file-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.file-card:hover { border-color: #d5c9b8; transform: translateY(-1px); }
.file-card-media {
  aspect-ratio: 4 / 3; background: var(--paper-deep); display: grid; place-items: center; overflow: hidden;
}
.file-card-media img, .file-card-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-card-media .ph { font-family: var(--serif); font-size: 30px; color: #c3b7a5; }
.file-card-body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.file-card-body .nm { font-family: var(--serif); font-size: 13px; }
.asset-audio { width: 100%; height: 30px; }
.version-list { display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow: auto; }
.version-list .list-row { padding: 6px 2px; border-bottom: 1px dashed var(--line-soft); }
.file-grid.sm { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }

.code-preview {
  font-family: var(--mono); font-size: 12px; background: var(--ink); color: #f2e9d8;
  padding: 10px 12px; border-radius: 8px; letter-spacing: 0.02em; word-break: break-all;
}
.bind-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 132px; overflow-y: auto; padding: 2px; }

/* ------------------------------------------------------------ 评论 */
.comment {
  padding: 13px 4px; border-bottom: 1px solid var(--line-soft);
  display: flex; gap: 12px;
}
.comment:last-child { border-bottom: 0; }
.comment .av {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--paper-deep); color: var(--ink-2);
  display: grid; place-items: center; font-family: var(--serif); font-size: 12px;
}
.comment .bd { flex: 1; min-width: 0; }
.comment .hd { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.comment .txt { font-size: 13px; line-height: 1.75; color: var(--ink-2); }
.comment .quote {
  border-left: 2px solid var(--line); padding: 2px 0 2px 10px; margin: 6px 0;
  font-family: var(--serif); font-size: 12.5px; color: var(--muted);
  background: var(--surface-soft);
}
.comment .ops { display: flex; gap: 6px; margin-top: 6px; }
.comment.strong .av { background: var(--accent-soft); color: var(--accent-deep); }

/* ------------------------------------------------------------ 检索 */
.searchbox { display: flex; gap: 8px; align-items: center; }
.searchbox input { flex: 1; width: auto; height: 42px; font-size: 14px; border-radius: 10px; }
.result {
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); margin-bottom: 10px;
}
.result .head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.result .score { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--accent); }
.result .txt { font-family: var(--serif); font-size: 13.5px; line-height: 1.9; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.result mark { background: #f6e6c9; color: inherit; padding: 0 1px; }

/* ------------------------------------------------------------ 书源 */
.code-block {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.7;
  background: #211d19; color: #e8dfd0; border-radius: 12px;
  padding: 16px; overflow: auto; max-height: 420px; white-space: pre;
}

/* ------------------------------------------------------------ 阅读器 */
body.reader-body { background: var(--paper); overflow: hidden; height: 100vh; }

/* 主题变量必须挂在 body 上：目录 / 评论 / 设置面板与遮罩都是 body 的子元素，
   不在 .reader 里。以前只有 .reader 定义 --r-bg，面板取不到变量 → 背景透明，
   遮罩从面板底下透上来，看起来就像「遮罩盖住了抽屉」。 */
body.reader-body,
.reader {
  --r-bg: #f6f1e6;
  --r-text: #2b241d;
  --r-dim: #8b7f70;
  --r-line: #e2d8c6;
}
body.reader-body[data-theme="day"], .reader[data-theme="day"] { --r-bg: #ffffff; --r-text: #232323; --r-dim: #8f8f8f; --r-line: #ececec; }
body.reader-body[data-theme="night"], .reader[data-theme="night"] { --r-bg: #191817; --r-text: #c9c2b6; --r-dim: #7c766c; --r-line: #302d29; }
body.reader-body[data-theme="day"] { background: #ffffff; }
body.reader-body[data-theme="night"] { background: #191817; }

.reader {
  height: 100vh; display: flex; flex-direction: column;
  background: var(--r-bg); color: var(--r-text);
  transition: background 0.3s, color 0.3s;
}

.reader-top {
  height: 54px; flex: 0 0 54px; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--r-line);
  font-size: 12px; color: var(--r-dim);
  transition: opacity 0.25s, transform 0.25s;
  /* 顶栏永远可点：面板和遮罩都比它低一层，点「设置」能直接从目录切过去，
     不用先关面板（以前被遮罩盖住，点一下就只是关掉面板） */
  position: relative; z-index: 63; background: var(--r-bg);
}
.reader-top .book-name { font-family: var(--serif); color: var(--r-text); font-size: 13.5px; }
.reader-top .spacer { flex: 1; }
.reader-top .icon-btn { color: var(--r-dim); }
.reader-top .icon-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--r-text); }
.reader-top .icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.reader-top .icon-btn:disabled:hover { background: transparent; color: var(--r-dim); }
.chapter-nav { display: inline-flex; gap: 2px; margin-left: 2px; }
.chapter-nav .icon-btn svg { width: 16px; height: 16px; }

.reader-stage { flex: 1; position: relative; overflow: hidden; display: flex; justify-content: center; }
.reader-page-wrap {
  position: relative; width: min(760px, 92vw); height: 100%;
  padding: 18px 4px 22px;
  perspective: 2200px;
  overflow: hidden;
}
.book-columns {
  height: 100%;
  column-fill: auto;
  column-gap: 56px;
  font-family: var(--serif);
  font-size: var(--r-fs, 19px);
  line-height: var(--r-lh, 2.05);
  letter-spacing: 0.012em;
  text-align: justify;
  transition: transform 0.42s cubic-bezier(0.25, 0.1, 0.25, 1);
  will-change: transform;
}
.book-columns p { margin: 0 0 0.72em; text-indent: 2em; orphans: 1; widows: 1; }
.book-columns h1.chapter-title {
  font-size: 1.32em; text-indent: 0; margin: 0 0 1.1em; font-weight: 500;
  letter-spacing: 0.04em; line-height: 1.7;
}
.book-columns .chapter-meta { text-indent: 0; font-family: var(--sans); font-size: 11px; color: var(--r-dim); margin-bottom: 2em; letter-spacing: 0.05em; }
.book-columns .chapter-end { text-indent: 0; text-align: center; color: var(--r-dim); font-size: 12px; margin: 2em 0; letter-spacing: 0.3em; }

.turn-sheet {
  position: absolute; inset: 0; display: none;
  background: linear-gradient(100deg, #fbf7ee 0%, #f1ead9 46%, #e6dbc5 100%);
  border-radius: 2px;
  box-shadow: inset 0 0 60px rgba(120, 100, 70, 0.14), 0 10px 40px rgba(60, 46, 30, 0.16);
  transform-origin: left center; z-index: 6; pointer-events: none;
}
.reader[data-theme="day"] .turn-sheet { background: linear-gradient(100deg, #ffffff 0%, #f7f6f2 46%, #ecebe6 100%); }
.reader[data-theme="night"] .turn-sheet { background: linear-gradient(100deg, #24211e 0%, #1c1a17 46%, #141210 100%); box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.5); }
.turn-sheet::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(70, 55, 35, 0.16), transparent 22%, transparent 70%, rgba(70, 55, 35, 0.05));
  opacity: 0.9;
}
.turn-sheet.run { display: block; animation: sheet-turn 0.62s cubic-bezier(0.42, 0.1, 0.28, 1) forwards; }
.turn-sheet.run.back { transform-origin: right center; animation: sheet-turn-back 0.62s cubic-bezier(0.42, 0.1, 0.28, 1) forwards; }
@keyframes sheet-turn {
  0% { transform: rotateY(0deg); opacity: 1; }
  55% { opacity: 1; }
  100% { transform: rotateY(-176deg); opacity: 0; }
}
@keyframes sheet-turn-back {
  0% { transform: rotateY(0deg); opacity: 1; }
  55% { opacity: 1; }
  100% { transform: rotateY(176deg); opacity: 0; }
}
.reader[data-anim="slide"] .book-columns { transition-duration: 0.32s; }
.reader[data-anim="none"] .book-columns { transition-duration: 0s; }

/* 翻页热区只做视觉提示，不吃指针事件：否则正文段落左右各 22% 选不中、点不到，
   段评的悬停按钮和「点段落选中」在窄屏上会直接失效。翻页判定在 reader.js 里按
   点击位置算（点正文不翻页）。 */
.page-zone {
  position: absolute; top: 0; bottom: 0; width: 22%;
  z-index: 5; cursor: pointer; pointer-events: none;
}
.page-zone.left { left: 0; }
.page-zone.right { right: 0; }
.page-zone .hint {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: var(--r-dim);
  background: rgba(255, 255, 255, 0.5); border: 1px solid var(--r-line);
  opacity: 0; transition: opacity 0.2s;
}
.reader[data-theme="night"] .page-zone .hint { background: rgba(0, 0, 0, 0.25); }
.page-zone.left .hint { left: 8px; }
.page-zone.right .hint { right: 8px; }
.page-zone.hint-on .hint { opacity: 1; }

.reader-foot {
  height: 46px; flex: 0 0 46px; display: flex; align-items: center; gap: 16px;
  padding: 0 24px; font-size: 11px; color: var(--r-dim);
  border-top: 1px solid var(--r-line);
}
.reader-foot .bar { flex: 1; height: 2px; background: var(--r-line); border-radius: 2px; overflow: hidden; }
.reader-foot .bar i { display: block; height: 100%; background: var(--r-dim); opacity: 0.7; }

/* 遮罩只盖正文，层级压在抽屉/面板之下：抽屉是实色面板，
   遮罩低于它才符合「点空白关面板、面板本身不被蒙灰」的直觉。 */
body.reader-body .drawer-mask { z-index: 58; }

.reader-panel {
  position: fixed; top: 54px; right: 0; bottom: 0; width: min(400px, 92vw);
  background: var(--r-bg); border-left: 1px solid var(--r-line);
  transform: translateX(100%); transition: transform 0.28s ease;
  /* 抽屉 62、顶栏 63：都高于遮罩(58)，点目录/评论/设置不会命中遮罩 */
  z-index: 62;
  display: flex; flex-direction: column; color: var(--r-text);
  box-shadow: -18px 0 42px rgba(36, 31, 26, 0.16);
}
.reader-panel.open { transform: none; }

/* 目录检索 */
.toc-search { padding: 12px 14px 4px; border-bottom: 1px solid var(--r-line); }
.toc-search .search-input input { background: rgba(0, 0, 0, 0.03); height: 32px; }
.reader[data-theme="night"] .toc-search .search-input input { background: rgba(255, 255, 255, 0.05); }
.toc-item.hit .t { color: var(--accent); }
.toc-item .n.hit { color: var(--accent); }
.toc-empty { padding: 28px 12px; text-align: center; font-size: 12px; color: var(--r-dim); }
.reader-panel .ph { padding: 18px 20px; border-bottom: 1px solid var(--r-line); display: flex; align-items: center; gap: 10px; }
.reader-panel .ph h3 { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 500; }
.reader-panel .pb { flex: 1; overflow-y: auto; padding: 8px 12px 20px; }
.reader-panel .pf { padding: 14px 18px; border-top: 1px solid var(--r-line); }
.toc-item {
  display: flex; align-items: baseline; gap: 10px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}
.toc-item:hover { background: rgba(0, 0, 0, 0.035); }
.toc-item.current { background: rgba(138, 90, 59, 0.1); }
.toc-item .n { font-family: var(--mono); font-size: 10.5px; color: var(--r-dim); width: 28px; }
.toc-item .t { font-family: var(--serif); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reader-settings { display: flex; flex-direction: column; gap: 18px; padding: 18px 20px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-row .lb { font-size: 12px; color: var(--r-dim); }
.theme-dots { display: flex; gap: 8px; }
.theme-dot { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--r-line); cursor: pointer; }
.theme-dot.active { outline: 2px solid var(--r-dim); outline-offset: 2px; }

.selection-pop {
  position: fixed; z-index: 40; background: var(--ink); color: #f8f4ec;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; cursor: pointer;
  box-shadow: var(--shadow-md); transform: translate(-50%, -120%);
  display: none; white-space: nowrap;
}
.selection-pop.show { display: block; }

/* 段落批注：鼠标移入段落即「悬浮」，右侧浮出「评论」按钮；点选段落（Shift 连选）
   直接把段号作为评论目标，不再有右上角的下拉选段。
   按钮必须放在 .page-zone(z-index:5) 之上——左右各 22% 的翻页区盖住了正文，
   放正文里的按钮在那两条带子上点不到。
   悬浮底色用 background + 外扩 box-shadow 模拟内边距：改 padding/margin 会让
   分栏重新分页，翻着页就跳行了。 */
.book-columns p.para {
  position: relative; border-radius: 3px; cursor: pointer;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}
.book-columns p.para:hover {
  background: rgba(138, 90, 59, 0.08);
  box-shadow: 0 0 0 6px rgba(138, 90, 59, 0.08);
}
.book-columns p.para.selected {
  background: rgba(138, 90, 59, 0.14);
  box-shadow: 0 0 0 6px rgba(138, 90, 59, 0.14);
}
.reader[data-theme="night"] .book-columns p.para:hover {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.07);
}
.reader[data-theme="night"] .book-columns p.para.selected {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.12);
}
.book-columns p.para.annotated::after {
  content: attr(data-count);
  position: absolute; right: -1px; top: -0.15em;
  font-family: var(--mono); font-size: 9px; color: var(--accent, #8a5a3b); opacity: 0.75;
}
.book-columns p.para.flash { animation: para-flash 1.1s ease; }
.para-tools {
  position: absolute; z-index: 8; opacity: 0; pointer-events: none;
  transition: opacity 0.14s, transform 0.14s; transform: translateY(-1px);
}
.para-tools.show { opacity: 1; transform: none; }
.para-tools button {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px 0 7px; border-radius: 999px;
  border: 1px solid var(--r-line); background: var(--r-bg); color: var(--r-dim);
  font-size: 11px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 10px rgba(36, 31, 26, 0.16); white-space: nowrap;
}
.para-tools button svg { width: 13px; height: 13px; }
.para-tools button:hover { color: var(--r-text); background: rgba(0, 0, 0, 0.05); }
@keyframes para-flash {
  0%, 100% { background: transparent; }
  30% { background: rgba(138, 90, 59, 0.14); }
}

/* 段落选择动作条：选中一段或多段后浮在正文底部，抽屉关着也看得见选了什么 */
.para-bar {
  position: fixed; left: 50%; bottom: 62px; transform: translateX(-50%);
  z-index: 44; display: flex; align-items: center; gap: 8px;
  max-width: 90vw; padding: 7px 9px 7px 14px; border-radius: 999px;
  background: var(--ink); color: #f8f4ec; box-shadow: var(--shadow-md); font-size: 12px;
}
.para-bar[hidden] { display: none; }
.para-bar .pb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.para-bar .btn { background: rgba(255, 255, 255, 0.16); border-color: transparent; color: #f8f4ec; }
.para-bar .btn:hover { background: rgba(255, 255, 255, 0.26); }
.para-bar .btn.primary { background: var(--accent, #8a5a3b); }
.para-bar .btn.primary:hover { background: var(--accent, #8a5a3b); filter: brightness(1.08); }

/* 评论目标（段落 / 选中片段） */
.comment-target {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 12px; color: var(--r-dim); line-height: 1.6;
}
.comment-target .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-target button {
  border: none; background: none; padding: 0; cursor: pointer;
  font-size: 11px; color: var(--r-dim); text-decoration: underline;
}
.comment-para-chip {
  font-family: var(--mono); font-size: 10px; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--r-line); color: var(--r-dim); cursor: pointer;
}

/* 编辑本章：大弹框（80% 屏以上），左边改正文，右边选处理方式 */
.edit-modal {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -48%) scale(0.985);
  width: min(1360px, 94vw); height: 88vh; min-height: 80vh;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-md); z-index: 64;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  display: flex; flex-direction: column; overflow: hidden;
}
.edit-modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.edit-head {
  padding: 16px 22px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: flex-start; gap: 12px; flex: 0 0 auto;
}
.edit-head h2 { font-family: var(--serif); font-size: 18px; font-weight: 500; margin: 0; }
.edit-body { flex: 1; display: flex; min-height: 0; }
.edit-body > textarea {
  flex: 1; min-width: 0; border: 0; border-radius: 0; resize: none;
  padding: 22px 26px; font-family: var(--serif); font-size: 14.5px; line-height: 2;
  background: var(--surface); outline: none;
}
.edit-body > textarea:focus { box-shadow: none; border: 0; }
.edit-side {
  width: 330px; flex: 0 0 330px; border-left: 1px solid var(--line-soft);
  background: var(--surface-soft); padding: 16px 18px 20px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.edit-foot {
  padding: 12px 22px; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 0 0 auto;
}
.edit-foot .tiny { margin-right: auto; }
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio-item {
  display: flex; gap: 9px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 12.5px;
  transition: border-color 0.15s, background 0.15s;
}
.radio-item input { margin-top: 3px; accent-color: var(--accent); }
.radio-item b { font-weight: 600; }
.radio-item em { display: block; font-style: normal; color: var(--muted); font-size: 11.5px; line-height: 1.65; margin-top: 3px; }
.radio-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.edit-note { line-height: 1.7; }
.edit-versions { display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow-y: auto; font-size: 11px; }
.edit-versions .v { display: flex; gap: 8px; color: var(--muted); }
.edit-versions .v.now { color: var(--ink-2); }
.edit-versions .v .n { font-family: var(--mono); flex: 0 0 auto; }

/* 全章复盘 */
.review-box { margin: 6px 8px 12px; }
.review-card {
  border: 1px solid var(--r-line); border-radius: 10px; padding: 12px 14px;
  background: rgba(0, 0, 0, 0.02); font-size: 12.5px; line-height: 1.85;
}
.review-card h4 { margin: 0 0 6px; font-family: var(--serif); font-size: 13.5px; font-weight: 500; }
.review-card .issues { margin: 8px 0 0; padding-left: 16px; color: var(--r-text); }
.review-card .issues li { margin-bottom: 6px; }
.review-card .issues li b { font-weight: 500; }
.review-body {
  white-space: pre-wrap; font-family: var(--serif); font-size: 13.5px; line-height: 2;
  max-height: 52vh; overflow-y: auto; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-soft);
}
.review-diff { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.review-diff b { color: var(--ink); font-weight: 600; }

.reader .toast-host { bottom: 60px; }

@media (max-width: 700px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar .crumb { display: none; }
  .topbar #btn-upload { padding: 0 10px; font-size: 0; gap: 0; }
  .topbar #btn-upload svg { width: 16px; height: 16px; }
  .topbar .book-select { padding: 4px 8px 4px 6px; }
  .book-select select { max-width: 108px; font-size: 12px; }
  .content { padding: 16px 14px 50px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head h1 { font-size: 21px; }
  .hero { flex-direction: column; padding: 18px; gap: 14px; }
  .hero > * { min-width: 0; }
  .hero-cover { width: 74px; flex: 0 0 74px; }
  .hero h2 { font-size: 20px; }
  .hero .logline { font-size: 12.5px; }
  .hero .row { width: 100%; }
  .hero .row .btn { width: 100%; justify-content: center; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .v { font-size: 21px; }
  .split { grid-template-columns: 1fr; }
  .search .searchbox { flex-wrap: wrap; }
  .chapter-row { grid-template-columns: 34px minmax(0, 1fr) 56px 56px; gap: 6px; }
  .chapter-row .acts, .chapter-row .updated, .chapter-row .scorebar { display: none; }
  .drawer { width: 100vw; }
  .modal { width: 94vw; }
}

@media (max-width: 520px) {
  .reader-top { padding: 0 12px; gap: 8px; }
  .reader-top .book-name, .reader-top .sep { display: none; }
  #chapter-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }
  .chapter-nav { gap: 0; }
  .chapter-nav .icon-btn, .reader-top .icon-btn { width: 27px; }
  .reader-page-wrap { width: 94vw; padding: 14px 2px 18px; }
  .reader-foot { padding: 0 14px; gap: 10px; }
  .reader-foot #chapter-label { display: none; }
  .edit-modal { width: 100vw; height: 94vh; border-radius: 12px; }
  .edit-body { flex-direction: column; }
  .edit-body > textarea { padding: 16px 18px; font-size: 14px; }
  .edit-side { width: 100%; flex: 0 0 auto; max-height: 44%; border-left: 0; border-top: 1px solid var(--line-soft); }
}

@media (max-width: 980px) {
  .sidebar { width: 64px; flex: 0 0 64px; padding: 18px 8px; }
  .brand-text, .nav-label, .nav-item span, .sidebar-foot { display: none; }
  .brand { justify-content: center; padding: 0 0 18px; }
  .nav-item { justify-content: center; padding: 9px 0; }
  .content { padding: 18px 16px 60px; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3, .split { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .chapter-row { grid-template-columns: 42px minmax(0, 1fr) 62px 70px; }
  .chapter-row .scorebar, .chapter-row .acts, .chapter-row .updated { display: none; }
}

/* ------------------------------------------------------------ 创作流程 / 风格与灵魂 */
.flow-steps { display: flex; flex-direction: column; }
.flow-step {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 8px; border-bottom: 1px solid var(--line-soft);
}
.flow-step:last-child { border-bottom: 0; }
.flow-step .mark {
  width: 22px; height: 22px; flex: 0 0 22px; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: var(--surface);
}
.flow-step.now .mark { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }
.flow-step.done .mark { border-color: transparent; background: var(--sage-soft); color: #46573f; }
.flow-step.now { background: var(--surface-soft); border-radius: var(--radius-sm); }
.flow-step .flow-name { font-family: var(--serif); font-size: 13.5px; }
.flow-step.todo .flow-name { color: var(--muted); }
.flow-step .flow-hint { font-size: 11.5px; color: var(--muted); line-height: 1.65; margin-top: 2px; }

.opt-card { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.opt-card:last-child { margin-bottom: 0; }
.opt-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.opt {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  width: 100%; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 12.5px;
}
.opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.opt.rec { border-color: #dfd2c2; background: var(--surface-soft); }
.opt .k { font-weight: 600; }
.opt .d { font-size: 11px; color: var(--muted); }

.mini-stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.mini-stat .k { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; }
.mini-stat .v { font-family: var(--serif); font-size: 17px; }

.gate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gate {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft); background: var(--surface-soft);
}
.gate .k { font-size: 11px; color: var(--muted); }
.gate .v { font-family: var(--serif); font-size: 15px; }
.gate .d { font-size: 10.5px; color: var(--muted-2); line-height: 1.5; }
.gate.bad { border-color: #ead9c4; background: var(--warn-soft); }
.gate.bad .v { color: var(--warn); }

.soul-card {
  margin: 4px 0 0; padding: 12px 14px;
  background: var(--surface-soft); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.85;
  white-space: pre-wrap; word-break: break-word; color: var(--ink-2);
  max-height: 320px; overflow: auto;
}
.soul-core {
  font-family: var(--serif); font-size: 16px; line-height: 1.7;
  padding: 10px 12px; border-left: 2px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.soul-rules { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--ink-2); }
.soul-rules li { margin-bottom: 4px; }

.meter { display: flex; align-items: center; gap: 8px; font-size: 11.5px; margin-bottom: 6px; }
.meter .k { width: 62px; flex: 0 0 62px; color: var(--muted); }
.meter .bar { flex: 1; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter .v { width: 56px; flex: 0 0 56px; text-align: right; font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); }

@media (max-width: 760px) {
  .gate-grid { grid-template-columns: 1fr; }
}

/* 3.18 设定生态 / 剧本 */
.eco-tree { display: flex; flex-direction: column; gap: 2px; max-height: 64vh; overflow: auto; }
.eco-name { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.eco-name:hover { background: var(--line-soft); }
.eco-name.active { background: rgba(76, 120, 96, 0.12); }
.eco-block { border-top: 1px solid var(--line-soft); padding: 10px 0; }
