:root {
  --bg: #eceae4;
  --paper: #f7f5ef;
  --card: #ffffff;
  --line: #d9d3c6;
  --text: #2e2923;
  --muted: #7a7265;
  --accent: #c9783d;
  --accent-soft: #f2e3d2;
  --danger: #b94f3b;
  --shadow: 0 6px 18px rgba(46, 33, 15, 0.06);
  --reader-font: 17px;
  --reader-width: 1120px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.mobile-only {
  display: none;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 16% 8%, #faf6ef 0%, var(--bg) 42%, #e8e5de 100%);
  font-family: "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

body.theme-dark {
  --bg: #1f2328;
  --paper: #232a31;
  --card: #2a333d;
  --line: #38424f;
  --text: #e8e3dc;
  --muted: #a7acb2;
  --accent: #d08c52;
  --accent-soft: #3c2f26;
  --danger: #dc7667;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
  background: radial-gradient(circle at 20% 8%, #2b3138 0%, #1f2328 45%, #181c21 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 48;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 245, 238, 0.9);
  backdrop-filter: blur(10px);
}

.brand-wrap {
  display: flex;
  align-items: center;
  min-width: 210px;
}

.brand-home-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 10px;
}

.brand-home-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(145deg, #e3af72, #cb7f43);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 15px;
}

.brand-logo {
  height: 46px;
  width: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(75, 33, 0, 0.16));
}

.status-wrap {
  position: relative;
  margin-left: auto;
}

.status-toggle-btn {
  min-width: 62px;
}

.status {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 66;
  min-width: 360px;
  max-width: min(860px, calc(100vw - 30px));
  color: #6d5f4f;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  background: #fff8ee;
  border: 1px solid #e3ccb3;
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(81, 56, 28, 0.18);
  padding: 10px 12px;
  white-space: normal;
}

.top-icon-btn {
  height: 34px;
  min-width: 42px;
  padding: 0 10px;
  border-radius: 9px;
}

.agent-pulse {
  position: fixed;
  top: 76px;
  right: 14px;
  z-index: 80;
  border: 1px solid #e2c6a6;
  background: #fff7eb;
  color: #7f4d25;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(116, 74, 34, 0.18);
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(520px, calc(100vw - 32px));
}

body.theme-dark .agent-pulse {
  background: #3a2f26;
  color: #f8d7b6;
  border-color: #88654a;
}

body.theme-dark .status {
  color: #d4dbe2;
  background: #2a323d;
  border-color: #47586f;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.35);
}

.agent-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #cc7d3f;
  animation: pulse-dot 1s ease-in-out infinite;
}

.agent-pulse-text {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layout {
  --left-col: 292px;
  --middle-col: 360px;
  display: grid;
  grid-template-columns: var(--left-col) var(--middle-col) minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
  flex: 1;
  min-height: 0;
  position: relative;
}

body.collapse-left .layout {
  --left-col: 0px;
}

body.collapse-middle .layout {
  --middle-col: 0px;
}

body.collapse-left .panel-left,
body.collapse-middle .panel-middle {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

body.focus-mode .layout {
  grid-template-columns: minmax(0, 1fr);
}

body.focus-mode .panel-left,
body.focus-mode .panel-middle {
  display: none;
}

body.focus-mode .panel-right {
  grid-column: 1 / -1;
}

body.focus-mode .panel-resizer {
  display: none;
}

body.focus-mode .reader,
body.focus-mode .doc-pane {
  max-width: min(1440px, calc(100vw - 28px));
}

.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(28, 22, 16, 0.45);
  z-index: 58;
}

.panel {
  background: var(--paper);
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.18s ease;
}

.panel-resizer {
  position: absolute;
  top: 78px;
  width: 12px;
  height: 28px;
  padding: 0;
  border: 1px solid #d9ccb9;
  border-radius: 8px;
  background: rgba(248, 241, 232, 0.95);
  color: #7b5637;
  box-shadow: 0 8px 14px rgba(114, 81, 45, 0.14);
  cursor: pointer;
  z-index: 26;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
  transition: 0.18s ease;
}

.panel-resizer:hover {
  background: #fdf3e7;
  border-color: #d9ad84;
}

.panel-resizer:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.panel-resizer-left {
  left: var(--left-col);
}

.panel-resizer-middle {
  left: calc(var(--left-col) + var(--middle-col));
}

.panel-splitter {
  position: absolute;
  top: 64px;
  bottom: 0;
  width: 6px;
  transform: translateX(-50%);
  z-index: 24;
  cursor: col-resize;
  background: transparent;
  border-radius: 8px;
}

.panel-splitter::before {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-radius: 999px;
  background: rgba(145, 114, 78, 0.16);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.panel-splitter:hover::before,
.panel-splitter.dragging::before {
  opacity: 1;
}

.panel-splitter-left {
  left: var(--left-col);
}

.panel-splitter-middle {
  left: calc(var(--left-col) + var(--middle-col));
}

body.collapse-left .panel-resizer-left {
  left: 8px;
  transform: none;
}

body.collapse-middle:not(.collapse-left) .panel-resizer-middle {
  left: calc(var(--left-col) + 22px);
  transform: none;
}

body.collapse-left.collapse-middle .panel-resizer-left {
  left: 8px;
}

body.collapse-left.collapse-middle .panel-resizer-middle {
  left: 30px;
  transform: none;
}

body.theme-dark .panel-resizer {
  background: rgba(54, 61, 70, 0.95);
  border-color: #566171;
  color: #d6ba9c;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

body.focus-mode .panel-splitter,
body.collapse-left .panel-splitter-left,
body.collapse-middle .panel-splitter-middle {
  display: none;
}

.panel-head {
  height: 56px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.panel-head.split {
  justify-content: space-between;
}

.head-title {
  font-size: 14px;
  font-weight: 600;
}

.head-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

#read-toolbar {
  position: sticky;
  top: 64px;
  z-index: 12;
  background: rgba(247, 245, 239, 0.9);
  backdrop-filter: blur(8px);
}

body.theme-dark #read-toolbar {
  background: rgba(35, 42, 49, 0.92);
}

.toolbar.compact {
  gap: 7px;
  padding: 8px 10px;
}

.tts-audio {
  height: 32px;
  max-width: 280px;
}

.auto-full-progress {
  border-bottom: 1px solid var(--line);
  padding: 7px 12px 9px;
  background: #f9f4ec;
}

.auto-full-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #6a5948;
  margin-bottom: 6px;
}

.auto-full-track {
  height: 8px;
  border-radius: 999px;
  background: #e8dccf;
  overflow: hidden;
}

.auto-full-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #cc7d3f 0%, #dca671 100%);
  transition: width 0.28s ease;
}

.toolbar-menu {
  position: relative;
  margin-left: auto;
  z-index: 28;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: transparent;
  z-index: 24;
}

#project-actions-toggle-btn {
  position: relative;
  z-index: 30;
}

.menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 32px rgba(47, 33, 17, 0.16);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 32;
}

.menu-title {
  font-size: 11px;
  color: #8e7f6e;
  padding: 2px 6px 6px;
}

.menu-item {
  border: 1px solid var(--line);
  background: #f6f1e9;
  color: #5b4d3b;
  border-radius: 8px;
  min-height: 32px;
  padding: 0 10px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.menu-item:hover {
  background: #f9f4ed;
}

.menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.menu-item.danger {
  color: #9f4333;
  border-color: #dfb8a8;
  background: #fbeeea;
}

.menu-divider {
  height: 1px;
  background: #e7ded2;
  margin: 3px 2px;
}

.list {
  overflow: auto;
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  box-shadow: none;
  cursor: pointer;
  transition: 0.18s ease;
}

.card:hover {
  border-color: #d2c6b3;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card.active {
  border-color: #d8b28f;
  background: linear-gradient(180deg, #fffefb 0%, #fff8ee 100%);
  box-shadow: 0 10px 22px rgba(147, 88, 34, 0.13);
}

.card.loading {
  border-color: #e0b88e;
  box-shadow: 0 10px 20px rgba(183, 120, 58, 0.12);
}

.card h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gen-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  font-size: 11px;
  color: #824c21;
  border: 1px solid #e4c29e;
  background: #fbf0e3;
  border-radius: 999px;
  padding: 2px 7px;
}

.gen-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cc7d3f;
  animation: pulse-dot 1s ease-in-out infinite;
}

.card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  margin-top: 7px;
  color: #8c8172;
  font-size: 11px;
}

.chapter-push-btn {
  border: 1px solid #e3cfba;
  background: #faf3e8;
  color: #6c4628;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

.card-actions-inline {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border: 1px solid #d6cec0;
  background: #f4efe6;
  color: #5d5040;
  white-space: nowrap;
}

.state-pill.state-active {
  border-color: #cddfce;
  color: #2f6b3f;
  background: #ecf7ef;
}

.state-pill.state-paused {
  border-color: #dfd4c4;
  color: #7a684d;
  background: #f6f0e8;
}

.state-pill.state-completed {
  border-color: #d0d8e8;
  color: #325782;
  background: #edf3fc;
}

.state-pill.state-starred {
  border-color: #e7d2ab;
  color: #8b5b19;
  background: #faf2e2;
}

.meta-chips {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #e1d6c7;
  background: #f8f4ec;
  color: #756959;
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
}

.meta-chip.accent {
  border-color: #e2c3a1;
  background: #fdf2e5;
  color: #7f4d25;
}

.progress-row {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.progress-text {
  color: #7c7163;
  font-size: 11px;
}

.progress-track {
  margin-top: 4px;
  height: 6px;
  background: #ece2d5;
  border-radius: 999px;
  overflow: hidden;
}

.progress-track > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #cc7d3f 0%, #dfab74 100%);
}

body.theme-dark .state-pill {
  border-color: #4a5563;
  background: #313a45;
  color: #cdd3da;
}

body.theme-dark .state-pill.state-active {
  border-color: #51725b;
  background: #2f3d35;
  color: #b9dcc2;
}

body.theme-dark .state-pill.state-paused {
  border-color: #5b5b56;
  background: #3b3a34;
  color: #d4cab5;
}

body.theme-dark .state-pill.state-completed {
  border-color: #4b5e7a;
  background: #2f3e53;
  color: #c2d6ef;
}

body.theme-dark .state-pill.state-starred {
  border-color: #746142;
  background: #3d3425;
  color: #f0d6a8;
}

body.theme-dark .meta-chip {
  border-color: #445161;
  background: #2e3743;
  color: #b8c0ca;
}

body.theme-dark .meta-chip.accent {
  border-color: #6f563f;
  background: #3c2f25;
  color: #f0ccaa;
}

body.theme-dark .progress-text {
  color: #a6afb9;
}

body.theme-dark .progress-track {
  background: #2f3945;
}

.chapter-push-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tags {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 10px;
  color: #805d41;
  background: #f7eee4;
  border: 1px solid #e9d4bd;
  border-radius: 999px;
  padding: 2px 6px;
}

.btn {
  border: 0;
  height: 34px;
  border-radius: 10px;
  padding: 0 12px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.secondary {
  background: #dfd8cc;
  color: #473f33;
}

.btn.ghost {
  background: #f4efe6;
  color: #5a4c3b;
  border: 1px solid var(--line);
}

.btn.ghost.active {
  border-color: #d6ad86;
  background: #faeddc;
  color: #6a3f21;
}

.btn.ghost.danger {
  color: var(--danger);
  border-color: #ddbaa8;
  background: #fcf2ef;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.search {
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  min-width: 190px;
}

.chip {
  border: 1px solid var(--line);
  background: #f6f2eb;
  color: #5d5143;
  height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  cursor: pointer;
  font-size: 12px;
}

.chip.active {
  background: var(--accent-soft);
  border-color: #d8b18c;
  color: #623a1e;
}

.checkline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  border: 1px solid var(--line);
  background: #f4f0e9;
  color: #5f5447;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent-soft);
  border-color: #d8b08a;
  color: #623a1e;
}

.reader,
.doc-pane {
  padding: 12px 16px 24px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.66;
  font-size: var(--reader-font);
}

.reader {
  max-width: var(--reader-width);
  width: 100%;
  margin: 4px auto 0;
}

.reader.empty,
.doc-pane.empty {
  color: var(--muted);
}

.reader h2 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.28;
  text-align: center;
}

.reader .summary {
  font-size: 13px;
  color: #564c3f;
  background: var(--accent-soft);
  border-left: 4px solid #d3a985;
  padding: 9px 11px;
  border-radius: 9px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reader .summary > strong {
  font-size: 11px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #835b3c;
}

.reader .content {
  font-size: var(--reader-font);
  line-height: 1.72;
}

.reader .content.prose {
  white-space: normal;
}

.reader .content.prose p {
  margin: 0 0 0.92em;
  text-indent: 2em;
}

.reader .content.prose p:last-child {
  margin-bottom: 0;
}

.reader .content.prose p.empty-para {
  text-indent: 0;
  color: var(--muted);
}

.chapter-top {
  margin-bottom: 8px;
  color: #948676;
  font-size: 12px;
  text-align: center;
}

.chapter-runtime {
  margin: 0 auto 8px;
  color: #7a5738;
  font-size: 12px;
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  border: 1px solid #ebd3b8;
  background: #fbf3e8;
  border-radius: 999px;
  padding: 4px 10px;
}

.loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cc7d3f;
  animation: pulse-dot 1s ease-in-out infinite;
}

.reader-loading {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #ead8c2;
  border-radius: 10px;
  background: #fffcf7;
  padding: 14px;
}

.skeleton-line {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f3e7d8 25%, #fbf4ea 50%, #f3e7d8 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.25s linear infinite;
}

.skeleton-line.w58 {
  width: 58%;
}

.skeleton-line.w92 {
  width: 92%;
}

.skeleton-line.w74 {
  width: 74%;
}

.skeleton-line.w86 {
  width: 86%;
}

.quality-line {
  margin-bottom: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quality-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #e6ceb4;
  background: #faefe2;
  color: #6b4427;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.review-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.review-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.review-card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: #5c5246;
  white-space: pre-wrap;
}

.task-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.task-pane-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.task-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.task-type {
  font-size: 12px;
  font-weight: 600;
  color: #5d4a37;
}

.task-status {
  font-size: 11px;
  color: #6b4427;
  background: #f8eddf;
  border: 1px solid #e8d3ba;
  border-radius: 999px;
  padding: 1px 8px;
}

.task-status.status-failed {
  color: #9a2d2d;
  background: #faecea;
  border-color: #e2b1ac;
}

.task-status.status-running {
  color: #2f5e92;
  background: #edf5ff;
  border-color: #bcd4ef;
}

.task-status.status-queued {
  color: #8b5b19;
  background: #f9f1e2;
  border-color: #e7d1ab;
}

.task-project {
  font-size: 11px;
  color: #8b7e6f;
}

.task-phase {
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 8px;
  border: 1px solid #e6d9c9;
  background: #f5efe6;
  color: #645543;
}

.task-phase-awaken {
  color: #705335;
  border-color: #e5cfb5;
  background: #f8efdf;
}

.task-phase-express {
  color: #2f5e92;
  border-color: #bcd4ef;
  background: #edf5ff;
}

.task-phase-confirm {
  color: #2f6b3f;
  border-color: #bddcc4;
  background: #ecf7ef;
}

.task-phase-feedback {
  color: #9a2d2d;
  border-color: #e2b1ac;
  background: #faecea;
}

.task-meta {
  font-size: 11px;
  color: #857867;
  margin-bottom: 4px;
}

.task-stage {
  font-size: 12px;
  color: #4f463d;
  line-height: 1.5;
}

.task-error {
  margin-top: 4px;
  font-size: 11px;
  color: #9e3e35;
  line-height: 1.5;
}

.task-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.task-timeline {
  margin-top: 8px;
  border: 1px dashed #dfd3c4;
  border-radius: 8px;
  background: #fffdf9;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-timeline-row {
  display: grid;
  grid-template-columns: 155px 56px 1fr;
  align-items: center;
  gap: 8px;
}

.task-timeline-time {
  font-size: 11px;
  color: #8b7c6d;
}

.task-timeline-phase {
  font-size: 10px;
  text-align: center;
  border-radius: 999px;
  padding: 1px 6px;
  border: 1px solid #e6d9c9;
  background: #f5efe6;
}

.task-timeline-stage {
  font-size: 12px;
  color: #5a5044;
  line-height: 1.4;
}

.task-timeline-empty {
  font-size: 12px;
  color: #8b7b6a;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.risk-high {
  color: #9a2d2d;
  border-color: #e2b1ac;
  background: #faecea;
}

.risk-mid {
  color: #8b5b19;
  border-color: #e7d1ab;
  background: #f9f1e2;
}

.risk-low {
  color: #2f6b3f;
  border-color: #bddcc4;
  background: #ecf7ef;
}

.reader-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reader-editor input,
.reader-editor textarea,
.dialog-form input,
.dialog-form textarea,
.dialog-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}

.reader-editor textarea,
.dialog-form textarea {
  min-height: 96px;
  resize: vertical;
}

.reader-editor textarea.large {
  min-height: 430px;
  line-height: 1.8;
}

.range-label {
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.range-label input {
  width: 92px;
}

.star {
  color: #d2954d;
  font-size: 13px;
  margin-left: 6px;
}

dialog {
  border: 0;
  border-radius: 14px;
  width: min(860px, calc(100vw - 32px));
  padding: 0;
  box-shadow: 0 22px 50px rgba(39, 27, 13, 0.28);
}

#fanqie-dialog {
  width: min(700px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(38, 25, 13, 0.35);
}

.dialog-form {
  padding: 18px;
}

.dialog-form.dialog-form-narrow {
  width: min(680px, calc(100vw - 32px));
}

.command-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.command-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
  max-height: 340px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

body.theme-dark .command-list {
  background: #1f252c;
}

.command-item {
  border: 0;
  border-bottom: 1px solid #eee2d3;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
}

.command-item:last-child {
  border-bottom: 0;
}

.command-item:hover,
.command-item.active {
  background: #f6eee4;
}

body.theme-dark .command-item {
  border-bottom-color: #343e49;
}

body.theme-dark .command-item:hover,
body.theme-dark .command-item.active {
  background: #2f3741;
}

body.theme-dark .topbar {
  background: rgba(28, 34, 42, 0.92);
  border-bottom-color: #404c5c;
}

body.theme-dark .panel {
  background: #232c36;
}

body.theme-dark .panel-head,
body.theme-dark .toolbar {
  background: rgba(32, 39, 48, 0.72);
}

body.theme-dark .auto-full-progress {
  background: #2a333f;
}

body.theme-dark .auto-full-line {
  color: #c0c9d4;
}

body.theme-dark .auto-full-track {
  background: #3a4654;
}

body.theme-dark .menu-popover {
  background: #252f3a;
  border-color: #44546a;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34);
}

body.theme-dark .menu-title {
  color: #a8b5c4;
}

body.theme-dark .menu-item {
  background: #2f3a47;
  border-color: #475972;
  color: #dce6f0;
}

body.theme-dark .menu-item:hover {
  background: #344254;
}

body.theme-dark .menu-item.danger {
  color: #f1b1a6;
  border-color: #7b4a49;
  background: #472e31;
}

body.theme-dark .menu-divider {
  background: #3e4c61;
}

body.theme-dark .btn {
  color: #1f1913;
}

body.theme-dark .btn.secondary {
  background: #374353;
  color: #e2e9f2;
}

body.theme-dark .btn.ghost {
  background: #2c3744;
  color: #d7e0ea;
  border-color: #4a5a70;
}

body.theme-dark .btn.ghost.active {
  border-color: #7d613f;
  background: #3d3228;
  color: #f0d3b1;
}

body.theme-dark .btn.ghost.danger {
  background: #432c30;
  border-color: #7a4b50;
  color: #f0b2a9;
}

body.theme-dark .search {
  background: #1f2933;
  border-color: #4a5b72;
  color: #e6edf4;
}

body.theme-dark .search::placeholder {
  color: #92a0b1;
}

body.theme-dark .chip {
  background: #2d3744;
  border-color: #4a5b71;
  color: #d4deea;
}

body.theme-dark .chip.active {
  background: #3b3026;
  border-color: #74583f;
  color: #f0d2af;
}

body.theme-dark .tab {
  background: #2e3947;
  border-color: #4a5c72;
  color: #d4deea;
}

body.theme-dark .tab.active {
  background: #3b3026;
  border-color: #74583f;
  color: #f0d2af;
}

body.theme-dark .card {
  background: #27313d;
  border-color: #435469;
  box-shadow: none;
}

body.theme-dark .card:hover {
  border-color: #5d7088;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
}

body.theme-dark .card.active {
  border-color: #8a6a4f;
  background: linear-gradient(180deg, #2d3642 0%, #312e2a 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

body.theme-dark .card p {
  color: #b8c2ce;
}

body.theme-dark .meta {
  color: #9ca8b5;
}

body.theme-dark .tag {
  color: #cfb69a;
  background: #382f27;
  border-color: #6a5644;
}

body.theme-dark .chapter-push-btn {
  background: #3b3025;
  border-color: #73573f;
  color: #efd4b3;
}

body.theme-dark .chapter-push-btn:disabled {
  opacity: 0.42;
}

body.theme-dark .reader .summary {
  color: #ddcbba;
  background: linear-gradient(90deg, #3d2f24 0%, #2f2620 100%);
  border-left-color: #9c6f49;
}

body.theme-dark .reader .summary > strong {
  color: #f0ceab;
}

body.theme-dark .chapter-top {
  color: #a0aab8;
}

body.theme-dark .chapter-runtime {
  color: #f1d4b4;
  border-color: #6f553d;
  background: #3b2f24;
}

body.theme-dark .reader-loading {
  border-color: #425366;
  background: #222c37;
}

body.theme-dark .skeleton-line {
  background: linear-gradient(90deg, #303c4b 25%, #3a4858 50%, #303c4b 75%);
  background-size: 200% 100%;
}

body.theme-dark .quality-pill {
  border-color: #6e5842;
  background: #3b3025;
  color: #efd1af;
}

body.theme-dark .review-card {
  background: #27313d;
  border-color: #435469;
}

body.theme-dark .review-card h4 {
  color: #e4ebf3;
}

body.theme-dark .review-card p {
  color: #c6d0dc;
}

body.theme-dark .task-row {
  background: #27313d;
  border-color: #435469;
}

body.theme-dark .task-type,
body.theme-dark .task-stage,
body.theme-dark .task-timeline-stage {
  color: #d8e1eb;
}

body.theme-dark .task-status {
  color: #f1d0ad;
  background: #3a3025;
  border-color: #6d573f;
}

body.theme-dark .task-project,
body.theme-dark .task-meta,
body.theme-dark .task-timeline-time {
  color: #a6b2bf;
}

body.theme-dark .task-timeline {
  border-color: #495a70;
  background: #242f3a;
}

body.theme-dark .task-timeline-empty {
  color: #afbbc7;
}

body.theme-dark .reader-editor input,
body.theme-dark .reader-editor textarea,
body.theme-dark .dialog-form input,
body.theme-dark .dialog-form textarea,
body.theme-dark .dialog-form select {
  background: #1f2833;
  border-color: #4a5b72;
  color: #e8eef5;
}

body.theme-dark .dialog-form input::placeholder,
body.theme-dark .dialog-form textarea::placeholder {
  color: #8f9caf;
}

body.theme-dark dialog {
  background: #202a34;
  border: 1px solid #44556a;
  color: var(--text);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.44);
}

body.theme-dark dialog::backdrop {
  background: rgba(5, 9, 13, 0.65);
}

body.theme-dark .dialog-form h3 {
  color: #e6edf5;
}

body.theme-dark .fanqie-preview {
  background: #202933;
  border-color: #43556c;
  color: #c4ceda;
}

body.theme-dark .fanqie-preview-row {
  border-bottom-color: #45566d;
}

body.theme-dark .empty-note {
  background: #25303b;
  border-color: #43546a;
  color: #b7c2ce;
}

.command-key {
  font-size: 11px;
  color: #8e7c67;
}

.command-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
}

.dialog-form h3 {
  margin: 0 0 14px;
}

.create-mode-switch {
  display: inline-flex;
  gap: 8px;
  margin: 0 0 12px;
}

.project-import-grid {
  margin-top: 2px;
}

.project-import-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grid.fanqie-grid {
  grid-template-columns: 1fr;
}

.fanqie-preview {
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  color: #6a5b4a;
  font-size: 12px;
}

.fanqie-preview-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed #eadfce;
}

.fanqie-preview-row:last-child {
  border-bottom: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

label.full {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.empty-note {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  background: #faf8f4;
}

/* Home page */
body.home-page {
  height: auto;
  min-height: 100vh;
}

.home-topbar {
  gap: 10px;
}

.home-search {
  max-width: 440px;
  flex: 1;
}

.home-top-stats {
  margin-left: auto;
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 6px;
  align-items: stretch;
}

.home-top-stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 5px 8px;
  min-width: 0;
}

.home-top-stat-action {
  cursor: pointer;
  text-align: left;
  color: inherit;
}

.home-top-stat-action.active {
  border-color: #d8b08a;
  background: var(--accent-soft);
}

.home-top-stat .label {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.home-top-stat .value {
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 700;
}

.home-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 18px auto 24px;
  display: grid;
  gap: 14px;
}

.home-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.home-intro {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 420px);
  gap: 12px;
  align-items: center;
}

.home-intro h1 {
  margin: 0;
  font-size: 28px;
}

.home-intro p {
  margin: 8px 0 0;
  color: var(--muted);
}

.home-hero-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.home-capabilities-head {
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.home-capabilities-head h2 {
  margin: 0;
  font-size: 18px;
}

.home-capabilities-head span {
  color: var(--muted);
  font-size: 12px;
}

.home-capability-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.home-capability-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.home-capability-card:hover {
  border-color: #d9ad84;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(115, 77, 34, 0.12);
}

.home-capability-card strong {
  display: block;
  font-size: 15px;
}

.home-capability-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.ui-toast {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 120;
  min-width: 220px;
  max-width: min(460px, calc(100vw - 20px));
  border-radius: 10px;
  border: 1px solid #e0cab1;
  background: #fff8ee;
  color: #6b4427;
  box-shadow: 0 12px 26px rgba(76, 47, 17, 0.2);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.ui-toast.error {
  border-color: #e2b1ac;
  background: #fff1ef;
  color: #9a2d2d;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.home-stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 10px 12px;
}

.home-stat .label {
  font-size: 12px;
  color: var(--muted);
}

.home-stat .value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
}

.home-filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.home-filter-toolbar {
  padding: 0;
  border: 0;
}

.home-hint {
  font-size: 12px;
  color: var(--muted);
}

.home-book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.book-card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 9px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.book-card:hover {
  transform: translateY(-1px);
  border-color: #d9ad84;
  box-shadow: 0 10px 22px rgba(115, 77, 34, 0.12);
}

.book-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.book-card-head h3 {
  margin: 0;
  font-size: 18px;
}

.book-desc {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  min-height: 58px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-actions {
  display: flex;
  justify-content: flex-end;
}

.home-advanced {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf8f4;
  padding: 6px 8px;
}

.home-advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

body.theme-dark .home-advanced {
  background: #2b333c;
}

body.theme-dark .ui-toast {
  border-color: #566171;
  background: #303842;
  color: #e9d7c3;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.34);
}

@keyframes pulse-dot {
  0% {
    opacity: 0.45;
    transform: scale(0.88);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.45;
    transform: scale(0.88);
  }
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (max-width: 1250px) {
  .home-book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-capability-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    --left-col: 260px;
    --middle-col: 320px;
    grid-template-columns: var(--left-col) var(--middle-col) minmax(460px, 1fr);
  }

  .agent-pulse {
    top: 70px;
    right: 10px;
  }
}

@media (max-width: 980px) {
  body {
    min-height: 100dvh;
  }

  body.home-page .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .home-search {
    width: 100%;
    max-width: none;
    min-width: 0;
    order: 10;
  }

  .home-top-stats {
    order: 6;
    margin-left: 0;
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    gap: 5px;
  }

  .home-top-stat {
    padding: 4px 7px;
  }

  .home-top-stat .value {
    font-size: 16px;
  }

  .home-panel {
    padding: 12px;
    border-radius: 14px;
  }

  .home-shell {
    width: calc(100% - 14px);
    margin-top: 8px;
    margin-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  .home-book-grid {
    grid-template-columns: 1fr;
  }

  .home-capability-grid {
    grid-template-columns: 1fr;
  }

  .home-filter-row {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 8px;
  }

  .home-filter-toolbar {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .panel-resizer {
    display: none !important;
  }

  .panel-splitter {
    display: none !important;
  }

  .topbar {
    height: auto;
    padding: max(8px, env(safe-area-inset-top, 0px)) 10px 8px;
    flex-wrap: nowrap;
  }

  .brand-wrap {
    min-width: auto;
  }

  .mobile-only {
    display: inline-flex;
  }

  .mobile-reader-actions .btn {
    min-width: 60px;
  }

  .mobile-reader-actions {
    margin-left: auto;
    gap: 6px;
    align-items: center;
  }

  #project-search,
  #command-open-btn,
  #theme-toggle-btn,
  #status-wrap,
  #new-project-btn {
    display: none;
  }

  .panel-left,
  .panel-middle {
    display: none;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(88vw, 360px);
    z-index: 60;
    border-right: 1px solid var(--line);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.24);
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.mobile-drawer-projects .panel-left {
    display: flex;
  }

  body.mobile-drawer-chapters .panel-middle {
    display: flex;
  }

  body.mobile-drawer-projects .mobile-drawer-backdrop,
  body.mobile-drawer-chapters .mobile-drawer-backdrop {
    display: block !important;
  }

  .panel-right {
    min-height: 0;
  }

  .panel-head {
    min-height: 52px;
    height: auto;
    padding: 8px 12px;
  }

  .toolbar {
    gap: 7px;
    padding: 8px 10px;
  }

  .toolbar.compact {
    gap: 6px;
    padding: 7px 10px;
  }

  .btn {
    height: 36px;
    padding: 0 11px;
  }

  .chip {
    height: 32px;
    padding: 0 10px;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .panel-middle > .toolbar:first-of-type {
    display: none;
  }

  .panel-middle #auto-full-progress {
    display: none !important;
  }

  #star-btn,
  #tts-btn,
  #fanqie-push-current-btn,
  #rewrite-btn,
  #review-btn,
  #edit-chapter-btn,
  #focus-mode-btn,
  #save-chapter-btn,
  #cancel-edit-btn {
    display: none !important;
  }

  #line-width-wrap,
  #tts-audio,
  #line-width {
    display: none !important;
  }

  #read-toolbar {
    top: 0;
    padding: 8px 10px;
    gap: 6px;
  }

  #read-toolbar .btn {
    height: 34px;
  }

  #font-size {
    width: 102px;
  }

  .reader h2 {
    font-size: 22px;
    margin-bottom: 8px;
  }

  .reader,
  .doc-pane {
    padding: 14px 14px calc(20px + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
  }

  .reader .content,
  .doc-pane {
    line-height: 1.78;
  }

  dialog {
    width: min(860px, calc(100vw - 16px));
    border-radius: 12px;
    max-height: calc(100dvh - 16px);
  }

  .dialog-form {
    padding: 14px;
    max-height: calc(100dvh - 20px);
    overflow: auto;
  }

  .dialog-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--paper), rgba(247, 245, 239, 0.92));
    padding-top: 8px;
    margin-top: 12px;
  }

  body.theme-dark .dialog-actions {
    background: linear-gradient(to top, #232a31, rgba(35, 42, 49, 0.92));
  }

  .ui-toast {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    max-width: none;
    min-width: 0;
  }

  .agent-pulse {
    right: 10px;
    top: calc(62px + env(safe-area-inset-top, 0px));
    max-width: calc(100vw - 20px);
  }
}

@media (max-width: 640px) {
  .topbar {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .brand-logo {
    height: 40px;
  }

  .top-icon-btn {
    min-width: 38px;
    height: 32px;
    padding: 0 8px;
  }

  .home-top-stats {
    width: 100%;
    order: 11;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-left: 0;
  }

  .home-top-stat {
    padding: 4px 6px;
  }

  .home-top-stat .label {
    font-size: 10px;
  }

  .home-top-stat .value {
    font-size: 14px;
  }

  .home-panel {
    padding: 11px;
  }

  .home-hint {
    font-size: 11px;
  }

  .book-card {
    padding: 10px;
    gap: 7px;
  }

  .book-card-head h3 {
    font-size: 16px;
  }

  .book-desc {
    font-size: 12px;
    min-height: 0;
  }

  .panel-left,
  .panel-middle {
    width: min(92vw, 340px);
  }

  .panel-head {
    padding: 8px 10px;
  }

  .toolbar,
  .toolbar.compact {
    padding-left: 8px;
    padding-right: 8px;
  }

  .btn {
    height: 35px;
    font-size: 13px;
  }

  .chip {
    height: 31px;
    font-size: 12px;
  }

  .reader,
  .doc-pane {
    padding: 12px 12px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .reader h2 {
    font-size: 20px;
  }

  .reader .summary {
    padding: 8px 9px;
    margin-bottom: 12px;
  }

  .reader .content {
    font-size: 16px;
    line-height: 1.8;
  }

  dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 10px;
  }

  .dialog-form {
    padding: 12px;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
