/* ═══════════════════════════════════════════════════════════
   OneBook Dashboard — Premium Dark UI
   ═══════════════════════════════════════════════════════════ */

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

/* ─── Design Tokens ─── */
:root {
  /* Backgrounds */
  --bg:          #07080f;
  --surface:     #0c0e18;
  --card:        #0f1221;
  --card-hi:     #141728;

  /* Borders */
  --border:      rgba(255, 255, 255, 0.06);
  --border-hi:   rgba(255, 255, 255, 0.12);

  /* Accent palette */
  --indigo:      #6366f1;
  --indigo-20:   rgba(99, 102, 241, 0.20);
  --indigo-10:   rgba(99, 102, 241, 0.10);
  --cyan:        #22d3ee;
  --cyan-20:     rgba(34, 211, 238, 0.18);
  --violet:      #8b5cf6;
  --violet-30:   rgba(139, 92, 246, 0.30);

  /* Status */
  --green:       #10b981;
  --green-20:    rgba(16, 185, 129, 0.20);
  --amber:       #f59e0b;
  --red:         #ef4444;
  --red-20:      rgba(239, 68, 68, 0.20);

  /* Text */
  --t1: #eef1f8;
  --t2: #8b95a8;
  --t3: #475569;

  /* Typography */
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'Fira Code', 'Cascadia Code', 'Menlo', monospace;

  /* Layout */
  --header-h:  54px;
  --sidebar-w: 340px;

  /* Motion */
  --ease:       150ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-slow:  250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Base ─── */
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--t1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
}

button { font-family: var(--sans); }
input, select, textarea { font-family: var(--sans); }
a { color: inherit; text-decoration: none; }

/* ─── Scrollbars ─── */
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
}

/* ─── Animations ─── */
@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50%       { transform: scale(1.8); opacity: 0; }
}
@keyframes stage-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--indigo-10); }
  50%       { box-shadow: 0 0 0 7px rgba(99,102,241,0.04); }
}
@keyframes dlg-in {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1);      opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; } to { opacity: 1; }
}

/* ══════════════════════════════════════════════
   SETTINGS & STUDIO DIALOGS (native <dialog>)
══════════════════════════════════════════════ */
#settings-drawer,
#dialog-rename-book,
dialog.studio-modal-dialog {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  outline: none !important;
  max-width: 95vw !important;
  max-height: 95vh !important;
  overflow: visible !important;
  z-index: 10000 !important;
}

#settings-drawer::backdrop,
#dialog-rename-book::backdrop,
dialog.studio-modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  animation: fade-in var(--ease-slow) both;
}

/* Legacy fallback: when toggled via class */
#settings-drawer.hidden,
#dialog-rename-book.hidden,
dialog.studio-modal-dialog.hidden { display: none !important; }

.dlg-inner {
  width: 420px;
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04) inset;
  overflow: hidden;
  animation: dlg-in var(--ease-slow) both;
}

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

.dlg-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
}

.dlg-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dlg-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color var(--ease);
}

.dlg-field:focus-within { border-color: var(--indigo); }

.dlg-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--t2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dlg-field input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--t1);
  font-size: 13px;
  width: 100%;
}

.dlg-field input::placeholder { color: var(--t3); }

.field-hint {
  font-size: 11px;
  color: var(--t3);
  line-height: 1.4;
}

.opt-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--t3);
  background: rgba(255,255,255,0.04);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* ══════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Header ─── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  background: rgba(7, 8, 15, 0.92);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
  position: relative;
}

/* Subtle gradient line at bottom of header */
.app-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--indigo), var(--cyan), transparent);
  opacity: 0.4;
}

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

.brand-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-mark svg { width: 28px; height: 28px; }

.brand-name {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.1;
  background: linear-gradient(120deg, var(--t1) 40%, var(--indigo));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-sub {
  display: block;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-top: 1px;
}

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

/* Status Pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px 5px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--t2);
  user-select: none;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  animation: pulse-ring 2.5s infinite;
}

.status-dot.red  { background: var(--red);   }
.status-dot.red::after  { background: var(--red);   }
.status-dot.green{ background: var(--green); }
.status-dot.green::after{ background: var(--green); }

/* ─── App Body ─── */
.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ══════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.07) transparent;
}

/* ─── Card ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
}

.card-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.65px;
  color: var(--t3);
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}

.head-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.status-text {
  font-size: 11px;
  color: var(--t3);
}

/* ─── Seed Textarea ─── */
.seed-area {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--t1);
  font-size: 12.5px;
  line-height: 1.65;
  resize: none;
  padding: 11px 13px;
  display: block;
  min-height: 90px;
}

.seed-area::placeholder { color: var(--t3); }

/* ─── Config Grid ─── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.cfg-cell {
  background: var(--card);
  padding: 9px 12px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cfg-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--t3);
}

.cfg-select {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238b95a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right center;
  border: none;
  outline: none;
  color: var(--t1);
  font-size: 12.5px;
  font-weight: 500;
  appearance: none;
  width: 100%;
  cursor: pointer;
  padding: 0 16px 0 0;
}

.cfg-select option { background: #1a1d2e; color: var(--t1); }

/* Checkbox Row */
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
  transition: color var(--ease);
  user-select: none;
}

.check-row:hover { color: var(--t1); }
.check-row input { display: none; }

.checkmark {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--border-hi);
  border-radius: 4px;
  flex-shrink: 0;
  position: relative;
  transition: all var(--ease);
}

.check-row input:checked ~ .checkmark {
  background: var(--indigo);
  border-color: var(--indigo);
}

.check-row input:checked ~ .checkmark::after {
  content: '';
  position: absolute;
  left: 3px; top: 0;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* Launch Area */
.launch-area {
  padding: 11px 13px;
}

/* ─── Projects ─── */
.project-list {
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 140px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.empty-msg {
  display: block;
  padding: 12px 8px;
  font-size: 11.5px;
  color: var(--t3);
  text-align: center;
}

/* JS-generated .history-item */
.history-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 6px;
  transition: background var(--ease);
  font-size: 11.5px;
}

.history-item:hover { background: rgba(255,255,255,0.03); }

.proj-idx  { color: var(--t3); font-size: 10.5px; min-width: 16px; }
.proj-name { color: var(--t2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta { color: var(--t3); font-size: 10px; white-space: nowrap; }

/* JS mini buttons */
.mini-btn  { padding: 2px 5px !important; font-size: 10px !important; border-radius: 4px !important; min-width: 20px; flex-shrink: 0; }
.rename-btn { color: var(--cyan) !important; }
.delete-btn { color: var(--red) !important; }

/* ─── Pipeline Stages ─── */
.stage-list { padding: 2px 0; }

.timeline-item {
  display: flex;
  gap: 11px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  transition: background var(--ease);
}

.timeline-item:last-child { border-bottom: none; }
.timeline-item:hover { background: rgba(255,255,255,0.015); }

.stage-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border-hi);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
  transition: all var(--ease-slow);
}

.stage-num  { font-size: 10.5px; font-weight: 700; color: var(--t3); }
.stage-check { display: none; color: #fff; }

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

.stage-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t2);
  line-height: 1.3;
  transition: color var(--ease);
}

.stage-sub {
  font-size: 10.5px;
  color: var(--t3);
  margin: 2px 0 5px;
}

.stage-metric {
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--indigo);
  background: var(--indigo-10);
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
}

/* Active stage */
.timeline-item.active .stage-icon {
  border-color: var(--indigo);
  background: var(--indigo-20);
  animation: stage-pulse 2.5s infinite;
}

.timeline-item.active .stage-num  { color: var(--indigo); }
.timeline-item.active .stage-name { color: var(--t1); }

/* Completed stage */
.timeline-item.completed .stage-icon {
  border-color: var(--green);
  background: var(--green-20);
  animation: none;
}

.timeline-item.completed .stage-num   { display: none; }
.timeline-item.completed .stage-check { display: block; }
.timeline-item.completed .stage-name  { color: var(--green); }
.timeline-item.completed .stage-metric { color: var(--green); background: var(--green-20); }

/* ══════════════════════════════════════════════
   BUTTONS (Premium Design System)
   ══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.15px;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.96); opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: default; pointer-events: none; }
.btn-full { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--indigo));
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #9b6ffd, #6e72f2);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #dc2626);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.38);
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.btn-danger:active {
  transform: translateY(0) scale(0.97);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--t2);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--t1);
  border-color: var(--border-hi);
  transform: translateY(-1px);
}
.btn-ghost:active {
  transform: translateY(0) scale(0.97);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.02);
  color: var(--t2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn-outline:hover {
  color: var(--t1);
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.04);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
  transform: translateY(-1px);
}
.btn-outline:active {
  transform: translateY(0) scale(0.97);
}

.btn-danger-ghost {
  background: rgba(239, 68, 68, 0.02);
  color: rgba(248, 113, 113, 0.9);
  border: 1px solid rgba(239, 68, 68, 0.22);
}
.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.45);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
  transform: translateY(-1px);
}
.btn-danger-ghost:active {
  transform: translateY(0) scale(0.97);
}

.btn-sm  { padding: 7px 15px; font-size: 12.5px; border-radius: 7px; }
.btn-xs  { padding: 5px 11px; font-size: 11.5px; border-radius: 6px; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--t2);
  cursor: pointer;
  transition: all var(--ease);
}
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--t1); border-color: var(--border-hi); }

.icon-btn-sm {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--t3);
  cursor: pointer;
  transition: all var(--ease);
  flex-shrink: 0;
}
.icon-btn-sm:hover { color: var(--t1); border-color: var(--border-hi); }

.hidden, .show-mobile { display: none !important; }

/* ══════════════════════════════════════════════
   MAIN PANEL
══════════════════════════════════════════════ */
.main-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: var(--bg);
}

/* ─── Tab Bar ─── */
.tab-bar {
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  height: 56px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--t3);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tab-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.tab-btn:hover {
  color: var(--t1);
  background: rgba(255,255,255,0.06);
  border-color: var(--border);
}
.tab-btn:hover svg { opacity: 1; }

.tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(99,102,241,0.30) 0%, rgba(6,182,212,0.20) 100%);
  border-color: rgba(99,102,241,0.45);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.20) inset,
              0 4px 16px rgba(99,102,241,0.15);
  font-weight: 600;
}
.tab-btn.active svg { opacity: 1; }

.tab-spacer { flex: 1; }

.clear-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--t3);
  font-family: var(--sans);
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all var(--ease);
}
.clear-btn:hover { color: var(--t1); border-color: var(--border-hi); }

/* ─── Tab Content ─── */
.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}
.tab-content.active { display: flex; }

#tab-export {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.07) transparent;
}

/* ══════════════════════════════════════════════
   TERMINAL / CONSOLE
══════════════════════════════════════════════ */
.terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.45);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-r { background: #ff5f57; }
.dot-y { background: #ffbd2e; }
.dot-g { background: #28c840; }

.term-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--t3);
}

.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #7d8fa3;
  background: #040509;
  white-space: pre-wrap;
  word-break: break-all;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

/* Log color classes (used by app.js) */
.log-stdout  { color: #7d8fa3; }
.log-stderr  { color: #4b5563; }
.log-warning, .log-warn { color: var(--amber); }
.log-error   { color: var(--red); font-weight: 500; }
.log-command { color: var(--cyan); }
.log-action  { color: var(--indigo); font-weight: 500; }

/* ══════════════════════════════════════════════
   PLANS TAB
══════════════════════════════════════════════ */
.plans-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.plans-subnav {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.plans-subnav::-webkit-scrollbar { display: none; }

.sub-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--t3);
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
}
.sub-tab-btn:hover { color: var(--t1); background: rgba(255,255,255,0.04); }
.sub-tab-btn.active {
  color: var(--cyan);
  background: var(--cyan-20);
  border-color: rgba(34,211,238,0.2);
}

.sub-spacer { flex: 1; }

.doc-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.doc-bar {
  padding: 7px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  flex-shrink: 0;
}

.doc-filename {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--indigo);
}

.doc-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

/* ─── Markdown Body ─── */
.markdown-body { color: var(--t2); line-height: 1.75; }
.markdown-body h1 { font-size: 20px; font-weight: 700; color: var(--t1); margin-bottom: 16px; }
.markdown-body h2 {
  font-size: 15px; font-weight: 600; color: var(--t1); margin: 28px 0 10px;
  padding-bottom: 7px; border-bottom: 1px solid var(--border);
}
.markdown-body h3 { font-size: 13.5px; font-weight: 600; color: var(--cyan); margin: 18px 0 7px; }
.markdown-body p  { margin-bottom: 12px; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin-bottom: 12px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body strong { color: var(--t1); font-weight: 600; }
.markdown-body hr  { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.markdown-body code {
  background: rgba(255,255,255,0.07); padding: 2px 5px; border-radius: 4px;
  font-family: var(--mono); font-size: 11.5px; color: var(--t1);
}
.markdown-body pre {
  background: rgba(0,0,0,0.35); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; margin: 14px 0;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--indigo); padding-left: 14px;
  color: var(--t2); margin: 14px 0; font-style: italic;
}
.markdown-body table  { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 12px; }
.markdown-body td, .markdown-body th { border: 1px solid var(--border); padding: 7px 10px; }
.markdown-body th { background: rgba(255,255,255,0.03); color: var(--t1); font-weight: 600; }
.markdown-body td { color: var(--t2); }

/* ─── Empty State ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 52px 24px; text-align: center; color: var(--t3); height: 100%;
}
.empty-state svg  { opacity: 0.35; }
.empty-state p    { font-size: 13px; }
.empty-state small { font-size: 11px; }

/* ══════════════════════════════════════════════
   MANUSCRIPT TAB
══════════════════════════════════════════════ */
.ms-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 230px 1fr;
  overflow: hidden;
  min-height: 0;
}

/* Chapter Panel */
.ch-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.ch-panel-head {
  flex-shrink: 0;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ch-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.65px;
  color: var(--t3);
}

.ms-stats { font-size: 11px; color: var(--t3); }

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

.audiobook-status {
  font-size: 10.5px;
  color: var(--t3);
  display: block;
}

.chapter-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

/* JS-generated .chapter-item */
.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--ease);
  gap: 8px;
  border: 1px solid transparent;
}

.chapter-item:hover { background: rgba(255,255,255,0.04); }

.chapter-item.active {
  background: var(--indigo-10);
  border-color: var(--indigo-20);
}

.ch-info   { flex: 1; min-width: 0; }
.ch-name   { font-size: 12.5px; font-weight: 500; color: var(--t1); display: block; }
.ch-words  { font-size: 10.5px; color: var(--t3); display: block; margin-top: 1px; }

.empty-list-msg {
  padding: 24px 14px;
  font-size: 12px;
  color: var(--t3);
  text-align: center;
}

/* Prose Panel */
.prose-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.prose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.prose-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
}

.word-badge {
  font-size: 11px;
  color: var(--t3);
  background: rgba(255,255,255,0.05);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.prose-body {
  flex: 1;
  overflow-y: auto;
  padding: 30px 44px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

/* ══════════════════════════════════════════════
   TEXT MUTED utility (used by app.js innerHTML)
══════════════════════════════════════════════ */
.text-muted { color: var(--t3); }

/* Export Tab Cards */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.export-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--t1);
}

.export-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hi);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.export-card:active {
  transform: translateY(0);
}

.export-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  flex-shrink: 0;
  color: var(--t2);
}

.export-card:hover .export-icon {
  background: rgba(255, 255, 255, 0.1);
  color: var(--t1);
}

.export-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--t1);
}

.export-info p {
  font-size: 13px;
  color: var(--t3);
  margin: 0;
  line-height: 1.5;
}

/* Navigation buttons in Header */
.nav-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--t3);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
}

.nav-btn:hover {
  color: var(--t1);
  background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
  color: #fff;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.15);
  font-weight: 600;
}

/* Historial Grid and Cards */
.history-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.history-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #8b5cf6, #22d3ee);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.history-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(139, 92, 246, 0.05);
}

.history-card:hover::before {
  opacity: 1;
}

.history-card.active-project {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.02);
}

.history-card.active-project::before {
  background: var(--accent);
  opacity: 1;
}

.hcard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hcard-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.3;
  word-break: break-word;
}

.hcard-date {
  font-size: 12px;
  color: var(--t3);
  white-space: nowrap;
}

.hcard-body {
  font-size: 13px;
  color: var(--t2);
  line-height: 1.5;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 58px;
}

.hcard-stats {
  display: flex;
  gap: 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.hstat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hstat-label {
  font-size: 10px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hstat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
}

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


/* Spinner animation for loading states */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.spin-animation {
  animation: spin 0.9s linear infinite;
  display: block;
}

/* ══════════════════════════════════════════════
   3D FLIPBOOK VIEW
══════════════════════════════════════════════ */
.flipbook-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  background: var(--bg);
}

.flipbook-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(16, 12, 32, 0.4) 0%, rgba(3, 3, 5, 0.8) 100%), var(--bg);
  padding: 40px;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 32px;
}

/* 3D Viewport container */
.book-container-3d {
  width: 400px;
  height: 560px;
  position: relative;
  perspective: 1600px;
  transform-style: preserve-3d;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  flex-shrink: 0; /* Prevents squishing vertically */
}

.book-container-3d.opened {
  transform: translateX(200px);
}

/* Base style for all pages in 3D */
.page-3d {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1), z-index 0s linear 0.4s;
  cursor: pointer;
  border-radius: 0 16px 16px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

/* Double pages layout inside */
.page-face {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  backface-visibility: hidden;
  padding: 30px 32px 36px;
  box-sizing: border-box;
  background: #fbfbf6; /* Textured elegant paper tone */
  border-radius: 0 16px 16px 0;
  box-shadow: inset 12px 0 20px rgba(0, 0, 0, 0.08), inset -4px 0 10px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Front Face */
.page-front {
  transform: rotateY(0deg);
  z-index: 2;
}

/* Back Face */
.page-back {
  transform: rotateY(180deg);
  border-radius: 16px 0 0 16px;
  box-shadow: inset -12px 0 20px rgba(0, 0, 0, 0.08), inset 4px 0 10px rgba(0,0,0,0.03);
}

/* Spine effect for back pages */
.page-back::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 100%;
  background: linear-gradient(to left, rgba(0,0,0,0.15), transparent);
}

/* Spine effect for front pages */
.page-front::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 100%;
  background: linear-gradient(to right, rgba(0,0,0,0.15), transparent);
}

/* Flipped state */
.page-3d.flipped {
  transform: rotateY(-180deg);
  z-index: 10;
}

/* 3D cover styles */
.book-cover-3d {
  background: linear-gradient(135deg, #1f1437 0%, #0d061c 100%);
  color: #fff !important;
  border-left: 5px solid #2e1f4d;
  box-shadow: inset 16px 0 30px rgba(0,0,0,0.5), 0 12px 40px rgba(0,0,0,0.6) !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px !important;
}

.book-cover-3d img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  margin-bottom: 20px;
}

.book-cover-title {
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.book-cover-author {
  font-size: 14px;
  color: var(--t3);
  font-weight: 500;
}

/* Paper page content details */
.page-content-text {
  font-family: 'Inter', Georgia, serif;
  font-size: 13px;
  line-height: 1.5;
  color: #2b2b2b;
  overflow: hidden;
  flex-grow: 1;
  text-align: justify;
}

.page-content-text p {
  margin-bottom: 8px;
  text-indent: 20px;
}

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

.page-footer-num {
  font-size: 11px;
  color: #8c8c87;
  text-align: center;
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 10px;
  margin-top: auto;
  font-family: var(--sans);
}

.flipbook-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 30px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.flipbook-page-indicator {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--t2);
  min-width: 100px;
  text-align: center;
}


/* ══════════════════════════════════════════════
   RESPONSIVE LAYOUT & MOBILE DRAWER
   ══════════════════════════════════════════════ */

/* Mobile hamburger button */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--t2);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 12px;
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--border-hi);
}

/* Sidebar Backdrop overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  width: 100vw;
  height: calc(100vh - 56px);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: flex;
  }

  .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 56px;
    left: -350px;
    width: 340px;
    height: calc(100vh - 56px);
    z-index: 1000;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    border-right: 1px solid var(--border);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    left: 0;
  }

  .tab-bar {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 12px;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 8px 14px;
    font-size: 12.5px;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 8px;
    gap: 6px;
  }

  .logo-text {
    display: none !important;
  }

  .header-nav {
    display: none !important;
  }

  .header-actions {
    margin-left: auto !important;
  }

  .nav-btn {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }

  .status-pill {
    padding: 3px 6px !important;
    font-size: 10px !important;
  }

  #user-info-pill {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  
  .terminal-body {
    font-size: 11px !important;
    padding: 10px !important;
  }

  #api-status, .hide-mobile, #user-email-text, #logout-btn {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }
}


/* ══════════════════════════════════════════════
   CREATIVE BRAINSTORMING WIZARD MODAL
   ══════════════════════════════════════════════ */
.wizard-modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
}

.wizard-modal .wizard-container {
  background: rgba(20, 18, 30, 0.75);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

/* Steps Indicator */
.wizard-steps-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--border);
}

.wizard-steps-indicator .step-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 2;
  opacity: 0.4;
  transition: all 0.3s ease;
  width: 50px;
}

.wizard-steps-indicator .step-dot.active {
  opacity: 1;
}

.wizard-steps-indicator .step-dot span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.wizard-steps-indicator .step-dot.active span {
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  border-color: transparent;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.wizard-steps-indicator .step-dot small {
  font-size: 10px;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wizard-steps-indicator .step-dot.active small {
  color: #fff;
}

.wizard-steps-indicator .step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 -10px;
  transform: translateY(-13px);
  z-index: 1;
}

/* Wizard Body */
.wizard-body {
  padding: 24px;
  min-height: 260px;
  background: rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.wizard-step-pane {
  display: none;
  animation: fadeInRight 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.wizard-step-pane.active {
  display: block;
}

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

/* Form Fields */
.wizard-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.wizard-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--t3);
}

.wizard-field input[type="text"],
.wizard-field select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.wizard-field input[type="text"]:focus,
.wizard-field select:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.25);
}

/* Mobile responsive fixes for wizard indicator */
@media (max-width: 580px) {
  .wizard-steps-indicator {
    padding: 16px 20px;
  }
  .wizard-steps-indicator .step-dot small {
    display: none;
  }
  .wizard-steps-indicator .step-line {
    transform: translateY(0);
  }
}


/* ══════════════════════════════════════════════
   HEIGHT-BASED RESPONSIVE FLIPBOOK SCALING
   ══════════════════════════════════════════════ */
@media (max-height: 850px) {
  .flipbook-stage {
    padding: 20px;
    gap: 16px;
  }
  .book-container-3d {
    transform: scale(0.9);
  }
  .book-container-3d.opened {
    transform: translateX(180px) scale(0.9);
  }
}

@media (max-height: 720px) {
  .flipbook-stage {
    padding: 10px;
    gap: 10px;
  }
  .book-container-3d {
    transform: scale(0.78);
  }
  .book-container-3d.opened {
    transform: translateX(156px) scale(0.78);
  }
}

@media (max-height: 620px) {
  .flipbook-stage {
    padding: 8px;
    gap: 8px;
  }
  .book-container-3d {
    transform: scale(0.65);
  }
  .book-container-3d.opened {
    transform: translateX(130px) scale(0.65);
  }
}

/* ══════════════════════════════════════════════
   WIDTH-BASED RESPONSIVE FLIPBOOK SCALING (MOBILE)
   ══════════════════════════════════════════════ */
@media (max-width: 950px) {
  .book-container-3d {
    transform: scale(0.8) !important;
  }
  .book-container-3d.opened {
    transform: translateX(160px) scale(0.8) !important;
  }
}

@media (max-width: 768px) {
  .flipbook-stage {
    padding: 12px !important;
    gap: 16px !important;
  }
  .book-container-3d {
    transform: scale(0.65) !important;
  }
  .book-container-3d.opened {
    transform: translateX(130px) scale(0.65) !important;
  }
}

@media (max-width: 540px) {
  .flipbook-stage {
    padding: 8px !important;
    gap: 12px !important;
  }
  .book-container-3d {
    transform: scale(0.5) !important;
  }
  .book-container-3d.opened {
    transform: translateX(100px) scale(0.5) !important;
  }
}

@media (max-width: 400px) {
  .book-container-3d {
    transform: scale(0.42) !important;
  }
  .book-container-3d.opened {
    transform: translateX(84px) scale(0.42) !important;
  }
}

/* ═════════════════════════════════════════════════════════════════════
   TERABOOK STUDIO 2.0 — MODERN COMMERCIAL SAAS DESIGN SYSTEM
   ═════════════════════════════════════════════════════════════════════ */
:root {
  --lime: #bef264;
  --lime-hover: #d9f99d;
  --lime-dark: #84cc16;
  --lime-glow: rgba(190, 242, 100, 0.22);
  --lime-glow-strong: rgba(190, 242, 100, 0.45);
  
  --obsidian-950: #060908;
  --obsidian-900: #0a0f0d;
  --obsidian-850: #0e1512;
  --obsidian-800: #131c18;
  --obsidian-750: #182420;
  
  --glass-card: rgba(14, 21, 18, 0.72);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-border-hi: rgba(190, 242, 100, 0.25);
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-width: 260px;
}

/* ─── App V2 Shell ─── */
.studio-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  background-color: var(--obsidian-950);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(190, 242, 100, 0.035) 0%, transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(34, 211, 238, 0.03) 0%, transparent 45%);
  color: #f8fafc;
  font-family: var(--font-main);
  overflow: hidden;
  position: relative;
}

/* Wireframe mesh background overlay */
.mesh-geometry-bg {
  position: absolute;
  top: -60px;
  right: -60px;
  width: 580px;
  height: 580px;
  pointer-events: none;
  opacity: 0.38;
  z-index: 1;
  transform: rotate(15deg);
}

/* ─── Modern Sidebar ─── */
.studio-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--obsidian-900);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 16px;
  z-index: 10;
  flex-shrink: 0;
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px 8px;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.brand-icon-box {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #182420, #0a0f0d);
  border: 1px solid rgba(190, 242, 100, 0.35);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(190, 242, 100, 0.15);
  color: var(--lime);
}

.brand-title-group h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #ffffff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.brand-title-group h1 span {
  color: var(--lime);
}
.brand-title-group p {
  font-size: 11px;
  color: #64748b;
  margin: 0;
  font-weight: 500;
}

/* Nav Menu */
.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
}

.studio-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  width: 100%;
  position: relative;
}

.studio-nav-item:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.03);
}

.studio-nav-item.active {
  color: #ffffff;
  background: rgba(190, 242, 100, 0.08);
  border-color: rgba(190, 242, 100, 0.22);
}

.studio-nav-item.active .nav-dot {
  opacity: 1;
  transform: scale(1);
}

.studio-nav-item .nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.studio-nav-item.active .nav-icon {
  color: var(--lime);
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  position: absolute;
  right: 14px;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

/* Sidebar Footer User Info */
.sidebar-footer-card {
  background: var(--obsidian-850);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-meta-name {
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.credit-badge-v2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(190, 242, 100, 0.08);
  border: 1px solid rgba(190, 242, 100, 0.25);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.credit-badge-v2:hover {
  background: rgba(190, 242, 100, 0.15);
  border-color: var(--lime);
}

.credit-val {
  font-weight: 700;
  font-size: 13px;
  color: var(--lime);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Main Stage Views ─── */
.studio-main-stage {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  position: relative;
  z-index: 2;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
}

/* ─── VIEW 1: LIBRARY DASHBOARD ─── */
.library-container {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.library-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.section-pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--lime);
  background: rgba(190, 242, 100, 0.08);
  border: 1px solid rgba(190, 242, 100, 0.2);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.section-pill-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 6px var(--lime);
}

.library-heading h2 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: #ffffff;
  margin: 0 0 6px 0;
}

.library-heading h2 span {
  color: var(--lime);
}

.library-heading p {
  font-size: 14px;
  color: #94a3b8;
  margin: 0;
}

/* Action Button Neon */
.btn-neon-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--lime);
  color: #090e0b;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 30px;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 24px var(--lime-glow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-neon-primary:hover {
  background: var(--lime-hover);
  transform: translateY(-2px);
  box-shadow: 0 0 32px var(--lime-glow-strong), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

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

/* Search Bar */
.library-search-box {
  position: relative;
  width: 100%;
}

.library-search-input {
  width: 100%;
  background: var(--obsidian-850);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 20px 14px 46px;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.library-search-input:focus {
  border-color: rgba(190, 242, 100, 0.4);
  background: var(--obsidian-800);
  box-shadow: 0 0 20px rgba(190, 242, 100, 0.08);
}

.library-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
}

/* Books Grid */
.library-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
}

/* Quick Start Generate Card */
.create-trigger-card {
  background: linear-gradient(145deg, rgba(19, 28, 24, 0.7), rgba(10, 15, 13, 0.85));
  border: 1px dashed rgba(190, 242, 100, 0.25);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 160px;
}

.create-trigger-card:hover {
  border-color: var(--lime);
  background: linear-gradient(145deg, rgba(24, 36, 30, 0.85), rgba(14, 21, 18, 0.95));
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), 0 0 30px rgba(190, 242, 100, 0.1);
}

.create-icon-bubble {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: rgba(190, 242, 100, 0.12);
  border: 1px solid rgba(190, 242, 100, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lime);
  flex-shrink: 0;
}

.create-card-text h3 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 4px 0;
}

.create-card-text p {
  font-size: 13px;
  color: #94a3b8;
  margin: 0;
}

/* Book Item Card */
.studio-book-card {
  background: var(--obsidian-850);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  gap: 20px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.studio-book-card:hover {
  border-color: rgba(190, 242, 100, 0.35);
  background: var(--obsidian-800);
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 25px rgba(190, 242, 100, 0.08);
}

/* 3D Realistic Cover Miniature */
.book-cover-3d-thumb {
  width: 90px;
  height: 125px;
  border-radius: 6px;
  flex-shrink: 0;
  position: relative;
  background: #1e293b;
  box-shadow: 
    -4px 4px 12px rgba(0, 0, 0, 0.6),
    inset 4px 0 6px rgba(255, 255, 255, 0.15),
    inset -2px 0 4px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.book-cover-3d-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-cover-fallback {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
}

/* Card Details */
.book-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.genre-tag-pill {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #a3e635;
  background: rgba(163, 230, 53, 0.12);
  padding: 3px 8px;
  border-radius: 6px;
  align-self: flex-start;
  margin-bottom: 6px;
}

.book-card-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 4px 0;
  line-height: 1.3;
}

.book-card-sub {
  font-size: 12px;
  color: #64748b;
  margin: 0 0 12px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.book-meta-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11.5px;
  color: #94a3b8;
  margin-bottom: 12px;
}

.book-meta-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.book-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(190, 242, 100, 0.12);
  color: var(--lime);
  border: 1px solid rgba(190, 242, 100, 0.25);
  align-self: flex-start;
}

.card-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
  position: relative;
}

.card-progress-fill {
  height: 100%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  border-radius: 4px;
}


/* ─── VIEW 2: NEW BOOK WIZARD ─── */
.wizard-page-container {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.wizard-title-header h2 {
  font-size: 28px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 8px 0;
}

.wizard-title-header p {
  font-size: 14px;
  color: #94a3b8;
  margin: 0;
}

/* Stepper Bar */
.stepper-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.step-node {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: color 0.2s;
}

.step-node.active {
  color: #ffffff;
}

.step-node.completed {
  color: var(--lime);
}

.step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  transition: all 0.2s;
}

.step-node.active .step-circle {
  border-color: var(--lime);
  color: var(--lime);
  box-shadow: 0 0 12px var(--lime-glow);
}

.step-node.completed .step-circle {
  background: var(--lime);
  border-color: var(--lime);
  color: #0a0f0d;
}

.step-connector-line {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
}

.step-connector-line.active {
  background: var(--lime);
}

/* Wizard Glass Card */
.wizard-content-card {
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 36px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.wizard-field-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-field-label {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.wizard-field-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: -4px;
}

.wizard-textarea-v2 {
  width: 100%;
  min-height: 120px;
  background: var(--obsidian-900);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px;
  color: #ffffff;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.wizard-textarea-v2:focus {
  border-color: var(--lime);
  box-shadow: 0 0 16px rgba(190, 242, 100, 0.1);
}

.wizard-select-v2, .wizard-input-v2 {
  width: 100%;
  background: var(--obsidian-900);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.wizard-select-v2:focus, .wizard-input-v2:focus {
  border-color: var(--lime);
}

/* Sliders & Estimates */
.slider-control-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.slider-val-badge {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--lime);
}

.range-slider-lime {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: #1e293b;
  outline: none;
}

.range-slider-lime::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--lime);
  cursor: pointer;
  box-shadow: 0 0 10px var(--lime-glow-strong);
  transition: transform 0.1s ease;
}

.range-slider-lime::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Estimation Callout Box */
.estimation-box-v2 {
  background: rgba(190, 242, 100, 0.04);
  border: 1px solid rgba(190, 242, 100, 0.18);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.estimation-meta-text {
  font-size: 13px;
  color: #94a3b8;
}

.estimation-number-highlight {
  font-size: 18px;
  font-weight: 800;
  color: var(--lime);
}

/* Toggle Switches */
.toggle-switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.switch-label-group h4 {
  margin: 0 0 2px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: #ffffff;
}

.switch-label-group p {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}

/* CSS Toggle */
.custom-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

.custom-toggle input:checked + .toggle-slider {
  background-color: var(--lime);
}

.custom-toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background-color: #0a0f0d;
}

.wizard-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-ghost-back {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-ghost-back:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}


/* ─── VIEW 3: LIVE GENERATION STUDIO WORKSPACE ─── */
.studio-workspace-container {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.studio-header-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.studio-project-title h2 {
  font-size: 26px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 4px 0;
}

.studio-project-title p {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 10px 0;
}

.studio-project-tags {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag-badge-v2 {
  font-size: 11.5px;
  font-weight: 600;
  background: var(--obsidian-850);
  border: 1px solid var(--glass-border);
  padding: 4px 10px;
  border-radius: 8px;
  color: #cbd5e1;
}

/* Real-time Agent Activity Banner */
.agent-live-banner {
  background: linear-gradient(90deg, rgba(190, 242, 100, 0.12), rgba(16, 185, 129, 0.08), rgba(14, 21, 18, 0.95));
  border: 1px solid rgba(190, 242, 100, 0.45);
  border-radius: 16px;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 25px rgba(190, 242, 100, 0.15);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.agent-live-banner.is-active {
  border-color: #bef264;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5), 0 0 30px rgba(190, 242, 100, 0.25);
}

.agent-status-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.agent-live-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(190, 242, 100, 0.2);
  border-top-color: #bef264;
  border-right-color: #bef264;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(190, 242, 100, 0.4);
}

.agent-live-spinner.done {
  animation: none;
  border: 2px solid var(--lime);
  background: rgba(190, 242, 100, 0.18);
  color: var(--lime);
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 0 10px rgba(190, 242, 100, 0.3);
}

.agent-live-spinner.done::before {
  content: "✓";
}

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

.agent-live-msg {
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.agent-live-msg span {
  color: var(--lime);
}

.agent-step-counter {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
}

/* Studio Workspace Grid (Manuscript vs Covers) */
.studio-grid-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
}

/* Manuscript Chapters Card */
.manuscript-card-v2 {
  background: var(--obsidian-850);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.manuscript-head-row h3 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.chapter-progress-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--lime);
}

.chapters-interactive-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.chapter-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--obsidian-900);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.chapter-item-row:hover {
  border-color: rgba(190, 242, 100, 0.3);
  background: var(--obsidian-800);
  transform: translateX(4px);
}

.chapter-item-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ch-check-icon {
  color: var(--lime);
  font-size: 16px;
}

.ch-title-text {
  font-size: 13.5px;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0 0 2px 0;
}

.ch-word-count {
  font-size: 11.5px;
  color: #64748b;
  margin: 0;
}

.quality-score-badge {
  font-size: 11px;
  font-weight: 800;
  color: var(--lime);
  background: rgba(190, 242, 100, 0.12);
  border: 1px solid rgba(190, 242, 100, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
}

/* Covers Studio Card */
.covers-studio-card {
  background: var(--obsidian-850);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.covers-split-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cover-slot {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cover-slot-label {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cover-slot-preview {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--obsidian-900);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.cover-slot-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-slot-actions {
  display: flex;
  gap: 6px;
}

.btn-cover-action {
  flex: 1;
  background: var(--obsidian-900);
  border: 1px solid var(--glass-border);
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-cover-action:hover {
  color: #ffffff;
  border-color: rgba(190, 242, 100, 0.3);
}

/* ─── VIEW 4: EXPORT MODAL / DRAWER ─── */
.export-panel-v2 {
  background: var(--obsidian-850);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.export-checklist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--obsidian-900);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px;
}

.export-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #cbd5e1;
  cursor: pointer;
}

.export-checkbox-item input[type="checkbox"] {
  accent-color: var(--lime);
  width: 15px;
  height: 15px;
}

.format-export-buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.btn-format-export {
  background: var(--obsidian-900);
  border: 1px solid var(--glass-border);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.btn-format-export:hover {
  border-color: var(--lime);
  background: rgba(190, 242, 100, 0.08);
  color: var(--lime);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .studio-shell {
    flex-direction: column;
  }
  .studio-sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 12px 20px;
    align-items: center;
  }
  .sidebar-nav-group {
    flex-direction: row;
    margin-top: 0;
  }
  .studio-main-stage {
    padding: 24px 20px;
  }
  .studio-grid-layout {
    grid-template-columns: 1fr;
  }
}

.wizard-speed-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
}

.wizard-speed-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}

.wizard-speed-card.selected {
  background: rgba(190, 242, 100, 0.06);
  border-color: var(--lime);
  box-shadow: 0 0 15px rgba(190, 242, 100, 0.12);
}

.wizard-speed-card.selected-deep {
  background: rgba(96, 165, 250, 0.06);
  border-color: #60a5fa;
  box-shadow: 0 0 15px rgba(96, 165, 250, 0.12);
}

/* ═══════════════════════════════════════════════════════════
   LIBRARY TOOLBAR, CARD ACTIONS & BATCH BAR
   ═══════════════════════════════════════════════════════════ */
.library-toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.library-toolbar-row .library-search-box {
  flex: 1;
  margin-bottom: 0;
}

.btn-glass-batch {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 12px 18px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-glass-batch:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-glass-batch.active {
  background: rgba(190, 242, 100, 0.12);
  border-color: var(--lime);
  color: var(--lime);
}

/* Card Selection Checkbox */
.card-select-checkbox-wrap {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: none;
}

.batch-mode-active .card-select-checkbox-wrap {
  display: block;
}

.card-select-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--lime);
  cursor: pointer;
  border-radius: 6px;
}

.studio-book-card.is-selected {
  border-color: var(--lime) !important;
  background: rgba(190, 242, 100, 0.04) !important;
  box-shadow: 0 0 20px rgba(190, 242, 100, 0.12) !important;
}

/* Card 3-Dots Action Button & Menu */
.card-action-trigger {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  opacity: 0;
  transition: all 0.2s ease;
}

.studio-book-card:hover .card-action-trigger,
.card-action-trigger.menu-open {
  opacity: 1;
}

.card-action-trigger:hover,
.card-action-trigger.menu-open {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.card-action-menu {
  position: absolute;
  top: 48px;
  right: 12px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  backdrop-filter: blur(12px);
  animation: fadeInDown 0.15s ease-out;
}

.card-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: #cbd5e1;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.card-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.card-menu-item.danger {
  color: #f87171;
}

.card-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* Floating Batch Action Bar */
.library-batch-bar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #090e17;
  border: 1px solid rgba(190, 242, 100, 0.35);
  border-radius: 20px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  z-index: 100;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(190, 242, 100, 0.15);
  backdrop-filter: blur(20px);
  animation: slideUpBatch 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpBatch {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.batch-bar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #f8fafc;
}

.batch-count-badge {
  background: var(--lime);
  color: #05080e;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
}

.batch-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-batch-action {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-batch-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.btn-batch-download {
  background: var(--lime) !important;
  border-color: var(--lime) !important;
  color: #05080e !important;
  font-weight: 700 !important;
}

.btn-batch-download:hover {
  background: #a3e635 !important;
  box-shadow: 0 0 15px rgba(190, 242, 100, 0.4);
}

.btn-batch-delete {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  color: #fca5a5 !important;
}

.btn-batch-delete:hover {
  background: rgba(239, 68, 68, 0.3) !important;
  border-color: #ef4444 !important;
  color: #fff !important;
}

.btn-batch-close {
  background: transparent !important;
  border-color: transparent !important;
  color: #94a3b8 !important;
}

.btn-batch-close:hover {
  color: #fff !important;
}


