/* ==============================================================================
   AuraBook AI — Design System & Stylesheet
   Modern Glassmorphic Dark Architecture with Dynamic Micro-Animations
   ============================================================================== */

:root {
  /* Color Palette - Curated Slate & Cosmic Indigo */
  --bg-base: #07090e;
  --bg-surface: #0e1320;
  --bg-card: rgba(18, 24, 40, 0.75);
  --bg-card-hover: rgba(26, 35, 58, 0.85);
  --bg-input: rgba(13, 18, 32, 0.8);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --border-glow: rgba(129, 140, 248, 0.25);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #090d16;

  /* Accent Gradients & Colors */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
  --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);

  /* Typography */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 48px -10px rgba(0, 0, 0, 0.6), 0 0 25px rgba(99, 102, 241, 0.15);

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Ambient Glows */
.app-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.4;
  animation: pulseGlow 14s ease-in-out infinite alternate;
}

.glow-1 {
  top: -10%;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, transparent 70%);
}

.glow-2 {
  top: 40%;
  right: -5%;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.2) 0%, transparent 70%);
  animation-delay: -5s;
}

.glow-3 {
  bottom: -10%;
  left: 5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.15) 0%, transparent 70%);
  animation-delay: -9s;
}

@keyframes pulseGlow {
  0% { transform: scale(1) translate(0, 0); opacity: 0.35; }
  50% { transform: scale(1.15) translate(30px, -20px); opacity: 0.55; }
  100% { transform: scale(0.95) translate(-20px, 30px); opacity: 0.35; }
}

/* ==============================================================================
   Header Navigation
   ============================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 9, 14, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  height: 72px;
  display: flex;
  align-items: center;
}

.header-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
  transition: transform var(--transition-fast);
}

.brand-icon:hover {
  transform: scale(1.05);
}

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

.brand-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.4);
}

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

.header-status-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.system-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.status-dot.pulsing {
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.badge-counter {
  padding: 1px 7px;
  border-radius: 9999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
}

.user-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  max-width: 28px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.new-book-btn {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  color: #c7d2fe;
}

.new-book-btn:hover {
  background: rgba(99, 102, 241, 0.28);
  border-color: rgba(99, 102, 241, 0.6);
  color: #ffffff;
}

/* ==============================================================================
   Main Layout & Hero Section
   ============================================================================== */

.main-content {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  transition: all 0.3s ease;
}

.main-content.workspace-active {
  padding-top: 14px;
  gap: 16px;
}

.studio-workspace {
  width: 100%;
}

.hero-section {
  text-align: center;
  max-width: 880px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-light);
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 3.25rem;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.hero-description {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 32px;
}

/* Quick Inspirations Chips */
.quick-inspirations {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.inspirations-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chip-btn {
  padding: 8px 16px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--text-primary);
  transform: translateY(-2px);
}

/* ==============================================================================
   Generator Card & Form
   ============================================================================== */

.card {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.generator-card {
  padding: 36px;
  text-align: left;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.span-2 {
  grid-column: span 2;
}

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

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.label-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 13px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(18, 25, 45, 0.9);
}

.form-textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.5;
}

.input-icon {
  position: absolute;
  right: 16px;
  pointer-events: none;
  font-size: 1.1rem;
}

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.engine-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.indicator-icon {
  color: var(--accent-amber);
}

/* Primary & Secondary Action Buttons */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 12px;
  background: var(--gradient-primary);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--primary-glow);
  transition: all var(--transition-fast);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px var(--primary-glow);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* ==============================================================================
   Live Pipeline Visualizer Section
   ============================================================================== */

.pipeline-section {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.pipeline-card {
  padding: 36px;
}

.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.pipeline-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: var(--accent-cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.pulse-circle {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulseDot 1.5s infinite;
}

.active-book-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
}

.pipeline-current-msg {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.pipeline-stats {
  display: flex;
  gap: 12px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Progress Bar */
.progress-container {
  margin-bottom: 32px;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 9999px;
  transition: width 0.4s ease;
  box-shadow: 0 0 14px var(--primary-glow);
}


.stage-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
}

.badge-pending {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.badge-running {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.4);
  animation: pulseBadge 1.8s infinite;
}

@keyframes pulseBadge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.badge-completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}


/* Event Stream Terminal */
.pipeline-events-terminal {
  border-radius: 12px;
  background: #090c14;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.terminal-dots span:nth-child(1) { background: #ff5f56; }
.terminal-dots span:nth-child(2) { background: #ffbd2e; }
.terminal-dots span:nth-child(3) { background: #27c93f; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.terminal-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

.terminal-body {
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #a5b4fc;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.terminal-line {
  line-height: 1.4;
}

.term-time {
  color: var(--text-muted);
  margin-right: 8px;
}

/* ==============================================================================
   Embedded Live Studio Output (Integrated Directly Beneath Action Buttons)
   ============================================================================== */

.embedded-live-studio {
  margin-top: 18px;
  padding: 16px 20px;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), inset 0 0 20px rgba(99, 102, 241, 0.06);
  animation: fadeIn 0.3s ease;
  width: 100%;
}

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

.embedded-live-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.embedded-live-title-row .active-book-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
}

.embedded-live-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.embedded-live-stats .pipeline-current-msg {
  font-size: 0.82rem;
  color: #94a3b8;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embedded-terminal {
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(3, 7, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.embedded-terminal .terminal-body {
  max-height: 110px;
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ==============================================================================
   High-Visibility Processing / Loading State on Buttons
   ============================================================================== */

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

.animate-spin {
  display: inline-block;
  animation: spin 0.75s linear infinite;
}

.btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #38bdf8;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

button.btn-processing {
  cursor: not-allowed !important;
  pointer-events: none !important;
  opacity: 0.9 !important;
  position: relative;
  outline: none;
  box-shadow: 0 0 0 2px #0f172a, 0 0 0 4px #38bdf8, 0 0 24px rgba(56, 189, 248, 0.6) !important;
  animation: pulseCyanRing 1.5s infinite ease-in-out !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
}

@keyframes pulseCyanRing {
  0%, 100% {
    box-shadow: 0 0 0 2px #0f172a, 0 0 0 4px #38bdf8, 0 0 16px rgba(56, 189, 248, 0.4);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 0 2px #0f172a, 0 0 0 5px #06b6d4, 0 0 28px rgba(6, 182, 212, 0.85);
    filter: brightness(1.15);
  }
}

/* ==============================================================================
   Interactive Book Reader Section
   ============================================================================== */

.reader-section {
  animation: fadeIn 0.4s ease;
}

.reader-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  margin-bottom: 28px;
}

.reader-meta-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.meta-item {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.reader-actions-group {
  display: flex;
  gap: 10px;
}

.print-btn {
  padding: 9px 18px;
  font-size: 0.85rem;
}

/* Reader Split Layout */
.reader-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: start;
}

/* Sticky Sidebar TOC */
.reader-sidebar {
  position: sticky;
  top: 96px;
}

.sidebar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  transition: all var(--transition-fast);
}

.toc-nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.toc-nav-link.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  font-weight: 600;
}

/* Manuscript Main Canvas */
.manuscript-canvas {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 56px 64px;
  box-shadow: var(--shadow-md);
}

.manuscript-header {
  text-align: center;
  margin-bottom: 48px;
}

.manuscript-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 9999px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.manuscript-title {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 12px;
}

.manuscript-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.manuscript-credits {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 12px;
}

.manuscript-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
  margin: 36px 0;
}

.book-section {
  margin-bottom: 64px;
  scroll-margin-top: 100px;
}

.section-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.chapter-title-header {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.chapter-subtitle-header {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Editorial Body Typography */
.manuscript-body {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #cbd5e1;
}

.manuscript-body p {
  margin-bottom: 1.4rem;
}

.manuscript-body h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2.2rem 0 1rem;
  letter-spacing: -0.02em;
}

.manuscript-body h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 1.8rem 0 0.8rem;
}

.manuscript-body blockquote {
  position: relative;
  margin: 2rem 0;
  padding: 18px 24px;
  border-left: 4px solid var(--primary);
  background: rgba(99, 102, 241, 0.06);
  border-radius: 0 12px 12px 0;
  font-style: italic;
  color: #e0e7ff;
  font-size: 1.1rem;
}

.manuscript-body ul, .manuscript-body ol {
  margin: 1rem 0 1.5rem 1.6rem;
}

.manuscript-body li {
  margin-bottom: 0.6rem;
}

.manuscript-body strong {
  color: #fff;
}

/* Custom Styled Blocks for Exercises & Frameworks */
.exercise-callout-card {
  margin: 2.2rem 0;
  padding: 24px;
  border-radius: 14px;
  background: rgba(6, 182, 212, 0.05);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.exercise-callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 12px;
}

.takeaways-pill-box {
  margin: 2rem 0;
  padding: 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
}

.takeaways-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-light);
  margin-bottom: 12px;
}

/* ==============================================================================
   Library Modal & Grid
   ============================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  width: 100%;
  max-width: 740px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

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

.library-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.library-book-item {
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.library-book-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.book-item-meta h4 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.book-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

.library-empty {
  text-align: center;
  padding: 48px 20px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ==============================================================================
   Toast Notifications
   ============================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: 10px;
  background: #1e293b;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  animation: slideToast 0.3s ease;
}

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

/* ==============================================================================
   Multi-Stage Studio Stepper Sub-Bar & Compact Stage Components
   ============================================================================== */

.stepper-subbar {
  position: sticky;
  top: 65px;
  z-index: 95;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: all 0.25s ease;
}

.stepper-container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

.studio-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  margin: 0;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.55;
  transition: all 0.2s ease;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 8px;
  user-select: none;
}

.step-item:hover {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.05);
}

.step-item.active {
  opacity: 1;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.step-item.completed {
  opacity: 0.95;
}

.step-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.step-item.active .step-circle {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  border-color: #a5b4fc;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
  transform: scale(1.06);
}

.step-item.completed .step-circle {
  background: #10b981;
  color: #ffffff;
  border-color: #6ee7b7;
  font-size: 0.72rem;
}

.step-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.step-status {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.step-item.active .step-status {
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.4);
}

.step-item.completed .step-status {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

.step-line {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 8px;
  min-width: 14px;
  transition: all 0.3s ease;
}

.step-line.completed {
  background: linear-gradient(90deg, #10b981, #6366f1);
}

.stage-card-header {
  margin-bottom: 24px;
}

.stage-tag {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stage-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.stage-substep-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #c7d2fe;
  letter-spacing: 0.3px;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
  transition: all 0.25s ease;
}

.stage-substep-indicator .substep-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #818cf8;
  box-shadow: 0 0 8px #6366f1;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.25); }
}

.stage-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 6px;
}

.stage-subtitle {
  font-size: 0.92rem;
  color: #94a3b8;
  line-height: 1.5;
}

.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.substep-view {
  animation: fadeIn 0.3s ease;
}

.stage-review-box {
  margin-top: 24px;
  animation: fadeIn 0.4s ease;
}

.review-box-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.review-badge {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.review-meta h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 4px;
}

.review-meta p {
  font-size: 0.88rem;
  color: #94a3b8;
}

.review-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.toc-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.toc-card-editor {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.toc-card-editor:hover, .toc-card-editor:focus-within {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.toc-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toc-ch-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc-field-group {
  margin-bottom: 10px;
}

.toc-field-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc-field-input {
  width: 100%;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: #f8fafc;
  font-size: 0.88rem;
  transition: border-color 0.2s ease;
}

.toc-field-input:focus {
  outline: none;
  border-color: #6366f1;
}

.toc-field-textarea {
  width: 100%;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: #f8fafc;
  font-size: 0.84rem;
  resize: vertical;
  min-height: 54px;
  font-family: inherit;
}

.toc-field-textarea:focus {
  outline: none;
  border-color: #6366f1;
}

.outline-summary-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.65);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.outline-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #e2e8f0;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.outline-chip:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

/* ==============================================================================
   Sub-Step Sticky Navigation Footer
   ============================================================================== */

.stage-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding: 14px 18px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  position: sticky;
  bottom: 16px;
  z-index: 25;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-footer-left,
.nav-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-footer-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chapter-pagination-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.8);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==============================================================================
   Stage 2: Chapter Pagination Tabs & Single-Chapter Editor Screen
   ============================================================================== */

.chapter-tabs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 4px 14px 4px;
  margin-bottom: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.chapter-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  user-select: none;
}

.chapter-tab:hover {
  background: rgba(30, 41, 59, 0.8);
  color: #f8fafc;
  border-color: rgba(99, 102, 241, 0.3);
}

.chapter-tab.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: #6366f1;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.25);
}

.chapter-tab-num {
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}

.chapter-tab.active .chapter-tab-num {
  background: #6366f1;
  color: #ffffff;
}

.chapter-tab-title {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.single-chapter-editor-container {
  margin-top: 8px;
}

.single-chapter-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeIn 0.25s ease;
}

.single-chapter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.single-chapter-title-group {
  flex: 1;
  min-width: 240px;
}

.single-chapter-badge {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.single-chapter-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 4px;
}

.single-chapter-subtitle {
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.4;
}

.single-chapter-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.single-chapter-wordcount {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
}

.ch-markdown-editor {
  width: 100%;
  min-height: 240px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 14px;
  color: #f8fafc;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
}

.ch-markdown-editor:focus {
  outline: none;
  border-color: #6366f1;
}

.ch-exercise-editor {
  min-height: 80px;
}

/* ==============================================================================
   Token Balance & Pay-Per-Generation Styles
   ============================================================================== */

.token-balance-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.12);
  padding: 5px 12px 5px 10px;
  border-radius: 9999px;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}

.token-balance-pill:hover {
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.22);
}

.token-coin-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fbbf24;
}

.token-balance-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.92rem;
  color: #fbbf24;
}

.token-balance-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.buy-tokens-chip-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  margin-left: 2px;
  transition: all var(--transition-fast);
}

.buy-tokens-chip-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

/* Insufficient Tokens Banner */
.insufficient-tokens-banner {
  max-width: 1200px;
  margin: 0 auto 24px auto;
  padding: 0 24px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.insufficient-tokens-banner .banner-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(185, 28, 28, 0.25) 100%);
  border: 1px solid rgba(239, 68, 68, 0.45);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.15);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 16px 20px;
}

.banner-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  flex-shrink: 0;
}

.banner-content {
  flex: 1;
}

.banner-title {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  color: #fecaca;
  margin-bottom: 2px;
}

.banner-message {
  font-size: 0.88rem;
  color: #fca5a5;
  margin: 0;
  line-height: 1.4;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.banner-action-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.banner-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.banner-close-btn {
  background: transparent;
  border: none;
  color: #fca5a5;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.banner-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Buy Tokens Modal Card */
.token-modal-card {
  max-width: 520px;
  width: 92%;
}

.token-balance-summary-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 22px;
}

.summary-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.summary-val-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.summary-value {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 800;
  color: #fbbf24;
}

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

.rates-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-align: right;
}

.rate-chips {
  display: flex;
  gap: 6px;
}

.rate-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  color: #cbd5e1;
}

.rate-chip strong {
  color: #fbbf24;
}

.section-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.package-option {
  position: relative;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.package-option:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

.package-option.selected {
  background: rgba(99, 102, 241, 0.15);
  border-color: #6366f1;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.25);
}

.pkg-badge {
  position: absolute;
  top: -9px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 9999px;
  letter-spacing: 0.04em;
}

.pkg-amount {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fbbf24;
}

.pkg-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f8fafc;
}

.pkg-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  line-height: 1.2;
}

.custom-amount-row {
  margin-bottom: 22px;
}

.custom-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.custom-input-group .form-input {
  padding-right: 70px;
}

.custom-input-group .input-suffix {
  position: absolute;
  right: 140px;
  color: var(--text-muted);
  font-size: 0.82rem;
  pointer-events: none;
}

.custom-price-tag {
  position: absolute;
  right: 14px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.88rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
}

.pkg-price {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 2px;
}

.customer-email-row {
  margin-bottom: 16px;
}

.customer-email-row .form-input {
  width: 100%;
}

.paystack-trust-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 0.78rem;
  color: #a7f3d0;
}

.paystack-trust-badge strong {
  color: #34d399;
}

.confirm-purchase-btn {
  background: linear-gradient(135deg, #059669 0%, #0284c7 100%) !important;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.35) !important;
}

.confirm-purchase-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.5) !important;
}

.modal-action-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==============================================================================
   Authentication & User Identity Dropdown Styles
   ============================================================================== */

.sign-in-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(129, 140, 248, 0.28));
  border: 1px solid rgba(129, 140, 248, 0.45);
  color: #f1f5f9;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.sign-in-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.32), rgba(129, 140, 248, 0.45));
  border-color: rgba(165, 180, 252, 0.8);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
  color: #ffffff;
}

.sign-in-btn svg {
  color: #818cf8;
  transition: transform 0.2s ease;
}

.sign-in-btn:hover svg {
  transform: translateX(2px);
  color: #a5b4fc;
}

/* User Profile Wrapper & Dropdown */
.user-profile-wrapper {
  position: relative;
  display: inline-block;
}

.user-profile-wrapper .user-pill {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 5px 12px 5px 6px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  user-select: none;
}

.user-profile-wrapper .user-pill:hover,
.user-profile-wrapper.open .user-pill {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.dropdown-chevron {
  color: #94a3b8;
  transition: transform 0.25s ease;
}

.user-profile-wrapper.open .dropdown-chevron {
  transform: rotate(180deg);
  color: #e2e8f0;
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 14px;
  z-index: 1000;
  animation: dropdownSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dropdown-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
}

.dropdown-user-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.dropdown-user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.dropdown-user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dropdown-user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-user-email {
  font-size: 0.78rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-tokens-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.dropdown-tokens-count {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  color: #38bdf8;
  letter-spacing: 0.02em;
}

.dropdown-topup-btn {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-topup-btn:hover {
  background: rgba(99, 102, 241, 0.4);
  color: #ffffff;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

.dropdown-item-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.dropdown-item-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}

.dropdown-item-btn svg {
  color: #94a3b8;
  transition: color 0.15s ease;
}

.dropdown-item-btn:hover svg {
  color: #6366f1;
}

.signout-item-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.signout-item-btn:hover svg {
  color: #ef4444;
}

/* ==============================================================================
   Auth Modal Components
   ============================================================================== */

.auth-modal-container {
  max-width: 440px !important;
  border-radius: 20px !important;
  background: rgba(15, 23, 42, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
}

.auth-modal-header {
  padding: 22px 24px 16px 24px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.auth-header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-header-brand .brand-icon.small {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.25));
  border: 1px solid rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-modal-body {
  padding: 22px 24px 24px 24px !important;
}

.google-auth-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  color: #1e293b;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.google-auth-btn:hover {
  background: #f8fafc;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

.google-auth-btn:active {
  transform: translateY(0);
}

.google-g-icon {
  flex-shrink: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-divider span {
  padding: 0 12px;
  letter-spacing: 0.02em;
}

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

.auth-input-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  color: #64748b;
  pointer-events: none;
}

.auth-email-input {
  padding-left: 42px !important;
  width: 100%;
}

.auth-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 12px 18px !important;
  font-size: 0.95rem !important;
  margin-top: 4px;
}

.auth-inline-error {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  margin-top: 14px;
  animation: shakeError 0.3s ease;
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-inline-error svg {
  flex-shrink: 0;
  color: #ef4444;
}

.auth-success-view {
  text-align: center;
  padding: 16px 8px 8px 8px;
}

.auth-success-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.4));
}

.auth-success-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 8px;
}

.auth-success-desc {
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.5;
  margin-bottom: 20px;
}

.auth-success-desc strong {
  color: #38bdf8;
}

.auth-reset-btn {
  font-size: 0.84rem;
  padding: 8px 16px;
  margin: 0 auto;
}

.auth-footer-note {
  font-size: 0.74rem;
  color: #64748b;
  text-align: center;
  margin-top: 20px;
  line-height: 1.45;
}

/* ==============================================================================
   Responsive Queries
   ============================================================================== */

@media (max-width: 900px) {
  .hero-title { font-size: 2.4rem; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .reader-layout { grid-template-columns: 1fr; }
  .reader-sidebar { position: static; }
  .manuscript-canvas { padding: 32px 24px; }
  .reader-toolbar { flex-direction: column; gap: 16px; align-items: stretch; }
  .reader-actions-group { justify-content: space-between; flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .stepper-container {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .stepper-container::-webkit-scrollbar {
    display: none;
  }
  .studio-stepper {
    min-width: 480px;
  }
  .step-status {
    display: none;
  }
}

@media print {
  body { background: #fff; color: #000; }
  .app-header, .stepper-subbar, .hero-section, .pipeline-section, .reader-toolbar, .reader-sidebar, .app-background { display: none !important; }
  .reader-layout { display: block; }
  .manuscript-canvas { border: none; box-shadow: none; padding: 0; }
  .manuscript-body { color: #111; }
  .manuscript-body blockquote { border-left-color: #333; background: #f9f9f9; color: #222; }
}
