/* =========================================
   QuantumWriter v8 — Professional Book Studio
   Complete CSS with all panels and features
   ========================================= */

/* ===== 1. CSS VARIABLES ===== */
:root {
  /* Primary (purple) */
  --primary: hsl(271 85% 58%);
  --primary-700: hsl(271 85% 38%);
  --primary-100: hsl(271 85% 95%);
  --primary-200: hsl(271 85% 88%);
  --primary-h: 271;

  /* AI purple accent */
  --ai-h: 268;
  --ai-s: 86%;
  --ai-l: 62%;
  --ai: hsl(var(--ai-h) var(--ai-s) var(--ai-l));
  --ai-100: hsl(var(--ai-h) 90% 95%);

  /* Neutrals */
  --bg: hsl(220 30% 96%);
  --panel: hsl(0 0% 100%);
  --panel-2: hsl(220 22% 98%);
  --panel-3: hsl(220 18% 94%);
  --text: hsl(220 25% 12%);
  --text-soft: hsl(220 16% 30%);
  --muted: hsl(220 12% 46%);
  --border: hsl(220 18% 88%);
  --border-soft: hsl(220 18% 92%);

  /* Shadows */
  --sh-1: 0 2px 10px rgba(0,0,0,.05);
  --sh-2: 0 10px 28px rgba(0,0,0,.08);
  --sh-3: 0 18px 46px rgba(0,0,0,.12);
  --shadow-strong: 0 22px 70px rgba(20, 20, 35, .18);
  --shadow-mid: 0 14px 38px rgba(20, 20, 35, .14);
  --shadow-soft: 0 8px 22px rgba(20, 20, 35, .10);

  /* Radii */
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 22px;

  /* Layout */
  --sidebar-w: 340px;
  --header-h: 72px;
  --menubar-h: 46px;
  --formatbar-h: 54px;
  --statusbar-h: 46px;

  /* z-index */
  --z-dropdown: 50;
  --z-toast: 60;
  --z-sidebar: 40;
  --z-modal: 70;

  /* Focus rings */
  --ring: 0 0 0 3px rgba(140, 60, 255, .22), 0 0 0 7px rgba(50, 140, 255, .12);
  
  /* Paper */
  --paper-1: hsl(40 60% 98%);
  --paper-2: hsl(40 35% 96%);
}

/* ===== 2. BASE STYLES ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% 0%, hsl(271 85% 92% / .55), transparent 60%),
    radial-gradient(900px 600px at 90% 10%, hsl(268 90% 94% / .45), transparent 55%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 10px;
}

/* ===== 3. ANIMATIONS ===== */
@keyframes ai-glow {
  0% { box-shadow: 0 0 5px hsla(var(--ai-h), 86%, 62%, 0.2), 0 2px 10px rgba(0,0,0,.08), inset 0 1px 1px rgba(255,255,255,0.2); }
  50% { box-shadow: 0 0 25px hsla(var(--ai-h), 86%, 62%, 0.5), 0 10px 24px rgba(0,0,0,.12), inset 0 1px 1px rgba(255,255,255,0.3); }
  100% { box-shadow: 0 0 5px hsla(var(--ai-h), 86%, 62%, 0.2), 0 2px 10px rgba(0,0,0,.08), inset 0 1px 1px rgba(255,255,255,0.2); }
}

@keyframes slideInRight {
  from { transform: translateX(14px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes heartPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); filter: drop-shadow(0 0 10px rgba(255, 107, 107, 0.55)); }
  100% { transform: scale(1); }
}

/* ===== 4. LAYOUT ===== */
.app {
  height: 100%;
  width: 100%;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, var(--sidebar-w)) 1fr;
  height: 100%;
  width: 100%;
}

/* ===== 5. SIDEBAR ===== */
.sidebar {
  background: hsla(0, 0%, 100%, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  min-width: 260px;
  box-shadow: var(--sh-3), inset 0 1px 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.4);
  position: relative;
  height: 100%;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 70px;
}

.sidebar-top {
  min-height: var(--header-h);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.sb-top-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-title {
  display: flex;
  align-items: center;
}

.sidebar-title-text {
  font-weight: 700;
  letter-spacing: .2px;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  background: var(--panel-3);
  box-shadow: var(--sh-1);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.sidebar-toggle:hover {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--sh-2);
}

/* Sidebar Tabs */
.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
  padding: 4px;
  background: var(--panel-3);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 0;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  background: transparent;
}

.tab-btn i { font-size: 14px; }

.tab-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}

.tab-btn.active {
  background: var(--panel);
  color: var(--primary);
  box-shadow: var(--sh-1);
}

/* Sidebar Mode Dropdown */
.sidebar-mode {
  width: 100%;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  padding: 0 14px;
  color: var(--text-soft);
  font-weight: 600;
  cursor: pointer;
}

.sidebar-mode optgroup {
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: transparent;
  padding: 8px 0 4px 0;
}

.sidebar-mode optgroup:not(:first-child) {
  margin-top: 6px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-mode option {
  font-weight: 600;
  padding: 6px 12px;
  background: var(--panel);
}

.sidebar-mode option:disabled {
  color: var(--muted);
  font-style: italic;
  opacity: 0.6;
}

.sidebar-mode:hover {
  border-color: var(--primary-200);
}

/* Collapsible Widget */
.collapsible-widget {
  margin: 8px 12px;
}

.collapsible-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--sh-1);
  font-size: 12px;
  font-weight: 900;
  color: var(--text-soft);
}

.collapsible-summary span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.collapsible-summary::-webkit-details-marker { display: none; }
.collapsible-summary::marker { content: ''; }
.collapsible-chevron { transition: transform .2s ease; opacity: .65; }
.collapsible-widget[open] .collapsible-chevron { transform: rotate(180deg); }

/* ===== 6. QUICK STATS ===== */
.stats-card {
  margin: 8px 12px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(145deg, var(--panel), var(--panel-2));
  box-shadow: var(--sh-2);
}

.sc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.sc-item {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 10px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  text-align: center;
  box-shadow: var(--sh-1);
}

.sc-value {
  font-size: 22px;
  font-weight: 950;
  color: var(--primary);
  line-height: 1.05;
  font-feature-settings: "tnum";
}

.sc-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}

.sc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

.sc-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 900;
  color: var(--text-soft);
}

.sc-mini i { opacity: .9; }
.sc-mini .fa-fire { color: #ff9800; }

.sc-goal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 900;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.sc-goal-num { color: var(--primary-700); font-weight: 950; }
.sc-goal-num .muted { color: var(--muted); font-weight: 900; }

.sc-goal-track {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.12);
}

.sc-goal-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--ai));
  transition: width .25s ease;
}

/* ===== 7. INSPIRATION SNACK ===== */
.inspo-snack {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--primary-200);
  background: var(--primary-100);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.is-icon {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  box-shadow: 0 10px 22px hsl(271 85% 58% / .22);
  flex: 0 0 auto;
}

.is-title {
  font-weight: 950;
  font-size: 13px;
  margin-bottom: 3px;
}

.is-quote {
  font-size: 12px;
  font-weight: 850;
  color: var(--text-soft);
  font-style: italic;
  line-height: 1.35;
}

/* ===== 8. QUICK ACTIONS ===== */
.quick-actions {
  margin: 8px 12px 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.qa-btn {
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--panel-3);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--sh-1);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.qa-btn i { color: var(--primary); font-size: 16px; }
.qa-btn span { font-size: 11px; font-weight: 900; color: var(--text-soft); }

.qa-btn:hover {
  transform: translateY(-2px);
  background: var(--panel);
  box-shadow: var(--sh-2);
}

/* ===== 9. SIDEBAR PANELS ===== */
.sidebar-panels {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-content {
  display: none;
}

.panel-content.active {
  display: block;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header h3 i {
  color: var(--primary);
}

/* ===== 10. CHAPTER LIST ===== */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  box-shadow: var(--sh-1);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.12s ease;
}

.chapter-item:hover {
  transform: translateX(2px);
  box-shadow: var(--sh-2);
  border-color: var(--border);
}

.chapter-item.active {
  border-color: hsl(271 92% 70%);
  background: linear-gradient(135deg, var(--primary-100), var(--panel));
}

.chapter-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  box-shadow: 0 10px 22px hsl(271 85% 58% / .25);
  font-weight: 900;
}

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

.chapter-title {
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.chapter-actions {
  display: flex;
  gap: 6px;
  opacity: .9;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
}

.btn-icon:hover {
  background: var(--panel-3);
  border-color: var(--border);
  box-shadow: var(--sh-1);
}

/* ===== 11. MOMENTUM CARD ===== */
.momentum-card {
  margin-top: 12px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(135deg, color-mix(in oklab, var(--primary) 8%, var(--panel)) 0%, var(--panel) 45%, var(--panel-2) 100%);
  box-shadow: var(--sh-2);
  padding: 12px;
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}

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

.momentum-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 950;
  letter-spacing: -0.01em;
  color: var(--text);
}

.momentum-title i {
  color: var(--primary);
}

.momentum-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.06);
  color: var(--text-soft);
  font-weight: 900;
  font-size: 11px;
  white-space: nowrap;
}

.momentum-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.momentum-metric {
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--sh-1);
  padding: 10px;
}

.momentum-value {
  font-weight: 950;
  font-size: 18px;
  color: var(--primary-700);
  line-height: 1.1;
  font-feature-settings: "tnum";
}

.momentum-label {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}

.momentum-progress {
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.06);
  padding: 10px;
}

.momentum-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 900;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.momentum-track {
  height: 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
}

.momentum-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--ai));
  border-radius: 999px;
  transition: width .25s ease;
}

.momentum-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.momentum-hint {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-soft);
  opacity: .88;
  line-height: 1.35;
}

/* ===== 12. OUTLINE ===== */
.outline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outline-item {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  box-shadow: var(--sh-1);
  cursor: pointer;
}

.outline-item:hover {
  background: var(--panel-2);
  box-shadow: var(--sh-2);
}

.outline-item.h1 {
  font-weight: 900;
  border-left: 4px solid var(--primary);
}

.outline-item.h2 {
  padding-left: 22px;
  font-weight: 800;
}

.outline-item.h3 {
  padding-left: 32px;
  font-weight: 700;
  color: var(--muted);
}

/* ===== 13. BOOK INFO ===== */
.book-info .form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.book-info label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-soft);
  letter-spacing: .2px;
}

.book-info input,
.book-info textarea {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--panel);
  padding: 12px 14px;
  color: var(--text);
  width: 100%;
}

.book-info input:focus,
.book-info textarea:focus {
  border-color: hsl(271 85% 70%);
  box-shadow: 0 0 0 4px hsl(271 85% 58% / .16);
  outline: none;
}

.book-info textarea {
  min-height: 110px;
  resize: vertical;
}

.book-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.stat {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--sh-1);
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-weight: 900;
  font-size: 22px;
  color: var(--primary);
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .4px;
  text-transform: uppercase;
}

/* ===== 14. EXPORT PANEL ===== */
.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.export-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 14px 0;
}

/* ===== 15. ENGINE CONSOLE ===== */
.engine-console {
  margin-top: 14px;
  padding: 12px 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(159, 85, 255, 0.10), rgba(255,255,255,0.04));
  border: 1px solid rgba(159, 85, 255, 0.22);
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}

.engine-console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.engine-console-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.engine-console-stage {
  font-size: 12px;
  opacity: 0.85;
}

.engine-console-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.engine-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.engine-step.done {
  border-color: rgba(40,167,69,0.25);
}

.engine-step i.fa-circle-check {
  color: #28a745;
}

/* ===== 16. SETTINGS PANEL ===== */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--sh-1);
}

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

.settings-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 0;
}

.module-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== 17. ETHICS SECTION ===== */
.ethics-summary {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

.ethics-stat {
  flex: 1;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  background: var(--panel);
}

.hint {
  font-size: 12px;
  opacity: .7;
  margin-top: 4px;
}

/* ===== 18. SUPPORT HUB ===== */
.support-hub {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.support-hub-copy {
  background: linear-gradient(180deg, color-mix(in oklab, var(--ai) 10%, var(--panel)), var(--panel));
  border: 1px solid color-mix(in oklab, var(--ai) 20%, var(--border));
  border-radius: 16px;
  padding: 12px;
}

.support-hub-title {
  font-weight: 950;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.support-hub-sub {
  color: var(--text-soft);
  font-weight: 750;
  font-size: 12px;
  line-height: 1.4;
  opacity: .95;
}

.sprint-section,
.inspiration-section {
  background: var(--panel-2);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border-soft);
}

.sprint-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-chip {
  background: var(--panel-3);
  border: 1px solid var(--border-soft);
  color: var(--text-soft);
  padding: 6px 12px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-chip:hover {
  background: var(--panel);
  border-color: var(--border);
  transform: translateY(-1px);
}

.sprint-timer {
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  color: var(--primary);
  margin: 8px 0;
}

.inspire-box {
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  min-height: 70px;
  border: 1px dashed var(--border);
  margin-top: 10px;
  color: var(--text-soft);
}

/* Advanced Support Links */
.support-advanced {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  padding: 10px 12px;
  margin-top: 10px;
}

.support-advanced summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--text);
  padding: 4px 0;
}

.support-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.support-stack {
  align-items: stretch;
}

.support-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
}

.support-hint {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-soft);
  opacity: .85;
}

.support-dual-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.btn-donate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in oklab, var(--ai) 35%, var(--border));
  background: color-mix(in oklab, var(--ai) 16%, var(--panel-2));
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-donate:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-2);
}

.btn-donate-kofi {
  border: 1px solid rgba(114, 66, 255, 0.22);
  background: linear-gradient(135deg, rgba(114, 66, 255, 0.14), rgba(255, 94, 125, 0.10));
}

/* ===== 19. RESEARCH PANEL ===== */
.research-quick {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.research-quick input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

/* ===== 20. AGENTS PANEL ===== */
.agents-canvas {
  min-height: 120px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
  background: var(--panel-2);
}

.agents-placeholder {
  opacity: .7;
  text-align: center;
}

/* ===== 21. PUBLISH PANEL ===== */
.platform-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.platform-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
}

.metadata-score {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.score-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-100);
  font-weight: 700;
  color: var(--primary-700);
}

/* ===== 22. TRANSLATE PANEL ===== */
.language-selector select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: var(--panel);
  color: var(--text);
}

/* ===== 23. CHARACTERS & LOCATIONS ===== */
.character-item,
.location-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.character-item:last-child,
.location-item:last-child {
  border-bottom: none;
}

/* ===== 24. TIMELINE FEATURE ===== */
.timeline-controls {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--panel-2);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-soft);
}

.timeline-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.timeline-filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.timeline-filter-btn:hover {
  background: var(--primary-100);
  border-color: var(--primary-200);
  transform: translateY(-1px);
}

.timeline-filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary-700);
}

.timeline-acts {
  display: flex;
  gap: 8px;
}

.act-pill {
  flex: 1;
  padding: 8px 4px;
  border-radius: var(--r);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.act-pill:hover {
  background: var(--panel-3);
  transform: translateY(-1px);
}

.act-pill.active {
  background: var(--primary-100);
  color: var(--primary-700);
  border-color: var(--primary-200);
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.timeline-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r);
  border: 1px solid var(--border-soft);
  background: var(--panel);
  box-shadow: var(--sh-1);
  cursor: grab;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.timeline-event:hover {
  transform: translateX(4px) translateY(-1px);
  box-shadow: var(--sh-2);
  border-color: var(--primary-200);
}

.timeline-event:active {
  cursor: grabbing;
  transform: scale(0.99);
}

.event-drag-handle {
  color: var(--muted);
  font-size: 16px;
  cursor: grab;
  padding: 0 4px;
}

.event-drag-handle:active {
  cursor: grabbing;
}

.event-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.event-badge.plot {
  background: hsl(271 85% 58%);
}

.event-badge.character {
  background: hsl(142 70% 45%);
}

.event-content {
  flex: 1;
  min-width: 0;
}

.event-title {
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta {
  display: flex;
  gap: 8px;
  margin-top: 2px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

.event-actions {
  display: flex;
  gap: 4px;
  opacity: 0.7;
}

.timeline-add-btn {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--r);
  border: 1px dashed var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.timeline-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-100);
  transform: translateY(-1px);
}

/* ===== 25. MARKETING PANEL ===== */
.blurb-generator textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  resize: vertical;
}

/* ===== 26. SIDEBAR BOTTOM ===== */
.sidebar-bottom {
  padding: 14px 16px;
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel-2), var(--panel-3));
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  bottom: 0;
  z-index: 50;
}

.sb-support {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

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

.funding-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
  width: 100%;
}

.funding-btn:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.12);
  box-shadow: 0 14px 26px rgba(0,0,0,0.12);
}

.funding-btn.paypal {
  background: linear-gradient(135deg, rgba(0,48,135,0.92), rgba(0,198,255,0.35));
  border-color: rgba(0,48,135,0.3);
  color: white;
}

.funding-btn.kofi {
  background: linear-gradient(135deg, rgba(114, 66, 255, 0.92), rgba(255, 94, 125, 0.35));
  border-color: rgba(114, 66, 255, 0.32);
  color: white;
}

.sb-tiny {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 850;
  margin-top: 4px;
}

.sb-tiny .dot {
  opacity: .6;
}

/* ===== 27. WORKSPACE ===== */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* ===== 28. HEADER ===== */
.header {
  min-height: var(--header-h);
  height: auto;
  background: linear-gradient(90deg, hsl(0 0% 100%) 0%, hsl(271 85% 98%) 40%, hsl(214 90% 98%) 100%);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-soft);
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.95) 0%, rgba(255,255,255,.55) 35%, rgba(166, 97, 255, .35) 100%),
              linear-gradient(135deg, rgba(166,97,255,.95), rgba(123,44,191,.75));
  border: 1px solid rgba(255,255,255,.55);
  box-shadow: 0 10px 25px rgba(123,44,191,.25), inset 0 1px 0 rgba(255,255,255,.7);
  color: rgba(30, 10, 60, .92);
}

.brand-logo i {
  font-size: 20px;
  filter: drop-shadow(0 2px 8px rgba(123,44,191,.35));
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.version {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  background: var(--primary-100);
  color: var(--primary-700);
  border: 1px solid hsl(271 85% 86%);
}

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

.brand-copyright {
  margin-left: 10px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

/* ===== 29. BUTTONS ===== */
.btn-primary,
.btn-secondary,
.btn-action {
  height: 40px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-weight: 800;
  transition: transform .12s ease, box-shadow .12s ease;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.btn-primary {
  background: linear-gradient(135deg, hsl(271 85% 60%) 0%, hsl(214 90% 56%) 55%, hsl(190 90% 52%) 100%);
  color: #fff;
  box-shadow: var(--shadow-mid);
}

.btn-primary:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
  box-shadow: var(--shadow-strong);
}

.btn-secondary {
  border-color: var(--border-soft);
  background: linear-gradient(180deg, #fff, hsl(220 30% 96%));
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
  border-color: var(--border);
}

.btn-action {
  border-color: var(--border-soft);
  background: linear-gradient(180deg, #fff, hsl(220 30% 96%));
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.btn-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
  border-color: var(--border);
}

.btn-danger {
  border-color: hsl(0 75% 78%);
  color: hsl(0 60% 40%);
}

.btn-danger:hover {
  background: hsl(0 90% 97%);
  border-color: hsl(0 70% 66%);
}

.btn-ai {
  border-color: hsl(var(--ai-h) 85% 86%);
  background: linear-gradient(180deg, hsl(var(--ai-h) 90% 98%), var(--panel));
  color: hsl(var(--ai-h) 40% 28%);
  animation: ai-glow 3s infinite ease-in-out;
}

.btn-ai:hover {
  box-shadow: 0 16px 34px hsl(var(--ai-h) 86% 62% / .22);
  border-color: hsl(var(--ai-h) 86% 70%);
  animation: none;
}

.btn-export {
  border-color: hsl(271 85% 86%);
}

.btn-generate {
  background: linear-gradient(135deg, var(--ai), var(--primary));
  color: #fff;
  box-shadow: 0 16px 34px rgba(0,0,0,.12);
}

.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 50px rgba(0,0,0,.14);
}

.btn-text {
  display: inline;
}

/* ===== 30. MENU BAR ===== */
.menu-bar {
  height: var(--menubar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

.menu-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.menu-item {
  height: 36px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: var(--text-soft);
  font-weight: 800;
  background: linear-gradient(180deg, #fff, hsl(220 30% 96%));
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  letter-spacing: -0.02em;
}

.menu-item i {
  margin-right: 8px;
  color: var(--muted);
}

.menu-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
}

.menu-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: hsl(142 70% 45%);
  box-shadow: 0 0 0 4px hsl(142 70% 45% / .16);
}

/* ===== 31. DROPDOWNS ===== */
.dropdown {
  position: absolute;
  display: none;
  min-width: 220px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: hsl(0 0% 100% / .92);
  backdrop-filter: blur(10px);
  box-shadow: var(--sh-3), inset 0 1px 1px 0 rgba(255, 255, 255, 0.2);
  z-index: var(--z-dropdown);
}

.dropdown.open {
  display: block;
}

.drop-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 800;
  color: var(--text-soft);
}

.drop-item i {
  width: 18px;
  text-align: center;
  color: var(--muted);
}

.drop-item:hover {
  background: var(--panel-3);
  border-color: var(--border-soft);
}

.drop-item.danger {
  color: hsl(0 65% 42%);
}

.drop-item.danger i {
  color: hsl(0 65% 42%);
}

.drop-sep {
  height: 1px;
  background: var(--border-soft);
  margin: 8px 6px;
}

/* ===== 32. FORMAT BAR ===== */
.format-bar {
  height: var(--formatbar-h);
  background: linear-gradient(180deg, var(--panel-2), var(--panel-3));
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
}

.format-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.format-group.right {
  margin-left: auto;
}

.format-sep {
  width: 1px;
  height: 22px;
  background: var(--border-soft);
  margin: 0 6px;
}

.btn-format {
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #fff, hsl(220 30% 96%));
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  color: var(--text-soft);
  font-weight: 900;
}

.btn-format:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
  border-color: var(--border);
}

.select-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.select-label select {
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  padding: 0 12px;
  color: var(--text-soft);
  font-weight: 800;
  cursor: pointer;
}

/* ===== 33. MAIN PANES ===== */
.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  overflow: hidden;
}

.pane {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-2);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.3s ease;
}

.pane:hover {
  border-color: var(--primary-200);
  transform: translateY(-2px);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  flex-shrink: 0;
}

.pane-title h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pane-title h2 i {
  color: var(--primary);
}

#chapter-title {
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  padding: 0 14px;
  font-weight: 800;
  color: var(--text);
  width: min(420px, 46vw);
  flex-shrink: 0;
}

#chapter-title:focus {
  border-color: hsl(271 85% 70%);
  box-shadow: 0 0 0 4px hsl(271 85% 58% / .16);
  outline: none;
}

/* ===== 34. PANE CONTENT - CRITICAL FOR SCROLLING ===== */
.pane-content {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  display: flex;
  flex-direction: column;
}

/* ===== 35. EDITOR ===== */
.editor {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: radial-gradient(circle at 20% 0%, hsl(271 85% 98%) 0%, hsl(0 0% 100%) 45%, hsl(220 30% 98%) 100%);
  padding: 16px 18px;
  line-height: 1.75;
  font-size: 16px;
  box-shadow: var(--shadow-strong);
  outline: none;
  font-feature-settings: "salt" 1, "liga" 1, "kern" 1;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

.editor:empty::before {
  content: "Start writing your story here...";
  color: var(--muted);
  font-style: italic;
}

.editor h1,
.editor h2,
.editor h3 {
  line-height: 1.25;
  margin: 22px 0 12px;
  font-weight: 900;
}

.editor h1 {
  font-size: 32px;
  letter-spacing: -0.02em;
}

.editor h2 {
  font-size: 26px;
}

.editor h3 {
  font-size: 20px;
  color: var(--text-soft);
}

.editor p {
  margin: 14px 0;
}

.editor blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--primary);
  background: var(--primary-100);
  border-radius: 16px;
  color: var(--text-soft);
  font-style: italic;
}

.editor ul,
.editor ol {
  padding-left: 26px;
}

/* ===== 36. PREVIEW ===== */
.preview-content {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
  line-height: 1.85;
  letter-spacing: 0.01em;
  font-family: "Georgia", "Times New Roman", serif;
  max-width: 800px;
  margin: 0 auto;
  color: var(--text);
  background: linear-gradient(180deg, var(--paper-1), var(--paper-2));
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-mid);
  padding: 16px 18px;
}

.preview-content.kindle-view {
  background: rgba(0,0,0,0.10);
  padding: 26px 22px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.65;
  font-size: 17px;
}

.preview-content.kindle-view > * {
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.preview-content h1 {
  font-size: 32px;
  margin: 22px 0 12px;
}

.preview-content h2 {
  font-size: 26px;
  margin: 22px 0 12px;
}

.preview-content h3 {
  font-size: 20px;
  margin: 22px 0 12px;
  color: var(--text-soft);
}

.preview-content blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--primary);
  background: var(--primary-100);
  border-radius: 16px;
}

.preview-placeholder {
  color: var(--muted);
  font-style: italic;
}

/* ===== 37. PILLS & BADGES ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

/* ===== 38. STATUS BAR ===== */
.status-bar {
  height: var(--statusbar-h);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.status-left,
.status-center,
.status-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.doc-info {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.stat-item i {
  margin-right: 6px;
  color: var(--muted);
}

.status-bar .ticker i {
  color: rgba(255,107,107,0.85);
}

.engine-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  margin-right: 10px;
}

.engine-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0,0,0,0.25);
  display: inline-block;
}

.engine-light.green {
  background: #28a745;
  box-shadow: 0 0 10px rgba(40,167,69,0.55);
}

/* ===== 39. NOTIFICATIONS ===== */
#notification-container {
  position: fixed;
  top: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.notification {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: hsl(0 0% 100% / .92);
  backdrop-filter: blur(10px);
  box-shadow: var(--sh-3), inset 0 1px 1px 0 rgba(255, 255, 255, 0.2);
  min-width: 320px;
  max-width: min(420px, 92vw);
  font-weight: 800;
  color: var(--text-soft);
  animation: slideInRight .18s ease;
}

.notification button {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
}

.notification button:hover {
  background: var(--panel-3);
}

/* ===== 40. SELECTION ===== */
::selection {
  background: hsl(271 85% 58% / .20);
}

/* ===== 41. INPUTS ===== */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
textarea,
select {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: var(--ring);
  border-color: hsl(271 85% 70%);
}

/* ===== 42. SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 20px;
}

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

/* ===== 43. FOCUS MODE ===== */
body.focus-mode .sidebar,
body.focus-mode .preview-pane {
  display: none;
}

body.focus-mode .layout {
  grid-template-columns: 1fr;
}

body.focus-mode .main {
  grid-template-columns: 1fr;
}

body.focus-mode .editor {
  max-width: 820px;
  margin: 0 auto;
}

/* ===== 44. WRITING THEME ===== */
body.writing-theme .pane {
  background: linear-gradient(135deg, hsl(271 85% 98%), var(--panel));
}

body.writing-theme .editor {
  background: hsl(271 85% 99%);
}

/* ===== 45. LAYOUT MODES ===== */
:root[data-layout="editor"] .preview-pane {
  display: none !important;
}

:root[data-layout="preview"] .editor-pane {
  display: none !important;
}

/* ===== 46. DARK MODE ===== */
body.dark-mode {
  --bg: hsl(220 25% 10%);
  --panel: hsl(220 25% 14%);
  --panel-2: hsl(220 23% 16%);
  --panel-3: hsl(220 22% 19%);
  --text: hsl(220 15% 93%);
  --text-soft: hsl(220 12% 75%);
  --muted: hsl(220 10% 55%);
  --border: hsl(220 18% 22%);
  --border-soft: hsl(220 15% 18%);
  --sh-1: 0 2px 10px rgba(0, 0, 0, .3);
  --sh-2: 0 10px 28px rgba(0, 0, 0, .4);
  --sh-3: 0 18px 46px rgba(0, 0, 0, .5);
  --shadow-strong: 0 22px 70px rgba(0, 0, 0, .6);
  --shadow-mid: 0 14px 38px rgba(0, 0, 0, .5);
  --shadow-soft: 0 8px 22px rgba(0, 0, 0, .3);
  --paper-1: hsl(40 20% 15%);
  --paper-2: hsl(40 15% 12%);
}

body.dark-mode {
  background:
    radial-gradient(1200px 700px at 15% 0%, hsl(271 65% 25% / .45), transparent 60%),
    radial-gradient(900px 600px at 90% 10%, hsl(268 70% 22% / .35), transparent 55%),
    var(--bg);
}

body.dark-mode .sidebar {
  background: hsla(220, 25%, 10%, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .pane,
body.dark-mode .menu-bar,
body.dark-mode .format-bar,
body.dark-mode .status-bar {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select,
body.dark-mode .btn-secondary,
body.dark-mode .btn-action,
body.dark-mode .menu-item,
body.dark-mode .btn-format {
  background: var(--panel-3);
  border-color: var(--border);
  color: var(--text);
}

body.dark-mode .btn-ai {
  background: hsl(var(--ai-h) 35% 22%);
  border-color: hsl(var(--ai-h) 45% 35%);
  color: hsl(var(--ai-h) 75% 85%);
}

body.dark-mode .editor {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}

body.dark-mode .preview-content {
  background: linear-gradient(180deg, var(--paper-1), var(--paper-2));
  border-color: var(--border);
}

body.dark-mode .dropdown {
  background: hsla(220, 25%, 12%, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .notification {
  background: hsla(220, 25%, 12%, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
}

body.dark-mode .header {
  background: linear-gradient(90deg, var(--panel) 0%, hsl(271 35% 18%) 40%, hsl(214 35% 18%) 100%);
}

body.dark-mode .funding-btn.paypal,
body.dark-mode .funding-btn.kofi {
  color: white;
}

/* ===== 47. RESPONSIVE ===== */
@media (max-width: 1200px) {
  .header {
    padding: 12px 14px;
  }
  .brand-copyright {
    display: none;
  }
  .brand-sub {
    display: none;
  }
  .brand {
    min-width: auto;
  }
}

@media (max-width: 1000px) {
  .brand-text h1 {
    font-size: 16px;
  }
  .brand-logo {
    width: 42px;
    height: 42px;
  }
  .version {
    font-size: 10px;
    padding: 2px 6px;
  }
}

@media (max-width: 900px) {
  .header-actions .btn-text {
    display: none;
  }
  .action-group.ai {
    order: 2;
    width: 100%;
    justify-content: flex-start;
  }
  .action-group:last-child {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
  .brand {
    order: 1;
  }
  .header {
    padding: 12px;
    gap: 8px;
  }
  .btn-primary,
  .btn-secondary,
  .btn-action {
    padding: 0 12px;
  }
  .format-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 760px) {
  :root {
    --sidebar-w: 300px;
  }
  .brand-copyright {
    display: none;
  }
  .btn-text {
    display: none;
  }
  .format-group {
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 600px) {
  .brand-text h1 {
    font-size: 15px;
  }
  .version {
    display: none;
  }
  .brand-logo {
    width: 38px;
    height: 38px;
  }
  .status-bar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }
  .status-left,
  .status-center,
  .status-right {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 520px) {
  body {
    overflow: auto;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(92vw, 340px);
    transform: translateX(-105%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-sidebar);
    box-shadow: var(--sh-3);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    padding: 10px;
  }
  .pane-header {
    flex-wrap: wrap;
  }
  #chapter-title {
    width: 100%;
  }
}

/* ===== 48. PRINT ===== */
@media print {
  .sidebar,
  .menu-bar,
  .format-bar,
  #notification-container,
  .header-actions,
  .sidebar-bottom {
    display: none !important;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .main {
    display: block;
    padding: 0;
  }
  .pane {
    box-shadow: none;
    border: 0;
  }
}

/* ===== 49. EDITOR POLISH - Premium Writing Experience ===== */

/* Smooth scrolling */
.editor {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
  scroll-padding-bottom: 2rem;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  caret-color: var(--primary);
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Focus state enhancement */
.editor:focus {
  box-shadow: 0 0 0 2px var(--primary-200), var(--shadow-strong);
  border-color: var(--primary-200);
}

/* Selection styling */
.editor::selection,
.editor *::selection {
  background: hsl(271 85% 58% / 0.25);
  color: var(--text);
}

/* Better paragraph spacing */
.editor p {
  margin: 1.2em 0;
  line-height: 1.75;
}

.editor p:first-child { margin-top: 0; }
.editor p:last-child { margin-bottom: 0; }

/* Smooth placeholder */
.editor:empty::before {
  content: "Start writing your story here...";
  color: var(--muted);
  font-style: italic;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.editor:focus:empty::before { opacity: 0.4; }

/* Chapter transition animation */
.pane {
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.3s ease;
}

.pane.chapter-loading {
  opacity: 0.7;
  pointer-events: none;
}

.pane.chapter-loading .editor { filter: blur(1px); }

/* Better scrollbar for editor */
.editor::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.editor::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 20px;
}

.editor::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 20px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.editor::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
  border: 3px solid transparent;
  background-clip: padding-box;
}

.editor::-webkit-scrollbar-corner { background: transparent; }

/* Heading refinements */
.editor h1 {
  font-size: 2.2em;
  letter-spacing: -0.02em;
  margin: 1.5em 0 0.5em;
  line-height: 1.2;
  font-weight: 900;
  color: var(--text);
}

.editor h1:first-child { margin-top: 0.5em; }

.editor h2 {
  font-size: 1.8em;
  letter-spacing: -0.01em;
  margin: 1.3em 0 0.5em;
  line-height: 1.3;
  font-weight: 800;
  color: var(--text-soft);
}

.editor h3 {
  font-size: 1.4em;
  margin: 1.2em 0 0.5em;
  line-height: 1.4;
  font-weight: 700;
  color: var(--text-soft);
}

/* Blockquote polish */
.editor blockquote {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  border-left: 4px solid var(--primary);
  background: linear-gradient(to right, var(--primary-100), transparent 80%);
  border-radius: 0 16px 16px 0;
  font-style: italic;
  color: var(--text-soft);
  font-size: 0.95em;
}

/* List styling */
.editor ul,
.editor ol {
  padding-left: 2em;
  margin: 1em 0;
}

.editor li {
  margin: 0.4em 0;
  line-height: 1.6;
}

/* Code blocks */
.editor code {
  background: var(--panel-3);
  padding: 0.2em 0.4em;
  border-radius: 6px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 0.9em;
  border: 1px solid var(--border-soft);
}

.editor pre {
  background: var(--panel-3);
  padding: 1em;
  border-radius: 12px;
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  margin: 1.5em 0;
}

.editor pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: 0.9em;
  line-height: 1.6;
}

/* Tables */
.editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95em;
}

.editor th {
  background: var(--panel-3);
  font-weight: 700;
  padding: 0.75em;
  text-align: left;
  border: 1px solid var(--border);
}

.editor td {
  padding: 0.75em;
  border: 1px solid var(--border-soft);
}

/* Horizontal rule */
.editor hr {
  margin: 2em 0;
  border: none;
  border-top: 2px dashed var(--border-soft);
}

/* Images */
.editor img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 1.5em 0;
  box-shadow: var(--sh-2);
}

/* Links */
.editor a {
  color: var(--primary-700);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.editor a:hover { border-bottom-color: var(--primary-700); }

/* Focus mode refinements */
body.focus-mode .editor {
  max-width: 720px;
  margin: 0 auto;
  font-size: 18px;
  line-height: 1.8;
}

body.focus-mode .editor h1 { font-size: 2.4em; }
body.focus-mode .editor h2 { font-size: 2em; }

/* Dark mode adjustments */
body.dark-mode .editor::selection,
body.dark-mode .editor *::selection {
  background: hsl(271 85% 58% / 0.35);
}

body.dark-mode .editor blockquote {
  background: linear-gradient(to right, hsl(271 25% 20%), transparent 80%);
}

body.dark-mode .editor code {
  background: var(--panel-2);
  border-color: var(--border);
}

body.dark-mode .editor pre { background: var(--panel-2); }
body.dark-mode .editor th { background: var(--panel-2); }


/* ===== Focus Line ===== */
.editor.focus-line-active > * {
  opacity: 0.45;
  transition: opacity 0.18s ease;
}

.editor.focus-line-active > *.active-block {
  opacity: 1;
}

.editor.focus-line-active > h1.active-block,
.editor.focus-line-active > h2.active-block,
.editor.focus-line-active > h3.active-block,
.editor.focus-line-active > p.active-block,
.editor.focus-line-active > blockquote.active-block,
.editor.focus-line-active > ul.active-block,
.editor.focus-line-active > ol.active-block,
.editor.focus-line-active > pre.active-block {
  transform: translateZ(0);
}

body.focus-mode .editor.focus-line-active > * {
  opacity: 0.35;
}

body.focus-mode .editor.focus-line-active > *.active-block {
  opacity: 1;
}



/* ===== IMPORT UPGRADE ===== */
.import-section {
  margin: 16px 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--sh-1);
}
.import-header h4,
.backup-section h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 900;
  color: var(--text-soft);
}
.import-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--panel-3);
  border-radius: 14px;
  margin-bottom: 12px;
}
.import-tab {
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
}
.import-tab.active {
  background: var(--panel);
  color: var(--primary);
  box-shadow: var(--sh-1);
}
#import-text {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  color: var(--text);
  margin-bottom: 10px;
}
#import-text:focus {
  outline: none;
  border-color: var(--primary-200);
  box-shadow: 0 0 0 4px hsl(271 85% 58% / .16);
}
.import-setting {
  margin-bottom: 10px;
  background: var(--panel-2);
  border-radius: 12px;
  padding: 10px 12px;
}
.import-actions,
.backup-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.import-actions > * , .backup-row > * {
  flex: 1 1 0;
}
.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 22px 16px;
  background: var(--panel-2);
  text-align: center;
}
.import-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-100);
}
.import-dropzone i {
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 8px;
}
.import-dropzone p {
  margin-bottom: 10px;
  font-weight: 800;
  color: var(--text-soft);
}
.import-file-name,
.backup-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.import-preview {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  animation: slideDown .2s ease;
}
.import-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.import-chapter-list {
  max-height: 110px;
  overflow-y: auto;
  font-size: 12px;
}
.import-chapter-list > div {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
}
.import-chapter-list > div:last-child {
  border-bottom: 0;
}
.backup-section {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
}
.backup-file-input {
  display: none;
}
.backup-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--panel);
  font-weight: 800;
  cursor: pointer;
}
.backup-label:hover {
  border-color: var(--primary);
  background: var(--primary-100);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}


/* v8 parser visuals */
.scene-break{margin:1.25rem auto;text-align:center;letter-spacing:.35em;opacity:.7;font-weight:700;}
.page-break{border:none;border-top:2px dashed rgba(255,255,255,.18);margin:1.5rem 0;}


/* ===== QuantumWriter Upgrade Pack ===== */
.menu-status {
  min-width: 220px;
}
.menu-status-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.15;
}
.menu-status-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.menu-status.is-unsaved .status-dot {
  background: hsl(45 95% 52%);
  box-shadow: 0 0 0 4px hsl(45 95% 52% / .16);
}
.menu-status.is-saving .status-dot {
  background: hsl(217 91% 60%);
  box-shadow: 0 0 0 4px hsl(217 91% 60% / .16);
}
.menu-status.is-saved .status-dot {
  background: hsl(142 70% 45%);
  box-shadow: 0 0 0 4px hsl(142 70% 45% / .16);
}
.import-preview-meta {
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.import-chapter-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.import-chapter-list .import-chapter-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-chapter-list .import-chapter-words {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
