/* Genesis 2 — Core Styles */
/* iPad-optimized writing studio */

@import url('themes.css');

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: fixed;
  touch-action: manipulation;
}

/* Prevent iOS rubber-band scrolling on body */
body.no-bounce {
  overscroll-behavior: none;
}

/* ============================================
   App Shell
   ============================================ */

#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) var(--chapter-nav-width, 220px) 1fr;
  grid-template-rows: var(--toolbar-height) 1fr var(--status-height);
  grid-template-areas:
    "sidebar chapnav toolbar"
    "sidebar chapnav editor"
    "sidebar chapnav status";
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#app.sidebar-collapsed {
  grid-template-columns: 0 var(--chapter-nav-width, 220px) 1fr;
}

#app.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

#app.chapnav-collapsed {
  --chapter-nav-width: 0px;
}

#app.chapnav-collapsed .chapter-nav {
  transform: translateX(-100%);
  width: 0;
  overflow: hidden;
}

#app.focus-mode {
  grid-template-columns: 0 0 1fr;
  grid-template-rows: 0 1fr 0;
}

#app.focus-mode .sidebar,
#app.focus-mode .chapter-nav,
#app.focus-mode .toolbar,
#app.focus-mode .status-bar {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

#app.focus-mode .status-bar {
  transform: translateY(100%);
}

/* Focus mode exit button — only visible in focus mode */
.focus-exit-btn {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  touch-action: manipulation;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.focus-exit-btn:hover,
.focus-exit-btn:active {
  opacity: 1;
}

/* JS toggles display:flex/none on #btn-exit-focus directly */

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  grid-area: sidebar;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--toolbar-height);
}

.sidebar-header h1 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--accent-primary);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-nav button {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  touch-action: manipulation;
}

.sidebar-nav button.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.sidebar-nav button:hover {
  color: var(--text-primary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Sidebar Cover */
.sidebar-cover {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.cover-image-container {
  position: relative;
  width: 100%;
  max-width: 180px;
  margin: 0 auto;
}

.cover-image {
  width: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: block;
}

.cover-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.cover-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
}

/* Project Card Cover */
.project-card-inner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.project-card-cover {
  width: 60px;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.project-card-cover-empty {
  width: 60px;
  height: 90px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px dashed var(--border-color);
}

.project-card-info {
  flex: 1;
  min-width: 0;
}

/* Export Cover Preview */
.export-cover-preview {
  width: 100%;
  max-width: 200px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  margin-bottom: 12px;
}

/* Manuscript Tree */
.tree-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: background 0.15s;
  touch-action: manipulation;
  min-height: 44px; /* iPad touch target */
  user-select: none;
  -webkit-user-select: none;
}

.tree-item:hover,
.tree-item:active {
  background: var(--accent-subtle);
}

.tree-item.active {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  font-weight: 600;
}

.tree-item.chapter {
  font-weight: 600;
  color: var(--text-primary);
}

.tree-item.scene {
  padding-left: 28px;
  font-size: 0.85rem;
}

.tree-item .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.tree-item .word-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.chapter-delete-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  margin-left: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}

.chapter-delete-btn:hover {
  color: var(--danger);
  background: rgba(231, 76, 60, 0.1);
}

.tree-item.chapter:hover .chapter-delete-btn {
  display: inline-flex;
}

@media (pointer: coarse) {
  .chapter-delete-btn {
    display: inline-flex;
  }
  .chapter-menu-btn {
    display: inline-flex;
  }
}

/* Chapter action menu (⋮ button and dropdown) */
.chapter-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  margin-left: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}

.chapter-menu-btn:hover {
  color: var(--text-primary);
  background: var(--accent-subtle);
}

.tree-item.chapter:hover .chapter-menu-btn {
  display: inline-flex;
}

.chapter-menu {
  display: none;
  position: absolute;
  right: 8px;
  top: 100%;
  z-index: 9999;
  min-width: 180px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  padding: 4px 0;
  overflow: hidden;
}

.tree-item.chapter {
  position: relative;
}

.chapter-menu.open {
  display: block;
}

.chapter-menu button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.chapter-menu button:hover {
  background: var(--accent-subtle);
}

.chapter-menu button.danger {
  color: var(--danger);
}

.chapter-menu button.danger:hover {
  background: rgba(231, 76, 60, 0.1);
}

/* Chapter Toolbar (Select All, Delete Selected, Accept Outline) — moved to chapter nav toolbar */
.chapter-toolbar {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.chapter-select-all-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

.chapter-select-all-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.chapter-toolbar-btn {
  font-size: 0.7rem !important;
  padding: 4px 8px !important;
  min-height: 28px;
  white-space: nowrap;
}

.chapter-delete-selected-btn {
  border-color: var(--danger) !important;
  color: var(--danger) !important;
  margin-left: auto;
}

.chapter-delete-selected-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chapter-delete-selected-btn:not(:disabled):hover {
  background: rgba(231, 76, 60, 0.1);
}

.chapter-accept-outline-btn {
  border-color: var(--accent-primary) !important;
  color: var(--accent-primary) !important;
}

.chapter-accept-outline-btn:hover {
  background: var(--accent-subtle);
}

/* Chapter Checkbox */
.chapter-checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--accent-primary);
}

/* New item button */
.tree-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  margin: 4px 0;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  width: 100%;
  min-height: 44px;
  touch-action: manipulation;
}

.tree-add:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ============================================
   Toolbar
   ============================================ */

.toolbar {
  grid-area: toolbar;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  transition: all 0.3s ease;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-group + .toolbar-group {
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
}

.toolbar-btn {
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  touch-action: manipulation;
}

.toolbar-btn:hover,
.toolbar-btn:active {
  background: var(--accent-subtle);
  color: var(--accent-primary);
}

.toolbar-btn.active {
  background: var(--accent-subtle);
  color: var(--accent-primary);
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-title {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
  padding: 0 12px;
}

/* ============================================
   Editor Area
   ============================================ */

.editor-area {
  grid-area: editor;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-editor);
  padding: 40px 20px;
}

.editor-container {
  width: 100%;
  max-width: 720px;
  min-height: 100%;
}

.editor {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.85;
  color: var(--text-editor);
  outline: none;
  min-height: 60vh;
  padding: 20px 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  caret-color: var(--accent-primary);
}

/* Multi-Chapter Read-Only View */
.editor.multi-chapter-view {
  cursor: default;
}

/* Multi-Chapter Split View — originals left, translations right */
.editor-area.multi-chapter-split {
  display: flex;
  gap: 0;
  padding: 0;
  overflow: hidden; /* parent must NOT scroll — children scroll independently */
}

.editor-area.multi-chapter-split .editor-container {
  flex: 1;
  min-width: 0;
  max-width: none;
  padding: 0;           /* padding goes on inner editor */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  height: 100%;          /* fill grid cell height */
  min-height: 0;         /* override base min-height: 100% */
  box-sizing: border-box;
}

/* Left pane gets a right border */
.editor-area.multi-chapter-split > .editor-container:first-child {
  border-right: 2px solid var(--border-color);
}

/* Override editor min-height in split mode */
.editor-area.multi-chapter-split .editor {
  min-height: 0;
  padding: 40px 20px;
}

/* Right pane (translation) */
.editor-area.multi-chapter-split .translation-pane {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
}

/* Hide translation pane header/progress in split mode */
.editor-area.multi-chapter-split .translation-pane .editor-pane-header,
.editor-area.multi-chapter-split .translation-pane .translation-progress {
  display: none !important;
}

/* The editor inside translation pane needs to scroll */
.editor-area.multi-chapter-split .translation-pane .editor {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 40px 20px;
}

/* Hide illustration gallery & welcome in split mode */
.editor-area.multi-chapter-split #chapter-illustrations-gallery,
.editor-area.multi-chapter-split #welcome-overlay {
  display: none !important;
}

.editor-area.multi-chapter-split .multi-split-content {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.85;
  color: var(--text-editor);
  max-width: 720px;
  margin: 0 auto;
}

.multi-split-pane-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* Mobile: stack vertically in split mode */
@media (max-width: 768px) {
  .editor-area.multi-chapter-split {
    flex-direction: column;
  }
  .editor-area.multi-chapter-split .editor-container {
    flex: none;
    height: 50%;
    border-right: none !important;
    border-bottom: 2px solid var(--border-color);
  }
  .editor-area.multi-chapter-split .translation-pane {
    flex: none;
    height: 50%;
  }
}

.multi-chapter-separator {
  text-align: center;
  padding: 32px 0 16px;
  user-select: none;
}

.multi-chapter-separator:first-child {
  padding-top: 0;
}

.multi-chapter-divider {
  border-top: 2px solid var(--border-color, #444);
  margin-bottom: 12px;
}

.multi-chapter-separator:first-child .multi-chapter-divider {
  display: none;
}

.multi-chapter-label {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: 0.5px;
}

.multi-chapter-wordcount {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.multi-chapter-content {
  padding-bottom: 24px;
}

.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  font-style: italic;
}

.editor p {
  margin-bottom: 0.8em;
  text-indent: 1.5em;
}

.editor p:first-child {
  text-indent: 0;
}

.editor h1, .editor h2, .editor h3 {
  font-family: var(--font-serif);
  margin: 1.2em 0 0.6em;
  text-indent: 0;
}

.editor blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 1.2em;
  margin: 1em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.editor em {
  font-style: italic;
}

.editor strong {
  font-weight: 700;
}

/* Chapter heading in editor */
.chapter-heading {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5em;
  padding-bottom: 0.5em;
  border-bottom: 2px solid var(--border-color);
  text-indent: 0 !important;
  outline: none;
}

/* ============================================
   Status Bar
   ============================================ */

.status-bar {
  grid-area: status;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  gap: 20px;
  transition: all 0.3s ease;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.status-item .label {
  opacity: 0.7;
}

.status-item .value {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.status-spacer {
  flex: 1;
}

/* ============================================
   Panels (Analysis, Characters, etc.)
   ============================================ */

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.panel-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(420px, 85vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel.visible {
  transform: translateX(0);
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.panel-header h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-primary);
}

.panel-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
}

.panel-close:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

/* ============================================
   Full-Screen Cover Editor
   ============================================ */

.cover-editor-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg-primary);
  flex-direction: column;
}

.cover-editor-overlay.visible {
  display: flex;
}

.cover-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  min-height: 48px;
  flex-shrink: 0;
}

.cover-editor-header h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-primary);
  margin: 0;
}

.cover-editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.cover-editor-canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  background: #1a1a1a;
}

.cover-editor-canvas-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: calc(100vh - 130px);
}

.cover-editor-canvas-wrapper canvas {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  cursor: crosshair;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  touch-action: none;
}

.ce-canvas-info {
  margin-top: 10px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  text-align: center;
}

.cover-editor-controls {
  width: 380px;
  min-width: 320px;
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
  padding: 12px;
  flex-shrink: 0;
}

/* Sections */
.ce-section {
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ce-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 10px;
  margin: 0;
  cursor: pointer;
  background: var(--bg-secondary);
  color: var(--text-primary);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ce-section-title::after {
  content: '\25BC';
  font-size: 0.65rem;
  opacity: 0.5;
  transition: transform 0.2s;
}

.ce-section-title.collapsed::after {
  transform: rotate(-90deg);
}

.ce-section-body {
  padding: 10px;
}

.ce-section-body.collapsed {
  display: none;
}

/* Layout helpers */
.ce-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.ce-half { flex: 1; }
.ce-third { flex: 1; min-width: 0; }

.ce-row .form-group { margin-bottom: 0; }
.ce-section-body .form-group { margin-bottom: 8px; }
.ce-section-body label { font-size: 0.78rem; display: block; margin-bottom: 2px; color: var(--text-muted); }
.ce-section-body .form-input { font-size: 0.82rem; padding: 5px 8px; }

/* Text block cards */
.ce-block {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.ce-block.selected {
  border-color: var(--accent-primary);
}

.ce-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  user-select: none;
  gap: 4px;
}

.ce-block-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ce-block-body {
  padding: 8px;
  display: none;
}

.ce-block.expanded .ce-block-body {
  display: block;
}

.ce-block-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 1px 4px;
  border-radius: 2px;
  line-height: 1;
}

.ce-block-btn:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.ce-block-remove:hover {
  color: var(--danger);
}

.ce-color-input {
  width: 100%;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 1px;
}

.ce-check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-primary);
}

.ce-check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.ce-details {
  margin-top: 6px;
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
}

.ce-details summary {
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  margin-bottom: 6px;
  user-select: none;
}

.ce-details summary:hover {
  color: var(--text-primary);
}

/* Slider + number combo */
.ce-slider-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ce-slider-group input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.ce-slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-surface);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.1s;
}

.ce-slider-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.ce-slider-group input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.1);
  background: var(--accent-secondary, var(--accent-primary));
}

.ce-slider-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-surface);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.ce-slider-group input[type="range"]::-moz-range-track {
  background: var(--border-color);
  height: 6px;
  border-radius: 3px;
}

.ce-slider-group input[type="number"] {
  width: 54px;
  flex-shrink: 0;
  font-size: 0.78rem;
  padding: 3px 4px;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.ce-slider-group input[type="number"]:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.ce-unit-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 14px;
}

/* Responsive: stack on narrow screens */
@media (max-width: 768px) {
  .cover-editor-body {
    flex-direction: column;
  }
  .cover-editor-controls {
    width: 100%;
    min-width: unset;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: 45vh;
  }
  .cover-editor-canvas-wrapper canvas {
    max-height: 40vh;
  }
}

/* ============================================
   Analysis Widgets
   ============================================ */

.analysis-section {
  margin-bottom: 24px;
}

.analysis-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.meter {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.meter-fill.good { background: var(--success); }
.meter-fill.warning { background: var(--warning); }
.meter-fill.danger { background: var(--danger); }
.meter-fill.info { background: var(--info); }

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.word-tag {
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.word-tag .count {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: 4px;
}

/* Sentence length visualization */
.sentence-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 60px;
  padding: 4px 0;
}

.sentence-bar {
  flex: 1;
  min-width: 3px;
  max-width: 8px;
  background: var(--accent-primary);
  border-radius: 2px 2px 0 0;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.sentence-bar:hover {
  opacity: 1;
}

.sentence-bar.short { background: var(--info); }
.sentence-bar.medium { background: var(--success); }
.sentence-bar.long { background: var(--warning); }
.sentence-bar.very-long { background: var(--danger); }

/* ============================================
   Modals & Dialogs
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(500px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  min-height: 44px;
  touch-action: manipulation;
  transition: all 0.15s;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:hover, .btn:active {
  background: var(--accent-subtle);
}

.btn-primary {
  background: #007AFF;
  color: #ffffff;
  border-color: #007AFF;
  font-weight: 600;
}

.btn-primary:hover {
  background: #0062CC;
  border-color: #0062CC;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  min-height: 36px;
}

.btn-icon {
  padding: 8px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   Form Elements
   ============================================ */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  min-height: 44px;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

textarea.form-input {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ============================================
   Character Cards
   ============================================ */

.character-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
}

.character-card:hover, .character-card:active {
  background: var(--accent-subtle);
}

.character-card .name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.character-card .role {
  font-size: 0.8rem;
  color: var(--accent-primary);
  margin-top: 2px;
}

.character-card .desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

/* ============================================
   Story Structure
   ============================================ */

.beat-sheet {
  border-left: 3px solid var(--border-color);
  margin-left: 8px;
}

.beat-item {
  position: relative;
  padding: 12px 16px 12px 24px;
  margin-bottom: 4px;
}

.beat-item::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-color);
  border: 2px solid var(--bg-surface);
}

.beat-item.completed::before {
  background: var(--accent-primary);
}

.beat-item .beat-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.beat-item .beat-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.beat-item .beat-percent {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-primary);
  margin-top: 4px;
}

/* ============================================
   Welcome / Empty State
   ============================================ */

.welcome {
  text-align: center;
  padding: 60px 24px;
  max-width: 480px;
  margin: 0 auto;
}

.welcome h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.welcome p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 32px;
}

.welcome .btn {
  font-size: 1rem;
  padding: 14px 32px;
}

/* ============================================
   iPad-specific optimizations
   ============================================ */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }
}

@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toolbar"
      "editor"
      "status";
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 150;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .chapter-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--chapter-nav-width);
    z-index: 140;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .chapter-nav.mobile-open {
    transform: translateX(0);
  }
}

/* iPad Split View */
@media (min-width: 768px) and (max-width: 1024px) {
  .editor {
    font-size: 1.1rem;
  }
}

/* iPad Pro landscape */
@media (min-width: 1024px) and (max-width: 1400px) {
  .editor {
    font-size: 1.15rem;
  }
}

/* Touch device optimizations */
@media (pointer: coarse) {
  .tree-item {
    min-height: 48px;
    padding: 10px 12px;
  }

  .toolbar-btn {
    min-width: 48px;
    min-height: 48px;
  }
}

/* Safe area support for iPad */
@supports (padding: env(safe-area-inset-top)) {
  .toolbar {
    padding-top: env(safe-area-inset-top);
  }

  .status-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sidebar {
    padding-left: env(safe-area-inset-left);
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============================================
   Floating Word Count
   ============================================ */

.floating-word-count {
  position: fixed;
  bottom: calc(var(--status-height) + 12px);
  right: 20px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  z-index: 40;
  opacity: 0.7;
  transition: opacity 0.2s;
  pointer-events: none;
}

.floating-word-count:hover {
  opacity: 1;
}

.fwc-divider {
  color: var(--border-color);
  margin: 0 4px;
}

#fwc-words {
  color: var(--accent-primary);
  font-weight: 600;
}

/* ============================================
   Continue Writing Bar
   ============================================ */

.continue-bar {
  position: fixed;
  bottom: calc(var(--status-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-width: 600px;
  width: calc(100% - 32px);
  animation: slideUp 0.3s ease;
  align-items: center;
}

.continue-bar .continue-word-btn {
  font-size: 0.8rem;
  padding: 8px 4px;
  min-width: 0;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.continue-bar .generating-text {
  font-size: 0.85rem;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

/* ============================================
   AI Generate Spinner
   ============================================ */

.generate-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Scoring Progress Bar
   ============================================ */

.scoring-progress-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
}

.scoring-progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary, var(--accent-primary)));
  width: 30%;
  animation: scoring-progress 1.5s ease-in-out infinite;
}

@keyframes scoring-progress {
  0% { margin-left: 0%; width: 30%; }
  50% { margin-left: 40%; width: 40%; }
  100% { margin-left: 70%; width: 30%; }
}

/* ============================================
   Iterative Writing Progress
   ============================================ */

.iterative-score-display {
  margin: 12px 0;
}

.iterative-score-number {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
  transition: color 0.3s;
}

.iterative-score-number.score-poor { color: var(--danger); }
.iterative-score-number.score-fair { color: var(--warning); }
.iterative-score-number.score-good { color: var(--info, #17a2b8); }
.iterative-score-number.score-excellent { color: var(--success); }

.iterative-progress-bar {
  position: relative;
  height: 12px;
  background: var(--border-color);
  border-radius: 6px;
  overflow: visible;
}

.iterative-progress-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--danger);
  transition: width 0.5s ease, background 0.5s ease;
}

.iterative-progress-fill.score-fair { background: var(--warning); }
.iterative-progress-fill.score-good { background: var(--info, #17a2b8); }
.iterative-progress-fill.score-excellent { background: var(--success); }

.iterative-progress-threshold {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 90%;
  width: 2px;
  background: var(--success);
  border-radius: 1px;
  opacity: 0.8;
}

/* Prominent scoring notice for iterative writing */
.iterative-scoring-notice {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  margin: 12px 0;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  animation: iterative-scoring-pulse 1.8s ease-in-out infinite;
}

.iterative-scoring-notice.visible {
  display: flex;
}

.iterative-scoring-notice .scoring-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: iterative-scoring-dot 1s ease-in-out infinite;
}

.iterative-scoring-notice .scoring-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

@keyframes iterative-scoring-pulse {
  0%, 100% { border-color: var(--accent-primary); box-shadow: 0 0 0 0 rgba(var(--accent-primary-rgb, 79, 140, 255), 0); }
  50% { border-color: var(--accent-primary); box-shadow: 0 0 8px 2px rgba(var(--accent-primary-rgb, 79, 140, 255), 0.25); }
}

@keyframes iterative-scoring-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.iterative-chunk-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

/* ============================================
   Landing Page
   ============================================ */

#landing-page {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 500;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.landing-view {
  min-height: 100vh;
  min-height: 100dvh;
}

/* User Selection */
.landing-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 20px;
}

.landing-logo {
  text-align: center;
  margin-bottom: 40px;
}

.landing-logo h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  color: var(--accent-primary);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.landing-logo p {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.landing-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.landing-card h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 20px;
  text-align: center;
}

.user-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.user-list:empty {
  display: none;
}

.user-btn {
  padding: 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
  transition: all 0.15s;
  flex: 1;
  min-width: 100px;
  text-align: center;
}

.user-btn:hover, .user-btn:active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-subtle);
}

.landing-input-row {
  display: flex;
  gap: 8px;
}

.landing-input-row .form-input {
  flex: 1;
}

.landing-error {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  background: rgba(231, 76, 60, 0.1);
}

/* Project Selection */
.landing-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.landing-top-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.landing-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--accent-primary);
  font-weight: 700;
}

.landing-welcome {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.landing-body {
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
}

.landing-create-btn {
  width: 100%;
  margin-bottom: 32px;
  padding: 14px 24px;
  font-size: 1rem;
}

.projects-section {
  margin-bottom: 32px;
}

.projects-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
}

.project-card:hover, .project-card:active {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
}

.project-card-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.project-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.project-genre {
  color: var(--accent-primary);
}

.project-card-goal {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-family: var(--font-mono);
}

.projects-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.owner-group {
  margin-bottom: 20px;
}

.owner-group h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Loading state */
.landing-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .landing-top-left {
    flex-direction: column;
    gap: 2px;
  }

  .landing-card {
    padding: 24px 20px;
  }

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

/* Print book container — hidden on screen, visible only when printing */
#print-book-container {
  display: none;
}

/* Print styles for manuscript export */
@media print {
  /* When the print-book-container exists, hide the app and show the container */
  #print-book-container {
    display: block !important;
    position: static !important;
    overflow: visible !important;
    height: auto !important;
    width: 100% !important;
  }

  /* Hide the entire app UI when printing the full book */
  body:has(#print-book-container) #app,
  #app[style*="display: none"] {
    display: none !important;
  }

  body {
    background: white;
    color: black;
    position: static;
    overflow: visible;
    height: auto;
    margin: 0;
    padding: 0;
  }

  #app {
    display: block;
    height: auto;
  }

  .sidebar, .toolbar, .status-bar, .panel, .panel-overlay {
    display: none !important;
  }

  .editor-area {
    padding: 0;
    overflow: visible;
  }

  .editor {
    font-family: 'Courier New', monospace;
    font-size: 12pt;
    line-height: 2;
    color: black;
  }

  .editor p {
    text-indent: 0.5in;
  }

  .chapter-heading {
    page-break-before: always;
    text-align: center;
    font-size: 14pt;
    margin-top: 3in;
  }

  /* Print book styles */
  #print-book-container {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12pt;
    line-height: 2;
    color: black;
    background: white;
  }

  .print-title-page {
    text-align: center;
    padding-top: 33%;
    page-break-after: always;
  }

  .print-title-page h1 {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14pt;
    text-transform: uppercase;
    margin-bottom: 24pt;
  }

  .print-title-page .print-byline {
    font-size: 12pt;
  }

  .print-title-page .print-wordcount {
    margin-top: 48pt;
    font-size: 12pt;
  }

  .print-chapter {
    page-break-before: always;
  }

  .print-chapter-heading {
    padding-top: 33%;
    text-align: center;
    margin-bottom: 48pt;
  }

  .print-chapter-heading h2 {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14pt;
    text-transform: uppercase;
    font-weight: bold;
  }

  .print-chapter-content p {
    text-indent: 0.5in;
    margin: 0;
  }

  .print-chapter-content p:first-of-type {
    text-indent: 0;
  }

  .print-illustration {
    text-align: center;
    margin: 24pt 0;
    page-break-inside: avoid;
  }

  .print-illustration img {
    max-width: 100%;
    max-height: 6in;
  }

  .print-illustration figcaption {
    font-style: italic;
    font-size: 10pt;
    margin-top: 6pt;
  }
}

/* ============================================
   Flyout Tooltips
   ============================================ */

#tooltip-flyout {
  display: none;
  position: fixed;
  z-index: 100000;
  max-width: 300px;
  padding: 10px 14px;
  background: rgba(20, 20, 30, 0.95);
  color: #f0f0f0;
  font-size: 0.82rem;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
}

#tooltip-flyout.visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

#tooltip-flyout .tooltip-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: #fff;
}

#tooltip-flyout .tooltip-body {
  color: rgba(240,240,240,0.85);
}

#tooltip-flyout::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(20, 20, 30, 0.95);
  transform: rotate(45deg);
  border: 1px solid rgba(255,255,255,0.1);
}

#tooltip-flyout.arrow-top::before {
  top: -6px;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%) rotate(45deg);
  border-bottom: none;
  border-right: none;
}

#tooltip-flyout.arrow-bottom::before {
  bottom: -6px;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%) rotate(45deg);
  border-top: none;
  border-left: none;
}

/* On light/sepia themes, darken tooltip further */
[data-theme="light"] #tooltip-flyout,
[data-theme="sepia"] #tooltip-flyout {
  background: rgba(30, 30, 40, 0.97);
}

/* ============================================
   Setup Book Pill
   ============================================ */

.sidebar-setup-book {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
}

.setup-book-pill {
  width: 100%;
  padding: 8px 16px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-primary);
  border-radius: 20px;
  color: var(--accent-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  touch-action: manipulation;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.setup-book-pill:hover,
.setup-book-pill:active {
  background: var(--accent-primary);
  color: #1a1a2e;
}

/* ============================================
   New Project Help Modal
   ============================================ */

.new-project-help-modal {
  width: min(640px, 92vw) !important;
  max-height: 88vh !important;
}

#new-project-help-overlay,
#new-project-overlay {
  z-index: 600;
}

.help-step {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  align-items: flex-start;
}

.help-step-number {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #1a1a2e;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.help-step-content h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.help-step-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ============================================
   Book Structure Panel
   ============================================ */

.bs-words-calc {
  transition: color 0.3s;
}

/* ============================================
   Prose Quality Review
   ============================================ */

.prose-score-display {
  text-align: center;
  padding: 20px;
  margin-bottom: 16px;
}

.prose-score-number {
  font-size: 3rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}

.prose-score-number.score-excellent { color: var(--success); }
.prose-score-number.score-good { color: var(--accent-primary); }
.prose-score-number.score-fair { color: var(--warning); }
.prose-score-number.score-poor { color: var(--danger); }

.prose-score-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.prose-issues-list {
  list-style: none;
  padding: 0;
}

.prose-issue-item {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.prose-issue-item.severity-high {
  border-left-color: var(--danger);
}

.prose-issue-item.severity-low {
  border-left-color: var(--info);
}

.prose-patterns-list {
  list-style: none;
  padding: 0;
}

.prose-pattern-item {
  padding: 8px 12px;
  margin-bottom: 6px;
  background: rgba(255, 59, 48, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.prose-pattern-item strong {
  color: var(--danger);
}

/* Sub-scores breakdown */
.prose-subscores {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.prose-subscore-row {
  display: grid;
  grid-template-columns: 1fr 45px 80px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
}

.prose-subscore-row:last-child {
  margin-bottom: 0;
}

.prose-subscore-label {
  color: var(--text-secondary);
}

.prose-subscore-value {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.75rem;
}

.prose-subscore-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.prose-subscore-bar .meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Severity filter bar */
.prose-filter-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.prose-filter-btn {
  padding: 4px 10px;
  font-size: 0.72rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.prose-filter-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.prose-filter-btn.active {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

.prose-filter-btn.prose-filter-high {
  border-color: var(--danger);
  color: var(--danger);
}

.prose-filter-btn.prose-filter-high.active {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.prose-filter-btn.prose-filter-medium {
  border-color: var(--warning);
  color: var(--warning);
}

.prose-filter-btn.prose-filter-medium.active {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}

.prose-filter-btn.prose-filter-low {
  border-color: var(--info);
  color: var(--info);
}

.prose-filter-btn.prose-filter-low.active {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}

/* Impact badges */
.prose-impact-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(39, 174, 96, 0.15);
  color: var(--success);
  margin-left: 6px;
}

.prose-impact-inline {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--success);
  margin-left: 4px;
}

/* Category tags */
.prose-category-tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Danger outline button for "Fix Serious Only" */
.btn-danger-outline {
  border: 1px solid var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn-danger-outline:hover {
  background: var(--danger);
  color: #fff;
}

/* ============================================
   Chapter Outline Display
   ============================================ */

/* --- Two-column layout for Before You Generate dialog --- */
.accept-outline-columns {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.accept-outline-left {
  flex: 0 0 280px;
  padding: 20px 24px;
  overflow-y: auto;
}

.accept-outline-right {
  flex: 1;
  padding: 20px 24px;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.accept-outline-textarea {
  width: 100%;
  flex: 1;
  min-height: 350px;
  max-height: 60vh;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  resize: vertical;
  margin-bottom: 12px;
}

.accept-outline-btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.accept-outline-rethink-area {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
}

.accept-outline-rethink-area textarea {
  width: 100%;
}

@media (max-width: 700px) {
  .accept-outline-columns {
    flex-direction: column;
  }
  .accept-outline-left {
    flex: none;
    border-bottom: 1px solid var(--border-color);
  }
  .accept-outline-right {
    border-left: none;
  }
}

/* === Translation Grid === */
.translation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.translation-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s, background-color 0.15s;
}

.translation-option:hover {
  border-color: var(--accent-primary);
}

.translation-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.translation-option input[type="checkbox"]:checked + span {
  color: var(--accent-primary);
  font-weight: 600;
}

/* === Front/Back Matter Grid === */
.matter-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.matter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.matter-option:hover {
  border-color: var(--accent-primary);
  background: var(--bg-tertiary, var(--bg-secondary));
}

.matter-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.matter-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.matter-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.matter-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.matter-option input[type="checkbox"]:checked ~ .matter-info .matter-name {
  color: var(--accent-primary);
}

/* ============================================
   Chapter Navigator
   ============================================ */

.chapter-nav {
  grid-area: chapnav;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: transform 0.2s ease, width 0.2s ease;
  min-width: 0;
}

.chapter-nav-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  background: var(--bg-secondary);
}

.chapter-nav-title {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-nav-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.chapter-nav-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.chapter-nav-btn:hover {
  background: var(--bg-tertiary, rgba(255,255,255,0.05));
  color: var(--text-primary);
  border-color: var(--border-color);
}

.chapter-nav-btn-danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.chapter-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.chapter-nav-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

/* --- Resize Handle --- */
.chapter-nav-resize {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}

.chapter-nav-resize:hover,
.chapter-nav-resize.dragging {
  background: var(--accent-primary);
  opacity: 0.4;
}

/* --- Sections (Front Matter, Chapters, Back Matter) --- */
.nav-section {
  margin-bottom: 2px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-section-header:hover {
  color: var(--text-primary);
}

.nav-section-arrow {
  font-size: 0.65rem;
  transition: transform 0.2s;
  width: 10px;
  text-align: center;
}

.nav-section.collapsed .nav-section-arrow {
  transform: rotate(-90deg);
}

.nav-section.collapsed .nav-section-items {
  display: none;
}

.nav-section-count {
  margin-left: auto;
  background: var(--bg-tertiary, rgba(255,255,255,0.08));
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* --- Individual Items --- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 20px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: all 0.12s;
  position: relative;
  min-height: 32px;
}

.nav-item:hover {
  background: var(--bg-tertiary, rgba(255,255,255,0.04));
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(var(--accent-primary-rgb, 181,141,75), 0.12);
  color: var(--accent-primary);
  border-left-color: var(--accent-primary);
  font-weight: 600;
}

.nav-item.selected {
  background: rgba(var(--accent-primary-rgb, 181,141,75), 0.06);
}

.nav-item-checkbox {
  width: 15px;
  height: 15px;
  min-width: 15px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.nav-item-icon {
  font-size: 0.75rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.nav-item-num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 3px;
  flex-shrink: 0;
}

.nav-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.nav-item-name-input {
  flex: 1;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 3px;
  padding: 2px 4px;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}

.nav-item-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-item-status {
  font-size: 0.6rem;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-tertiary, rgba(255,255,255,0.08));
  color: var(--text-muted);
  flex-shrink: 0;
}

.nav-item-status.done {
  background: rgba(76,175,80,0.15);
  color: var(--success, #4CAF50);
}

/* --- Drag and Drop --- */
.nav-item.dragging {
  opacity: 0.4;
  background: var(--bg-tertiary, rgba(255,255,255,0.08));
}

.nav-item.drag-over {
  border-top: 2px solid var(--accent-primary);
}

.nav-item.drag-over-bottom {
  border-bottom: 2px solid var(--accent-primary);
}

.nav-item .drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.nav-item:hover .drag-handle {
  opacity: 0.6;
}

.nav-item .drag-handle:active {
  cursor: grabbing;
}

/* --- Front/Back Matter item styles --- */
.nav-item.matter-item .nav-item-icon {
  color: var(--accent-primary);
  opacity: 0.6;
}

.nav-item.matter-item.empty .nav-item-name {
  font-style: italic;
  color: var(--text-muted);
}

/* ============================================
   Chapter Nav Toolbar
   ============================================ */

.chapter-nav-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary, rgba(255,255,255,0.03));
  flex-wrap: wrap;
}

.nav-select-all-label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.nav-select-all-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.nav-select-none-btn {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 5px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.3;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nav-select-none-btn:hover {
  color: var(--danger, #e55);
  border-color: var(--danger, #e55);
  background: rgba(255, 80, 80, 0.08);
}

.nav-toolbar-btn {
  font-size: 0.65rem !important;
  padding: 2px 6px !important;
  white-space: nowrap;
}

.nav-delete-btn {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
}

.nav-delete-btn:disabled {
  opacity: 0.3;
}

.nav-accept-btn {
  color: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
  margin-left: auto;
}

.nav-accept-btn:hover {
  background: var(--accent-subtle);
}

/* ============================================
   Translation Modal
   ============================================ */

.translation-step {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.translation-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trans-option {
  background: var(--bg-tertiary, rgba(255,255,255,0.03));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.trans-option-header {
  display: flex;
  align-items: center;
}

.trans-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.trans-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
}

.trans-option-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0 0 24px;
  line-height: 1.4;
}

.trans-option-desc em {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-style: italic;
}

.trans-option-detail {
  margin: 6px 0 0 24px;
}

.form-input-sm {
  font-size: 0.75rem;
  padding: 4px 8px;
}

.trans-scope-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.trans-scope-option:has(input:checked) {
  border-color: var(--accent-primary);
  background: rgba(226, 183, 20, 0.1);
}

/* ============================================
   Translation Side-by-Side View
   ============================================ */

.editor-area.translation-active {
  display: flex;
  gap: 0;
  padding: 0;
}

.editor-area.translation-active .editor-container {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--border-color);
  max-width: none;
  padding: 20px;
  overflow-y: auto;
}

.editor-area.translation-active .translation-pane {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.editor-area.translation-active .translation-pane .editor {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.editor-pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  min-height: 36px;
}

.pane-label {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-primary);
}

.pane-lang {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-tertiary, rgba(255,255,255,0.05));
  padding: 2px 8px;
  border-radius: 10px;
}

.pane-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.translation-progress {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.translation-progress-bar {
  height: 3px;
  background: var(--accent-primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}

.translation-progress-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: block;
}

/* Mobile: stack vertically */
@media (max-width: 768px) {
  .editor-area.translation-active {
    flex-direction: column;
  }
  .editor-area.translation-active .editor-container {
    flex: none;
    height: 50%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .editor-area.translation-active .translation-pane {
    flex: none;
    height: 50%;
  }
}

/* ═══ Translation Progress Overlay ═══ */
.translation-progress-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.translation-progress-card {
  background: #1e1e30;
  border: 1px solid #c8a96e;
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.translation-progress-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  border: 3px solid #333;
  border-top-color: #c8a96e;
  border-radius: 50%;
  animation: translation-spin 0.8s linear infinite;
}

@keyframes translation-spin {
  to { transform: rotate(360deg); }
}

.translation-progress-card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: #eee;
}

.translation-progress-detail {
  margin: 0 0 20px;
  font-size: 0.85rem;
  color: #aaa;
}

.translation-progress-track {
  height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.translation-progress-fill {
  height: 100%;
  width: 0%;
  background: #c8a96e;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.translation-progress-step {
  margin: 0;
  font-size: 0.75rem;
  color: #777;
}

/* ═══ Translation Split View Overlay ═══ */
.translation-split-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary, #1a1a2e);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.translation-split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1a1a2e;
  border-bottom: 2px solid #c8a96e;
  flex-shrink: 0;
}

.translation-split-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary, #eee);
}

.translation-split-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.translation-lang-dropdown {
  padding: 6px 10px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid var(--border-color, #333);
  background: var(--bg-primary, #1a1a2e);
  color: var(--text-primary, #eee);
  font-size: 0.85rem;
}

.translation-split-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.translation-split-overlay .translation-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.translation-split-overlay .translation-pane-label {
  padding: 8px 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;
  background: #2c2c3e;
  border-bottom: 2px solid #c8a96e;
  flex-shrink: 0;
}

.translation-split-overlay .translation-pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1.05rem;
  line-height: 1.75;
  /* FORCE black text on white — both panes identical and readable */
  color: #1a1a1a !important;
  background: #ffffff !important;
  /* No white-space: pre-wrap — we now use <p> tags for formatting */
}

.translation-pane-original {
  border-right: none;
}

.translation-divider {
  width: 3px;
  background: #c8a96e;
  flex-shrink: 0;
}

.translation-pane-translated {
  background: var(--bg-primary, #1a1a2e);
}

/* Remove faint accent color — use same black-on-white as original pane */
.translation-pane-translated .translation-pane-content {
  color: #1a1a1a !important;
  background: #ffffff !important;
}

.btn-close-split {
  background: transparent;
  border: 1px solid var(--border-color, #333);
  color: var(--text-primary, #eee);
  font-size: 1.1rem;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
}

.btn-close-split:hover {
  background: var(--bg-hover, #333);
}

/* Chapter filter bar */
.chapter-filter {
  display: flex;
}

.chapter-filter-btn {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid var(--border-color, #333);
  background: transparent;
  color: var(--text-muted, #888);
  cursor: pointer;
}

.chapter-filter-btn.active {
  background: var(--accent-primary, #c8a96e);
  color: var(--bg-primary, #1a1a2e);
  border-color: var(--accent-primary, #c8a96e);
}

/* Responsive: stack split view vertically on narrow screens */
@media (max-width: 768px) {
  .translation-split-body {
    flex-direction: column;
  }
  .translation-divider {
    width: 100%;
    height: 2px;
  }
  .translation-split-overlay .translation-pane-content {
    padding: 16px 20px;
  }
}

/* ═══ Localization Review Modal ═══ */
.localization-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.localization-container {
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.localization-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid #e0e0e0;
}

.localization-header h3 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: #1a1a1a;
}

.localization-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: #666;
}

.localization-progress {
  display: flex;
  justify-content: space-between;
  padding: 8px 24px;
  font-size: 0.8rem;
  color: #888;
  background: #f8f8f8;
  border-bottom: 1px solid #e0e0e0;
}

.localization-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px;
}

.loc-item {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fafafa;
  transition: border-color 0.15s;
}

.loc-item.approved {
  border-color: #4caf50;
  background: #f1f8e9;
}

.loc-item.rejected {
  border-color: #ccc;
  background: #f5f5f5;
  opacity: 0.6;
}

.loc-item-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 6px;
  font-weight: 600;
}

.loc-item-original {
  font-size: 0.95rem;
  color: #1a1a1a;
  margin-bottom: 8px;
  line-height: 1.5;
}

.loc-item-original strong {
  background: #fff3cd;
  padding: 1px 4px;
  border-radius: 3px;
}

.loc-item-suggestion {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.loc-item-arrow {
  color: #c8a96e;
  font-weight: bold;
  margin-top: 2px;
  flex-shrink: 0;
}

.loc-item-replacement {
  font-size: 0.95rem;
  color: #2e7d32;
  font-weight: 500;
  line-height: 1.5;
}

.loc-item-reasoning {
  font-size: 0.8rem;
  color: #666;
  font-style: italic;
  margin-bottom: 10px;
  line-height: 1.4;
}

.loc-item-actions {
  display: flex;
  gap: 8px;
}

.loc-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.loc-btn-approve {
  color: #2e7d32;
  border-color: #4caf50;
}

.loc-btn-approve:hover, .loc-btn-approve.active {
  background: #4caf50;
  color: #fff;
}

.loc-btn-reject {
  color: #888;
  border-color: #ccc;
}

.loc-btn-reject:hover, .loc-btn-reject.active {
  background: #eee;
  color: #666;
}

.loc-btn-custom {
  color: #1565c0;
  border-color: #42a5f5;
}

.loc-btn-custom:hover {
  background: #e3f2fd;
}

.loc-custom-input {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid #42a5f5;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: Georgia, serif;
  display: none;
  box-sizing: border-box;
}

.loc-custom-input.visible {
  display: block;
}

.localization-footer {
  padding: 16px 24px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  background: #f8f8f8;
  border-radius: 0 0 12px 12px;
}

.localization-footer .btn {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.localization-footer .btn-primary {
  background: #c8a96e;
  color: #fff;
  border: none;
  font-weight: 600;
}

.localization-footer .btn-secondary {
  background: #fff;
  border: 1px solid #ddd;
  color: #555;
}

@media (max-width: 768px) {
  .localization-container {
    max-height: 95vh;
    border-radius: 8px;
  }
  .localization-footer {
    flex-direction: column;
  }
}

/* ============================================
   Setup Book Central Modal
   ============================================ */

#setup-book-overlay {
  z-index: 350;
}

#setup-book-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#setup-book-overlay.visible .setup-book-modal {
  transform: scale(1);
}

.setup-book-modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(1100px, 96vw);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.setup-book-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.setup-book-header h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Tab Navigation */
.setup-book-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  padding: 0 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  gap: 4px;
  background: var(--bg-secondary);
}

.setup-tab {
  padding: 16px 28px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: -2px;
  min-height: 54px;
}

.setup-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.setup-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: var(--bg-surface);
}

.setup-tab .tab-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Tab Content */
.setup-book-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.setup-tab-content {
  display: none;
  padding: 28px 36px;
  max-width: 900px;
}

.setup-tab-content.active {
  display: block;
}

/* Section headings inside Setup Book */
.setup-tab-content .analysis-section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.setup-tab-content .analysis-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setup-tab-content .analysis-section h3 {
  font-size: 1rem;
  margin-bottom: 14px;
}

/* Larger form labels inside Setup Book */
.setup-tab-content .form-group label {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

/* Two-column layout for Book Setup form groups */
.setup-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Matter grids inside side-by-side columns stay single-column */
.matter-columns .matter-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Wider translation grid */
.setup-tab-content .translation-grid {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Export buttons in enlarged modal - two columns */
.setup-export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.setup-export-grid .btn {
  width: 100%;
  margin-bottom: 0;
}

/* ============================================
   Author Palette — AI-Selected Author Cards
   ============================================ */

.author-palette-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.author-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  transition: border-color 0.2s;
}

.author-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.author-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-number {
  background: rgba(255, 200, 50, 0.2);
  color: #ffc832;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}

.author-info {
  flex: 1;
}

.author-name {
  display: block;
  font-size: 14px;
  color: var(--text-primary, #fff);
}

.author-label {
  font-size: 12px;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

.btn-lock {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s, opacity 0.2s, border-color 0.2s;
  color: var(--text-secondary, rgba(255, 255, 255, 0.5));
  opacity: 0.45;
}

.btn-lock:hover {
  background: rgba(255, 255, 255, 0.08);
  opacity: 0.7;
}

.btn-lock.locked {
  background: rgba(255, 200, 50, 0.15);
  border-color: rgba(255, 200, 50, 0.4);
  color: var(--text-primary, #fff);
  opacity: 1;
}

.author-card-body {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  padding-left: 34px;
}

.author-role,
.author-temp {
  font-size: 11px;
  color: var(--text-muted, rgba(255, 255, 255, 0.45));
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.author-card-reason {
  font-size: 12px;
  color: var(--text-muted, rgba(255, 255, 255, 0.5));
  padding-left: 34px;
  margin-top: 4px;
  font-style: italic;
}

.palette-rationale {
  font-size: 13px;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
  margin-bottom: 8px;
  padding: 8px 12px;
  background: rgba(255, 200, 50, 0.05);
  border-left: 3px solid rgba(255, 200, 50, 0.3);
  border-radius: 0 4px 4px 0;
}

.palette-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.palette-hint {
  font-size: 12px;
  color: var(--text-muted, rgba(255, 255, 255, 0.4));
}

.badge-ai {
  background: rgba(255, 200, 50, 0.2);
  color: #ffc832;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: normal;
}

.palette-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
  font-size: 13px;
}

.palette-loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 200, 50, 0.2);
  border-top-color: #ffc832;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.palette-error {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  color: var(--error, #ff6b6b);
  font-size: 13px;
  background: rgba(255, 107, 107, 0.08);
  border-radius: 6px;
}

.palette-error button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-primary, #fff);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.palette-summary-inline {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted, rgba(255, 255, 255, 0.5));
}

.palette-summary-inline .palette-author-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0 0;
}

.palette-summary-inline .palette-author-list li {
  padding: 2px 0;
  font-size: 12px;
  color: var(--text-primary, #fff);
}

.palette-summary-inline .palette-author-list li .author-style-tag {
  color: var(--text-muted, rgba(255, 255, 255, 0.5));
  font-size: 11px;
}

/* Responsive adjustments for Setup Book Modal */
@media (max-width: 1024px) {
  .setup-book-modal {
    width: min(960px, 96vw);
  }

  .author-card-header {
    gap: 8px;
  }

  .author-card {
    padding: 8px 10px;
  }

  .setup-tab-content {
    padding: 24px 28px;
  }
}

@media (max-width: 768px) {
  .setup-book-modal {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .setup-book-tabs {
    padding: 0 12px;
    gap: 2px;
  }

  .setup-tab {
    padding: 12px 16px;
    font-size: 0.9rem;
    min-height: 48px;
  }

  .setup-tab .tab-icon {
    display: none;
  }

  .setup-tab-content {
    padding: 20px 16px;
  }

  .setup-form-row {
    grid-template-columns: 1fr;
  }

  .setup-tab-content .matter-grid {
    grid-template-columns: 1fr;
  }

  .setup-tab-content .translation-grid {
    grid-template-columns: 1fr 1fr;
  }

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

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

/* ============================================
   Outline Review Popup (overlays Setup Book)
   ============================================ */
.outline-review-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.outline-review-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.outline-review-modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  width: min(900px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.outline-review-overlay.visible .outline-review-modal {
  transform: scale(1);
}

.outline-review-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.outline-review-header h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--text-primary);
  font-weight: 700;
}

.outline-review-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 28px;
}

.outline-review-body .outline-chapter {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.outline-chapter h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.outline-chapter .outline-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.outline-chapter textarea.outline-edit {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.7;
  resize: vertical;
}

.outline-chapter textarea.outline-edit:focus {
  outline: none;
  border-color: #007AFF;
}

.outline-review-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.outline-review-footer .btn {
  min-width: 140px;
}

/* Rethink Comments Popup (overlays Outline Review) */
.rethink-comments-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.rethink-comments-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.rethink-comments-modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  width: min(560px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 768px) {
  .outline-review-modal {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* ============================================
   Multi-Agent Pipeline Styles
   ============================================ */

/* Agent Status Grid */
.ma-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.ma-agent-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  transition: border-color 0.3s, background 0.3s;
}

.ma-agent-card.agent-writing {
  border-color: var(--accent-primary);
  background: rgba(0, 122, 255, 0.08);
}

.ma-agent-card.agent-done {
  border-color: var(--success);
  background: rgba(52, 199, 89, 0.08);
}

.ma-agent-card.agent-error {
  border-color: var(--danger);
  background: rgba(255, 59, 48, 0.08);
}

.ma-agent-card.agent-winner {
  border-color: #FFD700;
  background: rgba(255, 215, 0, 0.12);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
  position: relative;
}

.ma-winner-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: #FFD700;
  color: #1a1a2e;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 1;
}

.ma-agent-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.ma-agent-status {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.ma-agent-score {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
}

/* Pipeline Progress Bar */
.ma-pipeline-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.ma-pipeline-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), #34C759);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Status Log */
.ma-status-log {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-height: 120px;
  overflow-y: auto;
  text-align: left;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-family: var(--font-mono, 'SF Mono', 'Menlo', monospace);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ============================================
   Genesis 3.0 Pipeline Progress Styles
   ============================================ */

.g3-phase {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.g3-phase.active {
  background: var(--accent-primary-alpha, rgba(59, 130, 246, 0.1));
  font-weight: 600;
  color: var(--accent-primary);
}
.g3-phase.completed {
  color: var(--success, #28a745);
}
.g3-icon {
  font-size: 0.9rem;
  width: 18px;
  text-align: center;
}

/* ============================================
   GO/NO-GO Mission Control Styles
   ============================================ */

.go-nogo-header {
  background: linear-gradient(135deg, #0a1628, #162544);
  padding: 20px 24px;
  text-align: center;
  border-bottom: 2px solid #1e3a5f;
}

.go-nogo-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #e0e6ed;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.go-nogo-subtitle {
  font-size: 0.8rem;
  color: #6b8bb5;
  letter-spacing: 1px;
  margin-top: 4px;
}

.go-nogo-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.go-nogo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-color);
  transition: border-color 0.3s;
}

.go-nogo-row.status-go {
  border-left-color: #34C759;
}

.go-nogo-row.status-nogo {
  border-left-color: #FF3B30;
}

.go-nogo-row.status-polling {
  border-left-color: var(--accent-primary);
}

.go-nogo-chapter-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

.go-nogo-chapter-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.go-nogo-chapter-status.go {
  color: #34C759;
  background: rgba(52, 199, 89, 0.12);
}

.go-nogo-chapter-status.nogo {
  color: #FF3B30;
  background: rgba(255, 59, 48, 0.12);
}

.go-nogo-chapter-status.polling {
  color: var(--accent-primary);
  background: rgba(0, 122, 255, 0.12);
}

.go-nogo-overall {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  margin-top: 16px;
  border-radius: var(--radius-md);
  background: rgba(52, 199, 89, 0.08);
  border: 1px solid rgba(52, 199, 89, 0.3);
}

.go-nogo-overall.status-nogo {
  background: rgba(255, 59, 48, 0.08);
  border-color: rgba(255, 59, 48, 0.3);
}

.go-nogo-status-icon {
  font-size: 1.5rem;
  color: #34C759;
}

.go-nogo-overall.status-nogo .go-nogo-status-icon {
  color: #FF3B30;
}

.go-nogo-status-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #34C759;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.go-nogo-overall.status-nogo .go-nogo-status-text {
  color: #FF3B30;
}

.go-nogo-conflict-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.go-nogo-conflict-item {
  padding: 10px 12px;
  background: rgba(255, 59, 48, 0.05);
  border-radius: var(--radius-sm);
  border-left: 3px solid #FF3B30;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.go-nogo-conflict-item .conflict-category {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.go-nogo-conflict-item .conflict-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Resolution Picker */
.go-nogo-resolution-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.go-nogo-resolution-card {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-primary);
  cursor: default;
  transition: border-color 0.2s, background 0.2s;
}

.go-nogo-resolution-card:hover {
  background: var(--bg-tertiary, rgba(255,255,255,0.03));
}

.resolution-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.resolution-icon {
  font-size: 1rem;
}

.resolution-approach {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.resolution-badge {
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(52, 199, 89, 0.15);
  color: #34C759;
  font-weight: 600;
  margin-left: auto;
}

.resolution-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}

.resolution-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.resolution-actions .btn {
  font-size: 0.75rem;
  padding: 4px 12px;
  min-width: auto;
}

.resolution-prose-preview {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: var(--font-serif, Georgia, serif);
}

.go-nogo-resolution-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#btn-go-nogo-find-resolutions {
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  color: #fff;
  border: none;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#btn-go-nogo-find-resolutions:hover {
  background: linear-gradient(135deg, #2196f3, #7c4dff);
}

#btn-go-nogo-find-resolutions:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ============================================
   Multi-Chapter Outline Styles
   ============================================ */

.multi-outline-card {
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.multi-outline-card .outline-ch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.multi-outline-card .outline-ch-header .ch-number {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
}

.multi-outline-card textarea {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
}

.multi-outline-card textarea:focus {
  outline: none;
  background: var(--bg-surface);
}

.multi-outline-gap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  margin-bottom: 12px;
  background: rgba(255, 149, 0, 0.08);
  border: 1px dashed rgba(255, 149, 0, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: #FF9500;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Responsive fixes for multi-agent overlays on laptop/desktop */
@media (min-width: 768px) {
  #multi-agent-overlay .modal,
  #go-nogo-overlay .modal {
    max-height: 85vh;
    overflow-y: auto;
  }

  .ma-agent-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }

  .ma-status-log {
    max-height: 160px;
  }

  .go-nogo-results {
    max-height: 300px;
  }
}

@media (max-width: 767px) {
  .ma-agent-grid {
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    gap: 6px;
  }

  .ma-agent-card {
    padding: 8px 6px;
  }

  .ma-agent-label {
    font-size: 0.65rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   Agent Count Slider
   ═══════════════════════════════════════════════════════════ */

.agent-count-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0;
}

#agent-count-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
}

#agent-count-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffc832;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.3);
}

#agent-count-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffc832;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.3);
}

.agent-count-value {
  font-size: 20px;
  font-weight: bold;
  color: #ffc832;
  min-width: 28px;
  text-align: center;
}

.agent-count-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  padding: 0 2px;
}

/* ═══ Scholarly Apparatus ═══ */
.scholarly-sub-options {
  padding: 6px 0;
}
.scholarly-sub-options .radio-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.scholarly-sub-options .radio-option input[type="radio"] {
  margin: 0;
  cursor: pointer;
}
#scholarly-apparatus-section .matter-option {
  padding: 8px 10px;
}

/* ═══ Illustrations Tab ═══ */
.ill-chapter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ill-chapter-row:hover {
  background: var(--bg-secondary);
}
.ill-chapter-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}
.ill-chapter-row .ill-ch-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.ill-chapter-row .ill-ch-count {
  width: 50px;
}
.ill-chapter-row .ill-ch-count input {
  width: 50px;
  text-align: center;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
}
.ill-chapter-expand {
  padding: 12px;
  margin: 4px 0 8px 26px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}
.ill-card {
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}
.ill-card h4 {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.ill-card .form-group {
  margin-bottom: 8px;
}
.ill-card .form-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.ill-desc-entry {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}
.ill-desc-entry .ill-desc-fields {
  flex: 1;
}
.ill-desc-entry .ill-desc-fields input,
.ill-desc-entry .ill-desc-fields textarea {
  width: 100%;
  margin-bottom: 4px;
}
.ill-desc-entry .ill-desc-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ill-prompt-card {
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}
.ill-prompt-card h4 {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.ill-prompt-card textarea {
  width: 100%;
  font-size: 0.85rem;
  resize: vertical;
}
.ill-prompt-card .ill-source-prose {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  max-height: 100px;
  overflow-y: auto;
}
.ill-variant-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ill-variant-card {
  flex: 1;
  min-width: 150px;
  max-width: 250px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}
.ill-variant-card.selected {
  border-color: #007AFF;
}
.ill-variant-card img {
  width: 100%;
  height: auto;
  display: block;
}
.ill-variant-card .ill-variant-label {
  padding: 6px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-secondary);
}
/* Chapter Illustrations Gallery (below editor) */
.chapter-illustrations-gallery {
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  background: var(--bg-secondary);
}
.chapter-ill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.chapter-ill-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.chapter-ill-images {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.chapter-ill-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  max-width: 280px;
  cursor: pointer;
}
.chapter-ill-item img {
  width: 100%;
  display: block;
  object-fit: cover;
}
.chapter-ill-item .chapter-ill-caption {
  padding: 6px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.ill-review-card {
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}
.ill-review-card h4 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.ill-review-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.ill-ref-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
}
.ill-ref-thumb.selected {
  border-color: #007AFF;
}
.ill-ref-thumb img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.ill-ref-thumb .ill-ref-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #007AFF;
  color: #fff;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
}
.ill-ref-thumb.selected .ill-ref-check {
  display: flex;
}

/* ═══════════════════════════════════════════════
   Illustration Dashboard (Redesigned)
   ═══════════════════════════════════════════════ */

.ill-dashboard-chapter {
  transition: border-color 0.2s;
}
.ill-dashboard-chapter:hover {
  border-color: var(--accent-primary) !important;
}

.ill-scene-row {
  transition: background-color 0.2s;
}
.ill-scene-row:hover {
  background-color: var(--bg-tertiary) !important;
}

.ill-thumb {
  transition: border-color 0.2s, transform 0.15s;
}
.ill-thumb:hover {
  transform: scale(1.05);
}
.ill-thumb.selected {
  border-color: var(--accent-primary) !important;
}

.ill-thumb-add {
  transition: background-color 0.2s, border-color 0.2s;
}
.ill-thumb-add:hover {
  border-color: var(--accent-primary) !important;
  background-color: var(--bg-tertiary);
}

.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  color: #fff;
  white-space: nowrap;
}

/* Workflow step indicator */
.ill-step {
  transition: opacity 0.3s;
}
.ill-step.active {
  color: var(--accent-primary);
}

/* Cost tracker */
#ill-cost-total {
  color: var(--accent-primary);
}

/* ── Export format checkboxes ── */
.export-option:hover {
  background: var(--surface-hover, rgba(0,0,0,0.03));
}
.export-option:has(input:checked) {
  background: var(--accent-light, #f0f4ff);
  border-color: var(--accent, #5b7bd4);
}

/* ═══════════════════════════════════════
   Localization Bible & Quality Checks
   ═══════════════════════════════════════ */

/* Bible status grid */
.bible-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-hover, rgba(0,0,0,0.03));
  font-size: 0.85rem;
}
.bible-status-row .bible-lang {
  flex: 1;
  font-weight: 500;
}
.bible-status-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.bible-status-badge.ready {
  background: #d4f5d9;
  color: #1a7a2e;
}
.bible-status-badge.missing {
  background: #fde2e2;
  color: #a33;
}
.bible-status-badge.generating {
  background: #fff3cd;
  color: #856404;
  animation: pulse-badge 1.5s infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.bible-status-actions {
  display: flex;
  gap: 4px;
}
.bible-status-actions .btn {
  font-size: 0.75rem;
  padding: 2px 8px;
}

/* Bible review tabs */
.bible-tab {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.bible-tab:hover {
  color: var(--text);
}
.bible-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 600;
}

/* Bible review entries */
.bible-entry {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--surface, #fff);
}
.bible-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.bible-entry-english {
  font-weight: 600;
  color: var(--text);
}
.bible-entry-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.bible-entry-localized {
  font-weight: 600;
  color: var(--accent-primary);
}
.bible-entry-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.bible-entry input.bible-edit {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  margin-top: 4px;
  background: var(--surface, #fff);
  color: var(--text);
}
.bible-entry-tone {
  white-space: pre-wrap;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
  padding: 8px 12px;
  background: var(--surface-hover, rgba(0,0,0,0.02));
  border-radius: 6px;
}

/* Quality report */
.qr-error-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  border-left: 3px solid transparent;
}
.qr-error-row.critical {
  background: #fde2e2;
  border-left-color: #c33;
}
.qr-error-row.major {
  background: #fff3cd;
  border-left-color: #b87900;
}
.qr-error-row.minor {
  background: var(--surface-hover, rgba(0,0,0,0.03));
  border-left-color: var(--text-muted);
}
.qr-severity {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 55px;
}
.qr-error-body {
  flex: 1;
}
.qr-error-expected {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Naturalness bar */
.qr-nat-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}
.qr-nat-label {
  width: 140px;
  text-align: right;
  color: var(--text-muted);
}
.qr-nat-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-hover, rgba(0,0,0,0.08));
  overflow: hidden;
}
.qr-nat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.qr-nat-fill.good { background: #2ecc71; }
.qr-nat-fill.ok { background: #f1c40f; }
.qr-nat-fill.poor { background: #e74c3c; }
.qr-nat-score {
  width: 30px;
  text-align: right;
  font-weight: 600;
}

/* Fix row */
.qr-fix-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 0.8rem;
  background: var(--surface-hover, rgba(0,0,0,0.03));
  border-radius: 4px;
}
.qr-fix-find {
  text-decoration: line-through;
  color: #c33;
}
.qr-fix-replace {
  color: #2ecc71;
  font-weight: 500;
}

/* Reader strength */
.qr-strength-row {
  padding: 6px 10px;
  font-size: 0.82rem;
  background: #d4f5d9;
  border-radius: 6px;
  border-left: 3px solid #2ecc71;
}
.qr-strength-quote {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

/* ════════════════════════════════════════════════════════════════
   Device Preview - Vellum-style Device Frames
   ════════════════════════════════════════════════════════════════ */

/* Device selector buttons */
/* ============================================
   Device Preview Mode (toolbar toggle)
   ============================================ */

/* Preview bar — sticky at top of editor area */
.device-preview-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  max-width: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.device-preview-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  flex-wrap: wrap;
}

.device-preview-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.device-preview-buttons .device-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  font-size: 0.7rem;
  min-width: 56px;
  cursor: pointer;
  background: var(--bg);
  border-radius: 6px;
}

.device-preview-buttons .device-btn .device-icon {
  font-size: 1.15em;
}

.device-preview-buttons .device-btn .device-label {
  font-size: 0.65rem;
}

.device-preview-bar-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: auto;
}

.device-preview-bar-info .device-info-sep {
  margin: 0 6px;
  opacity: 0.4;
}

.device-preview-bar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.device-preview-bar-actions select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}

/* Editor area in preview mode */
.editor-area.preview-active {
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.editor-area.preview-active .editor-container,
.editor-area.preview-active .translation-pane,
.editor-area.preview-active #welcome-overlay,
.editor-area.preview-active #chapter-illustrations-gallery {
  display: none !important;
}

.editor-area.preview-active .device-preview-bar {
  display: block !important;
}

.editor-area.preview-active .device-preview-pane {
  display: flex !important;
}

/* Preview pane — fills remaining space below bar */
.device-preview-pane {
  display: none;
  flex: 1;
  gap: 0;
  overflow: hidden;
  background: #eee;
  min-height: 0;
}

/* Single-frame wrapper */
.device-preview-frame-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.device-preview-frame-wrapper + .device-preview-frame-wrapper {
  border-left: 2px solid var(--border-color);
}

.device-preview-pane-label {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.device-preview-scroll {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  min-height: 0;
}

/* Toolbar button active state for preview toggle */
#btn-device-preview.active {
  background: color-mix(in srgb, var(--accent-primary) 18%, transparent);
  color: var(--accent-primary);
  border-radius: 6px;
}

/* Device frame styles shared between original and translation frames */
.device-frame-iphone,
.device-frame-ipad,
.device-frame-kindle,
.device-frame-laptop,
.device-frame-softcover,
.device-frame-hardcover {
  position: relative;
  transition: all 0.35s ease;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* Make translation frame use same content styles */
#device-frame-translation {
  position: relative;
  transition: all 0.35s ease;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* Content styling for translation frame mirrors original */
#device-preview-content-translation {
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}
#device-preview-content-translation::-webkit-scrollbar { width: 4px; }
#device-preview-content-translation::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }
#device-preview-content-translation h2.preview-chapter-title {
  font-size: 1.6em; text-align: center; margin: 0.5em 0 0.8em; font-weight: normal; letter-spacing: 0.03em;
}
#device-preview-content-translation .preview-separator { text-align: center; margin: 0 0 1em; color: #999; letter-spacing: 0.3em; }
#device-preview-content-translation p { margin: 0; text-indent: 1.5em; }
#device-preview-content-translation p:first-of-type { text-indent: 0; }

/* iPad responsive adjustments for preview bar */
@media (max-width: 1024px) {
  .device-preview-bar-inner {
    padding: 6px 10px;
    gap: 8px;
  }
  .device-preview-buttons .device-btn {
    min-width: 48px;
    padding: 5px 6px;
  }
  .device-preview-buttons .device-btn .device-label {
    display: none;
  }
  .device-preview-buttons .device-btn .device-icon {
    font-size: 1.3em;
  }
  .device-preview-scroll {
    padding: 16px 8px;
  }
}

.device-btn {
  border: 2px solid var(--border) !important;
  transition: all 0.2s ease !important;
}
.device-btn.active {
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
  color: var(--accent) !important;
  font-weight: 700 !important;
}
.device-btn:hover:not(.active) {
  border-color: var(--text-muted) !important;
}

/* Base device frame */
#device-frame,
#device-frame-translation {
  position: relative;
  transition: all 0.35s ease;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* ── iPhone Frame ── */
.device-frame-iphone {
  width: 280px;
  height: 580px;
  border: 10px solid #1a1a1a;
  border-radius: 40px;
  background: #1a1a1a;
  padding: 0;
}
.device-frame-iphone::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 22px;
  background: #1a1a1a;
  border-radius: 0 0 14px 14px;
  z-index: 2;
}
.device-frame-iphone #device-preview-content {
  border-radius: 30px;
  font-size: 11px;
  line-height: 1.5;
  padding: 30px 16px 16px;
}

/* ── iPad Frame ── */
.device-frame-ipad {
  width: 420px;
  height: 560px;
  border: 14px solid #2a2a2a;
  border-radius: 20px;
  background: #2a2a2a;
}
.device-frame-ipad #device-preview-content {
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.55;
  padding: 20px;
}

/* ── Kindle Frame ── */
.device-frame-kindle {
  width: 340px;
  height: 480px;
  border: 16px solid #3d3d3d;
  border-bottom-width: 40px;
  border-radius: 12px;
  background: #3d3d3d;
}
.device-frame-kindle::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  border: 2px solid #555;
  border-radius: 50%;
}
.device-frame-kindle #device-preview-content {
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.65;
  padding: 20px 18px;
  background: #f5f1e8 !important;
  color: #333 !important;
  font-family: 'Georgia', 'Bookerly', serif !important;
}

/* ── Laptop Frame ── */
.device-frame-laptop {
  width: 520px;
  height: 340px;
  border: 12px solid #222;
  border-bottom-width: 26px;
  border-radius: 12px 12px 0 0;
  background: #222;
}
.device-frame-laptop::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -30px;
  right: -30px;
  height: 18px;
  background: linear-gradient(to bottom, #333, #444);
  border-radius: 0 0 8px 8px;
}
.device-frame-laptop #device-preview-content {
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.6;
  padding: 24px 32px;
}

/* ── Softcover Print ── */
.device-frame-softcover {
  width: 340px;
  height: 510px;
  border: 2px solid #c9b99a;
  border-radius: 2px 8px 8px 2px;
  background: #fff;
  box-shadow: -3px 0 6px rgba(0,0,0,0.08), 4px 4px 16px rgba(0,0,0,0.12), inset 2px 0 4px rgba(0,0,0,0.04) !important;
}
.device-frame-softcover::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 16px;
  background: linear-gradient(to right, #e0d5c0, #f5f0e8 40%, transparent);
  border-radius: 2px 0 0 2px;
  z-index: 2;
}
.device-frame-softcover #device-preview-content {
  border-radius: 0 6px 6px 0;
  font-size: 11.5px;
  line-height: 1.6;
  padding: 36px 28px 28px 32px;
  font-family: 'Georgia', 'Garamond', serif !important;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* ── Hardcover Print ── */
.device-frame-hardcover {
  width: 360px;
  height: 520px;
  border: 6px solid #4a3728;
  border-radius: 3px 10px 10px 3px;
  background: #fff;
  box-shadow: -4px 0 8px rgba(0,0,0,0.1), 6px 6px 24px rgba(0,0,0,0.18), inset 3px 0 6px rgba(0,0,0,0.06) !important;
}
.device-frame-hardcover::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 22px;
  background: linear-gradient(to right, #6b5140, #8b7360 30%, #d4c8b8 70%, transparent);
  border-radius: 2px 0 0 2px;
  z-index: 2;
}
.device-frame-hardcover::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  bottom: 2px;
  width: 3px;
  background: rgba(0,0,0,0.08);
  z-index: 3;
}
.device-frame-hardcover #device-preview-content {
  border-radius: 0 8px 8px 0;
  font-size: 11.5px;
  line-height: 1.6;
  padding: 40px 30px 30px 36px;
  font-family: 'Georgia', 'Garamond', serif !important;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Preview content shared styles */
#device-preview-content {
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}
#device-preview-content::-webkit-scrollbar {
  width: 4px;
}
#device-preview-content::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

/* Preview illustration sizing inside device frames */
#device-preview-content figure.chapter-illustration,
#device-preview-content .chapter-illustration,
#device-preview-content-translation figure.chapter-illustration,
#device-preview-content-translation .chapter-illustration {
  text-align: center;
  margin: 1em auto;
  page-break-inside: avoid;
  max-width: 100%;
}
#device-preview-content figure.chapter-illustration img,
#device-preview-content .chapter-illustration img,
#device-preview-content-translation figure.chapter-illustration img,
#device-preview-content-translation .chapter-illustration img {
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 3px;
}
#device-preview-content .chapter-illustration figcaption,
#device-preview-content-translation .chapter-illustration figcaption {
  font-style: italic;
  font-size: 0.8em;
  color: #888;
  margin-top: 0.4em;
}
#device-preview-content .chapter-illustration.size-inline-full img,
#device-preview-content-translation .chapter-illustration.size-inline-full img { max-width: 100%; }
#device-preview-content .chapter-illustration.size-inline-half img,
#device-preview-content-translation .chapter-illustration.size-inline-half img { max-width: 50%; }
#device-preview-content .chapter-illustration.size-inline-third img,
#device-preview-content-translation .chapter-illustration.size-inline-third img { max-width: 33%; }
#device-preview-content .chapter-illustration.size-spot img,
#device-preview-content-translation .chapter-illustration.size-spot img { max-width: 25%; }

/* In small device frames, scale up smaller images for readability */
.device-frame-iphone #device-preview-content .chapter-illustration img { max-width: 100% !important; }
.device-frame-kindle #device-preview-content .chapter-illustration img { max-width: 100% !important; }
.device-frame-iphone #device-preview-content-translation .chapter-illustration img { max-width: 100% !important; }
.device-frame-kindle #device-preview-content-translation .chapter-illustration img { max-width: 100% !important; }

/* Translation frame inherits same per-device content styles */
.device-frame-iphone #device-preview-content-translation {
  border-radius: 30px; font-size: 11px; line-height: 1.5; padding: 30px 16px 16px;
}
.device-frame-ipad #device-preview-content-translation {
  border-radius: 8px; font-size: 13px; line-height: 1.55; padding: 20px;
}
.device-frame-kindle #device-preview-content-translation {
  border-radius: 4px; font-size: 13px; line-height: 1.65; padding: 20px 18px;
  background: #f5f1e8 !important; color: #333 !important; font-family: 'Georgia', 'Bookerly', serif !important;
}
.device-frame-laptop #device-preview-content-translation {
  border-radius: 4px; font-size: 14px; line-height: 1.6; padding: 24px 32px;
}
.device-frame-softcover #device-preview-content-translation {
  border-radius: 0 6px 6px 0; font-size: 11.5px; line-height: 1.6; padding: 36px 28px 28px 32px;
  font-family: 'Georgia', 'Garamond', serif !important; text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}
.device-frame-hardcover #device-preview-content-translation {
  border-radius: 0 8px 8px 0; font-size: 11.5px; line-height: 1.6; padding: 40px 30px 30px 36px;
  font-family: 'Georgia', 'Garamond', serif !important; text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}

/* Preview heading styles */
#device-preview-content h2.preview-chapter-title {
  font-size: 1.6em;
  text-align: center;
  margin: 0.5em 0 0.8em;
  font-weight: normal;
  letter-spacing: 0.03em;
}
#device-preview-content .preview-separator {
  text-align: center;
  margin: 0 0 1em;
  color: #999;
  letter-spacing: 0.3em;
}
#device-preview-content p {
  margin: 0 0 0;
  text-indent: 1.5em;
}
#device-preview-content p:first-of-type {
  text-indent: 0;
}

/* Fullscreen preview overlay */
#device-preview-fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}
#device-preview-fullscreen-overlay .close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 2rem;
  color: #fff;
  cursor: pointer;
  z-index: 10001;
  background: none;
  border: none;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════
   CONTINUITY SYSTEM UI
   ═══════════════════════════════════════════════════════════ */

.continuity-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  padding: 20px;
}
.continuity-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.continuity-modal {
  background: var(--bg-primary, #1a1a2e);
  border-radius: 16px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
}
.continuity-modal-wide {
  max-width: 860px;
}

.continuity-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
}
.continuity-header h2 {
  margin: 0;
  font-size: 1.3em;
  color: var(--text-primary, #e0e0e0);
}
.continuity-header .continuity-summary {
  margin: 4px 0 0;
  color: var(--text-secondary, #aaa);
  font-size: 0.9em;
}
.continuity-icon {
  font-size: 2em;
  line-height: 1;
  min-width: 40px;
  text-align: center;
}

.continuity-conflicts {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.continuity-conflict-card {
  background: var(--bg-secondary, #16213e);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid #999;
  position: relative;
}
.continuity-conflict-card.severity-critical { border-left-color: #e74c3c; }
.continuity-conflict-card.severity-moderate { border-left-color: #f39c12; }
.continuity-conflict-card.severity-minor { border-left-color: #3498db; }
.continuity-conflict-card.resolved {
  opacity: 0.6;
}
.continuity-conflict-card.compact {
  padding: 12px;
  font-size: 0.9em;
}

.conflict-severity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7em;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.conflict-category-tag {
  display: inline-block;
  margin-left: 8px;
  color: var(--text-secondary, #aaa);
  font-size: 0.8em;
}

.conflict-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
@media (max-width: 600px) {
  .conflict-comparison { grid-template-columns: 1fr; }
}
.conflict-side label {
  display: block;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #aaa);
  margin-bottom: 4px;
}
.conflict-side blockquote {
  margin: 0;
  padding: 8px 12px;
  border-radius: 6px;
  font-style: italic;
  font-size: 0.9em;
  line-height: 1.5;
}
.conflict-new blockquote {
  background: rgba(231, 76, 60, 0.1);
  border-left: 3px solid #e74c3c;
  color: var(--text-primary, #e0e0e0);
}
.conflict-canon blockquote {
  background: rgba(46, 204, 113, 0.1);
  border-left: 3px solid #2ecc71;
  color: var(--text-primary, #e0e0e0);
}
.conflict-side small {
  color: var(--text-secondary, #888);
  font-size: 0.8em;
}

.conflict-fix {
  margin-top: 8px;
}
.conflict-fix label {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #aaa);
}
.conflict-fix-text {
  color: var(--text-primary, #e0e0e0);
  font-size: 0.9em;
  margin-top: 4px;
}
.edit-fix-textarea {
  width: 100%;
  min-height: 60px;
  background: var(--bg-primary, #1a1a2e);
  color: var(--text-primary, #e0e0e0);
  border: 1px solid var(--border-color, rgba(255,255,255,0.2));
  border-radius: 6px;
  padding: 8px;
  font-size: 0.9em;
  resize: vertical;
  margin-bottom: 8px;
}

.conflict-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.btn-fix {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.2));
  background: var(--bg-primary, #1a1a2e);
  color: var(--text-primary, #e0e0e0);
  font-size: 0.85em;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s;
}
.btn-fix:hover { background: var(--bg-hover, #243b6a); }
.btn-accept-fix:hover { background: rgba(46, 204, 113, 0.2); }
.btn-override:hover { background: rgba(231, 76, 60, 0.2); }

.conflict-resolved {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(46, 204, 113, 0.1);
  border-radius: 6px;
}
.resolved-label {
  color: #2ecc71;
  font-size: 0.9em;
  flex: 1;
}
.btn-undo-resolution {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.2));
  background: transparent;
  color: var(--text-secondary, #aaa);
  font-size: 0.8em;
  cursor: pointer;
  min-height: 36px;
}
.btn-small {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.2));
  background: var(--bg-primary, #1a1a2e);
  color: var(--text-primary, #e0e0e0);
  cursor: pointer;
  font-size: 0.85em;
  min-height: 36px;
}

.continuity-actions {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
  flex-wrap: wrap;
}
.continuity-warning {
  color: #e74c3c;
  font-size: 0.85em;
  margin: 0;
  flex: 1;
}
.continuity-actions .btn-primary {
  padding: 10px 24px;
  border-radius: 8px;
  background: #2ecc71;
  color: #fff;
  border: none;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.continuity-actions .btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.continuity-actions .btn-secondary {
  padding: 10px 24px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #aaa);
  border: 1px solid var(--border-color, rgba(255,255,255,0.2));
  font-size: 0.95em;
  cursor: pointer;
  min-height: 44px;
}

/* Tabs for full audit */
.continuity-tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
}
.continuity-tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary, #aaa);
  font-size: 0.9em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  min-height: 44px;
}
.continuity-tab.active {
  color: var(--text-primary, #e0e0e0);
  border-bottom-color: #3498db;
}
.continuity-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.no-issues {
  color: #2ecc71;
  text-align: center;
  padding: 40px 20px;
  font-size: 1.1em;
}
.audit-chapter-section h3 {
  margin: 16px 0 8px;
  color: var(--text-primary, #e0e0e0);
  font-size: 1em;
}
.formatting-issue {
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-secondary, #16213e);
  border-radius: 8px;
  font-size: 0.9em;
  color: var(--text-primary, #e0e0e0);
}
.formatting-issue small {
  color: var(--text-secondary, #888);
}
.canon-chapter-summary {
  padding: 8px 12px;
  margin-bottom: 6px;
  color: var(--text-primary, #e0e0e0);
  font-size: 0.9em;
}
.canon-error {
  color: #e74c3c;
  font-size: 0.9em;
}

/* ═══════════════════════════════════════════════════════════
   PROCESS BANNER (below toolbar, non-blocking progress)
   ═══════════════════════════════════════════════════════════ */

.process-banner {
  position: relative;
  z-index: 100;
  background: var(--bg-secondary, #16213e);
  border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease;
}
.process-banner.visible {
  max-height: 120px;
  opacity: 1;
}
.process-banner.process-banner-exit {
  max-height: 0;
  opacity: 0;
}

.process-banner-inner {
  padding: 10px 20px 12px;
}

.process-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.process-banner-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.process-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3498db;
  animation: process-pulse 1.2s infinite;
  flex-shrink: 0;
}
.process-dot-done {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

@keyframes process-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.process-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary, #e0e0e0);
  white-space: nowrap;
}

.process-banner-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.process-percent {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary, #aaa);
  min-width: 32px;
  text-align: right;
}

.process-cancel-btn {
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.15));
  background: transparent;
  color: var(--text-secondary, #aaa);
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 32px;
  transition: background 0.15s, color 0.15s;
}
.process-cancel-btn:hover {
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
  border-color: rgba(231, 76, 60, 0.3);
}

.process-status {
  font-size: 0.78rem;
  color: var(--text-secondary, #999);
  margin-bottom: 6px;
  min-height: 1.1em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-bar-track {
  height: 4px;
  background: var(--border-color, rgba(255,255,255,0.08));
  border-radius: 2px;
  overflow: hidden;
}

.process-bar-fill {
  height: 100%;
  width: 0%;
  background: #3498db;
  border-radius: 2px;
  transition: width 0.4s ease, background 0.3s ease;
}

.process-bar-fill.indeterminate {
  width: 30% !important;
  animation: process-indeterminate 1.5s infinite ease-in-out;
}

@keyframes process-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
