/* 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;
}

/* Expand tab — sits at left edge of editor, only visible when nav is collapsed */
#btn-nav-expand {
  display: none;
  position: fixed;
  left: var(--sidebar-width, 280px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-left: none;
  color: var(--text-muted, #888);
  width: 18px;
  height: 48px;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  font-size: 0.65rem;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
#btn-nav-expand:hover {
  background: var(--bg-tertiary, rgba(255,255,255,0.08));
  color: var(--text-primary, #fff);
}
#app.chapnav-collapsed #btn-nav-expand {
  display: flex;
  align-items: center;
  justify-content: center;
}
#app.sidebar-collapsed #btn-nav-expand {
  left: 0;
}
@media (max-width: 768px) {
  #btn-nav-expand {
    left: 0;
  }
}

#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;
  aspect-ratio: 2/3; /* always holds book-cover shape — prevents cover-loading from overflowing when placeholder is hidden */
}

.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.75);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  gap: 10px;
  z-index: 10;
}
.cover-loading-spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cover-spin 0.8s linear infinite;
}
.cover-loading-text {
  text-align: center;
  padding: 0 8px;
  line-height: 1.3;
}
@keyframes cover-spin {
  to { transform: rotate(360deg); }
}

/* 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%;
}

/* Beauty style chapter header — shown above editor when style is applied */
#beauty-chapter-header {
  font-family: var(--font-serif);
  background: #fff;
  padding: 40px 40px 0;
  max-width: 720px;
  width: 100%;
  box-sizing: border-box;
  color: #111;
}
#beauty-chapter-header + .editor {
  padding-top: 12px;
}

.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: 5000; /* above wizard overlays (3000) and community modal (4000) */
  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 Download Dropdown ── */
.ce-download-group {
  position: relative;
  display: flex;
}
.ce-download-group .btn-sm:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: 1px solid rgba(255,255,255,0.15);
}
.ce-download-caret {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  padding: 0 6px !important;
  min-width: 22px;
}
.ce-download-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 100;
  min-width: 130px;
  overflow: hidden;
}
.ce-download-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.ce-download-item:hover {
  background: var(--accent-subtle);
}

/* ── Cover Editor Block Header Active State ── */
.ce-block-header-active {
  background: var(--accent-subtle) !important;
  border-left: 3px solid var(--accent-primary);
  padding-left: 5px !important;
}

.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;
  /* Prevent browser native drag-to-download on the canvas */
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-user-select: none;
  user-select: 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.8rem;
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1;
  min-width: 22px;
  text-align: center;
}

.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;
}

/* ── Adaptation Sections (Screenplays, Playwright, Audiobooks) ── */
.adaptations-section {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 24px;
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════════
   LIBRARY FOLDERS — Collapsible Dashboard Sections
   ═══════════════════════════════════════════════════════════════════ */
.library-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.library-folder {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.2s ease;
}

.library-folder:hover {
  border-color: rgba(139,92,246,0.25);
}

.library-folder-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.library-folder-header:hover {
  background: rgba(139,92,246,0.04);
}

.folder-chevron {
  font-size: 0.7rem;
  color: var(--text-secondary);
  transition: transform 0.25s ease;
  flex-shrink: 0;
  width: 14px;
}

.library-folder.collapsed .folder-chevron {
  transform: rotate(-90deg);
}

.folder-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}

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

.folder-info h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px 0;
  text-transform: none;
  letter-spacing: 0;
}

.folder-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(139,92,246,0.12);
  padding: 3px 10px;
  border-radius: 10px;
  flex-shrink: 0;
}

.folder-count:empty {
  display: none;
}

.folder-create-btn {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.library-folder-header:hover .folder-create-btn {
  opacity: 1;
}

.library-folder-content {
  padding: 0 18px 18px 18px;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  transition: padding 0.35s ease, opacity 0.25s ease;
  opacity: 1;
}

#standalone-books-list,
#series-folders-list,
#screenplays-section,
#playwright-section,
#audiobooks-section,
#video-storybooks-section,
#storyforge-section,
#globalprose-section {
  max-height: min(70vh, 900px);
}

.library-folder.collapsed .library-folder-content {
  max-height: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* GC104: the id list above carries specificity (1,0,0), which beats the collapsed rule's
   (0,3,0) — so a collapsed folder zeroed its opacity and padding but KEPT min(70vh,900px)
   of height, leaving the giant blank panel Bruce screenshotted when he collapsed the
   standalone books. Collapsed must outrank the id rule for every section it lists. */
.library-folder.collapsed #standalone-books-list,
.library-folder.collapsed #series-folders-list,
.library-folder.collapsed #screenplays-section,
.library-folder.collapsed #playwright-section,
.library-folder.collapsed #audiobooks-section,
.library-folder.collapsed #video-storybooks-section,
.library-folder.collapsed #storyforge-section,
.library-folder.collapsed #globalprose-section {
  max-height: 0;
}

/* Empty state for folders */
.library-folder-empty {
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 16px 0;
  text-align: center;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════ */
.adaptations-section-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.adaptations-icon {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}
.adaptations-section-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 2px;
}
.adaptations-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.adaptations-create-btn {
  margin-left: auto;
  flex-shrink: 0;
  margin-top: 4px;
}
/* Adaptation project cards */
.adaptation-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.adaptation-card:hover {
  border-color: rgba(139,92,246,0.4);
  background: rgba(139,92,246,0.04);
  transform: translateY(-1px);
}
.adaptation-card-type {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.adaptation-card-type.screenplay { color: #38bdb1; }
.adaptation-card-type.playwright { color: #f9a8b8; }
.adaptation-card-type.audiobook { color: #fbbf24; }
.adaptation-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.adaptation-card-meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.adaptation-card-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-complete { background: rgba(74,222,128,0.15); color: #4ade80; }
.status-in-progress { background: rgba(251,191,36,0.15); color: #fbbf24; }
.status-draft { background: rgba(139,92,246,0.15); color: #a78bfa; }
.adaptation-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.adaptations-empty {
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 20px 0;
}

.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);
}

.project-card {
  position: relative;
}

.project-card-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(220, 53, 69, 0.0);
  color: transparent;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
  z-index: 2;
}

.project-card:hover .project-card-delete {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
}

.project-card-delete:hover {
  background: rgba(220, 53, 69, 0.85) !important;
  color: #fff !important;
  transform: scale(1.1);
}

.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;
}

/* ============================================
   Local Find / Replace
   ============================================ */

#local-find-replace-bar {
  display: none;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-bottom: 2px solid #5b3fa8;
  padding: 10px 18px;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
  z-index: 12;
}

#local-find-replace-bar.visible {
  display: flex;
}

.local-fr-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 230px;
}

.local-fr-label {
  width: 54px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.local-fr-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
}

.local-fr-input:focus {
  border-color: #9b7fe8;
  box-shadow: 0 0 0 2px rgba(155, 127, 232, 0.18);
}

.local-fr-btn,
.local-fr-case-btn {
  flex-shrink: 0;
  min-height: 32px;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s, opacity 0.14s;
  white-space: nowrap;
}

.local-fr-btn {
  padding: 6px 11px;
}

.local-fr-case-btn {
  padding: 5px 8px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.local-fr-btn:hover,
.local-fr-case-btn:hover,
.local-fr-case-btn.active {
  background: rgba(91, 63, 168, 0.18);
  border-color: #9b7fe8;
  color: #d7c8ff;
}

.local-fr-btn.primary {
  background: #5b3fa8;
  border-color: #5b3fa8;
  color: #ffffff;
}

.local-fr-btn.primary:hover {
  background: #6c4cc5;
}

.local-fr-btn.danger {
  background: #c0392b;
  border-color: #c0392b;
  color: #ffffff;
}

.local-fr-btn.danger:hover {
  background: #a93226;
}

.local-fr-btn:disabled,
.local-fr-case-btn:disabled,
.local-fr-input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.local-fr-count {
  min-width: 66px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.local-fr-scope {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.local-fr-scope label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.local-fr-scope label.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.local-fr-scope input[type="radio"] {
  accent-color: #9b7fe8;
}

.local-fr-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
}

.local-fr-close:hover {
  color: var(--text-primary);
}

mark.local-fr-match {
  background: rgba(255, 213, 0, 0.56);
  border-radius: 2px;
  color: inherit;
  padding: 0;
}

mark.local-fr-match.current {
  background: rgba(255, 140, 0, 0.74);
  outline: 2px solid rgba(255, 140, 0, 0.88);
}

@media (max-width: 900px) {
  #local-find-replace-bar {
    padding: 9px 12px;
  }

  .local-fr-group,
  .local-fr-scope {
    width: 100%;
    flex-basis: 100%;
  }

  .local-fr-count {
    min-width: 54px;
  }
}

/* ============================================
   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;
  min-height: 0; /* critical: allows nested flex children to scroll correctly */
}

.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: hidden; /* clip to flex container; children scroll internally */
  min-height: 0;
}

.accept-outline-textarea {
  width: 100%;
  flex: 1;      /* grows to fill available height */
  min-height: 80px;  /* floor; flex handles the actual height */
  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: none;       /* flex controls height; manual resize would break layout */
  overflow-y: auto;   /* textarea scrolls internally */
  margin-bottom: 12px;
}

.accept-outline-btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0; /* always visible — never pushed off screen */
}

.accept-outline-rethink-area {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
  flex-shrink: 0; /* stays visible when rethink area is shown */
}

.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;
  touch-action: manipulation;
  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;
}

/* Show on hover (desktop) */
.nav-item:hover .drag-handle {
  opacity: 0.6;
}

/* Always show on touch devices (no hover) */
@media (pointer: coarse) {
  .nav-item .drag-handle {
    opacity: 0.5;
    font-size: 1rem;
    padding: 4px 6px;
    touch-action: none;
  }
}

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

/* Floating clone during touch drag */
.nav-drag-clone {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.85;
  background: var(--bg-secondary, #2a2520);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* --- 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;
}

/* Bio Wizard must float above the Setup Book modal */
#about-author-wizard-overlay {
  z-index: 400;
}

/* Also By picker is a light, folder-style workspace above Setup Book. */
#also-by-wizard-overlay {
  z-index: 410;
}

.also-by-wizard-modal {
  width: min(820px, 94vw);
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f7f9fc;
  color: #172033;
}

.also-by-wizard-modal .setup-book-header {
  background: #fff;
  color: #172033;
}

.also-by-wizard-modal .setup-book-header > div {
  min-width: 0;
}

.also-by-wizard-modal .setup-book-header h2 {
  margin: 0;
}

.also-by-wizard-modal .setup-book-header p {
  margin: 4px 0 0;
  color: #667085;
  font-size: 0.84rem;
}

.also-by-wizard-body {
  padding: 22px 26px;
  overflow-y: auto;
  color: #172033;
}

#also-by-project-catalog > h3 {
  margin: 22px 0 9px;
  color: #344054;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#also-by-project-catalog > h3:first-child {
  margin-top: 0;
}

.also-by-series-card,
.also-by-standalones {
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #d7deea;
  border-radius: 10px;
  background: #fff;
}

.also-by-series-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e9f0;
  background: #edf3fb;
  cursor: pointer;
}

.also-by-series-books {
  padding-left: 26px;
}

.also-by-book-row {
  display: grid;
  grid-template-columns: auto 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 8px 13px;
  border-bottom: 1px solid #edf0f5;
  cursor: pointer;
}

.also-by-book-row:last-child {
  border-bottom: 0;
}

.also-by-book-row:hover {
  background: #f8fbff;
}

.also-by-cover {
  width: 30px;
  height: 40px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.15);
}

.also-by-cover-empty {
  display: grid;
  place-items: center;
  background: #e9eef6;
  box-shadow: none;
}

.also-by-book-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  color: #172033;
  font-size: 0.88rem;
}

.also-by-book-subtitle {
  overflow: hidden;
  color: #667085;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.also-by-book-status {
  color: #667085;
  font-size: 0.73rem;
  white-space: nowrap;
}

.also-by-book-status.writing {
  color: #175cd3;
}

.also-by-book-status.ready {
  color: #067647;
}

.also-by-book-status.failed,
.also-by-error {
  color: #b42318;
}

.also-by-progress {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef4ff;
  color: #344054;
  font-size: 0.84rem;
}

.also-by-preview {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid #d7deea;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  line-height: 1.55;
}

.also-by-preview h2,
.also-by-preview h3,
.also-by-preview h4 {
  text-align: center;
}

.also-by-empty {
  padding: 18px;
  color: #667085;
  text-align: center;
}

.also-by-wizard-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #d7deea;
  background: #fff;
}

@media (max-width: 620px) {
  .also-by-series-books {
    padding-left: 10px;
  }
  .also-by-book-row {
    grid-template-columns: auto 30px minmax(0, 1fr);
  }
  .also-by-book-status {
    grid-column: 3;
  }
}

#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 */
/* v1944 (2026-09-12): the strip used to be ONE non-wrapping row that scrolled sideways
   with its scrollbar hidden (overflow-x:auto + scrollbar-width:none). Eight tabs filled a
   ~510px modal exactly, so the ninth — Production, shipped in v1943 — sat off the right
   edge where nothing indicated it existed. Bruce hard-refreshed and saw no tab. Tabs now
   wrap onto a second row instead; a tab can no longer be present and invisible. */
.setup-book-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  padding: 0 8px;
  flex-shrink: 0;
  gap: 2px;
  background: var(--bg-secondary);
}

.setup-tab {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  gap: 5px;
  border-radius: 0;
  margin-bottom: -1px;
  min-height: 40px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

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

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

.setup-tab .tab-icon {
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.85;
}

/* v1944: Production is the tab that finishes the book; it reads in the accent colour so it
   is findable at a glance, not one grey label among nine. */
.setup-tab[data-setup-tab="production"] {
  color: var(--accent-primary);
  font-weight: 700;
}
.setup-tab[data-setup-tab="production"] .tab-icon { opacity: 1; }

/* Tab Content */
.setup-book-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

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

/* Beauty tab needs full height — override the default block layout */
#setup-tab-beauty.setup-tab-content.active,
#setup-tab-beauty.active {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0 !important;
  max-width: none !important;
  overflow: hidden;
}

/* 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 {
  color: #1a1a1a;
  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; color: #1a1a1a; }
#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;
  color: #1a1a1a;  /* Explicit dark color — prevents dark-theme CSS vars cascading into white-bg frame */
}
#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;
  color: #1a1a1a;  /* Explicit dark text — the frame has background:#fff; theme vars would make it white-on-white */
}
#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-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-color, rgba(255,255,255,0.15));
  background: transparent;
  color: var(--text-secondary, #aaa);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.process-close-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary, #e0e0e0);
}

.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%); }
}

/* ── MasterProse Brand Logo ─────────────────────────────────────────────── */
.mp-brand-logo {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  color: var(--accent-primary);
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.mp-quill {
  width: 18px;
  height: 20px;
  flex-shrink: 0;
  color: var(--accent-primary);
}

/* Larger variant for welcome overlay */
.mp-brand-logo--welcome {
  font-size: 1.5rem;
  gap: 9px;
}

.mp-brand-logo--welcome .mp-quill {
  width: 22px;
  height: 25px;
}

/* sidebar-header h1 already sets font/color via .sidebar-header h1 — just need flex */
.sidebar-header h1.mp-brand-logo {
  font-size: 1.2rem;
}

/* landing-title override */
h1.landing-title.mp-brand-logo {
  font-size: 1.2rem;
}

/* ── Chapter H1 + H2 Headings (injected by AW for TOC generation) ─────────── */
.editor h1.chapter-h1-heading {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-align: center;
  margin: 1.5em 0 0.1em;
  padding-bottom: 0.3em;
  border-bottom: none;
  pointer-events: none;
}
.editor h2.chapter-title-heading {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-secondary, #888);
  text-align: center;
  margin: 0 0 1.2em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border-color);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   PROJECT TYPE SELECTOR (pt-* prefix)
   ═══════════════════════════════════════════════════════════════════ */
.pt-card {
  padding: 18px;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 10px;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
}
.pt-card:hover {
  border-color: var(--accent-primary, #5de0f4);
  background: rgba(14,116,144,0.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.pt-card-screen:hover {
  border-color: #5de0f4;
  background: rgba(14,116,144,0.1);
}
.pt-card-play:hover {
  border-color: #f9a8b8;
  background: rgba(139,32,53,0.1);
}
.pt-icon { font-size: 1.8rem; margin-bottom: 8px; }
.pt-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary, #e0e6ff);
  margin-bottom: 6px;
}
.pt-desc {
  font-size: 0.8rem;
  color: var(--text-secondary, rgba(255,255,255,0.5));
  line-height: 1.55;
  margin-bottom: 10px;
}
.pt-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
}
.pt-badge-free   { background: rgba(100,200,100,0.15); color: #86efac; border: 1px solid rgba(100,200,100,0.3); }
.pt-badge-ws     { background: rgba(96,165,250,0.15);  color: #93c5fd; border: 1px solid rgba(96,165,250,0.3); }
.pt-badge-aw     { background: rgba(201,168,76,0.15);  color: #e8d5a3; border: 1px solid rgba(201,168,76,0.3); }
.pt-badge-screen { background: rgba(14,116,144,0.2);   color: #5de0f4; border: 1px solid rgba(14,116,144,0.4); }
.pt-badge-play   { background: rgba(139,32,53,0.2);    color: #f9a8b8; border: 1px solid rgba(139,32,53,0.4); }
.pt-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e8d5a3;
}


/* ============================================
   Matter Tab — Row Layout with Generate Buttons
   ============================================ */

.matter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matter-row .matter-option {
  flex: 1;
  margin: 0;
}

.matter-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.matter-gen-btn {
  padding: 5px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.matter-status-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}

.matter-status-chip.done {
  background: rgba(74, 124, 89, 0.25);
  color: #6abf7b;
  border: 1px solid rgba(74, 124, 89, 0.4);
}

.matter-status-chip.done::before { content: '✓ '; }

.matter-status-chip.generating {
  background: rgba(240, 165, 0, 0.18);
  color: var(--accent, #f0a500);
  border: 1px solid rgba(240, 165, 0, 0.3);
}

.matter-status-chip.generating::before { content: '⟳ '; }

/* ═══════════════════════════════════════════════════
   Beauty Tab — layout overrides
   The beauty tab needs full-height flex, not block
═══════════════════════════════════════════════════ */
#setup-tab-beauty {
  padding: 0 !important;
  max-width: none !important;
  overflow: hidden;
}
#setup-tab-beauty.active {
  display: flex !important;
  flex-direction: column;
  height: 100%;
}

/* setup-book-body must always be scrollable — overflow:hidden blocked the Export tab.
   The Beauty tab manages its own overflow internally via its flex children. */
.setup-book-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Google Fonts for Beauty Tab typography previews */
@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400;600;700&family=Cinzel:wght@400;600&family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Spectral:ital,wght@0,400;0,600;1,400&family=Lora:ital,wght@0,400;0,600;1,400&family=Merriweather:ital,wght@0,400;0,700;1,400&family=EB+Garamond:ital,wght@0,400;0,500;1,400&family=Crimson+Pro:ital,wght@0,400;0,600;1,400;1,600&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,600&display=swap');

/* ═══════════════════════════════════════════════════════════
   AUDIT FIX MANAGEMENT — actionable conflict cards + fix panel
   ═══════════════════════════════════════════════════════════ */

/* Bulk action bar */
.audit-bulk-btn {
  padding: 5px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: rgba(200,200,200,0.7);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.audit-bulk-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #e0e0e0;
}

/* Full-audit finding cards */
.audit-full-card {
  background: var(--bg-secondary, #16213e);
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 14px 16px;
  border-left: 4px solid #555;
  transition: opacity 0.2s;
}
.audit-full-card.severity-critical { border-left-color: #e74c3c; }
.audit-full-card.severity-moderate { border-left-color: #f39c12; }
.audit-full-card.severity-minor    { border-left-color: #3498db; }
.audit-full-card.resolved   { opacity: 0.65; }
.audit-full-card.dismissed  { opacity: 0.35; }

.audit-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.audit-card-body { margin-bottom: 10px; }
.audit-evidence {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 600px) {
  .audit-evidence { grid-template-columns: 1fr; }
}
.audit-quote-block label,
.audit-canon-block label,
.audit-fix-block label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(200,200,200,0.4);
  margin-bottom: 4px;
}
.audit-quote-block blockquote {
  margin: 0;
  padding: 6px 10px;
  background: rgba(231,76,60,0.07);
  border-left: 2px solid rgba(231,76,60,0.3);
  font-size: 12px;
  color: rgba(220,200,200,0.8);
  font-style: italic;
  line-height: 1.5;
  border-radius: 0 4px 4px 0;
}
.audit-canon-block p {
  margin: 0;
  font-size: 12px;
  color: rgba(220,220,220,0.7);
  line-height: 1.5;
}
.audit-fix-block {
  padding: 8px 12px;
  background: rgba(46,204,113,0.06);
  border-left: 2px solid rgba(46,204,113,0.25);
  border-radius: 0 4px 4px 0;
}
.audit-fix-text {
  font-size: 12px;
  color: rgba(180,240,200,0.8);
  line-height: 1.5;
}

/* Per-card action buttons */
.audit-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.audit-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(200,200,200,0.75);
}
.audit-btn:hover { background: rgba(255,255,255,0.12); color: #e0e0e0; }
.audit-btn-accept {
  border-color: rgba(46,204,113,0.4);
  color: #2ecc71;
  background: rgba(46,204,113,0.08);
}
.audit-btn-accept:hover { background: rgba(46,204,113,0.18); }
.audit-btn-dismiss {
  border-color: rgba(200,200,200,0.15);
  color: rgba(200,200,200,0.4);
}
.audit-card-resolved {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.audit-resolved-label { flex: 1; }
.audit-btn-undo {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  background: none;
  color: rgba(200,200,200,0.4);
  cursor: pointer;
}
.audit-btn-undo:hover { color: rgba(200,200,200,0.7); }

/* ── Guided Fix Panel ──────────────────────────────────────── */
#audit-fix-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 11000;
  -webkit-overflow-scrolling: touch;
}
#audit-fix-panel-inner {
  background: #16182a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
}
#audit-fix-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
@media (max-width: 500px) {
  #audit-fix-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-radius: 14px 14px 0 0;
  }
}

/* Quote highlight in editor */
.audit-highlight {
  background: rgba(255, 220, 40, 0.35);
  border-bottom: 2px solid rgba(255, 200, 0, 0.7);
  border-radius: 2px;
  color: inherit;
}

/* Audit fix options spinner */
.audit-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(180,200,255,0.2);
  border-top-color: rgba(140,180,255,0.8);
  border-radius: 50%;
  animation: audit-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes audit-spin { to { transform: rotate(360deg); } }

/* Fix options panel within finding cards */
.audit-fix-options-panel blockquote {
  font-style: italic;
  word-break: break-word;
  overflow-wrap: break-word;
  max-height: 120px;
  overflow-y: auto;
}

/* ── Fixes Waiting badge pulse ────────────────────────────────── */
@keyframes fixesBadgePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
  50%      { box-shadow: 0 0 8px 4px rgba(46,204,113,0.3); }
}

/* ══════════════════════════════════════════════════════════════
   GlobalProse™ Wizard Styles
   ══════════════════════════════════════════════════════════════ */

.gp-wizard {
  min-height: 100vh;
  background: #f5f7f5;
  color: #1a2e1a;
  font-family: 'Inter', -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.gp-header {
  background: #ffffff;
  border-bottom: 1px solid #d0e4d0;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.gp-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.gp-logo { font-size: 24px; }
.gp-title { font-size: 18px; font-weight: 700; color: #1e7a1e; letter-spacing: -0.02em; }
.gp-title sup { font-size: 11px; color: #b8860b; }
.gp-sub { font-size: 11px; color: #6a9a6a; }

/* ── Step indicators ── */
.gp-steps {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  justify-content: center;
  overflow: hidden;
}
.gp-step-pip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.gp-pip-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e8f0e8;
  border: 1px solid #b8d4b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #6a9a6a;
  transition: all .2s;
}
.gp-step-pip.active .gp-pip-num {
  background: #d0ead0;
  border-color: #2d8a2d;
  color: #1e6a1e;
}
.gp-step-pip.done .gp-pip-num {
  background: #2d8a2d;
  border-color: #1e6a1e;
  color: #ffffff;
}
.gp-pip-label {
  font-size: 9px;
  color: #8aba8a;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.gp-step-pip.active .gp-pip-label,
.gp-step-pip.done .gp-pip-label { color: #2d7a2d; }
.gp-step-line {
  height: 1px;
  width: 24px;
  background: #c8dcc8;
  flex-shrink: 0;
  margin: 0 2px;
  margin-bottom: 14px;
}
.gp-step-line.done { background: #2d8a2d; }
.gp-close-btn {
  background: none;
  border: 1px solid #c0d8c0;
  color: #6a9a6a;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
}
.gp-close-btn:hover { border-color: #2d8a2d; color: #1e6a1e; }

/* ── Body ── */
.gp-body {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}
.gp-step-content {
  width: 100%;
  max-width: 780px;
}
.gp-step-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a3a1a;
  margin-bottom: 8px;
  letter-spacing: -.02em;
}
.gp-step-desc {
  font-size: 14px;
  color: #4a7a4a;
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ── Upload Zone ── */
.gp-upload-zone {
  border: 2px dashed #90c890;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 20px;
  background: #ffffff;
}
.gp-upload-zone:hover,
.gp-upload-zone.drag-over { border-color: #2d8a2d; background: #f0f8f0; }
.gp-upload-icon { font-size: 40px; margin-bottom: 12px; }
.gp-upload-label { font-size: 15px; color: #2a4a2a; margin-bottom: 10px; }
.gp-link { color: #1e7a1e; text-decoration: underline; }
.gp-upload-formats { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.gp-fmt {
  background: rgba(30,122,30,.08);
  color: #1e6a1e;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  border: 1px solid rgba(30,122,30,.2);
}
.gp-fmt-soon { opacity: .4; }
.gp-upload-hint { font-size: 12px; color: #7aaa7a; }
.gp-upload-error { color: #cc2222; font-size: 13px; margin-top: 12px; }

/* ── Progress ── */
.gp-progress-bar-wrap {
  background: #d8ecd8;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.gp-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2d8a2d, #5aaa5a);
  transition: width .3s;
}
.gp-progress-label { font-size: 13px; color: #4a7a4a; }
.gp-parse-progress { margin-bottom: 16px; }

/* ── Parsed preview ── */
.gp-parsed-preview {
  background: #ffffff;
  border: 1px solid #b8d8b8;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.gp-pv-title { font-size: 16px; font-weight: 700; color: #1a3a1a; }
.gp-pv-author { font-size: 13px; color: #4a7a4a; margin-left: 8px; }
.gp-parsed-stats { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.gp-stat-chip {
  background: rgba(30,122,30,.07);
  border: 1px solid rgba(30,122,30,.18);
  color: #1e6a1e;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
}
.gp-parsed-chapters { margin-top: 8px; }
.gp-chap-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; color: #2a4a2a; }
.gp-chap-type {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.gp-chap-chapter { background: rgba(30,122,30,.10); color: #1e6a1e; }
.gp-chap-front   { background: rgba(184,134,11,.10); color: #8a6a00; }
.gp-chap-back    { background: rgba(60,60,180,.10); color: #4444aa; }
.gp-chap-unknown { background: rgba(120,120,120,.10); color: #666; }
.gp-chap-name { color: #2a5a2a; font-weight: 500; }
.gp-chap-more { font-size: 12px; color: #7aaa7a; padding: 4px 0; }

/* ── Language grid ── */
.gp-lang-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.gp-lang-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 8px;
  background: #ffffff;
  border: 1px solid #c8dcc8;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.gp-lang-card:hover { border-color: #4a9a4a; background: #f0f8f0; }
.gp-lang-card.selected { border-color: #2d8a2d; background: #e8f5e8; }
.gp-lang-card.tier2 { opacity: .7; }
.gp-lang-flag { font-size: 22px; }
.gp-lang-name { font-size: 11px; color: #2a5a2a; font-weight: 600; }
.gp-lang-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 8px;
  background: #f0ead8;
  color: #7a6a10;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── Locale select ── */
.gp-label { font-size: 12px; font-weight: 600; color: #1e7a1e; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 6px; display: block; }
.gp-select {
  width: 100%;
  background: #ffffff;
  border: 1px solid #b8d4b8;
  color: #1a3a1a;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}
.gp-select:focus { border-color: #2d8a2d; }
.gp-field-hint { font-size: 12px; color: #7aaa7a; margin-top: 5px; line-height: 1.5; }

/* ── Radio groups ── */
.gp-config-section { margin-bottom: 28px; }
.gp-radio-group { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.gp-radio {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid #c8dcc8;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.gp-radio-content { flex: 1; min-width: 0; }
.gp-radio:hover { border-color: #4a9a4a; }
.gp-radio.selected { border-color: #2d8a2d; background: #eef8ee; }
.gp-radio input { accent-color: #2d8a2d; flex-shrink: 0; margin-top: 2px; }
.gp-radio-title { font-size: 14px; font-weight: 600; color: #1a3a1a; }
.gp-radio-desc { font-size: 12px; color: #5a8a5a; margin-top: 3px; line-height: 1.5; }
.gp-rec {
  font-size: 10px;
  background: rgba(184,134,11,.12);
  color: #7a5a00;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  font-weight: 500;
}

/* ── Metadata grid ── */
.gp-meta-grid { display: flex; flex-direction: column; gap: 20px; margin-bottom: 20px; }
.gp-meta-row { display: flex; align-items: center; gap: 16px; }
.gp-meta-col { flex: 1; }
.gp-meta-arrow { font-size: 20px; color: #8aba8a; flex-shrink: 0; }
.gp-meta-original {
  background: #f0f5f0;
  border: 1px solid #c8dcc8;
  color: #4a6a4a;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.gp-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #b8d4b8;
  color: #1a3a1a;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}
.gp-input:focus { border-color: #2d8a2d; }

/* ── Info box ── */
.gp-info-box {
  display: flex;
  gap: 10px;
  background: rgba(30,122,30,.04);
  border: 1px solid rgba(30,122,30,.18);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  color: #3a6a3a;
  line-height: 1.6;
  margin-bottom: 20px;
}
.gp-info-icon { flex-shrink: 0; }

/* ── Cover options ── */
.gp-cover-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 16px; }
.gp-cover-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 14px;
  background: #ffffff;
  border: 1px solid #c8dcc8;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.gp-cover-card:hover { border-color: #4a9a4a; }
.gp-cover-card.selected { border-color: #2d8a2d; background: #eef8ee; }
.gp-cover-card input { display: none; }
.gp-cover-icon { font-size: 28px; }
.gp-cover-name { font-size: 13px; font-weight: 600; color: #1a3a1a; }
.gp-cover-desc { font-size: 12px; color: #5a7a5a; line-height: 1.5; }
.gp-badge-price {
  font-size: 10px;
  background: rgba(200,60,60,.10);
  color: #cc3333;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}
.gp-warning {
  display: flex;
  gap: 10px;
  background: rgba(200,120,40,.07);
  border: 1px solid rgba(200,120,40,.25);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #8a5020;
  line-height: 1.5;
}

/* ── Theme grid ── */
.gp-theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gp-theme-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px 14px;
  background: #ffffff;
  border: 1px solid #c8dcc8;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.gp-theme-card:hover { border-color: #4a9a4a; }
.gp-theme-card.selected { border-color: #2d8a2d; background: #eef8ee; }
.gp-theme-card.gp-theme-featured { border-color: #2d8a2d; border-width: 2px; position: relative; }
.gp-theme-card.gp-theme-featured.selected { background: #eef8ee; box-shadow: 0 0 0 2px rgba(45,138,45,.20); }
.gp-theme-card input { display: none; }
.gp-theme-icon { font-size: 22px; }
.gp-theme-name { font-size: 13px; font-weight: 600; color: #1a3a1a; }
.gp-theme-desc { font-size: 11px; color: #5a7a5a; line-height: 1.4; }
.gp-badge-recommended { display: inline-block; font-size: 9px; font-weight: 700; background: #d8f0d8; color: #1e6a1e; border: 1px solid #90c890; border-radius: 10px; padding: 1px 6px; vertical-align: middle; margin-left: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.gp-info-success { border-left-color: #2d8a2d !important; background: rgba(45,138,45,.05) !important; }

/* ── Step 2: Marketing Files ── */
.gp-mkt-file-list { background:#f8fbf8; border:1px solid rgba(30,122,30,.18); border-radius:8px; padding:12px 14px; margin-bottom:16px; }
.gp-mkt-file-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid rgba(30,122,30,.08); }
.gp-mkt-file-row:last-child { border-bottom:none; }
.gp-mkt-file-icon { font-size:1rem; }
.gp-mkt-file-name { flex:1; font-size:13px; color:#1a3a1a; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.gp-mkt-file-words { font-size:12px; color:#5a7a5a; white-space:nowrap; }
.gp-mkt-remove-btn { background:none; border:none; color:#cc3333; font-size:1.1rem; cursor:pointer; padding:0 4px; line-height:1; }
.gp-mkt-remove-btn:hover { color:#aa1111; }
.gp-mkt-total { font-size:12px; color:#4a7a4a; margin-top:10px; padding-top:8px; border-top:1px solid rgba(30,122,30,.1); }
.gp-upload-zone-sm { min-height:80px !important; }

/* ── Step 7: Payment ── */
.gp-payment-card {
  background: #ffffff;
  border: 1px solid rgba(30,122,30,.28);
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 16px;
}
.gp-payment-tier-label { font-size: 12px; font-weight: 700; color: #1e7a1e; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.gp-payment-price { font-size: 2.8rem; font-weight: 800; color: #1a3a1a; line-height: 1; margin-bottom: 6px; }
.gp-payment-desc { font-size: 13px; color: #4a7a4a; margin-bottom: 20px; }
.gp-payment-features { list-style: none; padding: 0; margin: 0 0 8px; text-align: left; display: inline-block; }
.gp-payment-features li { font-size: 13px; color: #3a6a3a; padding: 4px 0; }

/* ── Step 8 ── */
.gp-summary-card {
  background: #ffffff;
  border: 1px solid #b8d4b8;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.gp-summary-title { font-size: 18px; font-weight: 700; color: #1a3a1a; }
.gp-summary-meta { font-size: 13px; color: #4a7a4a; margin-bottom: 14px; }
.gp-summary-stats { display: flex; gap: 20px; margin-bottom: 14px; }
.gp-stat { display: flex; flex-direction: column; align-items: center; }
.gp-stat-n { font-size: 16px; font-weight: 700; color: #1e7a1e; }
.gp-stat-l { font-size: 11px; color: #6a9a6a; }
.gp-summary-config { display: flex; flex-wrap: wrap; gap: 6px; }
.gp-config-tag {
  font-size: 11px;
  background: rgba(30,122,30,.06);
  border: 1px solid rgba(30,122,30,.15);
  color: #3a7a3a;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── Translation progress ── */
.gp-progress-bar-wrap.gp-progress-large { height: 10px; }
.gp-progress-phase { font-size: 14px; font-weight: 600; color: #1a3a1a; margin-bottom: 10px; }
.gp-progress-counts { font-size: 12px; color: #4a7a4a; margin-top: 8px; margin-bottom: 16px; }
.gp-chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.gp-chap-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #3a6a3a; }
.gp-chap-dot { font-size: 14px; flex-shrink: 0; }
.gp-chap-dot.pending { color: #90c890; }
.gp-chap-dot.translating { color: #b8860b; animation: gp-spin 1s linear infinite; }
.gp-chap-dot.done { color: #1e7a1e; }
.gp-chap-dot.error { color: #cc2222; }
.gp-chap-name-sm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #2a4a2a; }
@keyframes gp-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Complete + Multi-Format Download ── */
.gp-complete-banner { text-align: center; padding: 30px 0 16px; }
.gp-complete-icon { font-size: 48px; margin-bottom: 12px; }
.gp-complete-title { font-size: 22px; font-weight: 700; color: #1e7a1e; margin-bottom: 6px; }
.gp-complete-sub { font-size: 14px; color: #4a7a4a; margin-bottom: 24px; }

.gp-format-grid { display: flex; flex-direction: column; gap: 10px; margin: 0 0 20px; }
.gp-format-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border: 1px solid #c8dcc8;
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color .15s;
}
.gp-format-card:hover { border-color: #4a9a4a; }
.gp-fmt-icon { font-size: 26px; flex-shrink: 0; width: 36px; text-align: center; }
.gp-fmt-info { flex: 1; min-width: 0; }
.gp-fmt-name { font-size: 14px; font-weight: 700; color: #1a3a1a; margin-bottom: 2px; }
.gp-fmt-desc { font-size: 11px; color: #5a7a5a; }
.gp-fmt-btn { flex-shrink: 0; min-width: 150px; justify-content: center; font-size: 13px; padding: 9px 18px; }

.gp-btn-secondary {
  background: #eef8ee;
  color: #1e7a1e;
  border: 1px solid #90c890;
}
.gp-btn-secondary:hover:not(:disabled) { background: #d8f0d8; border-color: #4a9a4a; }

.gp-generate-all-wrap { text-align: center; margin-top: 6px; padding-top: 16px; border-top: 1px solid rgba(30,120,30,.15); }
.gp-btn-gold {
  background: linear-gradient(135deg, #7a5a10, #c9a030);
  color: #fff8e0;
  border: 1px solid #c9a030;
  font-size: 15px;
  padding: 13px 28px;
}
.gp-btn-gold:hover:not(:disabled) { background: linear-gradient(135deg, #9a7a18, #deb840); }
.gp-btn-generate-all { width: 100%; justify-content: center; margin-bottom: 10px; }

.gp-format-status {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  padding: 12px;
  background: #f0f8f0;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: #1e7a1e;
}
.gp-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(30,122,30,.2);
  border-top-color: #2d8a2d;
  border-radius: 50%;
  animation: gp-spin 0.9s linear infinite;
}
.gp-spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid rgba(30,122,30,.25);
  border-top-color: #2d8a2d;
  border-radius: 50%;
  animation: gp-spin 0.8s linear infinite;
  flex-shrink: 0;
}
.gp-download-hint { font-size: 11px; color: #7aaa7a; margin-top: 4px; }

/* ── Error ── */
.gp-error-banner {
  background: rgba(200,40,40,.05);
  border: 1px solid rgba(200,40,40,.2);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}
.gp-error-icon { font-size: 36px; margin-bottom: 10px; }
.gp-error-title { font-size: 16px; font-weight: 700; color: #cc2222; margin-bottom: 8px; }
.gp-error-msg { font-size: 13px; color: #aa3333; margin-bottom: 16px; }

/* ── Nav ── */
.gp-nav { display: flex; justify-content: space-between; margin-top: 32px; }
.gp-btn {
  padding: 10px 24px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.gp-btn:disabled { opacity: .4; cursor: not-allowed; }
.gp-btn-primary {
  background: linear-gradient(135deg, #1e6a1e, #2d9a2d);
  color: #ffffff;
  border: 1px solid #1e7a1e;
}
.gp-btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #2d8a2d, #3aaa3a); }
.gp-btn-ghost {
  background: transparent;
  color: #4a7a4a;
  border: 1px solid #b8d4b8;
}
.gp-btn-ghost:hover { border-color: #4a9a4a; color: #2d7a2d; }
.gp-btn-launch { padding: 12px 32px; font-size: 15px; }

@media (max-width: 640px) {
  .gp-lang-grid { grid-template-columns: repeat(3, 1fr); }
  .gp-cover-options, .gp-theme-grid { grid-template-columns: 1fr; }
  .gp-summary-stats { flex-wrap: wrap; }
  .gp-steps { display: none; }
  .gp-chapter-grid { grid-template-columns: 1fr; }
  .gp-meta-row { flex-direction: column; }
  .gp-format-card { flex-wrap: wrap; }
  .gp-fmt-btn { width: 100%; }
}

/* ── Quality Polish Pass ────────────────────────────────────────────────── */
.gp-polish-upsell {
  background: linear-gradient(160deg, rgba(20,35,20,.95) 0%, rgba(12,24,12,.98) 100%);
  border: 1px solid rgba(180,150,40,.35);
  border-radius: 12px;
  padding: 28px 32px;
}
.gp-polish-badge {
  display: inline-block;
  background: linear-gradient(135deg, #7a6010, #c8a820);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 4px 14px;
  margin-bottom: 16px;
}
.gp-polish-title {
  font-size: 20px;
  font-weight: 700;
  color: #e8d870;
  margin: 0 0 14px;
  line-height: 1.3;
}
.gp-polish-desc {
  font-size: 13.5px;
  color: #a8c0a0;
  line-height: 1.75;
  margin: 0 0 12px;
}
.gp-polish-callout {
  background: rgba(0,0,0,.02);
  border: 1px solid rgba(0,0,0,.04);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 18px 0 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gp-polish-callout-row {
  font-size: 12.5px;
  color: #90a890;
  line-height: 1.6;
}
.gp-polish-price-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.gp-polish-price {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gp-polish-price-main {
  font-size: 22px;
  font-weight: 800;
  color: #e8d060;
}
.gp-polish-price-equiv {
  font-size: 12px;
  color: #6a8a6a;
}
.gp-polish-balance {
  font-size: 12px;
  color: #6aaa6a;
  background: rgba(80,180,80,.08);
  border: 1px solid rgba(80,180,80,.15);
  border-radius: 20px;
  padding: 3px 12px;
}
.gp-polish-balance-low {
  color: #e87070;
  background: rgba(180,80,80,.08);
  border-color: rgba(180,80,80,.2);
}
.gp-polish-cta {
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  margin-bottom: 12px;
}
.gp-polish-insufficient { margin-bottom: 12px; }
.gp-polish-skip { text-align: center; }
.gp-btn-link {
  background: none;
  border: none;
  color: #5a7a5a;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.gp-btn-link:hover { color: #8aaa8a; }

/* Polish — progress phases */
.gp-polish-progress {
  padding: 24px;
  text-align: center;
}
.gp-polish-phase-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8aaa6a;
  margin-bottom: 20px;
}
.gp-polish-spinner-wrap {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}
.gp-polish-status {
  font-size: 14px;
  color: #a0c080;
  margin-bottom: 10px;
  font-weight: 600;
}
.gp-polish-substatus {
  font-size: 12px;
  color: #5a7a5a;
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
}

/* Polish — audit results */
.gp-polish-results { padding: 4px 0; }
.gp-polish-score {
  font-size: 13px;
  color: #8aaa6a;
  margin: 10px 0 14px;
  font-style: italic;
}
.gp-polish-issue-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.gp-issue-count {
  font-size: 12px;
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 12px;
}
.gp-issue-count.high   { background: rgba(200,80,80,.15); color: #e88080; border: 1px solid rgba(200,80,80,.25); }
.gp-issue-count.med    { background: rgba(200,160,40,.12); color: #d4a840; border: 1px solid rgba(200,160,40,.2); }
.gp-issue-count.low    { background: rgba(80,160,80,.1); color: #6aaa6a; border: 1px solid rgba(80,160,80,.18); }
.gp-polish-results-intro { font-size: 13px; color: #7a9a7a; margin: 0 0 18px; }
.gp-issue-group-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6a8a6a;
  margin: 18px 0 10px;
}
.gp-issue-card {
  background: rgba(0,0,0,.02);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 3px solid transparent;
}
.gp-issue-high  { border-left-color: rgba(200,80,80,.5); }
.gp-issue-medium { border-left-color: rgba(200,160,40,.5); }
.gp-issue-low   { border-left-color: rgba(80,160,80,.4); }
.gp-issue-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.gp-issue-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-radius: 20px;
  padding: 2px 9px;
}
.gp-issue-badge-high   { background: rgba(200,80,80,.15); color: #e88080; }
.gp-issue-badge-medium { background: rgba(200,160,40,.12); color: #d4a840; }
.gp-issue-badge-low    { background: rgba(80,160,80,.1); color: #6aaa6a; }
.gp-issue-type {
  font-size: 12px;
  font-weight: 600;
  color: #90aa90;
  text-transform: capitalize;
  flex: 1;
}
.gp-issue-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; margin-left: auto; }
.gp-issue-toggle-label { font-size: 11px; color: #6a8a6a; }
.gp-issue-check { accent-color: #7acc7a; cursor: pointer; width: 14px; height: 14px; }
.gp-issue-passage {
  font-size: 12.5px;
  color: #7a9a7a;
  font-style: italic;
  line-height: 1.55;
  margin-bottom: 8px;
}
.gp-issue-desc {
  font-size: 12px;
  color: #6a8a6a;
  margin-bottom: 6px;
  line-height: 1.5;
}
.gp-issue-fix {
  font-size: 12px;
  color: #5a8a5a;
  line-height: 1.5;
}
.gp-issue-fix strong { color: #7aaa7a; }
.gp-polish-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.gp-polish-actions .gp-btn { flex: 1; min-width: 160px; }

/* Polish — done */
.gp-polish-done {
  text-align: center;
  padding: 28px;
}
.gp-polish-done-icon {
  font-size: 42px;
  color: #6acc6a;
  margin: 12px 0;
}
.gp-polish-done-title {
  font-size: 18px;
  font-weight: 700;
  color: #a8d8a0;
  margin-bottom: 10px;
}
.gp-polish-done-desc {
  font-size: 13px;
  color: #6a9a6a;
  margin-bottom: 14px;
}
.gp-polish-done-note {
  font-size: 12px;
  color: #4a7a4a;
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.6;
}


/* Publish nav tabs */
.gp-pub-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.gp-pub-nav::-webkit-scrollbar { display: none; }
.gp-pub-tab {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: #6b7280;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.gp-pub-tab:hover { color: #374151; }
.gp-pub-tab-active { color: #7acc7a !important; border-bottom-color: #7acc7a !important; }

/* Publish panel container */
.gp-pub-panel { padding-bottom: 12px; }

/* Section label / step indicator */
.gp-pub-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 6px;
}
.gp-pub-title { font-size: 18px; font-weight: 700; color: #1a3a1a; margin-bottom: 4px; }
.gp-pub-sub { font-size: 13px; color: #5a8a5a; margin-bottom: 16px; }

/* Publish cards */
.gp-pub-card {
  background: rgba(0,0,0,0.02);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.gp-pub-card-head {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}
.gp-pub-card-note {
  font-size: 11px;
  font-weight: 400;
  color: #9ca3af;
  margin-left: 4px;
}

/* Field rows */
.gp-pub-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.gp-pub-field-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.gp-pub-field { display: flex; flex-direction: column; gap: 4px; }
.gp-pub-label { font-size: 11px; color: #6b7280; }
.gp-pub-input {
  font-size: 13px;
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  padding: 6px 9px;
  color: #1a3a1a;
  width: 100%;
  transition: border-color .15s;
}
.gp-pub-input:focus { outline: none; border-color: rgba(120,200,120,0.5); }
.gp-pub-textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.gp-pub-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
  background: rgba(80,180,80,0.15);
  color: #7acc7a;
  border: 1px solid rgba(80,180,80,0.3);
}
.gp-pub-badge-ai { background: rgba(139,92,246,0.15); color: #a78bfa; border-color: rgba(139,92,246,0.3); }

/* AI generate blurb button */
.gp-pub-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid rgba(139,92,246,0.4);
  border-radius: 20px;
  background: rgba(139,92,246,0.08);
  cursor: pointer;
  color: #a78bfa;
  margin-top: 6px;
  transition: background .15s;
}
.gp-pub-ai-btn:hover { background: rgba(139,92,246,0.18); }
.gp-pub-ai-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Checkbox rows */
.gp-pub-check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 6px;
  cursor: pointer;
}
.gp-pub-check-row input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #7acc7a;
}

/* Platform selection grid */
.gp-platform-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.gp-platform-card {
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
  background: rgba(0,0,0,0.02);
}
.gp-platform-card:hover { border-color: rgba(120,200,120,0.4); background: rgba(120,200,120,0.05); }
.gp-platform-selected { border-color: rgba(120,200,120,0.6) !important; background: rgba(120,200,120,0.08) !important; }
.gp-platform-selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 11px;
  color: #7acc7a;
  font-weight: 700;
}
.gp-platform-icon { font-size: 18px; margin-bottom: 4px; }
.gp-platform-name { font-size: 13px; font-weight: 600; color: #1a3a1a; margin-bottom: 2px; }
.gp-platform-desc { font-size: 11px; color: #5a8a5a; }

/* Readiness checklist */
.gp-checklist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.gp-check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
}
.gp-check-ok    { background: rgba(74,222,128,0.07); }
.gp-check-warn  { background: rgba(251,191,36,0.07); }
.gp-check-info  { background: rgba(0,0,0,0.02); }
.gp-check-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.gp-check-ok   .gp-check-dot { background: #4ade80; }
.gp-check-warn .gp-check-dot { background: #fbbf24; }
.gp-check-info .gp-check-dot { background: rgba(0,0,0,0.15); }
.gp-check-strong { font-weight: 600; color: #1f2937; display: block; margin-bottom: 1px; }
.gp-check-detail { color: #9ca3af; font-size: 11px; }

/* Trim size pills */
.gp-trim-options { display: flex; flex-wrap: wrap; gap: 6px; }
.gp-trim-pill {
  padding: 5px 12px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: #4b5563;
  transition: all .15s;
}
.gp-trim-pill:hover { border-color: rgba(120,200,120,0.4); color: #1a3a1a; }
.gp-trim-active { background: rgba(120,200,120,0.15) !important; border-color: rgba(120,200,120,0.6) !important; color: #7acc7a !important; }

/* Toggle groups (paper/fontsize/color) */
.gp-toggle-group { display: flex; gap: 0; }
.gp-toggle-opt {
  padding: 5px 13px;
  font-size: 11px;
  border: 1px solid rgba(0,0,0,0.08);
  cursor: pointer;
  background: transparent;
  color: #6b7280;
  transition: all .15s;
}
.gp-toggle-opt:first-child { border-radius: 6px 0 0 6px; }
.gp-toggle-opt:last-child  { border-radius: 0 6px 6px 0; border-left: none; }
.gp-toggle-opt:not(:first-child):not(:last-child) { border-left: none; }
.gp-toggle-active { background: rgba(120,200,120,0.15) !important; border-color: rgba(120,200,120,0.5) !important; color: #7acc7a !important; }

/* Spine/cover calculator box */
.gp-spine-box {
  background: rgba(120,200,120,0.05);
  border: 1px solid rgba(120,200,120,0.2);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.gp-spine-title { font-size: 13px; font-weight: 600; color: #7acc7a; margin-bottom: 2px; }
.gp-spine-subtitle { font-size: 11px; color: #5a8a5a; margin-bottom: 8px; }
.gp-spine-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  font-size: 12px;
  margin-bottom: 8px;
}
.gp-spine-label { color: #9ca3af; }
.gp-spine-grid strong { color: #1a3a1a; }
.gp-spine-formula {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  line-height: 1.6;
}

/* Upload guide */
.gp-upload-guide {
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}
.gp-upload-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 12px;
}
.gp-upload-row:last-child { border-bottom: none; }
.gp-upload-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; margin-top: 1px; }
.gp-upload-info { flex: 1; min-width: 0; }
.gp-upload-name { font-weight: 600; color: #111827; margin-bottom: 2px; font-size: 12px; }
.gp-upload-steps { font-size: 11px; color: #374151; line-height: 1.5; }
.gp-upload-link {
  font-size: 11px;
  color: #7acc7a;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.gp-upload-link:hover { text-decoration: underline; }
.gp-pub-tip {
  font-size: 12px;
  color: #374151;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 7px;
  background: rgba(0,0,0,0.02);
  border: 1px solid rgba(0,0,0,0.04);
  margin-top: 10px;
}

/* Publish action row */
.gp-pub-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.04);
}

/* PDF reconfigure button */
#gp-pdf-reconfig {
  font-size: 11px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.1);
  color: #6b7280;
}
#gp-pdf-reconfig:hover { border-color: rgba(120,200,120,0.4); color: #7acc7a; }

/* Responsive tweaks */
@media (max-width: 540px) {
  .gp-pub-field-row, .gp-pub-field-row-3 { grid-template-columns: 1fr; }
  .gp-platform-grid { grid-template-columns: 1fr; }
  .gp-spine-grid { grid-template-columns: 1fr; }
}

/* ── Imported Project Lock ──────────────────────────────── */
.import-locked {
  position: relative;
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}
.import-locked::after {
  content: '🔒 Locked — imported project';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.7rem;
  color: var(--accent, #f0a500);
  opacity: 0.85;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* Series Dashboard — 3-Tier Project Tree                                     */
/* series-dashboard.js v1                                                     */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* ── Book Node ─────────────────────────────────────────────────────────────── */
.sd-book-node {
  margin: 6px 0;
  border-radius: var(--radius-sm, 6px);
  border-left: 3px solid transparent;
  transition: border-color 0.2s;
}
.sd-book-node:not(.sd-book-pending):hover {
  border-left-color: var(--accent-primary, #8b5cf6);
}
/* GC104: the whole pending node used to sit at opacity 0.6, which dimmed its ✕
   too — a child can never render more opaque than its parent, so the one control
   that removes a dead slot looked disabled. The dimming now lands on the info
   block and icon; the delete button keeps full contrast. */
.sd-book-node.sd-book-pending .folder-info,
.sd-book-node.sd-book-pending .folder-icon,
.sd-book-node.sd-book-pending .sd-book-cover-thumb {
  opacity: 0.6;
}
.sd-book-header h3.sd-book-title {
  font-size: 0.88rem;
  font-weight: 600;
}

/* ── Book cover thumbnail in project list ── */
.sd-book-cover-thumb {
  width: 32px;
  height: 45px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  flex-shrink: 0;
}

/* ── Derivative badge row ── */
.sd-deriv-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1;
}
.sd-deriv-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(139,92,246,0.10);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 2px;
}

/* ── Series Node ───────────────────────────────────────────────────────────── */
.sd-series-node {
  margin-bottom: 10px;
}
.sd-series-header {
  background: rgba(139,92,246,0.06);
}
.sd-series-content {
  padding-left: 12px;
}

/* ── Series Level Items (Bible, Export All) ────────────────────────────────── */
.sd-series-level-items {
  display: flex;
  gap: 8px;
  padding: 8px 0 12px 0;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.06));
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.sd-series-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.08));
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  background: var(--bg-surface);
}
.sd-series-action:hover {
  border-color: var(--accent-primary, #8b5cf6);
  color: var(--accent-primary, #8b5cf6);
  background: rgba(139,92,246,0.08);
}

/* ── Series Progress ───────────────────────────────────────────────────────── */
.sd-series-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.sd-series-progress {
  width: 80px;
  height: 4px;
  background: rgba(139,92,246,0.15);
  border-radius: 2px;
  overflow: hidden;
}
.sd-series-progress-bar {
  height: 100%;
  background: var(--accent-primary, #8b5cf6);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.sd-series-progress-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Leaf Rows ─────────────────────────────────────────────────────────────── */
.sd-leaves {
  padding: 4px 0 8px 0;
}
.sd-leaf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 0.82rem;
  color: var(--text-secondary);
  user-select: none;
}
.sd-leaf-row:hover {
  background: rgba(139,92,246,0.07);
  color: var(--text);
}
.sd-leaf-exists {
  color: var(--text);
}
.sd-leaf-empty {
  color: var(--text-secondary);
  font-style: italic;
}
.sd-leaf-empty:hover {
  color: var(--accent-primary, #8b5cf6);
}
.sd-leaf-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.sd-leaf-label {
  flex: 1;
}
.sd-leaf-indented {
  padding-left: 28px;
}
.sd-leaf-create-hint {
  font-size: 0.72rem;
  color: var(--accent-primary, #8b5cf6);
  opacity: 0.7;
  margin-left: auto;
}

/* ── Stale Badge ───────────────────────────────────────────────────────────── */
.sd-stale-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: #f59e0b;
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* ── Status Badges ─────────────────────────────────────────────────────────── */
.sd-status-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.sd-status-pending    { background: rgba(156,163,175,0.15); color: #9ca3af; }
.sd-status-generating { background: rgba(245,158,11,0.12);  color: #f59e0b; animation: sdPulse 1.6s ease-in-out infinite; }
.sd-status-complete   { background: rgba(34,197,94,0.12);   color: #22c55e; }
.sd-status-draft      { background: rgba(139,92,246,0.12);  color: #8b5cf6; }

@keyframes sdPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* ── Translations Group ────────────────────────────────────────────────────── */
.sd-translations-group {
  margin-top: 2px;
}
.sd-translations-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 2px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Pending Note ──────────────────────────────────────────────────────────── */
.sd-pending-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 10px 10px;
}

/* ── Delete Buttons (v7) ───────────────────────────────────────────────────── */
/* Book-level delete: hidden until book row is hovered */
.sd-book-delete {
  opacity: 0;
  transition: opacity 0.15s;
  background: transparent;
  border: 1px solid rgba(248,113,113,0.35);
  color: rgba(248,113,113,0.75);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 6px;
  flex-shrink: 0;
  line-height: 1;
}
.sd-book-header:hover .sd-book-delete {
  opacity: 1;
}
.sd-book-delete:hover {
  background: rgba(248,113,113,0.1);
  color: #f87171;
  border-color: rgba(248,113,113,0.6);
}

/* Leaf-level delete: hidden until leaf row is hovered */
.sd-leaf-delete {
  opacity: 0;
  transition: opacity 0.15s;
  background: transparent;
  border: none;
  color: rgba(248,113,113,0.6);
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
}
.sd-leaf-row:hover .sd-leaf-delete {
  opacity: 1;
}
.sd-leaf-delete:hover {
  background: rgba(248,113,113,0.12);
  color: #f87171;
}


/* ── Book List inside Series ───────────────────────────────────────────────── */
.sd-book-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Chapter Progress Grid (series-dashboard.js v10) ──────────────────────── */
.sd-book-chgrid {
  padding: 2px 10px 8px 34px;
  margin-top: -4px;
}
/* Hide grid when its sibling book node is collapsed */
.sd-book-node.collapsed + .sd-book-chgrid {
  display: none;
}
.sd-chapter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.sd-ch-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.sd-ch-pending {
  background: var(--border-color, rgba(128,128,128,0.3));
}
.sd-ch-done {
  background: #22c55e;
}
.sd-ch-active {
  background: #f59e0b;
  box-shadow: 0 0 4px 1px rgba(245,158,11,0.6);
  animation: sdChPulse 1s ease-in-out infinite;
}
@keyframes sdChPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
