/* PlumaLimpia Studio — Editorial Warmth Design System (Claro / Sepia / Oscuro) */
:root,
:root[data-theme="light"] {
  --bg-app: #faf9f6;
  --bg-surface: #ffffff;
  --bg-subtle: #f2efe8;
  --bg-hover: #eae4d8;
  --bg-preview-desk: #eae5dc;
  --border: #e4ddd0;
  --border-strong: #cfc5b4;

  --ink-primary: #1f1d1a;
  --ink-secondary: #5c554c;
  --ink-muted: #8a8175;

  --accent-warm: #b4532a;
  --accent-warm-hover: #97421f;
  --accent-warm-soft: #fdf2ec;

  /* Category highlight palette */
  --cat-structure-bg: rgba(217, 119, 6, 0.16);
  --cat-structure-line: #d97706;
  --cat-cliche-bg: rgba(190, 24, 93, 0.14);
  --cat-cliche-line: #be185d;
  --cat-gesture-bg: rgba(15, 118, 110, 0.15);
  --cat-gesture-line: #0f766e;
  --cat-rhythm-bg: rgba(79, 70, 229, 0.14);
  --cat-rhythm-line: #4f46e5;
  --cat-custom-bg: rgba(101, 163, 13, 0.18);
  --cat-custom-line: #4d7c0f;
  --cat-rae-bg: rgba(2, 132, 199, 0.15);
  --cat-rae-line: #0284c7;
  --cat-ai-bg: rgba(124, 58, 237, 0.15);
  --cat-ai-line: #7c3aed;

  /* Semantic UI boxes */
  --para-hover-bg: rgba(255, 255, 255, 0.68);
  --para-focus-bg: #fff9eb;
  --repair-before-bg: #fee2e2;
  --repair-before-ink: #991b1b;
  --repair-after-bg: #dcfce7;
  --repair-after-ink: #166534;
  --info-blue-bg: #eff6ff;
  --info-blue-border: #bfdbfe;
  --info-blue-ink: #1e3a8a;
  --info-violet-bg: #f5f3ff;
  --info-violet-border: #ddd6fe;
  --info-violet-ink: #5b21b6;
  --info-green-bg: #ecfdf5;
  --info-green-border: #a7f3d0;
  --info-green-ink: #065f46;
  --info-red-bg: #fef2f2;
  --info-red-border: #fecaca;
  --info-red-ink: #991b1b;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-editorial: 'Literata', 'Georgia', 'Times New Roman', serif;
  --font-garamond: 'EB Garamond', 'Garamond', 'Georgia', serif;
  --font-merriweather: 'Merriweather', 'Georgia', serif;
  --font-playfair: 'Playfair Display', 'Georgia', serif;
  --font-cinzel: 'Cinzel', 'Playfair Display', 'Georgia', serif;
  --font-cormorant: 'Cormorant Garamond', 'EB Garamond', 'Georgia', serif;
  --font-crimson: 'Crimson Pro', 'Lora', 'EB Garamond', 'Georgia', serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(31, 29, 26, 0.06);
  --shadow-md: 0 8px 24px rgba(31, 29, 26, 0.09);
  --shadow-page: 0 10px 30px rgba(31, 29, 26, 0.12), 0 1px 4px rgba(31, 29, 26, 0.06);
}

/* Modo Sepia (Lectura Suave) */
:root[data-theme="sepia"] {
  --bg-app: #f4ecd8;
  --bg-surface: #fbf5e6;
  --bg-subtle: #ede2c9;
  --bg-hover: #e4d6b6;
  --bg-preview-desk: #e5d8bc;
  --border: #dccca8;
  --border-strong: #c6b289;

  --ink-primary: #3b2f23;
  --ink-secondary: #5c4b39;
  --ink-muted: #826e58;

  --accent-warm: #a64b24;
  --accent-warm-hover: #893b1a;
  --accent-warm-soft: #f3dfd0;

  --cat-structure-bg: rgba(194, 102, 10, 0.16);
  --cat-structure-line: #b45309;
  --cat-cliche-bg: rgba(175, 24, 82, 0.14);
  --cat-cliche-line: #9d174d;
  --cat-gesture-bg: rgba(15, 118, 110, 0.15);
  --cat-gesture-line: #0f766e;
  --cat-rhythm-bg: rgba(67, 56, 202, 0.13);
  --cat-rhythm-line: #4338ca;
  --cat-custom-bg: rgba(88, 145, 15, 0.16);
  --cat-custom-line: #3f6212;
  --cat-rae-bg: rgba(3, 105, 161, 0.15);
  --cat-rae-line: #0369a1;
  --cat-ai-bg: rgba(109, 40, 217, 0.14);
  --cat-ai-line: #6d28d9;

  --para-hover-bg: rgba(251, 245, 230, 0.72);
  --para-focus-bg: #fff5d6;
  --info-blue-bg: #ebe6d8;
  --info-blue-border: #cbbca2;
  --info-blue-ink: #3b2f23;
  --info-violet-bg: #efe6dc;
  --info-violet-border: #d4c0b0;
  --info-violet-ink: #4a2d4c;
  --info-green-bg: #e7ead7;
  --info-green-border: #b8c49e;
  --info-green-ink: #2b421c;
}

/* Modo Oscuro (Nocturno / Escritura de Noche) */
:root[data-theme="dark"] {
  --bg-app: #141417;
  --bg-surface: #1e1e22;
  --bg-subtle: #18181c;
  --bg-hover: #27272d;
  --bg-preview-desk: #111114;
  --border: #2c2c34;
  --border-strong: #3e3e49;

  --ink-primary: #e4e4e7;
  --ink-secondary: #b4b4be;
  --ink-muted: #848490;

  --accent-warm: #e07a52;
  --accent-warm-hover: #ee8c65;
  --accent-warm-soft: rgba(224, 122, 82, 0.16);

  /* Resaltados ajustados para contraste suave y legible sobre fondo oscuro */
  --cat-structure-bg: rgba(245, 158, 11, 0.22);
  --cat-structure-line: #fbbf24;
  --cat-cliche-bg: rgba(244, 63, 94, 0.22);
  --cat-cliche-line: #fb7185;
  --cat-gesture-bg: rgba(20, 184, 166, 0.22);
  --cat-gesture-line: #2dd4bf;
  --cat-rhythm-bg: rgba(129, 140, 248, 0.22);
  --cat-rhythm-line: #818cf8;
  --cat-custom-bg: rgba(163, 230, 53, 0.2);
  --cat-custom-line: #a3e635;
  --cat-rae-bg: rgba(56, 189, 248, 0.22);
  --cat-rae-line: #38bdf8;
  --cat-ai-bg: rgba(167, 139, 250, 0.22);
  --cat-ai-line: #a78bfa;

  --para-hover-bg: rgba(255, 255, 255, 0.04);
  --para-focus-bg: rgba(251, 191, 36, 0.13);
  --repair-before-bg: rgba(239, 68, 68, 0.22);
  --repair-before-ink: #fca5a5;
  --repair-after-bg: rgba(34, 197, 94, 0.2);
  --repair-after-ink: #86efac;
  --info-blue-bg: rgba(59, 130, 246, 0.14);
  --info-blue-border: rgba(96, 165, 250, 0.3);
  --info-blue-ink: #bfdbfe;
  --info-violet-bg: rgba(139, 92, 246, 0.15);
  --info-violet-border: rgba(167, 139, 250, 0.32);
  --info-violet-ink: #ddd6fe;
  --info-green-bg: rgba(16, 185, 129, 0.14);
  --info-green-border: rgba(52, 211, 153, 0.3);
  --info-green-ink: #a7f3d0;
  --info-red-bg: rgba(239, 68, 68, 0.15);
  --info-red-border: rgba(248, 113, 113, 0.32);
  --info-red-ink: #fecaca;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-page: 0 12px 34px rgba(0, 0, 0, 0.55), 0 1px 4px rgba(0, 0, 0, 0.4);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ================= TOPBAR ================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 9px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 25;
}

.topbar-left-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.book-selector-wrap {
  position: relative;
}

.book-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-app);
  color: var(--ink-primary);
  border-radius: 7px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  max-width: 210px;
  transition: all 0.14s ease;
}
.book-selector-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--accent-warm);
}
.book-selector-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.book-selector-btn .caret {
  font-size: 10px;
  color: var(--ink-muted);
}

.book-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 290px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.book-dd-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 4px 8px 2px;
}
.book-dd-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}
.book-dropdown-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 9px;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-primary);
  font-size: 12.5px;
}
.book-dropdown-item:hover { background: var(--bg-subtle); }
.book-dropdown-item.active {
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
  font-weight: 600;
}
.book-dd-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.book-dd-meta {
  font-size: 11px;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.book-dd-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.book-dropdown-action {
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 9px;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-primary);
}
.book-dropdown-action:hover {
  background: var(--bg-subtle);
  color: var(--accent-warm);
}

.project-meta-box {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.project-title-input {
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-editorial);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-primary);
  padding: 2px 5px;
  margin-left: -5px;
  border-radius: 5px;
  width: 100%;
}
.project-title-input:hover { border-color: var(--border); }
.project-title-input:focus { outline: none; border-color: var(--accent-warm); background: var(--bg-app); }

.project-author-input {
  border: 1px solid transparent;
  background: transparent;
  font-size: 11.5px;
  color: var(--ink-secondary);
  padding: 1px 5px;
  margin-left: -5px;
  border-radius: 5px;
  width: 100%;
}
.project-author-input:hover { border-color: var(--border); }
.project-author-input:focus { outline: none; border-color: var(--accent-warm); background: var(--bg-app); }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-warm-soft);
  border: 1px solid rgba(180, 83, 42, 0.25);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-editorial);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink-primary);
}

.brand-badge {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-warm);
  margin-left: 4px;
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.topbar-tabs {
  display: flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.tab-btn:hover {
  color: var(--ink-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tab-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--ink-secondary);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.tab-btn.active .tab-num {
  background: var(--accent-warm);
  color: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.theme-btn {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}
.theme-btn:hover {
  color: var(--ink-primary);
  background: var(--bg-hover);
}
.theme-btn.active {
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-sm);
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-xs { padding: 4px 9px; font-size: 12px; }
.btn-full { width: 100%; }

.btn-primary {
  background: var(--accent-warm);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-warm-hover); }

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--ink-primary);
}
.btn-secondary:hover { background: var(--bg-subtle); }

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
}
.btn-ghost:hover, .btn-ghost.active {
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.btn-warm-soft {
  background: var(--accent-warm-soft);
  border-color: rgba(180, 83, 42, 0.2);
  color: var(--accent-warm);
  justify-content: space-between;
}
.btn-warm-soft:hover {
  background: var(--accent-warm-soft);
  filter: brightness(0.96);
}

.btn-outline-warm {
  background: transparent;
  border-color: rgba(180, 83, 42, 0.35);
  color: var(--accent-warm);
}
.btn-outline-warm:hover { background: var(--accent-warm-soft); }

.pill-soon {
  font-size: 10px;
  background: var(--accent-warm-soft);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 15px;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--ink-primary); }

.link-btn {
  border: none;
  background: none;
  color: var(--accent-warm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ================= WORKSPACE & MODULE VIEWS ================= */
.workspace {
  flex: 1;
  min-height: 0;
  position: relative;
}

.module-view {
  display: none;
  height: 100%;
  width: 100%;
}

.module-view.active {
  display: grid;
}

/* 3-Column Analyzer Dashboard */
#view-analyzer {
  grid-template-columns: 270px minmax(0, 1fr) 360px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-left {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
}

.panel-center {
  background: var(--bg-app);
  position: relative;
}

.panel-right {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  gap: 16px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 16px 10px;
}

.panel-right .panel-header {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-primary);
  letter-spacing: -0.01em;
}

.panel-caption {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
}

/* Left Column */
.left-tools {
  padding: 4px 16px 10px;
}

.count-pill {
  background: rgba(31, 29, 26, 0.08);
  color: var(--ink-primary);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.lang-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.lang-label {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-weight: 500;
}

.lang-pills {
  display: flex;
  gap: 3px;
  background: var(--bg-surface);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.lang-pill {
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--ink-secondary);
  cursor: pointer;
}
.lang-pill.active {
  background: var(--accent-warm);
  color: #fff;
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.14s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chapter-item:hover {
  background: var(--bg-hover);
}

.chapter-item.active {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.chapter-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chapter-item-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
  flex-shrink: 0;
}

.chapter-item-badge.clean {
  background: var(--info-green-bg);
  color: var(--info-green-ink);
}

.chapter-item-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.panel-footer-tip {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-secondary);
  background: var(--bg-app);
}

/* Center Column: Editor */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.editor-chapter-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 260px;
  min-width: 0;
}

.chapter-title-input {
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-editorial);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-primary);
  padding: 2px 8px;
  margin-left: -8px;
  border-radius: 6px;
  width: 100%;
  min-width: 0;
}
.chapter-title-input:hover { border-color: var(--border); }
.chapter-title-input:focus {
  outline: none;
  border-color: var(--accent-warm);
  background: var(--bg-app);
}

.chapter-stats-inline {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.editor-mode-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.highlight-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-secondary);
}

.legend-reset-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.legend-reset-btn:hover {
  transform: translateY(-1px);
}

.legend-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.legend-filter-btn:hover {
  border-color: var(--ink-muted);
}

.legend-filter-btn.active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.legend-filter-btn.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.legend-filter-btn.inactive {
  opacity: 0.45;
  background: transparent;
  color: var(--ink-muted);
  border-style: dashed;
}

.legend-filter-btn.inactive .swatch {
  filter: grayscale(1);
  opacity: 0.65;
}

.findings-filter-status {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.swatch {
  width: 12px;
  height: 5px;
  border-radius: 3px;
  display: inline-block;
}
.swatch-structure { background: var(--cat-structure-line); }
.swatch-cliche { background: var(--cat-cliche-line); }
.swatch-gesture { background: var(--cat-gesture-line); }
.swatch-rhythm { background: var(--cat-rhythm-line); }
.swatch-rae { background: var(--cat-rae-line); }
.swatch-custom { background: var(--cat-custom-line); }
.swatch-ai { background: var(--cat-ai-line); }

.chapter-reader {
  flex: 1;
  overflow-y: auto;
  padding: 34px 48px 180px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

.chapter-paragraph {
  position: relative;
  margin: 0 0 18px;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--font-editorial);
  font-size: 16.5px;
  line-height: 1.78;
  color: var(--ink-primary);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.chapter-paragraph:hover {
  background: var(--para-hover-bg);
}

.chapter-paragraph.paragraph-focused {
  background: var(--para-focus-bg);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.38);
}

.chapter-paragraph.paragraph-rhythm-flag {
  border-left: 3px solid var(--cat-rhythm-line);
  background: rgba(79, 70, 229, 0.04);
}

.para-num-tag {
  position: absolute;
  left: -34px;
  top: 12px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-muted);
  user-select: none;
  opacity: 0.6;
}

.para-scene-break {
  text-align: center;
  color: var(--ink-muted);
  letter-spacing: 0.3em;
  margin: 24px 0;
  font-size: 14px;
  user-select: none;
}

/* Soft Highlights */
.hl {
  border-radius: 3px;
  padding: 1px 2px;
  cursor: pointer;
  transition: filter 0.12s ease;
  border-bottom: 2px solid transparent;
}
.hl:hover { filter: brightness(0.95); }

.highlights-off .hl {
  background: transparent !important;
  border-bottom-color: transparent !important;
  padding: 0;
}

.hl-structure { background: var(--cat-structure-bg); border-bottom-color: var(--cat-structure-line); }
.hl-cliche { background: var(--cat-cliche-bg); border-bottom-color: var(--cat-cliche-line); }
.hl-gesture { background: var(--cat-gesture-bg); border-bottom-color: var(--cat-gesture-line); }
.hl-rhythm { background: var(--cat-rhythm-bg); border-bottom-color: var(--cat-rhythm-line); }
.hl-rae { background: var(--cat-rae-bg); border-bottom-color: var(--cat-rae-line); }
.hl-custom { background: var(--cat-custom-bg); border-bottom-color: var(--cat-custom-line); }

.copyright-pseudonym-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.copyright-pseudonym-toggle input {
  margin-top: 2px;
}
.copyright-pseudonym-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
}
.copyright-legal-tip {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-secondary);
}
.hl-ai { background: var(--cat-ai-bg); border-bottom-color: var(--cat-ai-line); border-bottom-style: dashed; }

.hl.hl-active {
  outline: 2px solid var(--accent-warm);
  outline-offset: 1px;
}

/* Raw Chapter Editor */
.chapter-raw-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 28px 24px;
  gap: 10px;
}

.raw-editor-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--accent-warm-soft);
  border: 1px solid rgba(180, 83, 42, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.chapter-raw-textarea {
  flex: 1;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  font-family: var(--font-editorial);
  font-size: 15.5px;
  line-height: 1.7;
  resize: none;
  background: var(--bg-surface);
  color: var(--ink-primary);
}
.chapter-raw-textarea:focus { outline: 2px solid rgba(180, 83, 42, 0.25); }

/* Editorial Suggestion Card */
.suggestion-card {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 40px));
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 16px 18px;
  z-index: 15;
}

.suggestion-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sc-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.sc-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-primary);
}

.sc-quote {
  margin: 0 0 8px;
  padding: 6px 10px;
  background: var(--bg-subtle);
  border-left: 3px solid var(--accent-warm);
  border-radius: 4px;
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 13.5px;
  color: var(--ink-primary);
}

.sc-advice {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.5;
}

.sc-guiding-box {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--info-violet-bg);
  border: 1px solid var(--info-violet-border);
}
.sc-guiding-label {
  display: block;
  font-size: 11.5px;
  color: var(--info-violet-ink);
  margin-bottom: 3px;
}
.sc-guiding-text {
  margin: 0;
  font-size: 13px;
  color: var(--ink-primary);
  font-weight: 500;
}

/* Phase 3: Deep Semantic AI Diagnostic Panel */
.diag-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 3px;
}

.diag-tab-btn {
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.diag-tab-btn.active {
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-sm);
}

.diag-tab-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-chapter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  background: var(--info-violet-bg);
  border: 1px solid var(--info-violet-border);
  border-radius: 8px;
}
.ai-banner-kicker {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--info-violet-ink);
  font-weight: 700;
}
.ai-banner-title {
  font-size: 13px;
  color: var(--ink-primary);
}

.ai-detector-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-detector-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.ai-detector-item:hover {
  background: var(--bg-subtle);
}
.ai-detector-item input {
  margin-top: 2px;
  accent-color: #7c3aed;
}
.ai-detector-name {
  display: block;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.3;
}
.ai-detector-desc {
  display: block;
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.35;
  margin-top: 1px;
}

.ai-estimator-box {
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-secondary);
  line-height: 1.45;
}
.ai-estimator-box strong {
  color: var(--ink-primary);
}

.ai-run-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-run-status {
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.4;
}
.ai-run-status.error {
  background: var(--info-red-bg);
  border: 1px solid var(--info-red-border);
  color: var(--info-red-ink);
}
.ai-run-status.info {
  background: var(--info-violet-bg);
  border: 1px solid var(--info-violet-border);
  color: var(--info-violet-ink);
}

.key-input-row {
  display: flex;
  gap: 6px;
}
.pill-connected {
  background: #dcfce7 !important;
  color: #166534 !important;
}

/* Phase 4: Repair Cards, Content Review & Blog Editorial */
.diag-tabs-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.diag-tabs-3 .diag-tab-btn {
  font-size: 11px;
  padding: 6px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-repair-box {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.repair-diff-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.4;
}

.repair-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.repair-before-label { background: var(--repair-before-bg); color: var(--repair-before-ink); }
.repair-after-label { background: var(--repair-after-bg); color: var(--repair-after-ink); }
.repair-before-text { text-decoration: line-through; color: var(--repair-before-ink); font-family: var(--font-editorial); }
.repair-after-text { color: var(--repair-after-ink); font-weight: 600; font-family: var(--font-editorial); }

.repair-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  transition: all 0.14s ease;
}
.repair-card:hover { border-color: var(--border-strong); background: var(--bg-app); }
.repair-card.active { border-color: var(--accent-warm); background: var(--accent-warm-soft); }
.repair-card-head {
  cursor: pointer;
}
.repair-card-mini-diff {
  font-size: 11.5px;
  background: var(--bg-app);
  padding: 5px 7px;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.repair-card-note {
  font-size: 11.5px;
  color: var(--ink-secondary);
  line-height: 1.38;
}
.repair-card-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.dict-kind-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 99px;
  margin-right: 6px;
  vertical-align: middle;
}
.dict-kind-pill.is-blacklist {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
}
.dict-kind-pill.is-exception {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}
:root[data-theme="dark"] .dict-kind-pill.is-blacklist {
  color: #fbbf24;
}
:root[data-theme="dark"] .dict-kind-pill.is-exception {
  color: #34d399;
}

.content-review-intro {
  background: var(--info-blue-bg);
  border: 1px solid var(--info-blue-border);
  color: var(--info-blue-ink);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.content-q-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--cat-rhythm-line);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.content-q-kind {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cat-rhythm-line);
  letter-spacing: 0.04em;
}
.content-q-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-primary);
}
.content-q-body {
  font-size: 12px;
  color: var(--ink-secondary);
  line-height: 1.45;
  margin: 0;
}
.content-q-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.characters-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.char-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-app);
  font-size: 12px;
}
.char-row-meta {
  font-size: 11px;
  color: var(--ink-muted);
}

.dict-form-3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dict-form-3 button[type="submit"] {
  grid-column: 1 / -1;
}

/* Module 3: Blog Editorial */
#view-blog {
  grid-template-columns: 1fr;
}
.blog-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.blog-sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.blog-sidebar-head {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.blog-filter-bar {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.blog-cat-pill {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.blog-cat-pill.active {
  background: var(--accent-warm);
  border-color: var(--accent-warm);
  color: #fff;
}
.blog-post-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.blog-list-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all 0.14s ease;
}
.blog-list-card:hover { border-color: var(--border-strong); }
.blog-list-card.active {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
}
.blog-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.blog-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--accent-warm);
}
.blog-card-title {
  font-family: var(--font-editorial);
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink-primary);
}
.blog-card-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
}
.blog-reader-wrap {
  overflow-y: auto;
  background: var(--bg-app);
  padding: 36px 40px 64px;
}
.blog-reader-article {
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 36px 44px;
}
.blog-article-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 22px;
}
.blog-article-title {
  font-family: var(--font-editorial);
  font-size: 26px;
  line-height: 1.25;
  margin: 10px 0 10px;
  color: var(--ink-primary);
}
.blog-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-muted);
}
.blog-permalink {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-secondary);
}
.blog-permalink a,
.blog-article-body a {
  color: var(--accent-warm);
  text-decoration: underline;
  word-break: break-word;
}

/* Freemium Export Gate, Auth & Wompi Pricing Modals */
.export-gate-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--ink-secondary);
  text-align: center;
}
.export-gate-pill.unlocked {
  background: var(--info-green-bg);
  border-color: var(--info-green-border);
  color: var(--info-green-ink);
}
.auth-google-btn {
  justify-content: center;
  font-weight: 600;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-error {
  margin: 0;
  font-size: 12px;
  color: var(--info-red-ink);
  background: var(--info-red-bg);
  border: 1px solid var(--info-red-border);
  padding: 6px 9px;
  border-radius: 6px;
}
.auth-user-summary {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  font-size: 13px;
  line-height: 1.5;
}
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.pricing-card {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 16px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pricing-card-pro {
  border-color: var(--accent-warm);
  box-shadow: 0 0 0 1px var(--accent-warm-soft);
}
.pricing-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}
.pricing-badge.pro {
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
}
.pricing-card h3 {
  margin: 0;
  font-size: 16px;
  color: var(--ink-primary);
}
.pricing-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-primary);
}
.pricing-price span {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-muted);
}
.pricing-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-secondary);
  flex: 1;
}
@media (max-width: 700px) {
  .pricing-grid { grid-template-columns: 1fr; }
}
.blog-article-body {
  font-family: var(--font-editorial);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink-primary);
}
.blog-article-body p {
  margin: 0 0 16px;
}

@media (max-width: 920px) {
  .blog-shell { grid-template-columns: 1fr; }
  .blog-reader-article { padding: 22px; }
}

.sc-inline-edit {
  margin-bottom: 12px;
}

.sc-edit-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink-secondary);
}

.sc-paragraph-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-editorial);
  font-size: 14.5px;
  line-height: 1.55;
  resize: vertical;
  background: var(--bg-app);
  color: var(--ink-primary);
}

.sc-edit-btns {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.suggestion-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Right Column: Diagnostic Panel */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.kpi-card {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-card.kpi-accent {
  background: var(--accent-warm-soft);
  border-color: rgba(180, 83, 42, 0.25);
}

.kpi-label {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
}

.kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-primary);
  letter-spacing: -0.02em;
}

.kpi-accent .kpi-value { color: var(--accent-warm); }

.scope-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 7px;
  border: 1px solid var(--border);
}

.scope-btn {
  border: none;
  background: transparent;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-secondary);
  border-radius: 5px;
  cursor: pointer;
}
.scope-btn.active {
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.diag-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diag-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diag-section-head h3 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
}

.diag-sublabel {
  font-size: 11px;
  color: var(--ink-muted);
}

.category-breakdown {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--ink-primary);
  cursor: pointer;
  font-size: 12.5px;
  text-align: left;
  transition: all 0.12s ease;
}
.cat-row:hover { background: var(--bg-subtle); }
.cat-row.active {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
}

.cat-row-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.cat-row-count {
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-primary);
}

.gesture-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.gesture-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
}
.gesture-chip.high {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.06);
}
.gesture-chip-count {
  font-weight: 700;
  color: var(--cat-gesture-line);
}

.findings-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.finding-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.14s ease;
  text-align: left;
}
.finding-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-app);
}
.finding-card.active {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
}

.finding-card-loc {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 2px;
}

.finding-card-rule {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-primary);
  margin-bottom: 3px;
}

.finding-card-snippet {
  font-family: var(--font-editorial);
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ignored-pill {
  font-size: 11px;
  color: var(--ink-muted);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}

/* ================= MODULE 2: BOOK LAYOUT STUDIO ================= */
#view-layout {
  grid-template-columns: 1fr;
}

.layout-shell {
  display: grid;
  grid-template-columns: 265px 325px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

/* Column 1: Matter Sidebar */
.matter-sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.matter-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.matter-header {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.matter-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.matter-list, .matter-chapters-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.matter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-app);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}

.matter-item:hover {
  background: var(--bg-surface);
  border-color: var(--border);
}

.matter-item.active {
  background: var(--bg-surface);
  border-color: var(--accent-warm);
  box-shadow: var(--shadow-sm);
}

.matter-item.disabled {
  opacity: 0.55;
}

.matter-item-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.matter-item-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-item-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.matter-move-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.matter-move-btn:hover {
  background: var(--bg-subtle);
  color: var(--ink-primary);
}
.matter-move-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.matter-chapter-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--ink-secondary);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.matter-chapter-btn:hover {
  background: var(--bg-surface);
  color: var(--ink-primary);
}

.matter-editor-panel {
  border-top: 1px solid var(--border-strong);
  background: var(--bg-surface);
  padding: 12px 14px;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.matter-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.matter-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
}

.matter-editor-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.matter-editor-body .form-input,
.matter-editor-body textarea {
  font-size: 12.5px;
  padding: 6px 8px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented-control-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.segmented-control-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.gutter-info-pill {
  margin-top: 4px;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--info-green-bg);
  border: 1px solid var(--info-green-border);
  color: var(--info-green-ink);
  font-size: 11.5px;
  font-weight: 500;
}

.mini-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
  color: var(--ink-secondary);
  border-bottom: 1px dashed var(--border);
}

.toggle-sm {
  width: 36px;
  height: 20px;
}
.toggle-sm .toggle-slider::before {
  height: 14px;
  width: 14px;
}
.toggle-sm input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.layout-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.layout-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.layout-export-bar {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.form-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--bg-surface);
  color: var(--ink-primary);
}
.form-input:focus {
  outline: none;
  border-color: var(--accent-warm);
}

.form-hint {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.template-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  cursor: pointer;
  text-align: left;
  transition: all 0.14s ease;
}
.template-card:hover { border-color: var(--border-strong); }
.template-card.active {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
}

.tpl-preview {
  width: 42px;
  height: 52px;
  border-radius: 5px;
  background: #fff;
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 18px;
}

.tpl-classic { font-family: var(--font-garamond); color: #2b2620; }
.tpl-romance { font-family: var(--font-playfair); color: #9d174d; }
.tpl-thriller { font-family: var(--font-sans); font-weight: 800; color: #111827; letter-spacing: -0.04em; }
.tpl-gothic { font-family: var(--font-cinzel); color: #1f1a24; background: #f6f4f8; }
.tpl-historical { font-family: var(--font-cormorant); color: #5a3a22; font-style: italic; font-size: 22px; }
.tpl-nonfiction { font-family: var(--font-sans); font-weight: 700; color: #1f2937; }

.tpl-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tpl-info strong { font-size: 13px; color: var(--ink-primary); }
.tpl-info span { font-size: 11.5px; color: var(--ink-secondary); line-height: 1.35; }

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.seg-btn {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-secondary);
}
.seg-btn.active {
  background: var(--accent-warm);
  color: #fff;
  border-color: var(--accent-warm);
}

.switch-box {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.switch-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.switch-title {
  font-size: 12.5px;
  display: block;
  margin-bottom: 3px;
}

.switch-desc {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-secondary);
  line-height: 1.4;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cfc5b4;
  border-radius: 999px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-warm);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.ornament-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ornament-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 4px;
}

.ornament-upload-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.slider-val-badge {
  font-size: 11px;
  color: var(--accent-warm);
  font-weight: 700;
}

.range-slider {
  width: 100%;
  accent-color: var(--accent-warm);
  cursor: pointer;
}

.ornament-btn {
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-primary);
  text-align: center;
}
.ornament-btn.active {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
  font-weight: 600;
}

/* Preview Area */
.layout-preview-area {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-preview-desk);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.preview-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spec-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.preview-pages-count {
  font-size: 12px;
  color: var(--ink-secondary);
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
}

.book-preview-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

/* Printed Book Page Simulation (Always authentic paper unless inverted by user) */
.book-page {
  background: #fffdf9;
  color: #1c1917;
  box-shadow: var(--shadow-page);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform-origin: top center;
  flex-shrink: 0;
}

.book-preview-canvas.preview-page-inverted .book-page {
  background: #1a1a1f;
  color: #e4e4e7;
}
.book-preview-canvas.preview-page-inverted .book-page-running-header,
.book-preview-canvas.preview-page-inverted .book-page-footer,
.book-preview-canvas.preview-page-inverted .book-cover-subtitle,
.book-preview-canvas.preview-page-inverted .book-cover-ornament,
.book-preview-canvas.preview-page-inverted .book-copyright-inner,
.book-preview-canvas.preview-page-inverted .book-toc-page,
.book-preview-canvas.preview-page-inverted .book-chapter-kicker,
.book-preview-canvas.preview-page-inverted .book-scene-ornament {
  color: #a1a1aa !important;
}
.book-preview-canvas.preview-page-inverted .book-chapter-heading,
.book-preview-canvas.preview-page-inverted .book-p.dropcap-classic::first-letter,
.book-preview-canvas.preview-page-inverted .book-p.dropcap-decorated::first-letter {
  color: #f4f4f5 !important;
  border-color: #52525b !important;
}
.book-preview-canvas.preview-page-inverted .book-p.dropcap-decorated::first-letter {
  background: #27272a !important;
}
.book-preview-canvas.preview-page-inverted .book-chapter-ornament,
.book-preview-canvas.preview-page-inverted .book-scene-ornament {
  color: #d4d4d8;
}
.book-preview-canvas.preview-page-inverted .book-ornament-img {
  filter: invert(0.9);
  mix-blend-mode: screen;
}

.book-page.size-5x8 {
  width: 5in;
  min-height: 8in;
}

.book-page.size-5\.5x8\.5 {
  width: 5.5in;
  min-height: 8.5in;
}

.book-page.size-6x9 {
  width: 6in;
  min-height: 9in;
}

/* Front & Back Matter Book Page Styles */
.book-copyright-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 8.5pt;
  line-height: 1.55;
  color: #57534e;
  padding-bottom: 0.4in;
}
.book-copyright-inner p { margin: 0 0 8px; }

.book-dedication-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-style: italic;
  font-size: 11.5pt;
  line-height: 1.65;
  padding: 0 0.5in;
}

.book-epigraph-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 0.4in 0 0.9in;
  font-style: italic;
  font-size: 10.5pt;
  line-height: 1.6;
}
.book-epigraph-attr {
  margin-top: 12px;
  font-style: normal;
  text-align: right;
  font-size: 9.5pt;
  color: #57534e;
}

.book-toc-heading {
  text-align: center;
  font-size: 16pt;
  margin: 0.2in 0 0.28in;
  letter-spacing: 0.04em;
}
.book-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.book-toc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5pt;
  border-bottom: 1px dotted #d6d3d1;
  padding-bottom: 3px;
}
.book-toc-row button {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.book-toc-row button:hover { color: var(--accent-warm); }
.book-toc-page {
  font-size: 9.5pt;
  color: #57534e;
  font-variant-numeric: tabular-nums;
}

/* Drop Cap (Letra Capitular) + Viudas/Huérfanas */
.book-p {
  margin: 0;
  text-align: justify;
  hyphens: auto;
  line-height: 1.52;
  font-size: 10.75pt;
  orphans: 3;
  widows: 3;
}

.book-chapter-heading {
  break-inside: avoid;
  page-break-inside: avoid;
  break-after: avoid;
  page-break-after: avoid;
}

.book-p.dropcap-classic::first-letter {
  float: left;
  font-family: var(--font-garamond);
  font-weight: 600;
  font-size: 3.1em;
  line-height: 0.82;
  padding-right: 0.1em;
  padding-top: 0.05em;
}

.book-p.dropcap-modern::first-letter {
  float: left;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 2.85em;
  line-height: 0.84;
  padding-right: 0.12em;
  padding-top: 0.05em;
  color: var(--accent-warm);
}

.book-p.dropcap-decorated::first-letter {
  float: left;
  font-family: var(--font-playfair);
  font-weight: 700;
  font-size: 2.65em;
  line-height: 0.88;
  padding: 0.08em 0.16em;
  margin-right: 0.14em;
  margin-top: 0.04em;
  border: 1px solid #a8a29e;
  background: #f5f2eb;
  border-radius: 3px;
}

.book-page-running-header {
  font-size: 8.5pt;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #78716c;
  text-align: center;
  margin-bottom: 18px;
  min-height: 14px;
}

.book-page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-page-footer {
  font-size: 9.5pt;
  color: #57534e;
  text-align: center;
  margin-top: 18px;
}

/* Title Page */
.book-title-page-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1in 0.3in;
}

.book-cover-title {
  font-size: 26pt;
  margin: 0 0 12px;
  line-height: 1.2;
}

.book-cover-subtitle {
  font-size: 12pt;
  color: #57534e;
  margin: 0 0 42px;
}

.book-cover-ornament {
  font-size: 16pt;
  margin-bottom: 42px;
  color: #78716c;
}

.book-cover-author {
  font-size: 13pt;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Book Paragraph & Chapter Styles */
.book-p + .book-p {
  text-indent: 1.4em;
}

.book-p.first-after-heading {
  text-indent: 0;
}

.book-scene-ornament {
  text-align: center;
  margin: 18px 0;
  font-size: 11.5pt;
  letter-spacing: 0.15em;
  color: #57534e;
}

.book-chapter-header-block {
  break-inside: avoid;
  page-break-inside: avoid;
  break-after: avoid;
  page-break-after: avoid;
}
.book-chapter-header-block.has-custom-header-ornament .book-chapter-heading::after {
  display: none;
}

.book-chapter-ornament {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #57534e;
}
.book-chapter-ornament.spacing-compact {
  margin: 4px 0 8px;
}
.book-chapter-ornament.spacing-normal {
  margin: 10px 0 14px;
}
.book-chapter-ornament.spacing-wide {
  margin: 18px 0 22px;
}

.book-chapter-svg {
  height: auto;
  max-height: 54px;
  display: block;
}

.book-scene-svg {
  width: auto;
  max-width: 80%;
  display: inline-block;
  vertical-align: middle;
}

.book-ornament-img {
  display: inline-block;
  height: auto;
  max-height: 90px;
  object-fit: contain;
  mix-blend-mode: multiply;
}
.book-scene-img {
  width: auto;
  max-width: 85%;
}

@media print {
  .book-ornament-img {
    mix-blend-mode: multiply !important;
    filter: none !important;
  }
}

/* Template 1: Novela Clásica */
.tpl-style-classic {
  font-family: var(--font-garamond);
}
.tpl-style-classic .book-chapter-heading {
  font-family: var(--font-garamond);
  text-align: center;
  font-size: 18pt;
  font-weight: 600;
  margin: 0.35in 0 0.28in;
  letter-spacing: 0.02em;
}
.tpl-style-classic .book-chapter-kicker {
  display: block;
  font-size: 9pt;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #78716c;
  margin-bottom: 6px;
}

/* Template 2: Romance / Contemporánea */
.tpl-style-romance {
  font-family: var(--font-merriweather);
}
.tpl-style-romance .book-p {
  font-size: 10pt;
  line-height: 1.62;
}
.tpl-style-romance .book-chapter-heading {
  font-family: var(--font-playfair);
  text-align: center;
  font-size: 19pt;
  font-style: italic;
  font-weight: 600;
  color: #4c1d3d;
  margin: 0.3in 0 0.25in;
}
.tpl-style-romance .book-chapter-kicker {
  display: block;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 8.5pt;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #9d174d;
  margin-bottom: 8px;
}
.tpl-style-romance .book-scene-ornament {
  color: #9d174d;
}

/* Template 3: Thriller / Misterio */
.tpl-style-thriller {
  font-family: var(--font-editorial);
}
.tpl-style-thriller .book-p {
  font-size: 10.5pt;
  line-height: 1.48;
  text-align: left;
}
.tpl-style-thriller .book-p + .book-p {
  text-indent: 0;
  margin-top: 8px;
}
.tpl-style-thriller .book-chapter-heading {
  font-family: var(--font-sans);
  text-align: left;
  font-size: 17pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #111827;
  border-bottom: 2.5px solid #111827;
  padding-bottom: 8px;
  margin: 0.25in 0 0.25in;
}
.tpl-style-thriller .book-chapter-kicker {
  display: block;
  font-size: 8.5pt;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #6b7280;
  margin-bottom: 4px;
}

/* Template 4: Gótico / Oscuro */
.tpl-style-gothic {
  font-family: var(--font-crimson);
  color: #18141c;
}
.tpl-style-gothic .book-p {
  font-size: 11pt;
  line-height: 1.58;
}
.tpl-style-gothic .book-p.dropcap-classic::first-letter,
.tpl-style-gothic .book-p.dropcap-modern::first-letter,
.tpl-style-gothic .book-p.dropcap-decorated::first-letter {
  font-family: var(--font-cinzel);
  color: #292033;
}
.tpl-style-gothic .book-chapter-heading {
  font-family: var(--font-cinzel);
  text-align: center;
  font-size: 16.5pt;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #211a29;
  border-top: 1px solid #968ca3;
  border-bottom: 1px solid #968ca3;
  padding: 13px 0;
  margin: 0.28in 0 0.26in;
}
.tpl-style-gothic .book-chapter-heading::after {
  content: "❦ · ☾ · ❦";
  display: block;
  font-size: 9.5pt;
  letter-spacing: 0.25em;
  color: #5b506b;
  margin-top: 7px;
  font-weight: 400;
}
.tpl-style-gothic .book-chapter-kicker {
  display: block;
  font-size: 8.5pt;
  letter-spacing: 0.26em;
  color: #5b5169;
  margin-bottom: 5px;
}
.tpl-style-gothic .book-chapter-kicker::before { content: "☾ "; }
.tpl-style-gothic .book-chapter-kicker::after { content: " ☽"; }
.tpl-style-gothic .book-scene-ornament { color: #3c324a; }

/* Template 5: Romance Histórico / Época */
.tpl-style-historical {
  font-family: var(--font-cormorant);
  color: #2a2118;
}
.tpl-style-historical .book-p {
  font-size: 11.2pt;
  line-height: 1.56;
}
.tpl-style-historical .book-chapter-heading {
  font-family: var(--font-playfair);
  text-align: center;
  font-size: 18.5pt;
  font-style: italic;
  font-weight: 600;
  color: #5a3a22;
  margin: 0.3in 0 0.26in;
  position: relative;
}
.tpl-style-historical .book-chapter-kicker {
  display: block;
  font-family: var(--font-cormorant);
  font-style: normal;
  font-size: 9.5pt;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #8c6239;
  margin-bottom: 6px;
}
.tpl-style-historical .book-chapter-heading::after {
  content: "❦";
  display: block;
  font-style: normal;
  font-size: 11pt;
  color: #8c6239;
  margin-top: 6px;
}
.tpl-style-historical .book-scene-ornament { color: #7c5836; }

/* Template 6: No Ficción / Ensayo */
.tpl-style-nonfiction {
  font-family: var(--font-sans);
  color: #1f2937;
}
.tpl-style-nonfiction .book-p {
  font-size: 10pt;
  line-height: 1.56;
  text-align: left;
}
.tpl-style-nonfiction .book-p + .book-p {
  text-indent: 0;
  margin-top: 9px;
}
.tpl-style-nonfiction .book-chapter-heading {
  font-family: var(--font-sans);
  text-align: left;
  font-size: 16.5pt;
  font-weight: 700;
  color: #111827;
  margin: 0.22in 0 0.24in;
  border-left: 4px solid #1f2937;
  padding-left: 12px;
}
.tpl-style-nonfiction .book-chapter-kicker {
  display: block;
  font-size: 8.5pt;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 3px;
}

/* ================= MODALS & TOAST ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.45);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  width: min(500px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal-card.modal-lg {
  width: min(680px, 100%);
}
.modal-card.modal-xl {
  width: min(900px, 100%);
}

/* Library Modal ("Mis Libros") */
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.library-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.library-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 12px;
}
.library-book-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.14s ease;
}
.library-book-card:hover {
  border-color: var(--border-strong);
}
.library-book-card.active {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
}
.lib-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 20px;
}
.lib-card-badges {
  display: flex;
  gap: 5px;
}
.lib-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
}
.lib-badge-active {
  background: var(--accent-warm);
  color: #fff;
}
.lib-badge-sample {
  background: var(--info-blue-bg);
  color: var(--info-blue-ink);
  border: 1px solid var(--info-blue-border);
}
.lib-card-date {
  font-size: 10.5px;
  color: var(--ink-muted);
}
.lib-card-title {
  margin: 2px 0 0;
  font-family: var(--font-editorial);
  font-size: 16px;
  line-height: 1.3;
  color: var(--ink-primary);
}
.lib-card-author {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-secondary);
}
.lib-card-stats {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.lib-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.modal-intro {
  margin: 0;
  font-size: 13px;
  color: var(--ink-secondary);
}

.import-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 22px 16px;
  text-align: center;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.import-dropzone.dragover {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
}

.dropzone-icon { font-size: 28px; }
.dropzone-title { margin: 0; font-size: 13.5px; }
.dropzone-sub { margin: 0; font-size: 12px; color: var(--ink-muted); max-width: 440px; }
.upload-status { font-size: 12px; font-weight: 600; color: var(--accent-warm); }

.divider-text {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 12px;
}
.divider-text::before, .divider-text::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.paste-textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-editorial);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  background: var(--bg-app);
  color: var(--ink-primary);
}

.dict-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.custom-dict-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-dict-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.ai-status-banner {
  background: var(--info-green-bg);
  border: 1px solid var(--info-green-border);
  color: var(--info-green-ink);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12.5px;
}

.ai-feature-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #1f1d1a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 60;
}

/* ================= HISTORY DRAWER & DIFF CONTROL ================= */
.history-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 14, 12, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: flex-end;
  z-index: 48;
}

.history-drawer {
  width: min(440px, 100vw);
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.history-drawer-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.history-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.history-tab-btn {
  border: none;
  background: transparent;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
}
.history-tab-btn.active {
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-sm);
}

.history-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-entry-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-entry-card.reverted {
  opacity: 0.72;
}

.history-entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-source-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
}

.history-time {
  font-size: 11px;
  color: var(--ink-muted);
}

.history-entry-loc {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-primary);
}

.history-diff-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-editorial);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-primary);
  max-height: 150px;
  overflow-y: auto;
}

.diff-del {
  background: var(--repair-before-bg);
  color: var(--repair-before-ink);
  text-decoration: line-through;
  padding: 0 2px;
  border-radius: 3px;
}

.diff-ins {
  background: var(--repair-after-bg);
  color: var(--repair-after-ink);
  text-decoration: none;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 500;
}

.history-entry-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.history-reverted-tag {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-weight: 600;
}

.autosave-pill {
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--info-green-bg);
  border: 1px solid var(--info-green-border);
  color: var(--info-green-ink);
  font-size: 11.5px;
}

.snapshot-form {
  display: flex;
  gap: 8px;
}
.snapshot-form .form-input {
  flex: 1;
}

.snapshot-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-app);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.14s ease;
}
.snapshot-card:hover {
  border-color: var(--accent-warm);
  background: var(--bg-surface);
}
.snapshot-card-name {
  font-size: 13.5px;
  color: var(--ink-primary);
}
.snapshot-card-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.snap-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.snap-diff-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-secondary);
  cursor: pointer;
}

.snap-preview-body {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  padding: 14px 16px;
  max-height: 46vh;
  overflow-y: auto;
  font-family: var(--font-editorial);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-primary);
}
.snap-diff-para {
  margin: 0 0 12px;
}

/* ================= HOME SCREEN: VISUAL EDITORIAL BOOKSHELF ================= */
#view-bookshelf {
  grid-template-columns: 1fr;
  overflow-y: auto;
  background: var(--bg-app);
}

.bookshelf-shell {
  max-width: 1260px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bookshelf-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.bookshelf-title {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

.bookshelf-subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.bookshelf-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.shelf-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.shelf-search-icon {
  position: absolute;
  left: 10px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0.7;
}
.shelf-search-input {
  padding-left: 30px !important;
  width: 220px;
}
.shelf-sort-select {
  width: auto;
  min-width: 205px;
}

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

.shelf-filter-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.shelf-filter-btn:hover {
  border-color: var(--accent-warm);
  color: var(--ink-primary);
}
.shelf-filter-btn.active {
  background: var(--accent-warm);
  border-color: var(--accent-warm);
  color: #fff;
}

/* Estantería Grid con repisas arquitectónicas sutiles */
.bookshelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 32px 24px;
  padding-top: 8px;
}

.shelf-book-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  padding-bottom: 14px;
  border-bottom: 6px solid var(--border);
  box-shadow: 0 4px 0 -2px rgba(0, 0, 0, 0.04);
  transition: transform 0.18s ease;
}

.shelf-book-card:hover {
  transform: translateY(-3px);
}

.shelf-create-card {
  border-bottom-color: transparent;
  box-shadow: none;
}

.shelf-create-cover {
  aspect-ratio: 2 / 3;
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--bg-subtle);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  transition: all 0.16s ease;
}
.shelf-create-cover:hover {
  border-color: var(--accent-warm);
  background: var(--accent-warm-soft);
}
.shelf-create-icon { font-size: 32px; }
.shelf-create-title {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: 16px;
  color: var(--ink-primary);
}
.shelf-create-desc {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--ink-secondary);
  line-height: 1.4;
}
.shelf-create-btns {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Vertical 2:3 Book Cover Frame */
.book-cover-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  border-radius: 3px 9px 9px 3px;
  overflow: hidden;
  box-shadow:
    inset 4px 0 10px rgba(0, 0, 0, 0.22),
    -2px 6px 18px rgba(20, 18, 15, 0.18),
    2px 2px 4px rgba(20, 18, 15, 0.1);
  background: #27222b;
}

.shelf-book-card.active-book .book-cover-frame {
  outline: 3px solid var(--accent-warm);
  outline-offset: 2px;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Typographic Generated Book Covers */
.book-cover-typo {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  padding: 20px 18px 18px 24px;
}

.cover-typo-spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,0.32) 0%, rgba(255,255,255,0.14) 55%, rgba(0,0,0,0.08) 100%);
}

.cover-typo-inner {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
}

.cover-typo-ornament {
  font-size: 16px;
  opacity: 0.85;
  letter-spacing: 0.15em;
}

.cover-typo-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  word-break: break-word;
}

.cover-typo-rule {
  width: 36px;
  height: 1px;
  background: currentColor;
  opacity: 0.5;
}

.cover-typo-author {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.9;
}

/* Genre Typographic Palettes */
.cover-genre-classic {
  background: linear-gradient(155deg, #273b32 0%, #17241e 100%);
  color: #f4ebd9;
  font-family: var(--font-garamond);
}
.cover-genre-romance {
  background: linear-gradient(155deg, #7f294a 0%, #4d162b 100%);
  color: #fdf2f4;
  font-family: var(--font-playfair);
}
.cover-genre-romance .cover-typo-title { font-style: italic; }

.cover-genre-thriller {
  background: linear-gradient(160deg, #1f2937 0%, #0f172a 100%);
  color: #f8fafc;
  font-family: var(--font-sans);
}
.cover-genre-thriller .cover-typo-title {
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.cover-genre-thriller .cover-typo-ornament { color: #ef4444; }

.cover-genre-gothic {
  background: linear-gradient(155deg, #1f1726 0%, #0e0b12 100%);
  color: #e6c98a;
  font-family: var(--font-cinzel);
}
.cover-genre-gothic .cover-typo-inner { border-color: rgba(230, 201, 138, 0.35); }

.cover-genre-historical {
  background: linear-gradient(155deg, #5c3d28 0%, #362214 100%);
  color: #f6ead6;
  font-family: var(--font-cormorant);
}
.cover-genre-historical .cover-typo-title { font-style: italic; font-size: 20px; }

.cover-genre-nonfiction {
  background: linear-gradient(155deg, #1e3a5f 0%, #10243d 100%);
  color: #f1f5f9;
  font-family: var(--font-sans);
}

/* Status & Pin Badges on Cover */
.book-status-badge {
  position: absolute;
  top: 9px;
  left: 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(20, 18, 16, 0.78);
  color: #fff;
  backdrop-filter: blur(4px);
  z-index: 3;
}
.book-status-badge.status-revision { background: rgba(180, 83, 42, 0.9); }
.book-status-badge.status-maquetar { background: rgba(15, 118, 110, 0.9); }
.book-status-badge.status-publicado { background: rgba(22, 101, 52, 0.92); }
.book-status-badge.status-archivado { background: rgba(82, 82, 91, 0.88); }

.book-sample-badge {
  position: absolute;
  bottom: 9px;
  left: 16px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #1e3a8a;
  z-index: 3;
}

.book-pin-btn {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 18, 16, 0.55);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0.75;
  z-index: 5;
  transition: all 0.14s ease;
}
.book-pin-btn:hover, .book-pin-btn.pinned {
  opacity: 1;
  background: var(--accent-warm);
  transform: scale(1.06);
}

/* Hover Quick Actions Overlay */
.book-hover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 15, 18, 0.84);
  backdrop-filter: blur(3px);
  padding: 42px 12px 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 7px;
  opacity: 0;
  transition: opacity 0.16s ease;
  z-index: 4;
}

.book-cover-frame:hover .book-hover-overlay,
.book-cover-frame:focus-within .book-hover-overlay {
  opacity: 1;
}

.book-overlay-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 5px;
}

.overlay-del-btn {
  color: #fca5a5 !important;
  border: 1px solid rgba(252, 165, 165, 0.35) !important;
}
.overlay-clear-cover {
  color: #e4e4e7 !important;
  font-size: 11px;
  text-align: center;
}

/* Info, Progress Bar & Meta beneath Cover */
.shelf-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.shelf-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.shelf-card-title {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shelf-active-dot {
  color: var(--accent-warm);
  font-size: 11px;
  flex-shrink: 0;
}
.shelf-card-author {
  font-size: 12px;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shelf-goal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 3px;
}
.shelf-word-count {
  font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.shelf-goal-edit-btn {
  border: none;
  background: none;
  color: var(--accent-warm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.shelf-goal-edit-btn:hover { text-decoration: underline; }

.shelf-progress-track {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
}
.shelf-progress-fill {
  height: 100%;
  background: var(--accent-warm);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.shelf-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}
.shelf-status-select {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-radius: 5px;
  font-size: 11px;
  padding: 2px 5px;
  max-width: 132px;
}
.shelf-card-date {
  font-size: 10.5px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.shelf-empty-note {
  grid-column: 1 / -1;
  padding: 32px;
  text-align: center;
  color: var(--ink-muted);
}

/* ================= RESPONSIVE ================= */
@media (max-width: 1140px) {
  #view-analyzer {
    grid-template-columns: 230px minmax(0, 1fr) 310px;
  }
  .layout-shell {
    grid-template-columns: 225px 285px minmax(0, 1fr);
  }
  .chapter-reader { padding: 26px 28px 180px; }
}

@media (max-width: 920px) {
  #app-shell { height: auto; overflow: auto; }
  #view-analyzer, .layout-shell {
    grid-template-columns: 1fr;
    height: auto;
  }
  .panel-left, .panel-right, .matter-sidebar, .layout-sidebar {
    border: none;
    border-bottom: 1px solid var(--border);
  }
}

/* ================= PRINT / PDF EXPORT ================= */
@media print {
  @page {
    margin: 0;
  }
  html, body, #app-shell, .workspace, #view-layout, .layout-shell, .layout-preview-area, .book-preview-canvas {
    height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .no-print {
    display: none !important;
  }
  #view-layout {
    display: block !important;
  }
  .book-page {
    box-shadow: none !important;
    margin: 0 auto !important;
    transform: none !important;
    background: #ffffff !important;
    break-after: page;
    page-break-after: always;
  }
  .book-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
