/* ============================================================
   小说模块（novel.css）
   主题变量驱动（--bg/--surface/--ink/--accent…由 theme.css 提供）
   ============================================================ */
.nv-main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.nv-head h1 { margin: 0 0 6px; font-size: 26px; }
.nv-head .muted { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
.nv-bookdesc { color: var(--ink-2); font-size: 14.5px; line-height: 1.7; margin: 0 0 10px; }
.nv-create { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.nv-create input[type=text] {
  flex: 1 1 160px; min-width: 0;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}

.nv-btn {
  appearance: none; border: 1px solid var(--accent); background: var(--accent);
  color: var(--on-accent, #fff); font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 18px; border-radius: 10px; cursor: pointer; text-decoration: none;
  display: inline-block; transition: opacity .15s;
}
.nv-btn:hover { opacity: .88; }
.nv-btn.ghost { background: transparent; color: var(--accent); }
.nv-btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.nv-btn:disabled { opacity: .5; cursor: wait; }

.nv-empty { text-align: center; padding: 80px 0; color: var(--muted); }
.nv-empty .ico { font-size: 44px; margin-bottom: 10px; }

.nv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 18px; }
.nv-book {
  display: flex; gap: 14px; padding: 16px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); text-decoration: none; color: var(--ink);
  transition: transform .15s, box-shadow .15s;
}
.nv-book:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.nv-cover {
  flex: 0 0 64px; height: 88px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; color: rgba(255,255,255,.92);
  text-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.nv-binfo { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.nv-binfo > b { font-size: 16px; }
.nv-desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.nv-meta { color: var(--muted); font-size: 12px; margin-top: auto; }
.nv-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft, rgba(0,0,0,.06)); color: var(--accent); vertical-align: 2px; }
.nv-tag.draft { background: rgba(220,120,40,.14); color: #c07a2a; }

/* ---------- 阅读 ---------- */
.nv-toc { margin-top: 22px; }
.nv-toc h2, .nv-chapter h2 { font-size: 20px; margin: 0 0 14px; }
.nv-toc ol { list-style: none; margin: 0; padding: 0; }
.nv-toc li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 6px; border-bottom: 1px solid var(--line); font-size: 14.5px;
}
.nv-toc li a { color: var(--ink); text-decoration: none; flex: 1; }
.nv-toc li a:hover { color: var(--accent); }
.nv-toc .muted { font-size: 12px; }
.nv-chapter { max-width: 720px; margin: 10px auto 0; }
.nv-body { font-size: 16.5px; line-height: 1.95; color: var(--ink); }
.nv-body p { margin: 0 0 1.2em; text-indent: 2em; }
.nv-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 14px;
}
.nv-nav a { color: var(--accent); text-decoration: none; }

/* ============================================================
   编辑器（三栏：章节列表 | 正文 | AI 助手）
   ============================================================ */
.nv-edit {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 340px;
  gap: 0;
  min-height: calc(100vh - 52px);
}
.nv-side, .nv-ai {
  border-right: 1px solid var(--line);
  padding: 14px;
  overflow-y: auto;
  max-height: calc(100vh - 52px);
  position: sticky; top: 52px;
  background: var(--bg-2, var(--bg));
}
.nv-ai { border-right: 0; border-left: 1px solid var(--line); }
.nv-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.nv-back { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-chlist { list-style: none; margin: 0; padding: 0; }
.nv-chlist li { display: flex; align-items: center; margin-bottom: 2px; }
.nv-chlist li a {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nv-chlist li a:hover { background: var(--accent-soft, rgba(0,0,0,.05)); }
.nv-chlist li a.on { background: var(--accent-soft, rgba(0,0,0,.07)); color: var(--accent); font-weight: 600; }
.nv-chlist .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.nv-chlist .dot.pub { background: #2e9e5b; }
.nv-chdel {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 15px; padding: 4px 6px; border-radius: 6px; opacity: 0;
}
.nv-chlist li:hover .nv-chdel { opacity: 1; }
.nv-chdel:hover { color: #d33; background: rgba(220,60,60,.1); }

.nv-editor { display: flex; flex-direction: column; min-width: 0; }
.nv-ed-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.nv-ed-head input#nv-title {
  flex: 1 1 180px; min-width: 120px;
  border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 17px; font-weight: 700; outline: none;
}
.nv-ed-head .muted { font-size: 12px; white-space: nowrap; }
.nv-ed-actions { display: flex; gap: 6px; }
#nv-content {
  flex: 1; width: 100%; box-sizing: border-box;
  border: 0; outline: none; resize: none;
  padding: 26px clamp(20px, 5vw, 60px);
  background: var(--bg); color: var(--ink);
  font: 16.5px/1.95 var(--font-body, -apple-system, "PingFang SC", sans-serif);
  min-height: 60vh;
}

/* ---------- AI 助手栏 ---------- */
.nv-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.nv-ai-head b { font-size: 14.5px; }
.nv-ai-head select {
  max-width: 170px; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.nv-ai-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.nv-ai-mode {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13px; padding: 8px 6px; border-radius: 9px; cursor: pointer;
}
.nv-ai-mode:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.nv-ai-mode:disabled { opacity: .45; cursor: wait; }
.nv-ai-result { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 12px; }
.nv-ai-res-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap;
  padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
}
.nv-ai-res-actions { display: flex; gap: 4px; }
.nv-ai-text {
  padding: 10px 12px; font-size: 13.5px; line-height: 1.8; color: var(--ink);
  max-height: 300px; overflow-y: auto; white-space: pre-wrap;
}
.nv-ai-chat { display: flex; flex-direction: column; min-height: 260px; }
.nv-chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; }
.nv-chat-msg { font-size: 13px; line-height: 1.7; padding: 8px 11px; border-radius: 11px; max-width: 92%; white-space: pre-wrap; }
.nv-chat-msg.u { align-self: flex-end; background: var(--accent-soft, rgba(0,0,0,.07)); color: var(--ink); }
.nv-chat-msg.a { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.nv-chat-msg .nv-ins { margin-top: 6px; display: block; }
.nv-chat-form { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.nv-chat-form input {
  flex: 1; min-width: 0; padding: 8px 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink);
}
.nv-versions { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.nv-versions > b { font-size: 13px; }
.nv-versions .v-item {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 7px 0; border-bottom: 1px dashed var(--line); color: var(--muted);
}
.nv-versions .v-item b { color: var(--ink); font-weight: 500; font-size: 12.5px; }
.nv-versions .preview {
  max-height: 180px; overflow-y: auto; white-space: pre-wrap;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 6px;
  font-size: 12.5px; color: var(--ink-2); background: var(--surface);
}
.nv-spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: nvspin .7s linear infinite; vertical-align: -2px; }
@keyframes nvspin { to { transform: rotate(360deg); } }

/* ---------- 移动端：三栏 → 上（编辑）下（AI）tab ---------- */
@media (max-width: 900px) {
  .nv-edit { grid-template-columns: 1fr; min-height: 0; }
  .nv-side, .nv-ai {
    position: static; max-height: none;
    border: 0; border-bottom: 1px solid var(--line);
  }
  .nv-side { order: 0; }
  .nv-editor { order: 1; min-height: 70vh; }
  .nv-ai { order: 2; border-top: 1px solid var(--line); }
  .nv-ai-head::before {
    content: "▼ 上滑使用 AI 助手";
    display: block; width: 100%; text-align: center;
    font-size: 11px; color: var(--muted); margin-bottom: 6px;
  }
}

/* ---------- 本章梗概条 ---------- */
.nv-sum {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 16px 10px;
}
.nv-sum-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.nv-sum-label { font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
.nv-sum-state { flex: 1; }
.nv-sum-toggle {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; cursor: pointer;
}
.nv-sum-toggle:hover { color: var(--accent); border-color: var(--accent); }
#nv-summary {
  display: block; width: 100%; margin-top: 6px; resize: vertical;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  color: var(--ink); font: inherit; font-size: 13px; line-height: 1.7; padding: 7px 10px;
}
#nv-summary:focus { outline: none; border-color: var(--accent); }
.nv-sum.collapsed #nv-summary { display: none; }

/* ---------- 大纲弹层 ---------- */
body.nv-modal-open { overflow: hidden; }
.nv-modal {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(10, 14, 20, .52);
  display: flex; align-items: center; justify-content: center;
  padding: 3vh 3vw;
  backdrop-filter: blur(2px);
}
.nv-modal[hidden] { display: none; }
.nv-modal-box {
  width: min(1120px, 100%); height: min(860px, 94vh);
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  display: flex; flex-direction: column; overflow: hidden;
}
.nv-modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.nv-modal-head b { font-size: 15px; }
.nv-modal-sub { font-size: 12px; color: var(--muted); flex: 1; }
.nv-modal-x {
  border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.nv-modal-x:hover { color: var(--ink); }
.nv-modal-body { flex: 1; display: grid; grid-template-columns: 360px 1fr; min-height: 0; }

/* 左：框架 */
.nv-fw-pane {
  border-right: 1px solid var(--line); padding: 16px 18px;
  overflow-y: auto; background: var(--bg-2, var(--bg));
}
.nv-seg { display: flex; gap: 0; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.nv-seg button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; padding: 7px 6px; cursor: pointer;
}
.nv-seg button.on { background: var(--accent); color: var(--on-accent, #fff); font-weight: 600; }
.nv-fw-pane label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.nv-fw-pane input, .nv-fw-pane textarea {
  display: block; width: 100%; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13px; line-height: 1.65; padding: 7px 10px;
  resize: vertical;
}
.nv-fw-pane input:focus, .nv-fw-pane textarea:focus { outline: none; border-color: var(--accent); }
.nv-fw-vol input { width: 90px; }
.nv-fw-actions { display: flex; gap: 8px; margin-top: 6px; }
.nv-fw-actions .nv-btn { flex: 1; }
.nv-fw-tip { font-size: 11.5px; color: var(--muted); line-height: 1.6; margin: 10px 0 0; }

/* 右：结构树 */
.nv-tree-pane { overflow-y: auto; padding: 16px 18px; }
.nv-tree { display: flex; flex-direction: column; gap: 12px; }
.nv-tree-empty { text-align: center; color: var(--ink-2); padding: 60px 20px; }
.nv-tree-empty p { margin: 0 0 8px; }
.nv-tree-empty .muted { color: var(--muted); font-size: 12.5px; }
.nv-vol { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.nv-vol-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 11px 14px; background: var(--accent-soft, rgba(0,0,0,.04));
  border-bottom: 1px solid var(--line);
}
.nv-vol-head b { font-size: 14px; }
.nv-vol-meta { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.nv-vol-body { padding: 10px 14px 12px; }
.nv-vol-sum { margin: 0 0 10px; font-size: 12.5px; line-height: 1.75; color: var(--ink-2); }
.nv-ols { list-style: none; margin: 0 0 10px; padding: 0; }
.nv-ols li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 0; border-top: 1px dashed var(--line);
}
.nv-ols li:first-child { border-top: 0; }
.nv-ol-main { flex: 1; min-width: 0; }
.nv-ol-main b { font-size: 13.5px; font-weight: 600; }
.nv-ol-sum { margin: 3px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--muted); }
.nv-ol-acts { flex: 0 0 auto; }
.nv-odone { color: var(--accent); font-style: normal; font-size: 12px; }
.nv-regen { margin-top: 2px; }

@media (max-width: 900px) {
  .nv-modal { padding: 0; }
  .nv-modal-box { width: 100%; height: 100%; border-radius: 0; max-height: none; }
  .nv-modal-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nv-fw-pane { border-right: 0; border-bottom: 1px solid var(--line); max-height: 52vh; }
  .nv-modal-sub { display: none; }
}
