/* ============================================
   Script-Doctor & Studio — Finary-inspired UI
   ============================================ */

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

:root {
  /* Dark palette */
  --bg-deep: #0a0a0f;
  --bg-base: #0f1017;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --bg-glass-strong: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: rgba(240, 240, 245, 0.6);
  --text-muted: rgba(240, 240, 245, 0.35);

  /* Accent */
  --accent: #7c5cfc;
  --accent-glow: rgba(124, 92, 252, 0.3);
  --accent-soft: rgba(124, 92, 252, 0.12);
  --accent-hover: #9478ff;

  /* Status */
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.12);

  /* Gamification */
  --xp-gradient: linear-gradient(90deg, #7c5cfc, #a78bfa, #c4b5fd);

  /* Bloom / Glow — mouse-reactive */
  --bloom: 1;
  --bloom-w: rgba(255, 255, 255, 0.06);
  --bloom-accent: rgba(124, 92, 252, 0.12);
  --mx: 50%;
  --my: 50%;

  /* Typography */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-script: 'Courier Prime', 'Courier New', monospace;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Glass */
  --glass-blur: blur(20px);
  --glass-border: 1px solid var(--border);
}

html { font-size: 16px; }

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Utilities --- */
.hidden { display: none !important; }

/* --- Animated background layer --- */
#bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 800px 500px at 15% 10%, rgba(124, 92, 252, 0.10), transparent 70%),
    radial-gradient(ellipse 600px 400px at 85% 80%, rgba(96, 165, 250, 0.07), transparent 70%),
    radial-gradient(ellipse 400px 400px at 50% 50%, rgba(124, 92, 252, 0.04), transparent 70%);
  animation: bg-breathe 8s ease-in-out infinite alternate;
}

@keyframes bg-breathe {
  0%   { opacity: 0.8; }
  100% { opacity: 1.2; }
}

/* ============================================
   GLASS CARD SYSTEM — mouse-reactive glow
   ============================================ */

/* Base: shared by .project-card, .block-card, .modal, .gamification-bar, .time-estimate */
.glass-card {
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
}

/* Shine line — top edge highlight */
.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.3s;
  opacity: 0.6;
}

.glass-card:hover::before {
  opacity: 1;
  left: 5%;
  right: 5%;
}

/* Mouse-follow glow — ::after tracks --mx, --my */
.glass-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    350px circle at var(--mx) var(--my),
    var(--card-glow, var(--bloom-accent)),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 1;
}

.glass-card:hover::after {
  opacity: 1;
}

/* --- App shell --- */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-left: calc(32px + env(safe-area-inset-left, 0px));
  padding-right: calc(32px + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  background: rgba(15, 16, 23, 0.7);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.04);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.topbar-brand .icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

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

/* --- Pomodoro widget --- */
.pomo-widget {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px 4px 6px;
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 0.25s;
  user-select: none;
  position: relative;
}

.pomo-widget:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
}

.pomo-ring {
  width: 28px;
  height: 28px;
  transform: rotate(-90deg);
}

.pomo-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 3;
}

.pomo-ring-fill {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

.pomo-time {
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  letter-spacing: -0.02em;
  transition: color 0.3s;
}

/* Active (focus session running) */
.pomo-active {
  border-color: rgba(124,92,252,0.4);
  background: rgba(124,92,252,0.08);
  box-shadow: 0 0 16px rgba(124,92,252,0.15), 0 0 4px rgba(124,92,252,0.2);
  animation: pomo-glow 2s ease-in-out infinite;
}

.pomo-active .pomo-ring-fill {
  stroke: var(--accent);
  filter: drop-shadow(0 0 4px rgba(124,92,252,0.5));
}

.pomo-active .pomo-time {
  color: var(--accent-light);
}

@keyframes pomo-glow {
  0%, 100% { box-shadow: 0 0 16px rgba(124,92,252,0.15), 0 0 4px rgba(124,92,252,0.2); }
  50% { box-shadow: 0 0 24px rgba(124,92,252,0.25), 0 0 8px rgba(124,92,252,0.3); }
}

/* Paused */
.pomo-paused {
  animation: pomo-pulse 1.5s ease-in-out infinite;
}

.pomo-paused .pomo-time {
  animation: pomo-blink 1s step-end infinite;
}

@keyframes pomo-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pomo-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Break */
.pomo-break {
  border-color: rgba(52,211,153,0.4);
  background: rgba(52,211,153,0.08);
  box-shadow: 0 0 16px rgba(52,211,153,0.15);
  animation: pomo-glow-break 2s ease-in-out infinite;
}

.pomo-break .pomo-ring-fill {
  stroke: var(--green);
  filter: drop-shadow(0 0 4px rgba(52,211,153,0.5));
}

.pomo-break .pomo-time {
  color: var(--green);
}

@keyframes pomo-glow-break {
  0%, 100% { box-shadow: 0 0 16px rgba(52,211,153,0.15); }
  50% { box-shadow: 0 0 24px rgba(52,211,153,0.25); }
}

/* Urgent (last 10 seconds) */
.pomo-urgent {
  animation: pomo-urgent-flash 0.6s ease-in-out infinite !important;
}

.pomo-urgent .pomo-ring-fill {
  stroke: var(--red) !important;
  filter: drop-shadow(0 0 6px rgba(239,68,68,0.6));
}

.pomo-urgent .pomo-time {
  color: var(--red) !important;
}

@keyframes pomo-urgent-flash {
  0%, 100% {
    border-color: rgba(239,68,68,0.5);
    box-shadow: 0 0 20px rgba(239,68,68,0.2);
    background: rgba(239,68,68,0.08);
  }
  50% {
    border-color: rgba(239,68,68,0.8);
    box-shadow: 0 0 40px rgba(239,68,68,0.35), 0 0 80px rgba(239,68,68,0.15);
    background: rgba(239,68,68,0.15);
  }
}

/* Pomodoro fullscreen alert */
.pomo-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7,7,13,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  transition: opacity 0.3s;
}

.pomo-alert-overlay.pomo-alert-visible {
  opacity: 1;
}

.pomo-alert-card {
  text-align: center;
  padding: 48px 56px;
  border-radius: var(--radius-xl);
  background: rgba(15,16,23,0.9);
  border: 1px solid rgba(255,255,255,0.1);
  max-width: 420px;
  width: 90%;
  animation: pomo-alert-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pomo-alert-pause {
  border-color: rgba(52,211,153,0.3);
  box-shadow: 0 0 60px rgba(52,211,153,0.12), 0 0 120px rgba(52,211,153,0.06);
}

.pomo-alert-work {
  border-color: rgba(124,92,252,0.3);
  box-shadow: 0 0 60px rgba(124,92,252,0.12), 0 0 120px rgba(124,92,252,0.06);
}

@keyframes pomo-alert-pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pomo-alert-emoji {
  font-size: 3.5rem;
  margin-bottom: 16px;
  animation: pomo-alert-bounce 1.5s ease-in-out infinite;
}

@keyframes pomo-alert-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.pomo-alert-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.pomo-alert-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.pomo-alert-detail {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
  margin-bottom: 8px;
}

.pomo-alert-sessions {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.pomo-alert-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.pomo-alert-btn-main {
  min-width: 160px;
}

/* User badge */
.user-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.user-role-admin {
  background: rgba(124,92,252,0.15);
  color: hsl(260,80%,72%);
}
.user-role-demo {
  background: rgba(96,165,250,0.15);
  color: hsl(210,90%,72%);
}
.user-role-writer {
  background: rgba(52,211,153,0.15);
  color: hsl(160,70%,60%);
}

.btn-logout {
  font-size: 1.1rem;
  padding: 4px 8px !important;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.btn-logout:hover { opacity: 1; }

/* Read-only mode: hide all write controls */
.read-only-mode .add-section-btn,
.read-only-mode .add-block-btn,
.read-only-mode .btn-delete-section,
.read-only-mode .btn-delete-block,
.read-only-mode [onclick*="addSection"],
.read-only-mode [onclick*="addBlock"],
.read-only-mode [onclick*="suggestSections"],
.read-only-mode [onclick*="analyzeNarrative"],
.read-only-mode [onclick*="setStudioStatus"],
.read-only-mode .studio-status-btns,
.read-only-mode .section-status-select {
  display: none !important;
}

.read-only-mode .block-user-textarea,
.read-only-mode .script-textarea,
.read-only-mode .script-editable-input,
.read-only-mode .script-scene-heading-input,
.read-only-mode .script-block-heading-input,
.read-only-mode .project-title-input {
  pointer-events: none;
  opacity: 0.7;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: var(--glass-border);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-glass-strong);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 4px 30px var(--accent-glow), 0 0 60px -15px rgba(124, 92, 252, 0.4);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-glass);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger {
  color: var(--red);
}
.btn-danger:hover {
  background: var(--red-soft);
  border-color: rgba(248, 113, 113, 0.3);
}

/* --- Dashboard --- */
.dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 32px;
}

.dashboard-header {
  margin-bottom: 40px;
}

.dashboard-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.dashboard-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* --- Project card --- */
.project-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --card-glow: rgba(124, 92, 252, 0.10);
}

.project-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-3px) scale(1.005);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 0 60px -20px var(--accent-glow);
}

.project-card-inner {
  position: relative;
  z-index: 1;
}

.project-card .title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.project-card .desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card .meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.project-card .meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.project-card .progress-mini {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.project-card .progress-mini-fill {
  height: 100%;
  background: var(--xp-gradient);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* New project card */
.project-card-new {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  background: transparent;
  --card-glow: rgba(124, 92, 252, 0.15);
}

.project-card-new::before { display: none; }

.project-card-new:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 40px -10px var(--accent-glow);
}

.project-card-new .plus {
  font-size: 2rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.project-card-new:hover .plus {
  color: var(--accent);
}

/* --- Status badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-active {
  background: var(--green-soft);
  color: var(--green);
}

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

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: rgba(15, 16, 23, 0.85);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 90%;
  max-width: 480px;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 80px -20px var(--accent-glow);
}

/* Modal shine line */
.modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  z-index: 2;
  pointer-events: none;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-form label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 6px;
}

.modal-form label:first-child { margin-top: 0; }

/* --- Form --- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* ================================================
   EDITOR VIEW
   ================================================ */
.editor-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 57px);
}

/* --- Editor Title Row (Row 1) --- */
.editor-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: rgba(15, 16, 23, 0.6);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.editor-title-row .project-title-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  outline: none;
  flex: 1 1 180px;
  min-width: 120px;
  padding: 4px 0;
  letter-spacing: -0.01em;
}

.editor-title-row .project-title-input::placeholder {
  color: var(--text-muted);
}

.editor-title-row .save-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color 0.3s;
  white-space: nowrap;
}

.editor-title-row .save-indicator.saving {
  color: var(--yellow);
}

.editor-title-row .save-indicator.saved {
  color: var(--green);
}

/* --- Editor Toolbar (Row 2) --- */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px;
  border-bottom: var(--glass-border);
  background: rgba(15, 16, 23, 0.4);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.editor-toolbar::-webkit-scrollbar {
  display: none;
}

.toolbar-spacer {
  flex: 1;
}

/* --- Gamification bar --- */
.gamification-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 32px;
  border-bottom: var(--glass-border);
  background: rgba(15, 16, 23, 0.5);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  font-size: 0.8rem;
  position: relative;
}

/* Subtle shine on gamification bar */
.gamification-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  pointer-events: none;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.stat-item .stat-icon {
  font-size: 1rem;
}

.stat-item .stat-value {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress-bar-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--xp-gradient);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  box-shadow: 0 0 12px rgba(124, 92, 252, 0.4), 0 0 4px rgba(167, 139, 250, 0.3);
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
  border-radius: 0 4px 4px 0;
}

.progress-pct {
  font-weight: 700;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.time-estimate {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  border: var(--glass-border);
  transition: box-shadow 0.3s;
}

.time-estimate.on-target { box-shadow: 0 0 20px -8px rgba(52, 211, 153, 0.3); }
.time-estimate.over-target { box-shadow: 0 0 20px -8px rgba(248, 113, 113, 0.3); }

.time-estimate.on-target { color: var(--green); }
.time-estimate.under-target { color: var(--yellow); }
.time-estimate.over-target { color: var(--red); }

/* --- Sections area --- */
.sections-container {
  flex: 1;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  padding: 32px;
}

.sections-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.add-section-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  width: 100%;
  font-family: var(--font-main);
  font-size: 0.85rem;
  margin-top: 16px;
}

.add-section-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 30px -10px var(--accent-glow);
}

/* --- Section card --- */
.section-card {
  --section-hue: 260;
  --sc: 136, 100, 200;
  background: var(--bg-card);
  border: 2px solid rgba(var(--sc), 0.3);
  border-radius: var(--radius-xl);
  --card-glow: rgba(var(--sc), 0.12);
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.section-card:hover {
  border-color: rgba(var(--sc), 0.5);
}

/* Section shot = green border accent */
.section-card.section-shot {
  border-color: rgba(74, 222, 128, 0.35);
}

/* Section redo = yellow border accent */
.section-card.section-redo {
  border-color: rgba(250, 204, 21, 0.3);
}

/* Section status select dropdown */
.section-status-select {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-main);
  outline: none;
  transition: all 0.2s;
}

.section-status-select:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.section-status-select.studio-select-shot {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(74, 222, 128, 0.25);
}

.section-status-select.studio-select-redo {
  background: var(--yellow-soft);
  color: var(--yellow);
  border-color: rgba(250, 204, 21, 0.2);
}

/* Section collapse button */
.section-collapse-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.65rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.section-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
}

.section-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1rem;
  user-select: none;
}

.section-drag-handle:hover { color: var(--text-secondary); }

.section-number {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  background: rgba(var(--sc), 0.15);
  color: rgba(var(--sc), 1);
}

.section-title-input {
  flex: 1;
  min-width: 120px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  font-family: var(--font-main);
  letter-spacing: -0.01em;
}

.section-title-input::placeholder { color: var(--text-muted); }

.section-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

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

.section-blocks {
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.blocks-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  font-size: 0.85rem;
}

/* --- Block card (inside section) --- */
.block-card {
  --block-hue: 260;
  --sc: 136, 100, 200;
  --block-color: hsl(var(--block-hue), 70%, 65%);
  --block-glow: hsla(var(--block-hue), 70%, 55%, 0.25);
  --block-soft: hsla(var(--block-hue), 70%, 55%, 0.08);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
}

.block-card:hover {
  background: rgba(255, 255, 255, 0.035);
}

.block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
}

.block-number {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  background: rgba(var(--sc), 0.12);
  color: rgba(var(--sc), 0.9);
}

.block-title-input {
  flex: 1;
  min-width: 100px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  font-family: var(--font-main);
}

.block-title-input::placeholder { color: var(--text-muted); }

.block-duration {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.block-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-included {
  background: var(--green-soft) !important;
  color: var(--green) !important;
  border-color: rgba(52, 211, 153, 0.3) !important;
}

/* Block summary */
.block-summary {
  padding: 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.block-summary-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-style: italic;
  outline: none;
  font-family: var(--font-main);
}

.block-summary-input::placeholder { color: var(--text-muted); }

/* AI content area — subtle, secondary */
.block-ai-content {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  position: relative;
  max-height: 120px;
  overflow-y: auto;
  transition: max-height 0.3s, opacity 0.3s;
  background: rgba(96, 165, 250, 0.02);
  opacity: 0.55;
}

.block-ai-content:hover {
  opacity: 1;
  background: rgba(96, 165, 250, 0.06);
}

.ai-label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(96, 165, 250, 0.5);
  margin-bottom: 4px;
}

.block-ai-content:hover .ai-label {
  color: var(--blue);
}

.ai-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
  font-style: italic;
  border-left: 2px solid rgba(96, 165, 250, 0.15);
  padding-left: 10px;
}

.block-ai-content:hover .ai-text {
  color: var(--text-secondary);
  border-left-color: rgba(96, 165, 250, 0.35);
}

/* Resize handle */
.resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  background: transparent;
  transition: background 0.2s;
}

.resize-handle:hover,
.resize-handle:active {
  background: linear-gradient(to top, rgba(96, 165, 250, 0.15), transparent);
}

.resize-handle::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.resize-handle:hover::after {
  background: rgba(96, 165, 250, 0.4);
}

/* (user content styles moved below) */

.block-score {
  padding: 4px 14px 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --- Studio slide custom elements --- */
.studio-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 12px;
}

.studio-block-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

.studio-block-content {
  font-family: var(--font-script);
  font-size: 1.4rem;
  line-height: 2;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 50vh;
  overflow-y: auto;
}

.studio-block-status {
  margin-top: 20px;
  display: inline-flex;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.studio-status-to_shoot { background: var(--bg-glass); color: var(--text-muted); }
.studio-status-shot { background: var(--green-soft); color: var(--green); }
.studio-status-redo { background: var(--yellow-soft); color: var(--yellow); }
.studio-status-deleted { background: var(--red-soft); color: var(--red); }

/* --- Toast --- */
.toast-msg {
  background: rgba(15, 16, 23, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  color: var(--text-primary);
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- Reels modal --- */
.hooks-list {
  padding-left: 20px;
  margin-bottom: 20px;
}

.hooks-list li {
  padding: 6px 0;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.reel-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

/* --- Project card actions --- */
.project-card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.project-status-select {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.project-status-select:hover {
  border-color: rgba(255,255,255,0.2);
}

.project-status-select.badge-active {
  color: var(--green);
  border-color: rgba(52,211,153,0.25);
  background: rgba(52,211,153,0.08);
}

.project-status-select.badge-archived {
  color: var(--yellow);
  border-color: rgba(250,204,21,0.25);
  background: rgba(250,204,21,0.08);
}

/* --- User text: more prominent than AI --- */
.block-user-content {
  padding: 10px 14px;
  background: rgba(124, 92, 252, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  border-left: 3px solid rgba(124, 92, 252, 0.3);
  position: relative;
}

.user-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(var(--sc), 0.85);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Focus mini button */
.btn-focus-mini {
  font-size: 0.55rem;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(124, 92, 252, 0.2);
  background: rgba(124, 92, 252, 0.08);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.btn-focus-mini:hover {
  background: rgba(124, 92, 252, 0.18);
  border-color: rgba(124, 92, 252, 0.4);
}

.block-user-textarea {
  width: 100%;
  min-height: 44px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-script);
  font-size: 0.9rem;
  line-height: 1.7;
  resize: none;
  outline: none;
  overflow: hidden;
  field-sizing: content;
}

.block-user-textarea:focus {
  background: rgba(124, 92, 252, 0.04);
  border-radius: 4px;
}

.block-user-textarea::placeholder { color: var(--text-muted); font-style: italic; }

/* --- Excluded blocks: stronger contrast --- */
.block-excluded {
  opacity: 0.3;
  border-style: dashed;
  border-color: rgba(248, 113, 113, 0.2);
}

.block-excluded:hover { opacity: 0.55; }

.block-excluded .block-header { background: rgba(248, 113, 113, 0.03); }

.btn-excluded {
  background: var(--red-soft) !important;
  color: var(--red) !important;
  border-color: rgba(248, 113, 113, 0.3) !important;
}

/* --- Collapse button --- */
.block-collapse-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.6rem;
  transition: all 0.15s;
  flex-shrink: 0;
}

.block-collapse-btn:hover {
  background: var(--bg-glass-strong);
  color: var(--text-primary);
}

.block-collapsed { border-style: solid; }
.block-collapsed .block-header { border-bottom: none; }

/* --- Block drag handle --- */
.block-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.85rem;
  user-select: none;
  flex-shrink: 0;
  padding: 2px;
  transition: color 0.15s;
}

.block-drag-handle:hover { color: var(--text-secondary); }
.block-drag-handle:active { cursor: grabbing; }

/* --- Drag states --- */
.section-card.dragging,
.block-card.dragging {
  opacity: 0.4;
  transform: scale(0.97);
}

.section-card.drag-over {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 30px -8px var(--accent-glow);
}

.block-card.drag-over {
  border-color: hsl(var(--block-hue, 260), 60%, 60%) !important;
  box-shadow: 0 0 0 2px hsla(var(--block-hue, 260), 60%, 60%, 0.15);
}

/* --- Section studio status badge --- */
.section-studio-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.studio-badge-shot { background: var(--green-soft); color: var(--green); }
.studio-badge-redo { background: var(--yellow-soft); color: var(--yellow); }
.studio-badge-deleted { background: var(--red-soft); color: var(--red); }

/* --- Timeline widget --- */
.timeline-bar {
  display: flex;
  height: 40px;
  margin: 0 32px;
  border-radius: 4px;
  overflow: hidden;
  gap: 2px;
}

.tl-segment {
  position: relative;
  border-radius: 3px;
  overflow: hidden;
  min-width: 4px;
  transition: all 0.3s;
  opacity: 0.75;
  cursor: default;
}

.tl-segment:hover { opacity: 1; transform: scaleY(1.15); }

.tl-segment.tl-shot {
  opacity: 1;
  box-shadow: inset 0 -3px 0 var(--green);
}

.tl-segment.tl-redo {
  box-shadow: inset 0 -3px 0 var(--yellow);
}

.tl-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

/* --- Narrative analysis modal --- */
.narrative-list {
  list-style: none;
  padding: 0;
  margin-bottom: 8px;
}

.narrative-list li {
  padding: 4px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.narrative-reorder {
  margin-top: 16px;
  padding: 12px;
  background: var(--blue-soft);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(96, 165, 250, 0.15);
}

/* Suggestion cards in modal */
.suggestion-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  box-shadow: 0 0 20px -8px var(--accent-glow);
}

.suggestion-card.added {
  opacity: 0.5;
  cursor: default;
  border-color: var(--green);
}

/* (old block-textarea/footer styles removed) */

/* --- Celebration overlay --- */
.celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.celebration-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: celebration-fly 1s ease-out forwards;
}

@keyframes celebration-fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

/* --- Validate pulse animation --- */
@keyframes validate-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.block-card.just-validated {
  animation: validate-pulse 0.6s ease-out;
}

/* --- Context menu --- */
.context-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-base);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 4px;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 50;
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.context-menu button:hover {
  background: var(--bg-glass-strong);
}

.context-menu button.danger {
  color: var(--red);
}

/* --- Empty state --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 24px;
}

/* ================================================
   STUDIO MODE — fullscreen slide-by-slide
   ================================================ */
.studio-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.studio-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.studio-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: var(--glass-border);
  background: rgba(15, 16, 23, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.studio-topbar .studio-title {
  font-weight: 700;
  font-size: 1rem;
}

.studio-topbar .studio-progress {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.studio-slide-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
}

.studio-slide {
  max-width: 800px;
  width: 100%;
  text-align: center;
}

/* Studio slide content now styled via .studio-block-* classes */

.studio-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 32px;
  border-top: var(--glass-border);
  background: rgba(15, 16, 23, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.studio-status-btns {
  display: flex;
  gap: 8px;
  margin-left: 24px;
}

.studio-status-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: var(--glass-border);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.studio-status-btn:hover { background: var(--bg-glass-strong); color: var(--text-primary); }
.studio-status-btn.status-shot { background: var(--green-soft); color: var(--green); border-color: rgba(52, 211, 153, 0.3); }
.studio-status-btn.status-redo { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(251, 191, 36, 0.3); }
.studio-status-btn.status-deleted { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, 0.3); }

/* Studio status indicators now in .studio-status-* classes */

/* ================================================
   SETTINGS VIEW
   ================================================ */
.settings-view {
  max-width: 600px;
  margin: 0 auto;
  padding: 48px 32px;
}

.settings-view h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 32px;
  letter-spacing: -0.02em;
}

.settings-section {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.settings-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: var(--glass-border);
}

.settings-row:last-child { border-bottom: none; }

.settings-row label {
  color: var(--text-primary);
  font-size: 0.9rem;
}

.settings-row .form-input {
  max-width: 300px;
}

.api-key-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 20px;
}

.api-key-status.configured {
  background: var(--green-soft);
  color: var(--green);
}

.api-key-status.missing {
  background: var(--red-soft);
  color: var(--red);
}

/* ================================================
   FOCUS MODE — iA Writer / screenplay style
   ================================================ */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #08080c;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.focus-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Top bar — minimal */
.focus-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background: transparent;
  flex-shrink: 0;
}

.focus-topbar .focus-block-title {
  font-family: var(--font-script);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.focus-topbar .focus-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.focus-topbar .focus-close {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.focus-topbar .focus-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

/* Writing area — centered, screenplay feel */
.focus-writing-area {
  flex: 1;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  padding: 60px 32px 120px;
}

.focus-editor {
  width: 100%;
  max-width: 640px;
  position: relative;
}

/* Screenplay page edges — subtle */
.focus-editor::before {
  content: '';
  position: absolute;
  top: -20px;
  left: -40px;
  right: -40px;
  bottom: -20px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  border-radius: 2px;
  pointer-events: none;
}

/* Left margin line — like a screenplay page */
.focus-editor::after {
  content: '';
  position: absolute;
  top: 0;
  left: -24px;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.focus-textarea {
  width: 100%;
  min-height: 60vh;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: rgba(240, 240, 245, 0.88);
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 1.2rem;
  line-height: 2;
  letter-spacing: 0.01em;
  caret-color: var(--accent);
}

.focus-textarea::placeholder {
  color: rgba(240, 240, 245, 0.15);
}

/* Sentence highlight — current line glow */
.focus-textarea:focus {
  text-shadow: 0 0 80px rgba(240, 240, 245, 0.03);
}

/* AI notes sidebar — slide in from right */
.focus-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  background: rgba(12, 12, 18, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  padding: 60px 24px 32px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 3001;
}

.focus-sidebar.open {
  transform: translateX(0);
}

.focus-sidebar-toggle {
  position: fixed;
  right: 16px;
  bottom: 24px;
  z-index: 3002;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 16, 23, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  display: none;
}

.focus-overlay.active .focus-sidebar-toggle {
  display: block;
}

.focus-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.focus-sidebar h3 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
  margin-bottom: 12px;
}

.focus-sidebar .focus-ai-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  font-family: var(--font-main);
}

.focus-sidebar .focus-ai-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* Word counter bottom bar */
.focus-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3001;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 12px 32px;
  background: linear-gradient(to top, #08080c 60%, transparent);
  pointer-events: none;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.3s;
}

.focus-overlay.active .focus-bottom-bar {
  opacity: 1;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .editor-title-row { flex-wrap: wrap; gap: 8px; }
  .editor-toolbar { flex-wrap: wrap; gap: 6px; }
  .view-switcher { flex-wrap: wrap; }
}

@media (max-width: 768px) {
  .topbar {
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    gap: 8px;
  }
  .topbar-brand span { display: none; }
  .dashboard { padding: 24px 16px; }
  .projects-grid { grid-template-columns: 1fr; }
  .editor-title-row {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .editor-toolbar {
    padding: 4px 12px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .editor-toolbar .btn { font-size: 0.65rem; padding: 4px 8px; }
  .view-switcher { gap: 2px; }
  .view-btn { font-size: 0.65rem; padding: 4px 8px; }
  .gamification-bar {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.75rem;
  }
  .sections-container { padding: 12px; }
  .section-header { flex-wrap: wrap; gap: 6px; }
  .section-actions { flex-wrap: wrap; }
  .section-meta { font-size: 0.65rem; }
  .block-header { flex-wrap: wrap; gap: 4px; }
  .block-actions { flex-wrap: wrap; gap: 4px; }
  .block-actions .btn { font-size: 0.6rem; padding: 3px 6px; }
  .studio-nav { flex-wrap: wrap; gap: 8px; justify-content: center; }
  .studio-status-btns { flex-wrap: wrap; gap: 4px; }
}

/* --- Toggle switch --- */
.toggle-row {
  display: flex;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

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

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

.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  transition: background 0.25s;
  cursor: pointer;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.25s, background 0.25s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent-soft);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: var(--accent);
}

/* --- Loading overlay --- */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-message {
  color: var(--text-primary);
  font-size: 0.95rem;
  text-align: center;
  max-width: 400px;
  line-height: 1.5;
}

/* ============================================
   VIEW SWITCHER
   ============================================ */
.view-switcher {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 2px;
}

.view-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.view-btn:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.view-btn.active { color: var(--text-primary); background: rgba(255,255,255,0.1); }

.topbar-separator {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.08);
  margin: 0 4px;
}

/* ============================================
   TIMELINE — draggable segments
   ============================================ */
.tl-segment { cursor: grab; transition: opacity 0.2s, transform 0.2s; }
.tl-segment:active { cursor: grabbing; }
.tl-segment.tl-dragging { opacity: 0.4; transform: scaleY(0.8); }
.tl-segment.tl-drag-over { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5); transform: scaleY(1.15); }

/* ============================================
   NODES VIEW (DaVinci Resolve style)
   ============================================ */
.nodes-container {
  padding: 32px 24px;
  overflow: auto;
  max-height: calc(100vh - 180px);
}

.nodes-canvas {
  position: relative;
  min-height: 600px;
}

/* Free-positioned node cards */
.node-card-wrap {
  transition: box-shadow 0.2s;
}

.node-card {
  --node-hue: 260;
  background: var(--bg-card);
  border: 1px solid hsla(var(--node-hue), 50%, 50%, 0.2);
  border-radius: var(--radius-lg);
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.node-card:hover {
  border-color: hsla(var(--node-hue), 60%, 60%, 0.4);
  box-shadow: 0 8px 32px hsla(var(--node-hue), 60%, 50%, 0.12);
}

.node-card.node-shot {
  border-color: rgba(74, 222, 128, 0.35);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.06) 0%, var(--bg-card) 60%);
}

.node-card.node-redo {
  border-color: rgba(250, 204, 21, 0.3);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.05) 0%, var(--bg-card) 60%);
}

.node-drag-handle {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: grab;
  z-index: 2;
  transition: background 0.2s, color 0.2s;
}

.node-drag-handle:hover { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
.node-drag-handle:active { cursor: grabbing; }

.node-card-body {
  padding: 14px 18px;
  cursor: pointer;
}

.node-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.node-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}

.node-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 4px;
  font-style: italic;
}

.node-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.node-expand-hint {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.2);
  margin-top: 6px;
  transition: color 0.2s;
}

.node-card-body:hover .node-expand-hint { color: var(--text-muted); }

.node-status-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  text-transform: uppercase;
}

.node-status-shot { background: var(--green-soft); color: var(--green); }
.node-status-redo { background: var(--yellow-soft); color: var(--yellow); }

/* Sub-nodes (blocks inside expanded section) */
.node-subnodes {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.node-subnode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: background 0.15s;
}

.node-subnode:hover { background: rgba(255,255,255,0.07); }

.node-subnode-title {
  font-size: 0.68rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.node-subnode-written {
  font-size: 0.6rem;
  color: var(--green);
  flex-shrink: 0;
  margin-left: 8px;
}

/* ---- Sub-node cards (separate mini-nodes connected by lines) ---- */
.node-subcard-wrap {
  pointer-events: auto;
  transition: none;
}

.node-subcard {
  background: rgba(20, 20, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-left: 3px solid;
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.2s, transform 0.1s;
  min-height: 36px;
}

.node-subcard:hover {
  background: rgba(30, 30, 45, 0.95);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transform: scale(1.02);
}

.node-sub-drag {
  font-size: 0.7rem;
  cursor: grab;
  color: rgba(255,255,255,0.25);
  flex-shrink: 0;
  user-select: none;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.node-sub-drag:hover {
  color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.08);
}

.node-sub-drag:active { cursor: grabbing; }

.node-subcard-num {
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  opacity: 0.8;
}

.node-subcard-title {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.node-subcard-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Node edit modal */
.node-edit-blocks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.node-edit-block {
  padding: 10px 14px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
}

.node-edit-block-title {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.node-edit-textarea {
  width: 100%;
  min-height: 60px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--font-script);
  font-size: 0.85rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}

.node-edit-textarea:focus { border-color: rgba(124, 92, 252, 0.3); }

.node-edit-ai {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  border-left: 2px solid rgba(96, 165, 250, 0.15);
  padding-left: 8px;
  opacity: 0.6;
}

.node-edit-ai:hover { opacity: 1; }

/* ============================================
   SCRIPT VIEW (Hollywood format)
   ============================================ */
.script-container {
  padding: 0;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.script-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 60px 60px 80px;
  background: #ffffff;
  color: #0a0a0a;
  min-height: 100vh;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: 0 0 80px rgba(0,0,0,0.4);
}

.script-title-page {
  text-align: center;
  padding: 80px 0 40px;
}

/* Script toolbar */
.script-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 0 12px;
  background: linear-gradient(to bottom, #fff 70%, transparent);
  flex-wrap: wrap;
}

.script-align-btn {
  width: 32px;
  height: 28px;
  border: 1px solid #ddd;
  background: #fafafa;
  color: #888;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}

/* Alignment icons via box-shadow lines */
.script-align-btn { font-size: 0; position: relative; overflow: hidden; }
.script-align-btn::before, .script-align-btn::after {
  content: '';
  position: absolute;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
/* Left align: long, short-left, long */
.script-align-btn:nth-child(1)::before { width: 14px; left: 9px; top: 9px; box-shadow: 0 8px 0 currentColor; }
.script-align-btn:nth-child(1)::after { width: 10px; left: 9px; top: 13px; }
/* Center: long, short-center, long */
.script-align-btn:nth-child(2)::before { width: 14px; left: 9px; top: 9px; box-shadow: 0 8px 0 currentColor; }
.script-align-btn:nth-child(2)::after { width: 10px; left: 11px; top: 13px; }
/* Right: long, short-right, long */
.script-align-btn:nth-child(3)::before { width: 14px; left: 9px; top: 9px; box-shadow: 0 8px 0 currentColor; }
.script-align-btn:nth-child(3)::after { width: 10px; left: 13px; top: 13px; }
/* Justify: all lines full width */
.script-align-btn:nth-child(4)::before { width: 14px; left: 9px; top: 9px; box-shadow: 0 8px 0 currentColor; }
.script-align-btn:nth-child(4)::after { width: 14px; left: 9px; top: 13px; }

.script-align-btn:hover {
  border-color: #999;
  background: #f0f0f0;
  color: #333;
}

.script-align-btn.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* Editable inputs in script view */
.script-editable-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  outline: none;
  font-family: 'Courier Prime', 'Courier New', monospace;
  color: #0a0a0a;
  width: 100%;
  transition: border-color 0.2s;
  text-align: inherit;
}

.script-editable-input:hover {
  border-bottom-color: #ddd;
}

.script-editable-input:focus {
  border-bottom-color: #999;
}

.script-main-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.15em;
  margin-bottom: 12px;
}

.script-main-title.script-editable-input {
  text-align: center;
  text-transform: uppercase;
}

.script-subtitle.script-editable-input {
  text-align: center;
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.script-subtitle {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.script-date {
  font-size: 11px;
  color: #999;
}

.script-separator {
  border: none;
  border-top: 1px solid #ccc;
  margin: 20px 0 40px;
}

.script-section {
  margin-bottom: 32px;
  page-break-inside: avoid;
}

.script-scene-heading {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  background: #f0f0f0;
  padding: 6px 12px;
  margin-bottom: 16px;
  border-left: 3px solid #333;
  letter-spacing: 0.05em;
}

.script-scene-heading-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f0f0f0;
  padding: 6px 12px;
  margin-bottom: 16px;
  border-left: 3px solid #333;
}

.script-scene-num {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.script-scene-heading-input {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  outline: none;
  font-family: 'Courier Prime', 'Courier New', monospace;
  color: #0a0a0a;
  flex: 1;
  padding: 0;
  transition: border-color 0.2s;
}

.script-scene-heading-input:hover { border-bottom-color: #ccc; }
.script-scene-heading-input:focus { border-bottom-color: #999; }

.script-block {
  margin-bottom: 16px;
  padding-left: 24px;
}

.script-block-heading {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  color: #333;
}

.script-block-heading-input {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  color: #333;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  outline: none;
  font-family: 'Courier Prime', 'Courier New', monospace;
  width: 100%;
  padding: 0;
  transition: border-color 0.2s;
}

.script-block-heading-input:hover { border-bottom-color: #ddd; }
.script-block-heading-input:focus { border-bottom-color: #999; }
.script-block-heading-input::placeholder { color: #ccc; font-style: italic; text-transform: none; }

.script-dialogue {
  white-space: pre-wrap;
  line-height: 1.7;
}

.script-block-empty {
  opacity: 0.4;
}

.script-textarea {
  width: 100%;
  min-height: 28px;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: #0a0a0a;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  outline: none;
  overflow: hidden;
  padding: 2px 0;
  transition: border-color 0.2s;
}

.script-textarea:focus {
  border-bottom-color: #ccc;
}

.script-textarea::placeholder {
  color: #bbb;
  font-style: italic;
}

.script-visual-note {
  font-size: 10px;
  color: #997744;
  font-style: italic;
  margin-top: 4px;
  padding-left: 24px;
}

.script-empty {
  text-align: center;
  padding: 80px;
  color: #999;
  font-style: italic;
}

/* Script toolbar enhancements */
.script-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.script-toolbar-sep {
  width: 1px;
  height: 20px;
  background: #ddd;
  margin: 0 6px;
}

.script-tool-btn {
  padding: 4px 12px;
  border: 1px solid #ddd;
  background: #fafafa;
  color: #555;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.script-tool-btn:hover {
  background: #eee;
  border-color: #999;
  color: #222;
}

.script-font-size-select,
.script-line-height-select {
  padding: 3px 6px;
  border: 1px solid #ddd;
  background: #fafafa;
  color: #555;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
}

.script-font-size-select:hover,
.script-line-height-select:hover {
  border-color: #999;
}

.script-visual-textarea {
  width: 100%;
  min-height: 20px;
  background: transparent;
  border: none;
  border-left: 2px solid #c0945a;
  color: #997744;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 10px;
  font-style: italic;
  line-height: 1.5;
  resize: none;
  outline: none;
  overflow: hidden;
  padding: 2px 0 2px 8px;
  margin-top: 4px;
  transition: border-color 0.2s;
}

.script-visual-textarea:focus {
  border-left-color: #d4a862;
}

.script-visual-textarea::placeholder {
  color: #ccc;
  font-style: italic;
}

.script-add-block-btn {
  display: block;
  margin: 8px 0 0 24px;
  padding: 2px 12px;
  border: 1px dashed #ccc;
  background: transparent;
  color: #aaa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.script-add-block-btn:hover {
  border-color: #888;
  color: #555;
  background: #f8f8f8;
}

/* ============================================
   BOARD VIEW (Kanban)
   ============================================ */
.board-container {
  padding: 0;
  height: calc(100vh - 180px);
  overflow: hidden;
}

.board-canvas {
  display: flex;
  gap: 16px;
  padding: 20px;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.board-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  color: var(--text-muted);
  font-style: italic;
}

.board-col {
  flex: 0 0 280px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.board-col-over {
  border-color: var(--accent) !important;
  background: rgba(124,92,252,0.06);
}

.board-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-top: 3px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.board-col-title {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  padding: 0;
}

.board-col-title::placeholder { color: var(--text-muted); }

.board-col-count {
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.board-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.board-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.board-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}

.board-card-done {
  border-left: 3px solid var(--green);
}

.board-card-dragging {
  opacity: 0.5;
}

.board-card-ghost {
  opacity: 0.3;
}

.board-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.board-card-untitled {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

.board-card-preview {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.board-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.65rem;
}

.board-card-words {
  color: var(--green);
  font-weight: 600;
}

.board-card-empty {
  color: var(--text-muted);
  font-style: italic;
}

.board-card-vn {
  background: rgba(192,148,90,0.15);
  color: #c0945a;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.6rem;
}

.board-add-btn {
  padding: 8px;
  margin: 4px 8px 8px;
  border: 1px dashed rgba(255,255,255,0.12);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.board-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124,92,252,0.06);
}

.board-col-add {
  flex: 0 0 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 0.15s;
}

.board-col-add:hover {
  border-color: var(--accent);
  background: rgba(124,92,252,0.04);
}

.board-col-add-inner {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Board edit modal */
.board-edit-modal {
  max-width: 560px;
  width: 100%;
}

.board-edit-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.board-edit-title {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  outline: none;
  padding: 4px 0;
}

.board-edit-title:focus { border-bottom-color: var(--accent); }

.board-edit-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.board-edit-close:hover { color: var(--text-primary); }

.board-edit-section-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.board-edit-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-top: 12px;
}

.board-edit-textarea {
  width: 100%;
  min-height: 150px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 12px;
  resize: vertical;
  outline: none;
}

.board-edit-textarea:focus { border-color: var(--accent); }

.board-edit-vn {
  width: 100%;
  min-height: 60px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 2px solid #c0945a;
  border-radius: var(--radius-sm);
  color: #c0945a;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 0.8rem;
  font-style: italic;
  line-height: 1.5;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}

.board-edit-vn:focus { border-color: #d4a862; }

.board-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

/* ============================================
   NOTES VIEW
   ============================================ */
.notes-container {
  padding: 0;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.notes-editor {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 180px);
}

.notes-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
}

.notes-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.notes-textarea {
  flex: 1;
  min-height: 400px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.8;
  padding: 24px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.notes-textarea:focus {
  border-color: rgba(124,92,252,0.3);
}

.notes-textarea::placeholder {
  color: var(--text-muted);
}

/* ============================================
   BACKGROUND CUSTOMIZER PANEL
   ============================================ */
.bg-panel {
  position: fixed;
  top: 100px;
  right: 24px;
  z-index: 500;
  width: 280px;
}

.bg-panel-inner {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: rgba(15, 16, 23, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: var(--glass-border);
}

.bg-panel h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.bg-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.bg-preset-btn {
  flex: 1;
  padding: 6px 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.bg-preset-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.bg-preset-btn.active { background: rgba(255,255,255,0.1); color: var(--text-primary); border-color: rgba(255,255,255,0.2); }

.bg-sliders {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bg-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.bg-slider-value {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bg-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  background: rgba(255,255,255,0.08);
}

.bg-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  margin-top: -5px;
  position: relative;
  z-index: 2;
}

.bg-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
}

.bg-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.bg-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
}

.bg-slider::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}

/* --- Font loading --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Courier+Prime&display=swap');

/* ============================================
   SECTION DESCRIPTION ROW
   ============================================ */
.section-description-row {
  padding: 0 16px 12px;
}

.section-desc-input {
  width: 100%;
  min-height: 32px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 8px 12px;
  resize: none;
  overflow: hidden;
  outline: none;
  transition: border-color 0.2s;
  field-sizing: content;
}

.section-desc-input:focus {
  border-color: rgba(124,92,252,0.3);
}

.section-desc-input::placeholder {
  color: rgba(240,240,245,0.2);
  font-style: italic;
}

/* ============================================
   SECTION COLOR PICKER
   ============================================ */
.section-color-picker {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: none;
  padding: 0;
  flex-shrink: 0;
  -webkit-appearance: none;
}

.section-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.section-color-picker::-webkit-color-swatch { border: 2px solid rgba(255,255,255,0.1); border-radius: 50%; }
.section-color-picker::-moz-color-swatch { border: 2px solid rgba(255,255,255,0.1); border-radius: 50%; }

/* ============================================
   VISUAL NOTES (STAGE DIRECTIONS)
   ============================================ */
.block-visual-content .user-label {
  color: hsl(35, 70%, 55%);
}

/* ============================================
   TIME OVER WARNING
   ============================================ */
.time-over {
  color: var(--red) !important;
  animation: timePulse 2s ease-in-out infinite;
}

.time-over #time-value {
  color: var(--red);
  font-weight: 700;
}

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

/* ============================================
   WRITER TOOLS VIEW
   ============================================ */
.writer-container {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.writer-page {
  width: 100%;
}

.writer-panel {
  padding: 32px;
  border-radius: 16px;
}

.writer-panel h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.writer-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.writer-panel h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 24px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.writer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.writer-stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.writer-stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.writer-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 4px;
}

.writer-stat-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.6;
}

.writer-section-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.writer-section-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
}

.writer-section-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.writer-mini-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.writer-mini-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.writer-section-pct {
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

.writer-section-words {
  font-size: 0.65rem;
  color: var(--text-muted);
  min-width: 55px;
  text-align: right;
}

.writer-word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.writer-word {
  color: var(--text-secondary);
  padding: 4px 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}

.writer-word sup {
  font-size: 0.5em;
  color: var(--text-muted);
  margin-left: 2px;
}

.writer-issues {
  list-style: none;
  padding: 0;
}

.writer-issues li {
  font-size: 0.8rem;
  color: var(--yellow);
  padding: 6px 12px;
  background: rgba(251, 191, 36, 0.06);
  border-radius: 6px;
  margin-bottom: 4px;
}

.writer-ok {
  font-size: 0.8rem;
  color: var(--green);
  padding: 8px 12px;
  background: rgba(52, 211, 153, 0.06);
  border-radius: 8px;
  margin-top: 12px;
}

.writer-scratchpad {
  width: 100%;
  min-height: 120px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: 'Courier Prime', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  padding: 16px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.writer-scratchpad:focus {
  border-color: rgba(124,92,252,0.3);
}
