/* ============================================================
   青灯 · 长篇网文创作台
   纸墨气质 / 三栏工作台 / 无外部依赖
   ============================================================ */

:root {
  --bg: #f2ecdf;
  --bg-deep: #e9e1d1;
  --paper: #fbf7ed;
  --paper-2: #f6f0e2;
  --paper-3: #efe7d6;
  --ink: #202722;
  --ink-2: #4c554d;
  --muted: #7e8378;
  --faint: #a4a79b;
  --line: #ddd3c2;
  --line-strong: #c8bba5;
  --pine: #2b574a;
  --pine-2: #3b6d5c;
  --pine-soft: #dde8e0;
  --cinnabar: #b14932;
  --cinnabar-soft: #f3ded7;
  --gold: #a98046;
  --gold-soft: #efe2c9;
  --blue: #48647a;
  --shadow-sm: 0 2px 8px rgba(52, 43, 28, 0.05);
  --shadow: 0 18px 48px rgba(52, 43, 28, 0.09);
  --shadow-lg: 0 28px 80px rgba(52, 43, 28, 0.16);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --editor-size: 17px;
  --radius: 10px;
  --topbar-h: 58px;
}

html[data-theme="dark"] {
  --bg: #151a17;
  --bg-deep: #101411;
  --paper: #1c231f;
  --paper-2: #202823;
  --paper-3: #252e28;
  --ink: #e9e3d6;
  --ink-2: #b9bdb2;
  --muted: #8c9389;
  --faint: #6d756c;
  --line: #303a33;
  --line-strong: #465249;
  --pine: #6fa38f;
  --pine-2: #8bbb9f;
  --pine-soft: #24352d;
  --cinnabar: #d77a61;
  --cinnabar-soft: #3a2722;
  --gold: #d0a970;
  --gold-soft: #382f20;
  --blue: #8aa6ba;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 700px at 8% -10%, rgba(255, 252, 242, 0.75), transparent 60%),
    radial-gradient(900px 600px at 104% 8%, rgba(213, 197, 170, 0.26), transparent 62%),
    repeating-linear-gradient(0deg, rgba(96, 80, 52, 0.016) 0 1px, transparent 1px 4px);
}

html[data-theme="dark"] body::before {
  background:
    radial-gradient(1000px 650px at 10% -10%, rgba(62, 91, 76, 0.22), transparent 62%),
    radial-gradient(900px 600px at 104% 8%, rgba(70, 52, 34, 0.2), transparent 62%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 4px);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
::selection { background: var(--pine-soft); color: var(--ink); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Top bar
   ============================================================ */
#app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  position: relative;
  z-index: 50;
}

.nav-toggle { display: none !important; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 4px 6px 4px 0;
  color: var(--ink);
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #f8f3e7;
  background:
    radial-gradient(120% 120% at 20% 10%, #497564 0%, #2b574a 46%, #1d3d33 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.13), 0 5px 12px rgba(35, 66, 55, 0.22);
}
.brand-mark .icon { width: 24px; height: 24px; stroke-width: 1.5; }
.brand-text { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.brand-text strong { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: 0.16em; }
.brand-text em { font-style: normal; font-size: 10px; letter-spacing: 0.24em; color: var(--muted); }

.project-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 9px 5px 6px;
  border-radius: 9px;
  min-width: 0;
  max-width: 300px;
  text-align: left;
}
.project-switch:hover { background: var(--paper-2); border-color: var(--line); }
.project-cover {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(145deg, #3c6658, #213f36);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
}
.project-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.13) 50%, transparent 70%);
}
.project-switch-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.project-switch-text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-switch-text small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.project-switch .chevron { width: 13px; height: 13px; color: var(--faint); transform: rotate(90deg); }

.topbar-spacer { flex: 1; }

.save-state {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 99px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pine-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pine-2) 14%, transparent); }
.save-state.dirty { color: var(--cinnabar); background: var(--cinnabar-soft); }
.save-state.dirty .save-dot { background: var(--cinnabar); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cinnabar) 16%, transparent); }
.save-state.saving .save-dot { animation: pulse 1s infinite; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  position: relative;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--paper-2); border-color: var(--line); color: var(--ink); }
.icon-btn.subtle { width: 29px; height: 29px; color: var(--muted); }
.badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--cinnabar);
  color: #fff9f2;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg);
  line-height: 1;
}
.badge.zero { display: none; }
.ai-toggle-btn { color: var(--pine); background: var(--pine-soft); }
.ai-toggle-btn:hover { background: var(--pine-soft); border-color: color-mix(in srgb, var(--pine) 22%, transparent); }

.copilot-backdrop { display: none; }

/* ============================================================
   Workspace / sidebar
   ============================================================ */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 376px;
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 16px 12px 12px;
  gap: 12px;
  background: color-mix(in srgb, var(--bg-deep) 44%, transparent);
}

.book-card {
  display: flex;
  gap: 12px;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 10px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s;
}
.book-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.book-cover {
  width: 58px;
  min-width: 58px;
  height: 82px;
  border-radius: 5px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.14), transparent 40%),
    linear-gradient(160deg, #3d695b 0%, #2a5145 45%, #1b372f 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 4px 4px 10px rgba(31, 45, 38, 0.16);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  padding-top: 9px;
}
.book-cover::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.12);
}
.cover-ring {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(226, 207, 169, 0.25);
  border-radius: 50%;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}
.cover-title {
  writing-mode: vertical-rl;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #f2ead6;
  max-height: 52px;
  overflow: hidden;
  z-index: 1;
}
.cover-line {
  position: absolute;
  bottom: 11px;
  right: 7px;
  width: 1px;
  height: 15px;
  background: var(--gold);
  opacity: 0.65;
}
.book-info { display: flex; flex-direction: column; min-width: 0; flex: 1; justify-content: center; gap: 3px; }
.book-kicker { font-size: 9px; letter-spacing: 0.18em; color: var(--faint); text-transform: uppercase; }
.book-info strong {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-info small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-progress { height: 3px; border-radius: 99px; background: var(--paper-3); overflow: hidden; margin-top: 6px; }
.book-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--pine-2), var(--gold)); border-radius: 99px; transition: width 0.4s; }
.book-meta { font-size: 9px; color: var(--faint); }

.main-nav { display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  text-align: left;
  position: relative;
  transition: background 0.14s, color 0.14s;
}
.nav-item .icon { width: 16px; height: 16px; color: var(--muted); }
.nav-item kbd { margin-left: auto; font-family: var(--sans); font-size: 9px; color: var(--faint); opacity: 0; transition: opacity 0.14s; }
.nav-item:hover { background: var(--paper-2); color: var(--ink); }
.nav-item:hover kbd { opacity: 1; }
.nav-item.active { background: var(--paper); color: var(--pine); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm); }
.nav-item.active .icon { color: var(--pine); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 3px;
  height: 17px;
  transform: translateY(-50%);
  border-radius: 0 3px 3px 0;
  background: var(--pine-2);
}

.chapter-block { min-height: 0; flex: 1; display: flex; flex-direction: column; border-top: 1px solid var(--line); padding-top: 10px; }
.chapter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--faint);
  text-transform: uppercase;
}
.chapter-head-actions { display: flex; gap: 2px; }
.mini-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}
.mini-btn:hover { background: var(--paper-2); color: var(--ink); }
.mini-btn .icon { width: 14px; height: 14px; }

.chapter-tree { overflow-y: auto; min-height: 0; padding: 0 2px 6px; }
.volume-group { margin-bottom: 8px; }
.volume-head {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 5px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  text-align: left;
}
.volume-head:hover { background: var(--paper-2); }
.volume-head .icon { width: 12px; height: 12px; color: var(--faint); transition: transform 0.15s; }
.volume-group.collapsed .volume-head .icon { transform: rotate(-90deg); }
.volume-group.collapsed .volume-chapters { display: none; }
.volume-head .vcount { margin-left: auto; font-weight: 400; color: var(--faint); font-size: 9px; }
.chapter-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 7px 7px 7px 8px;
  border-radius: 6px;
  text-align: left;
  color: var(--ink-2);
  position: relative;
}
.chapter-item:hover { background: var(--paper-2); color: var(--ink); }
.chapter-item.active { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm); }
.chapter-item.active::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 15px;
  background: var(--pine-2);
  border-radius: 2px;
}
.chapter-item .num {
  font-size: 9px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.chapter-item .c-title { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-item .c-words { font-size: 8.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); display: inline-block; margin-right: 5px; vertical-align: 1px; }
.status-dot.done { background: var(--pine-2); }
.status-dot.writing { background: var(--gold); }
.status-dot.draft { background: var(--faint); }

.sidebar-foot { border-top: 1px solid var(--line); padding: 9px 4px 2px; }
.today-line { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.today-line strong { color: var(--ink); font-weight: 600; }
.pulse-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--cinnabar); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cinnabar) 12%, transparent); }
.target-line { margin-left: auto; color: var(--faint); font-size: 9px; }
.foot-progress { height: 2px; background: var(--line); margin-top: 7px; border-radius: 99px; overflow: hidden; }
.foot-progress i { display: block; height: 100%; background: var(--pine-2); }

.nav-backdrop { display: none; }

/* ============================================================
   Main / write view
   ============================================================ */
.main { min-width: 0; min-height: 0; position: relative; }
.view { height: 100%; overflow-y: auto; }

.write-view {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 clamp(18px, 4vw, 52px);
  animation: fadeUp 0.28s ease both;
}
.chapter-top {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding-top: 26px;
  flex: 0 0 auto;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.crumbs .vol { color: var(--pine); font-weight: 600; }
.crumbs .sep { color: var(--faint); }
.chapter-title-row { display: flex; align-items: center; gap: 12px; }
.chapter-title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: clamp(26px, 3.1vw, 36px);
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0;
  outline: none;
  line-height: 1.25;
}
.chapter-title::placeholder { color: var(--faint); }
.chapter-title:focus { background: linear-gradient(transparent 92%, var(--line) 92%); }
.chapter-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.chapter-actions .text-btn { font-size: 10px; }

.chapter-subline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 9px;
  font-size: 10px;
  color: var(--muted);
  flex-wrap: wrap;
}
.chapter-subline .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }
.status-select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-2);
  border-radius: 99px;
  font-size: 10px;
  padding: 3px 20px 3px 9px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 11px) 50%, calc(100% - 7px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.blueprint-strip {
  width: 100%;
  max-width: 920px;
  margin: 16px auto 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
  flex: 0 0 auto;
}
.bp-cell {
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  padding: 8px 11px;
  min-width: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.bp-cell:hover { background: var(--paper); }
.bp-cell .bp-label { display: block; font-size: 8.5px; letter-spacing: 0.14em; color: var(--faint); text-transform: uppercase; margin-bottom: 2px; }
.bp-cell .bp-text { display: block; font-size: 10.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-cell.blueprint-empty .bp-text { color: var(--faint); font-style: italic; }
.bp-edit { background: transparent; border: 0; color: var(--pine); font-size: 9px; padding: 0; margin-left: 4px; }

.editor-shell {
  width: 100%;
  max-width: 920px;
  margin: 16px auto 22px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.editor-shell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--pine) 0%, color-mix(in srgb, var(--pine) 18%, transparent) 26%, transparent 70%);
  opacity: 0.55;
  pointer-events: none;
}
.editor-toolbar {
  height: 42px;
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper-2) 60%, transparent);
}
.tool-btn {
  height: 27px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  padding: 0 8px;
  font-size: 10.5px;
}
.tool-btn .icon { width: 14px; height: 14px; }
.tool-btn:hover { background: var(--paper); border-color: var(--line); color: var(--ink); }
.tool-sep { width: 1px; height: 16px; background: var(--line); margin: 0 5px; }
.toolbar-spacer { flex: 1; }
.font-size-label { font-family: var(--mono); font-size: 9px; color: var(--faint); min-width: 22px; text-align: center; }

.editor-paper-wrap { flex: 1; min-height: 0; display: flex; position: relative; }
#editor {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--editor-size);
  line-height: 1.98;
  letter-spacing: 0.025em;
  padding: 34px clamp(26px, 6vw, 74px) 50px;
  tab-size: 2;
  overflow-y: auto;
  caret-color: var(--pine);
}
#editor::placeholder { color: var(--faint); opacity: 0.78; font-style: italic; }

.completion-card {
  position: absolute;
  left: clamp(18px, 4vw, 52px);
  right: clamp(18px, 4vw, 52px);
  bottom: 14px;
  z-index: 6;
  padding: 9px 12px 10px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--pine-2);
  border-radius: 7px;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(3px);
  cursor: pointer;
  animation: fadeUp 0.16s ease both;
}
.completion-card[hidden] { display: none; }
.completion-card:hover { border-color: var(--pine-2); }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.cc-quote { font-family: var(--serif); font-size: 11px; color: var(--faint); border-left: 2px solid var(--line); padding-left: 7px; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-label { display: inline-flex; align-items: center; gap: 5px; font-size: 8.5px; letter-spacing: 0.1em; color: var(--pine); }
.cc-label .icon { width: 12px; height: 12px; }
.cc-keys { font-size: 8px; color: var(--faint); }
.cc-text { font-family: var(--serif); font-size: 13.5px; line-height: 1.78; color: var(--ink-2); max-height: 84px; overflow: hidden; }

.editor-foot {
  height: 32px;
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  font-size: 9px;
  color: var(--faint);
  background: color-mix(in srgb, var(--paper-2) 55%, transparent);
}
.editor-foot .right { margin-left: auto; }
.editor-foot strong { color: var(--ink-2); font-weight: 600; }
kbd {
  font-family: var(--sans);
  font-size: 9px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 4px;
  color: var(--muted);
  background: var(--paper);
}

.focus-exit {
  position: fixed;
  right: 22px;
  bottom: 20px;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
body.focus-mode .focus-exit { display: flex; }
body.focus-mode .topbar,
body.focus-mode .sidebar,
body.focus-mode .copilot { display: none; }
body.focus-mode .workspace { grid-template-columns: 1fr; }
body.focus-mode .write-view { padding: 0 24px; }
body.focus-mode .chapter-top { padding-top: 36px; }
body.focus-mode .editor-shell { max-width: 980px; box-shadow: var(--shadow-lg); }

/* ============================================================
   Shared page patterns
   ============================================================ */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px clamp(22px, 4vw, 48px) 80px;
  animation: fadeUp 0.3s ease both;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--serif); font-size: clamp(25px, 3vw, 34px); letter-spacing: 0.04em; margin: 2px 0 5px; line-height: 1.25; }
.eyebrow { font-size: 9px; letter-spacing: 0.26em; color: var(--gold); text-transform: uppercase; margin: 0; font-weight: 600; }
.page-desc { margin: 0; color: var(--muted); font-size: 11.5px; max-width: 660px; line-height: 1.7; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn .icon { width: 14px; height: 14px; }
.btn:hover { border-color: var(--line-strong); color: var(--ink); background: var(--paper-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--pine); border-color: var(--pine); color: #f8f4e9; box-shadow: 0 4px 12px color-mix(in srgb, var(--pine) 24%, transparent); }
.btn.primary:hover { background: var(--pine-2); border-color: var(--pine-2); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--cinnabar); }
.btn.danger:hover { background: var(--cinnabar-soft); border-color: color-mix(in srgb, var(--cinnabar) 35%, var(--line)); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 10px; border-radius: 5px; }
.btn.icon-only { width: 30px; padding: 0; }
.text-btn { border: 0; background: transparent; color: var(--muted); font-size: 10.5px; padding: 4px 6px; border-radius: 4px; display: inline-flex; align-items: center; gap: 4px; }
.text-btn:hover { color: var(--ink); background: var(--paper-2); }
.text-btn .icon { width: 13px; height: 13px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; }
.card-head .sub { font-size: 9.5px; color: var(--muted); }
.card-body { padding: 16px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > label, .field-label { font-size: 10px; color: var(--muted); letter-spacing: 0.04em; }
.field .hint { font-size: 9.5px; color: var(--faint); line-height: 1.55; }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 65%, var(--bg) 35%);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.7; font-family: var(--sans); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--pine-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pine-2) 12%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; padding-right: 26px; cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: 99px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}
.chip.pine { background: var(--pine-soft); color: var(--pine); border-color: transparent; }
.chip.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.chip.red { background: var(--cinnabar-soft); color: var(--cinnabar); border-color: transparent; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }

.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { width: 46px; height: 46px; margin: 0 auto 12px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 50%; color: var(--faint); }
.empty-state h3 { font-family: var(--serif); color: var(--ink-2); font-size: 16px; margin: 0 0 5px; }
.empty-state p { font-size: 11px; margin: 0 0 16px; line-height: 1.7; }

/* ============================================================
   Outline
   ============================================================ */
.outline-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.outline-tree { position: sticky; top: 18px; max-height: calc(100vh - 170px); overflow-y: auto; }
.ot-volume { border-bottom: 1px solid var(--line); }
.ot-volume:last-child { border-bottom: 0; }
.ot-volume-head { display: flex; align-items: center; gap: 8px; padding: 11px 13px; }
.ot-volume-head strong { font-size: 10.5px; font-weight: 600; }
.ot-volume-head .count { margin-left: auto; font-size: 9px; color: var(--faint); }
.ot-chapter { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 13px 7px 22px; color: var(--ink-2); font-size: 11px; border-left: 2px solid transparent; }
.ot-chapter:hover { background: var(--paper-2); }
.ot-chapter.active { background: var(--pine-soft); color: var(--pine); border-left-color: var(--pine-2); font-weight: 600; }
.ot-chapter .n { color: var(--faint); font-size: 9px; min-width: 18px; }
.ot-chapter .w { margin-left: auto; color: var(--faint); font-size: 8.5px; }
.outline-form { padding: 20px 22px 24px; }
.outline-form .section-title { font-family: var(--serif); font-size: 16px; margin: 0 0 3px; }
.form-note { font-size: 9.5px; color: var(--faint); margin-bottom: 16px; }
.outline-hint { display: flex; gap: 8px; padding: 10px 12px; background: var(--pine-soft); border-radius: 7px; color: var(--pine); font-size: 10px; line-height: 1.65; margin-bottom: 16px; }
.outline-hint .icon { width: 14px; height: 14px; margin-top: 1px; }

.outline-ai-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 14px; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: 7px; background: color-mix(in srgb, var(--paper-2) 55%, transparent); }
.outline-ai-bar span { font-size: 9px; color: var(--faint); line-height: 1.55; }
.field > label:has(.field-ai) { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-ai { border: 0; background: transparent; padding: 0; margin: 0; color: var(--pine); font-size: 8.5px; display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.field-ai .icon { width: 11px; height: 11px; }
.field-ai:hover { text-decoration: underline; }
.field-ai:disabled, .field-ai.busy { color: var(--faint); cursor: default; text-decoration: none; }

/* ============================================================
   Bible
   ============================================================ */
.bible-section { margin-bottom: 22px; }
.bible-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.bible-section-head h2 { font-family: var(--serif); font-size: 17px; margin: 0; letter-spacing: 0.03em; }
.bible-section-head .count { font-size: 9px; color: var(--faint); margin-left: 7px; font-family: var(--sans); }
.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.character-card {
  display: flex;
  gap: 11px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 9px;
  padding: 13px;
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}
.character-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fbf7ed;
  font-family: var(--serif);
  font-size: 15px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.char-body { min-width: 0; flex: 1; }
.char-top { display: flex; align-items: baseline; gap: 6px; }
.char-top strong { font-family: var(--serif); font-size: 15px; }
.char-top .role { font-size: 8.5px; color: var(--gold); background: var(--gold-soft); border-radius: 99px; padding: 1px 6px; }
.char-line { font-size: 10px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; }
.char-foot { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 8.5px; color: var(--faint); }
.char-desire { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.world-list { display: flex; flex-direction: column; }
.world-item { display: grid; grid-template-columns: 94px 1fr auto; gap: 12px; align-items: start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.world-item:last-child { border-bottom: 0; }
.world-item .cat { font-size: 9px; color: var(--gold); padding-top: 1px; }
.world-item strong { display: block; font-size: 12px; margin-bottom: 2px; }
.world-item p { margin: 0; font-size: 10.5px; color: var(--muted); line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.world-item .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.world-item .tag { font-size: 8px; color: var(--faint); border: 1px solid var(--line); padding: 0 5px; border-radius: 3px; }
.style-card { padding: 18px 20px; }
.style-card blockquote { margin: 8px 0 0; font-family: var(--serif); font-size: 12.5px; line-height: 1.9; color: var(--ink-2); border-left: 2px solid var(--gold); padding-left: 13px; }
.fact-list { display: flex; flex-direction: column; }
.fact-item { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px dashed var(--line); font-size: 10.5px; align-items: flex-start; }
.fact-item:last-child { border-bottom: 0; }
.fact-item .fact-ch { font-size: 8.5px; color: var(--faint); min-width: 46px; padding-top: 2px; }
.fact-item .fact-body { flex: 1; color: var(--ink-2); line-height: 1.65; }
.fact-item .fact-body b { color: var(--ink); font-weight: 600; }

/* ============================================================
   Foreshadow board
   ============================================================ */
.tracker-stats { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tracker-stat { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--paper); padding: 8px 13px; border-radius: 7px; font-size: 10px; color: var(--muted); }
.tracker-stat strong { color: var(--ink); font-size: 15px; font-family: var(--serif); }
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: start; }
.kanban-col { background: color-mix(in srgb, var(--bg-deep) 45%, transparent); border: 1px solid var(--line); border-radius: 9px; padding: 9px; min-height: 170px; }
.kanban-head { display: flex; align-items: center; gap: 6px; padding: 3px 4px 9px; font-size: 10px; font-weight: 600; color: var(--ink-2); }
.kanban-head .kcount { margin-left: auto; font-size: 8.5px; color: var(--faint); font-weight: 400; }
.fs-card { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 7px; padding: 10px 11px; margin-bottom: 7px; box-shadow: var(--shadow-sm); }
.fs-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.fs-card .fs-title { display: flex; align-items: flex-start; gap: 6px; font-size: 11px; font-weight: 600; line-height: 1.5; }
.fs-card .fs-note { font-size: 9.5px; color: var(--muted); line-height: 1.6; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fs-card .fs-meta { display: flex; align-items: center; gap: 7px; margin-top: 7px; font-size: 8.5px; color: var(--faint); flex-wrap: wrap; }
.priority-dot { width: 5px; height: 5px; border-radius: 50%; flex: 0 0 auto; margin-top: 6px; }
.priority-high { background: var(--cinnabar); }
.priority-medium { background: var(--gold); }
.priority-low { background: var(--faint); }

/* ============================================================
   Relations
   ============================================================ */
.relations-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.graph-card { overflow: hidden; position: relative; background: var(--paper); }
.graph-card svg { display: block; width: 100%; height: auto; min-height: 420px; }
.graph-legend { position: absolute; left: 14px; bottom: 12px; display: flex; gap: 12px; font-size: 8.5px; color: var(--faint); }
.graph-legend span { display: flex; align-items: center; gap: 4px; }
.rel-edge { stroke: var(--line-strong); stroke-width: 1.1; opacity: 0.55; }
.rel-edge-label { fill: var(--muted); font-family: var(--sans); font-size: 8.5px; paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.rel-node { cursor: pointer; }
.rel-node circle:first-child { transition: filter 0.15s, transform 0.15s; transform-origin: center; }
.rel-node:hover circle:first-child { filter: brightness(1.1); }
.rel-node-name { fill: #fbf7ed; font-family: var(--serif); font-size: 13.5px; font-weight: 600; pointer-events: none; }
.rel-node-role { fill: rgba(251, 247, 237, 0.62); font-family: var(--sans); font-size: 8px; pointer-events: none; }
.rel-list { display: flex; flex-direction: column; }
.rel-list > div:last-child { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rel-list > div:last-child .rel-item:nth-child(odd) { border-right: 1px solid var(--line); }
.rel-item { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.rel-item:last-child { border-bottom: 0; }
.rel-item .rel-names { font-size: 11px; font-weight: 600; }
.rel-item .rel-label { font-size: 9.5px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   Stats
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 14px 15px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -18px; bottom: -22px; width: 62px; height: 62px; border-radius: 50%; border: 1px solid var(--line); opacity: 0.55; }
.kpi .k-label { font-size: 9px; color: var(--muted); letter-spacing: 0.08em; }
.kpi .k-value { font-family: var(--serif); font-size: 27px; line-height: 1.2; margin-top: 5px; letter-spacing: 0.02em; }
.kpi .k-sub { font-size: 8.5px; color: var(--faint); margin-top: 3px; }
.kpi.pine .k-value { color: var(--pine); }
.kpi.gold .k-value { color: var(--gold); }
.kpi.red .k-value { color: var(--cinnabar); }
.stats-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; align-items: start; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 10px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: 58%; max-width: 22px; background: linear-gradient(180deg, var(--pine-2), color-mix(in srgb, var(--pine) 55%, var(--paper))); border-radius: 3px 3px 1px 1px; min-height: 2px; transition: height 0.5s ease; }
.chart-col.today .chart-bar { background: linear-gradient(180deg, var(--cinnabar), color-mix(in srgb, var(--cinnabar) 50%, var(--paper))); }
.chart-label { font-size: 7.5px; color: var(--faint); white-space: nowrap; }
.chart-label strong { color: var(--ink-2); font-weight: 600; }
.goal-block { padding: 4px 0; }
.goal-line { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.goal-line strong { font-family: var(--serif); font-size: 22px; }
.goal-line span { font-size: 9px; color: var(--muted); }
.goal-track { height: 6px; border-radius: 99px; background: var(--paper-3); overflow: hidden; }
.goal-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--pine), var(--gold)); border-radius: 99px; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.mini-stat { border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; }
.mini-stat .m-label { font-size: 8.5px; color: var(--muted); }
.mini-stat .m-value { font-size: 14px; font-weight: 600; margin-top: 2px; }
.advice-list { display: flex; flex-direction: column; gap: 8px; }
.advice { display: flex; gap: 8px; align-items: flex-start; font-size: 10.5px; line-height: 1.65; color: var(--ink-2); padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: color-mix(in srgb, var(--paper) 70%, transparent); }
.advice .icon { width: 14px; height: 14px; color: var(--gold); margin-top: 1px; }
.advice.red .icon { color: var(--cinnabar); }

/* ============================================================
   Library
   ============================================================ */
.library-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
  align-items: end;
  padding: 34px 0 26px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.library-hero h1 { font-family: var(--serif); font-size: clamp(32px, 4.5vw, 52px); line-height: 1.18; letter-spacing: 0.03em; margin: 8px 0 12px; }
.library-hero h1 em { font-style: normal; color: var(--pine); position: relative; }
.library-hero h1 em::after { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 6px; background: var(--gold-soft); z-index: -1; }
.library-hero p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.85; max-width: 520px; }
.library-quote { border-left: 2px solid var(--gold); padding-left: 16px; font-family: var(--serif); font-size: 13px; line-height: 1.9; color: var(--ink-2); }
.library-quote small { display: block; margin-top: 7px; font-family: var(--sans); font-size: 9px; color: var(--faint); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.library-card { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; overflow: hidden; text-align: left; padding: 0; transition: transform 0.18s, box-shadow 0.18s; position: relative; }
.library-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.library-cover {
  height: 132px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #3e6a5b, #213f36 55%, #172e27);
  display: flex;
  align-items: flex-end;
  padding: 16px;
}
.library-cover::before { content: ""; position: absolute; width: 130px; height: 130px; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 50%; right: -34px; top: -48px; }
.library-cover::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60%; background: linear-gradient(transparent, rgba(10, 25, 20, 0.5)); }
.library-cover h3 { position: relative; z-index: 1; margin: 0; color: #f7f1e1; font-family: var(--serif); font-size: 23px; letter-spacing: 0.08em; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); }
.library-cover .genre { position: absolute; top: 12px; left: 14px; z-index: 1; font-size: 8.5px; color: rgba(255, 248, 232, 0.72); letter-spacing: 0.12em; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 99px; padding: 2px 7px; }
.library-body { padding: 12px 14px 13px; }
.library-body .lib-sub { font-size: 10px; color: var(--muted); line-height: 1.55; min-height: 31px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-meta-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 8.5px; color: var(--faint); }
.lib-meta-row .lib-progress { flex: 1; height: 3px; background: var(--paper-3); border-radius: 99px; overflow: hidden; }
.lib-meta-row .lib-progress i { display: block; height: 100%; background: var(--pine-2); }
.lib-actions { display: flex; gap: 1px; position: absolute; top: 10px; right: 10px; z-index: 2; opacity: 0; transition: opacity 0.15s; }
.library-card:hover .lib-actions { opacity: 1; }
.lib-actions button { width: 25px; height: 25px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(12, 28, 23, 0.5); color: #f2ecdc; display: grid; place-items: center; backdrop-filter: blur(4px); }
.lib-actions button:hover { background: rgba(12, 28, 23, 0.8); }
.lib-actions .icon { width: 12px; height: 12px; }
.new-book-card { border: 1px dashed var(--line-strong); border-radius: 10px; min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: var(--muted); background: transparent; }
.new-book-card:hover { border-color: var(--pine-2); color: var(--pine); background: color-mix(in srgb, var(--pine-soft) 35%, transparent); }
.new-book-card .plus-ring { width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: 50%; display: grid; place-items: center; }
.new-book-card strong { font-size: 12px; font-weight: 500; }
.new-book-card small { font-size: 9px; color: var(--faint); }

/* ============================================================
   Copilot
   ============================================================ */
.copilot {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 55%, var(--bg) 45%);
}
.copilot-head { height: 52px; flex: 0 0 52px; display: flex; align-items: center; gap: 8px; padding: 0 13px 0 16px; border-bottom: 1px solid var(--line); }
.copilot-title { display: flex; align-items: center; gap: 8px; }
.spark-mark { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--pine-soft); color: var(--pine); }
.spark-mark .icon { width: 15px; height: 15px; }
.copilot-title strong { font-family: var(--serif); font-size: 14px; letter-spacing: 0.04em; }
.model-chip { margin-left: auto; font-size: 8.5px; color: var(--muted); border: 1px solid var(--line); background: var(--paper); padding: 3px 7px; border-radius: 99px; max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copilot-tabs { display: flex; gap: 0; padding: 0 14px; border-bottom: 1px solid var(--line); flex: 0 0 40px; height: 40px; align-items: stretch; }
.copilot-tab { border: 0; background: transparent; color: var(--muted); font-size: 10.5px; padding: 0 12px; position: relative; }
.copilot-tab:hover { color: var(--ink); }
.copilot-tab.active { color: var(--pine); font-weight: 600; }
.copilot-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--pine-2); border-radius: 2px 2px 0 0; }
.copilot-body { flex: 1; min-height: 0; overflow-y: auto; padding: 13px 14px 20px; }

.demo-banner { display: flex; gap: 8px; align-items: flex-start; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 26%, transparent); color: color-mix(in srgb, var(--gold) 82%, var(--ink)); padding: 8px 10px; border-radius: 6px; font-size: 9.5px; line-height: 1.55; margin-bottom: 11px; }
.demo-banner .icon { width: 13px; height: 13px; margin-top: 1px; flex: 0 0 auto; }
.demo-banner button { border: 0; background: transparent; color: inherit; text-decoration: underline; padding: 0; font-size: 9.5px; }

.ai-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.ai-action {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 7px;
  padding: 8px 10px;
  min-height: 48px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  position: relative;
}
.ai-action:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.ai-action strong { display: block; font-size: 11px; font-weight: 600; }
.ai-action small { display: block; font-size: 8.5px; color: var(--faint); margin-top: 2px; line-height: 1.4; }
.ai-action.selected { border-color: var(--pine-2); background: var(--pine-soft); box-shadow: inset 0 0 0 1px var(--pine-2); }
.ai-action.selected strong { color: var(--pine); }
.ai-action.primary { grid-column: 1 / -1; min-height: 52px; background: var(--pine); border-color: var(--pine); color: #f7f3e8; display: flex; align-items: center; justify-content: space-between; }
.ai-action.primary strong { color: #f7f3e8; font-size: 12px; }
.ai-action.primary small { color: rgba(247, 243, 232, 0.6); }
.ai-action.primary:hover { background: var(--pine-2); border-color: var(--pine-2); }
.ai-action.primary.selected { background: var(--pine-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--pine-2) 30%, transparent); }
.ai-action .kbd-hint { font-size: 8px; opacity: 0.6; border: 1px solid currentColor; border-radius: 3px; padding: 1px 3px; }

.selection-hint { display: flex; align-items: center; gap: 6px; font-size: 8.5px; color: var(--faint); padding: 5px 2px 8px; line-height: 1.5; }
.selection-hint.active { color: var(--pine); }
.selection-hint .icon { width: 12px; height: 12px; }
.selection-hint button { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 8.5px; text-decoration: underline; padding: 0; }

.ai-instruction { margin-bottom: 9px; }
.ai-instruction textarea { min-height: 58px; font-size: 11px; background: var(--paper); }
.ai-instruction .field-label { display: flex; justify-content: space-between; align-items: center; }
.ai-instruction .char-count { font-size: 8px; color: var(--faint); }

.run-row { display: flex; gap: 6px; margin-bottom: 12px; }
.run-btn { flex: 1; height: 35px; border-radius: 7px; border: 1px solid var(--pine); background: var(--pine); color: #faf5e8; font-size: 11.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 7px; }
.run-btn:hover { background: var(--pine-2); }
.run-btn:disabled { opacity: 0.5; }
.run-btn .icon { width: 14px; height: 14px; }
.stop-btn { width: 36px; height: 35px; border-radius: 7px; border: 1px solid color-mix(in srgb, var(--cinnabar) 35%, var(--line)); background: var(--cinnabar-soft); color: var(--cinnabar); display: grid; place-items: center; }
.stop-btn .icon { width: 14px; height: 14px; }

.auto-block { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 9px 10px 10px; margin: 0 0 12px; background: color-mix(in srgb, var(--paper-2) 55%, transparent); }
.auto-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auto-copy strong { display: block; font-size: 10px; font-weight: 600; }
.auto-copy small { display: block; font-size: 8.5px; color: var(--faint); line-height: 1.4; margin-top: 1px; }
.auto-run-btn {
  width: 100%;
  margin-top: 8px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--pine) 32%, var(--line));
  background: var(--pine-soft);
  color: var(--pine);
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.auto-run-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--pine-soft) 65%, var(--paper)); }
.auto-run-btn:disabled { opacity: 0.55; }
.auto-run-btn .icon { width: 13px; height: 13px; }
.auto-note { margin-top: 7px; font-size: 8px; color: var(--faint); line-height: 1.55; }
.auto-stop { margin-top: 7px; border: 0; background: transparent; padding: 0; font-size: 9px; color: var(--cinnabar); }
.auto-stop:hover { text-decoration: underline; }

.output-card { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; overflow: hidden; margin-top: 2px; }
.output-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper-2) 70%, transparent); font-size: 9px; color: var(--muted); }
.output-head strong { color: var(--ink-2); font-size: 9.5px; font-weight: 600; }
.output-head .mode-tag { font-size: 8px; padding: 1px 5px; border-radius: 3px; background: var(--gold-soft); color: var(--gold); }
.output-head .live-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--pine-2); }
.output-head .live-dot.running { animation: pulse 0.8s infinite; background: var(--cinnabar); }
.output-head .head-actions { margin-left: auto; display: flex; gap: 2px; }
.output-body { padding: 12px 13px; max-height: 330px; overflow-y: auto; font-family: var(--serif); font-size: 12.5px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }
.output-body.streaming::after { content: "▍"; color: var(--pine-2); animation: blink 0.9s steps(1) infinite; margin-left: 1px; }
.output-body .placeholder { color: var(--faint); font-family: var(--sans); font-size: 10px; line-height: 1.7; }
.output-actions { display: flex; flex-wrap: wrap; gap: 3px; padding: 7px 8px; border-top: 1px solid var(--line); }
.output-actions .btn { height: 25px; font-size: 9px; padding: 0 8px; }
.output-meta { padding: 0 10px 8px; font-size: 8px; color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; }

.review-intro { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.review-action {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 10px 11px;
  text-align: left;
}
.review-action:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.review-action .ra-icon { width: 30px; height: 30px; border-radius: 7px; background: var(--pine-soft); color: var(--pine); display: grid; place-items: center; flex: 0 0 auto; }
.review-action .ra-icon .icon { width: 15px; height: 15px; }
.review-action strong { display: block; font-size: 10.5px; }
.review-action small { display: block; font-size: 8.5px; color: var(--faint); margin-top: 1px; line-height: 1.4; }
.review-action .icon.chev { margin-left: auto; width: 12px; height: 12px; color: var(--faint); }

.issue-list { display: flex; flex-direction: column; gap: 7px; }
.issue-card { border: 1px solid var(--line); background: var(--paper); border-radius: 7px; padding: 9px 10px; }
.issue-top { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.severity { font-size: 8px; padding: 1px 5px; border-radius: 3px; font-weight: 600; }
.severity.high { background: var(--cinnabar-soft); color: var(--cinnabar); }
.severity.medium { background: var(--gold-soft); color: var(--gold); }
.severity.low { background: var(--pine-soft); color: var(--pine); }
.issue-type { font-size: 8px; color: var(--faint); }
.issue-quote { font-family: var(--serif); font-size: 10px; color: var(--muted); border-left: 2px solid var(--line-strong); padding-left: 7px; margin: 4px 0 5px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.issue-msg { font-size: 9.5px; line-height: 1.6; color: var(--ink-2); margin: 0; }
.issue-sug { font-size: 9px; line-height: 1.6; color: var(--pine); background: var(--pine-soft); border-radius: 4px; padding: 5px 7px; margin-top: 6px; }
.issue-actions { display: flex; gap: 2px; margin-top: 6px; }
.issue-actions button { border: 0; background: transparent; color: var(--muted); font-size: 8.5px; padding: 2px 4px; border-radius: 3px; }
.issue-actions button:hover { background: var(--paper-2); color: var(--ink); }

.context-summary { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 11px 12px; margin-bottom: 10px; }
.ctx-top { display: flex; align-items: baseline; justify-content: space-between; }
.ctx-top strong { font-family: var(--serif); font-size: 19px; }
.ctx-top span { font-size: 8.5px; color: var(--muted); }
.ctx-bar { height: 5px; background: var(--paper-3); border-radius: 99px; overflow: hidden; margin: 7px 0 6px; }
.ctx-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pine), var(--gold)); }
.ctx-meta { display: flex; justify-content: space-between; font-size: 8px; color: var(--faint); }
.ctx-section { display: flex; align-items: center; gap: 7px; padding: 7px 2px; border-bottom: 1px dashed var(--line); font-size: 9.5px; }
.ctx-section:last-child { border-bottom: 0; }
.ctx-section .ctx-name { min-width: 78px; color: var(--ink-2); }
.ctx-section .ctx-chars { margin-left: auto; font-size: 8px; color: var(--faint); font-variant-numeric: tabular-nums; }
.ctx-section.off { opacity: 0.42; }
.ctx-toggle { width: 25px; height: 14px; border-radius: 99px; border: 0; background: var(--pine-soft); position: relative; flex: 0 0 auto; }
.ctx-toggle::after { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--pine); top: 2px; right: 2px; transition: all 0.15s; }
.ctx-toggle.off { background: var(--line); }
.ctx-toggle.off::after { right: 13px; background: var(--faint); }
.ctx-actions { display: flex; gap: 5px; margin-top: 10px; }
.context-empty { padding: 24px 10px; text-align: center; font-size: 10px; color: var(--faint); line-height: 1.7; }

/* ============================================================
   Modals
   ============================================================ */
.modal-root:empty { display: none; }
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 24, 20, 0.48); backdrop-filter: blur(5px); animation: fadeIn 0.18s ease; }
.modal {
  position: relative;
  width: min(620px, 100%);
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s cubic-bezier(0.22, 0.9, 0.32, 1);
  overflow: hidden;
}
.modal.wide { width: min(880px, 100%); }
.modal.slim { width: min(460px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 17px 20px 13px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.modal-head h2 { font-family: var(--serif); font-size: 19px; margin: 0; letter-spacing: 0.03em; line-height: 1.3; }
.modal-head p { margin: 3px 0 0; font-size: 10px; color: var(--muted); line-height: 1.55; }
.modal-head .modal-close { margin-left: auto; }
.modal-close { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.modal-close:hover { background: var(--paper-2); color: var(--ink); }
.modal-close .icon { width: 15px; height: 15px; }
.modal-body { padding: 17px 20px; overflow-y: auto; min-height: 0; flex: 1; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--paper-2) 45%, transparent); flex: 0 0 auto; }
.modal-foot .left { margin-right: auto; }
.modal-note { padding: 10px 12px; border-radius: 6px; background: var(--paper-2); border: 1px solid var(--line); font-size: 9.5px; color: var(--muted); line-height: 1.65; margin-bottom: 14px; }
.modal-note.warn { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 25%, transparent); color: color-mix(in srgb, var(--gold) 80%, var(--ink)); }
.modal-section { margin-bottom: 17px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title { font-size: 9px; letter-spacing: 0.16em; color: var(--faint); text-transform: uppercase; margin: 0 0 9px; }
.form-actions-inline { display: flex; gap: 6px; align-items: center; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .tr-text strong { display: block; font-size: 11px; font-weight: 600; }
.toggle-row .tr-text small { display: block; font-size: 9px; color: var(--faint); line-height: 1.5; margin-top: 1px; }
.switch { width: 36px; height: 20px; border: 0; border-radius: 99px; background: var(--line-strong); position: relative; flex: 0 0 auto; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 3px; left: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.switch.on { background: var(--pine); }
.switch.on::after { transform: translateX(16px); }

.provider-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.provider-btn { border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 7px 8px; font-size: 10px; color: var(--ink-2); text-align: left; }
.provider-btn small { display: block; font-size: 8px; color: var(--faint); margin-top: 1px; }
.provider-btn:hover { border-color: var(--line-strong); }
.provider-btn.active { border-color: var(--pine-2); background: var(--pine-soft); color: var(--pine); }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--pine); }
.range-value { font-family: var(--mono); font-size: 9px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; min-width: 40px; text-align: center; }

.key-status { display: flex; align-items: center; gap: 7px; font-size: 9px; color: var(--faint); margin-top: 4px; }
.key-status .ok { color: var(--pine); }
.key-status button { border: 0; background: transparent; color: var(--cinnabar); font-size: 9px; padding: 0; text-decoration: underline; }
.test-result { display: none; margin-top: 9px; padding: 8px 10px; border-radius: 5px; font-size: 9.5px; line-height: 1.55; }
.test-result.show { display: block; }
.test-result.ok { background: var(--pine-soft); color: var(--pine); }
.test-result.err { background: var(--cinnabar-soft); color: var(--cinnabar); }

.issue-drawer-list { display: flex; flex-direction: column; gap: 8px; }
.issue-drawer-item { border: 1px solid var(--line); background: var(--paper); border-radius: 7px; padding: 10px 11px; }
.issue-drawer-item .idi-head { display: flex; align-items: center; gap: 6px; }
.issue-drawer-item .idi-ch { font-size: 8.5px; color: var(--faint); margin-left: auto; }
.issue-drawer-item .idi-msg { font-size: 10px; line-height: 1.65; margin: 5px 0; color: var(--ink-2); }
.issue-drawer-item .idi-sug { font-size: 9px; color: var(--pine); background: var(--pine-soft); border-radius: 4px; padding: 5px 7px; }
.issue-drawer-item.resolved { opacity: 0.55; }
.issue-drawer-item.resolved .idi-msg { text-decoration: line-through; }

.snapshot-list { display: flex; flex-direction: column; gap: 7px; }
.snapshot-item { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; background: var(--paper); }
.snapshot-item .snap-time { font-size: 9px; color: var(--muted); min-width: 92px; }
.snapshot-item .snap-preview { flex: 1; font-family: var(--serif); font-size: 10px; color: var(--ink-2); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.snapshot-item .snap-actions { display: flex; gap: 2px; }
.snapshot-empty { text-align: center; padding: 30px; color: var(--faint); font-size: 10px; }

.prompt-preview { font-family: var(--mono); font-size: 9.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 6px; padding: 12px; max-height: 56vh; overflow: auto; color: var(--ink-2); }

.relation-editor { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.rel-row { display: grid; grid-template-columns: 1fr 1fr 26px; gap: 5px; }
.rel-row .input, .rel-row .select { padding: 5px 7px; font-size: 10px; }
.rel-remove { border: 0; background: transparent; color: var(--faint); border-radius: 4px; }
.rel-remove:hover { color: var(--cinnabar); background: var(--cinnabar-soft); }

/* ============================================================
   Palette
   ============================================================ */
.palette-root:empty { display: none; }
.palette-root { position: fixed; inset: 0; z-index: 110; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 20px 20px; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(17, 22, 18, 0.4); backdrop-filter: blur(4px); }
.palette { position: relative; width: min(620px, 100%); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 11px; box-shadow: var(--shadow-lg); overflow: hidden; animation: modalIn 0.18s ease; }
.palette-input-wrap { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.palette-input-wrap .icon { color: var(--muted); }
.palette-input { flex: 1; border: 0; outline: none; background: transparent; font-size: 14px; }
.palette-input::placeholder { color: var(--faint); }
.palette-hint { font-size: 8px; color: var(--faint); border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 5px; }
.palette-group { padding: 7px 9px 3px; font-size: 8px; letter-spacing: 0.14em; color: var(--faint); text-transform: uppercase; }
.palette-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 9px; border-radius: 5px; color: var(--ink-2); font-size: 11px; }
.palette-item .icon { width: 15px; height: 15px; color: var(--muted); }
.palette-item .p-sub { margin-left: auto; font-size: 8.5px; color: var(--faint); max-width: 44%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item:hover, .palette-item.active { background: var(--pine-soft); color: var(--pine); }
.palette-item.active .icon { color: var(--pine); }
.palette-empty { padding: 28px; text-align: center; font-size: 10px; color: var(--faint); }

/* ============================================================
   Toast
   ============================================================ */
.toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none; }
.toast { background: #20261f; color: #f4efdf; font-size: 11px; padding: 8px 14px; border-radius: 99px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22); animation: toastIn 0.22s ease both; max-width: 80vw; text-align: center; }
.toast.out { animation: toastOut 0.2s ease both; }
.toast.err { background: var(--cinnabar); color: #fff8f2; }
.toast.ok { background: var(--pine); color: #f7f3e7; }

/* ============================================================
   Library mode / responsive
   ============================================================ */
body.library-mode .sidebar,
body.library-mode .copilot { display: none; }
body.library-mode .workspace { grid-template-columns: 1fr; }
body.library-mode .view { overflow-y: auto; }
body.library-mode .topbar .project-switch { opacity: 0.65; }
body.no-project .sidebar .main-nav,
body.no-project .sidebar .chapter-block,
body.no-project .sidebar .sidebar-foot { display: none; }
body.copilot-collapsed .copilot { display: none; }
body.copilot-collapsed .workspace { grid-template-columns: 268px minmax(0, 1fr); }

body.copilot-open .copilot { transform: none; }
body.copilot-open .copilot-backdrop { display: block; }

@media (max-width: 1320px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr) 350px; }
  .brand-text em { display: none; }
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr); }
  .copilot {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(92vw, 390px);
    z-index: 70;
    transform: translateX(101%);
    transition: transform 0.24s ease;
    box-shadow: -18px 0 50px rgba(20, 24, 20, 0.18);
    background: var(--paper);
  }
  body.copilot-collapsed .copilot { display: flex; }
  .copilot-close-mobile { display: grid; }
  .nav-toggle { display: grid !important; }
  body.copilot-open .copilot-backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0;
    z-index: 65;
    background: rgba(17, 22, 18, 0.35);
    backdrop-filter: blur(2px);
  }
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: min(84vw, 286px);
    z-index: 80;
    transform: translateX(-102%);
    transition: transform 0.24s ease;
    background: var(--bg);
    box-shadow: 18px 0 50px rgba(20, 24, 20, 0.18);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0; z-index: 75; background: rgba(17, 22, 18, 0.35); backdrop-filter: blur(2px); }
  .save-state { display: none; }
  .project-switch { max-width: 210px; }
  .outline-layout { grid-template-columns: 1fr; }
  .outline-tree { position: static; max-height: none; }
  .relations-layout { grid-template-columns: 1fr; }
  .rel-list > div:last-child { grid-template-columns: 1fr; }
  .rel-list > div:last-child .rel-item:nth-child(odd) { border-right: 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .library-hero { grid-template-columns: 1fr; }
  .library-quote { display: none; }
  .library-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { padding: 0 10px; gap: 5px; }
  .brand-text { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .project-switch { max-width: 150px; padding-right: 4px; }
  .project-switch-text small { display: none; }
  .project-cover { width: 25px; height: 25px; }
  .topbar .theme-btn { display: none; }
  .view { scrollbar-width: none; }
  .view::-webkit-scrollbar { display: none; }
  .write-view { padding: 0 12px; }
  .chapter-top { padding-top: 17px; }
  .chapter-title { font-size: 25px; }
  .chapter-actions .btn span { display: none; }
  .blueprint-strip { grid-template-columns: 1fr 1fr; margin-top: 11px; }
  .bp-cell:nth-child(3), .bp-cell:nth-child(4) { display: none; }
  .editor-shell { margin: 11px auto 10px; border-radius: 4px; }
  #editor { padding: 22px 20px 38px; font-size: 16px; line-height: 1.95; }
  .editor-toolbar { padding: 0 6px; overflow-x: auto; }
  .editor-toolbar .tool-btn span { display: none; }
  .editor-toolbar .tool-btn { padding: 0 7px; }
  .editor-foot .desktop-hint { display: none; }
  .page { padding: 20px 15px 60px; }
  .page-head { gap: 12px; margin-bottom: 16px; }
  .page-head h1 { font-size: 25px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .kpi .k-value { font-size: 22px; }
  .kanban { grid-template-columns: 1fr; }
  .character-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .library-hero h1 { font-size: 33px; }
  .library-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .library-cover { height: 100px; padding: 11px; }
  .library-cover h3 { font-size: 18px; }
  .library-body { padding: 9px 10px; }
  .library-body .lib-sub { display: none; }
  .modal-root { padding: 8px; align-items: end; }
  .modal { max-height: 92vh; border-radius: 12px 12px 0 0; }
  .modal.wide, .modal.slim { width: 100%; }
  .provider-grid { grid-template-columns: 1fr 1fr; }
  .toast-root { bottom: 14px; }
  .palette-root { padding: 8vh 10px 10px; }
}

@media (max-width: 430px) {
  .library-grid { grid-template-columns: 1fr; }
  .project-switch-text strong { max-width: 92px; }
  .topbar .issues-btn { display: none; }
  .chapter-actions .text-btn { display: none; }
}

code { font-family: var(--mono); font-size: 0.92em; background: var(--paper-2); border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   从正文提炼
   ============================================================ */
.extract-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 34px 12px; font-size: 10.5px; color: var(--muted); }
.extract-loading .icon { width: 15px; height: 15px; animation: spin 1.1s linear infinite; }
.extract-empty { padding: 26px 14px; text-align: center; font-size: 10.5px; color: var(--muted); line-height: 1.9; }
.extract-summary { font-size: 9px; color: var(--faint); margin-bottom: 13px; line-height: 1.6; }
.extract-section { margin-bottom: 15px; }
.extract-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.extract-head strong { font-size: 10.5px; color: var(--ink-2); }
.extract-head .count { font-size: 8px; color: var(--faint); border: 1px solid var(--line); border-radius: 99px; padding: 1px 6px; }
.extract-overwrite { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 8.5px; color: var(--muted); cursor: pointer; }
.extract-item { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; margin-bottom: 5px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); cursor: pointer; }
.extract-item:hover { border-color: var(--line-strong); }
.extract-item input { margin-top: 2px; accent-color: var(--pine); }
.extract-item.exists { opacity: 0.55; cursor: default; }
.ei-body { flex: 1; min-width: 0; display: block; }
.ei-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 10px; }
.ei-tag { font-size: 7.5px; color: var(--pine); background: var(--pine-soft); padding: 1px 5px; border-radius: 3px; }
.ei-desc { display: block; font-size: 9px; color: var(--muted); line-height: 1.65; margin-top: 2px; white-space: pre-wrap; }
.ei-exists { font-size: 8px; color: var(--faint); flex: 0 0 auto; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   新建作品：类型预设与标签
   ============================================================ */
.section-hint { font-size: 8.5px; font-weight: 400; color: var(--faint); margin-left: 7px; letter-spacing: 0; }
.preset-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.preset-cell { position: relative; display: flex; min-width: 0; }
.preset-cell .provider-btn { flex: 1; min-width: 0; }
.preset-cell .provider-btn small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-del { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--faint); font-size: 12px; line-height: 1; display: grid; place-items: center; padding: 0; }
.preset-del:hover { color: var(--cinnabar); border-color: var(--cinnabar); }
.preset-add { border-style: dashed; color: var(--muted); }
.preset-new { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.preset-new[hidden] { display: none; }
.preset-new .input { flex: 1; min-width: 0; }
.tag-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-height: 38px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.tag-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 9px; color: var(--pine); background: var(--pine-soft); border-radius: 99px; padding: 2px 4px 2px 8px; }
.tag-chip button { border: 0; background: transparent; color: inherit; font-size: 11px; line-height: 1; padding: 0 2px; opacity: 0.65; }
.tag-chip button:hover { opacity: 1; }
.tag-input { flex: 1; min-width: 130px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 10px; padding: 2px 0; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.tag-option { border: 1px dashed var(--line); background: transparent; color: var(--muted); font-size: 8.5px; padding: 2px 7px; border-radius: 99px; }
.tag-option:hover { border-color: var(--pine); color: var(--pine); }
.lib-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.lib-tags .tag { font-size: 7.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 6px; }

/* ============================================================
   粗纲
   ============================================================ */
.coarse-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: 7px; background: color-mix(in srgb, var(--paper-2) 55%, transparent); margin-bottom: 12px; }
.coarse-head label { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.coarse-head .select { width: auto; height: 28px; }
.coarse-summary { border-left: 3px solid var(--pine-2); padding: 2px 10px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 3px; }
.coarse-summary strong { font-family: var(--serif); font-size: 13px; }
.coarse-summary span { font-size: 9.5px; color: var(--muted); line-height: 1.6; }
.coarse-item { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; margin-bottom: 6px; background: var(--paper); }
.ci-head { display: flex; align-items: center; gap: 8px; font-size: 10.5px; }
.ci-no { font-size: 8px; color: var(--faint); border: 1px solid var(--line); border-radius: 99px; padding: 1px 6px; }
.ci-summary { font-size: 9.5px; color: var(--ink-2); line-height: 1.65; margin-top: 4px; }
.ci-meta { font-size: 8.5px; color: var(--faint); line-height: 1.6; margin-top: 3px; }

/* ============================================================
   故事设计（粗 → 细）
   ============================================================ */
.design-flow { display: flex; flex-direction: column; gap: 14px; }
.design-section { border: 1px solid var(--line); border-radius: 8px; padding: 12px 13px; background: var(--paper); }
.design-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; flex-wrap: wrap; }
.ds-no { width: 20px; height: 20px; border-radius: 50%; background: var(--pine-soft); color: var(--pine); font-size: 9px; display: grid; place-items: center; flex: 0 0 auto; }
.design-copy { flex: 1; min-width: 160px; }
.design-copy strong { display: block; font-size: 11px; }
.design-copy small { display: block; font-size: 8.5px; color: var(--faint); line-height: 1.5; margin-top: 1px; }
.design-candidates { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.design-candidates:empty { display: none; }
.design-candidate { text-align: left; border: 1px dashed var(--line-strong); background: var(--paper-2); color: var(--ink-2); font-size: 10px; line-height: 1.6; padding: 6px 9px; border-radius: 6px; }
.design-candidate:hover { border-color: var(--pine); color: var(--pine); background: var(--pine-soft); }
.design-section .textarea { font-size: 11px; line-height: 1.75; }
.design-volumes { display: flex; flex-direction: column; gap: 7px; margin: 8px 0; }
.design-volume { border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; background: var(--paper-2); }
.dv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dv-head strong { font-family: var(--serif); font-size: 12.5px; }
.dv-arc { font-size: 9px; color: var(--muted); }
.design-volume p { margin: 5px 0 0; font-size: 9.5px; line-height: 1.7; color: var(--ink-2); }
.dv-events { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.dv-events span { font-size: 8px; color: var(--pine); background: var(--pine-soft); border-radius: 99px; padding: 1px 7px; }
.dv-states { margin-top: 6px; font-size: 8.5px; color: var(--faint); }
.design-chapters { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.design-section .select { height: 28px; width: auto; }

/* 数量输入与更宽松的间距（粗纲 / 故事设计） */
.coarse-head { gap: 12px; padding: 10px 12px; }
.coarse-head .coarse-count { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.coarse-head .input { width: 76px; height: 30px; text-align: center; padding: 0 6px; font-size: 11px; }
.design-head { gap: 10px; }
.design-head .btn { flex: 0 0 auto; }
.design-count { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.design-count .input { width: 64px; height: 30px; text-align: center; padding: 0 6px; font-size: 11px; }
.design-copy small { font-size: 9px; line-height: 1.55; }
.design-section { padding: 14px 15px; }
#designVolumeSelect { min-width: 190px; max-width: 260px; height: 30px; }

/* 数字输入再宽松一点，避免数字和步进箭头挤在一起 */
.coarse-head .input { width: 92px; font-size: 12px; padding: 0 8px; }
.coarse-head .section-hint { font-size: 9px; }
.design-count .input { width: 68px; font-size: 12px; }

/* 粗纲头部改成两行，避免窄窗口挤压 */
.coarse-head { flex-direction: column; align-items: stretch; gap: 9px; }
.coarse-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 清理空章/空卷 */
.cleanup-note { display: flex; gap: 7px; align-items: flex-start; font-size: 9.5px; color: var(--cinnabar); background: var(--cinnabar-soft); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; line-height: 1.6; }
.cleanup-note .icon { width: 13px; height: 13px; margin-top: 1px; flex: 0 0 auto; }

/* ============================================================
   阅读字号：正文 / 设定集 / 章纲 / AI 输出
   统一调大一档，正文默认 19px
   ============================================================ */
:root { --editor-size: 19px; }

.page-desc { font-size: 12.5px; }
.field > label, .field-label { font-size: 11px; }
.field .hint { font-size: 10px; line-height: 1.6; }
.input, .textarea, .select { font-size: 13px; }
.textarea { line-height: 1.75; }

.char-top strong { font-size: 16px; }
.char-top .role { font-size: 9.5px; }
.char-line { font-size: 11.5px; line-height: 1.65; }
.char-foot { font-size: 9.5px; }
.char-desire { font-size: 10.5px; }

.world-item .cat { font-size: 9.5px; }
.world-item strong { font-size: 13px; }
.world-item p { font-size: 11.5px; line-height: 1.72; }
.world-item .tag { font-size: 9px; }

.style-card blockquote { font-size: 13px; }
.fact-item { font-size: 11.5px; line-height: 1.7; }
.fact-item .fact-ch { font-size: 9.5px; }

.bp-cell .bp-text { font-size: 11.5px; }
.output-body { font-size: 13.5px; line-height: 1.9; }
.issue-msg { font-size: 10.5px; line-height: 1.7; }
.issue-sug { font-size: 10px; line-height: 1.7; }
.issue-quote { font-size: 11.5px; }
.modal-section-title { font-size: 10px; }
