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

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;

  /* Speaker colors */
  --speaker-justin: #3b82f6;
  --speaker-betsey: #8b5cf6;
  --speaker-interviewer: #10b981;
  --speaker-other: #6b7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

header h1 {
  font-size: 2rem;
  color: var(--primary-color);
}

header .subtitle {
  color: var(--text-secondary);
  flex: 1;
}

/* Version footer at bottom right */
.version-footer {
  position: fixed;
  bottom: 12px;
  right: 16px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  opacity: 0.7;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--border-color);
}

/* Sections */
.section {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section h2 {
  margin-bottom: 16px;
  font-size: 1.25rem;
}

/* Section header with title and action button */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  margin-bottom: 0;
}

/* Icon button style */
.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--background);
  color: var(--text-primary);
  border-color: var(--primary-color);
}

.btn-icon .icon {
  font-size: 1rem;
}

.btn-icon.copied {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-icon.btn-danger {
  color: var(--error);
  border-color: var(--error);
}

.btn-icon.btn-danger:hover {
  background: var(--error);
  color: white;
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 60px 40px;
  text-align: center;
  transition: all 0.2s;
}

.drop-zone.dragover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.drop-icon {
  font-size: 3rem;
}

.or-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.file-input-label {
  cursor: pointer;
}

/* Upload Progress */
.upload-progress {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  width: 0%;
  transition: width 0.3s;
}

.progress-text {
  display: block;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Video Player */
.video-container {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

#video-player {
  width: 100%;
  max-height: 500px;
}

.video-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

#video-name {
  font-weight: 500;
  color: var(--text-primary);
}

.video-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-meta .separator {
  color: var(--border-color);
}

/* Processing Status */
.processing-status {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--background);
  border-radius: 8px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.status-item::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.status-item.complete::before {
  background: var(--success);
  animation: none;
}

.status-item.error::before {
  background: var(--error);
  animation: none;
}

.status-item.complete {
  color: var(--success);
}

.status-item.error {
  color: var(--error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Transcript */
.transcript-container {
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  background: var(--background);
  border-radius: 8px;
}

.transcript-segment {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface);
  border-left: 4px solid var(--speaker-other);
}

.transcript-segment.justin-wolfers {
  border-left-color: var(--speaker-justin);
}

.transcript-segment.betsey-stevenson {
  border-left-color: var(--speaker-betsey);
}

.transcript-segment.interviewer {
  border-left-color: var(--speaker-interviewer);
}

.transcript-segment .speaker {
  font-weight: 600;
  margin-bottom: 4px;
}

.transcript-segment .timestamp {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-left: 8px;
}

.transcript-segment .text {
  color: var(--text-primary);
}

.transcript-segment .text p {
  margin-bottom: 0.75em;
}

.transcript-segment .text p:last-child {
  margin-bottom: 0;
}

/* Metadata */
.metadata-container {
  display: grid;
  gap: 24px;
}

.metadata-group h3 {
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metadata-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metadata-item {
  padding: 12px 16px;
  background: var(--background);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metadata-item:hover {
  background: var(--border-color);
}

.metadata-item .copy-icon {
  opacity: 0;
  transition: opacity 0.2s;
}

.metadata-item:hover .copy-icon {
  opacity: 1;
}

.metadata-item.copied {
  background: rgba(34, 197, 94, 0.1);
}

.thumbnail-titles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thumbnail-titles .metadata-item {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-weight: 500;
}

/* Range extraction controls — in Thumbnail Selection section */
.range-extract {
  margin-bottom: 20px;
  padding: 0;
}

.range-scrubber-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.range-video {
  width: 240px;
  min-width: 240px;
  height: auto;
  border-radius: 6px;
  background: #000;
  object-fit: contain;
  aspect-ratio: 16 / 9;
}

.range-scrubber-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

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

.range-time-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
  white-space: nowrap;
}

.range-timeline {
  position: relative;
  flex: 1;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  background: #1a1a2e;
  cursor: pointer;
  user-select: none;
}

.range-filmstrip {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

/* Dimmed overlays outside the selection */
.range-overlay {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 2;
}

.range-overlay-left {
  left: 0;
  width: 0;
}

.range-overlay-right {
  right: 0;
  width: 0;
}

/* Selected region highlight */
.range-selection {
  position: absolute;
  top: 0;
  height: 100%;
  border: 2px solid var(--primary-color);
  border-radius: 2px;
  box-sizing: border-box;
  z-index: 3;
  /* Default: full width */
  left: 0%;
  width: 100%;
}

/* Drag handles */
.range-handle {
  position: absolute;
  top: 0;
  width: 14px;
  height: 100%;
  background: var(--primary-color);
  cursor: ew-resize;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.range-handle::after {
  content: '';
  width: 4px;
  height: 20px;
  border-left: 2px solid rgba(255,255,255,0.7);
  border-right: 2px solid rgba(255,255,255,0.7);
}

.range-handle:hover,
.range-handle.dragging {
  background: var(--primary-hover);
}

.range-handle-left {
  left: -2px;
  border-radius: 4px 0 0 4px;
}

.range-handle-right {
  right: -2px;
  border-radius: 0 4px 4px 0;
}

/* Playhead indicator */
.range-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: white;
  z-index: 5;
  pointer-events: none;
  opacity: 0.8;
  left: 0;
  transition: left 0.1s linear;
}

/* Actions row below timeline */
.range-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

/* Frames Grid */
.frames-instruction,
.editor-instruction {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* Batch separator for additional frame extractions */
.frames-batch-separator {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  margin: 8px 0;
}

.frames-batch-separator:first-child {
  padding-top: 0;
  margin-top: 0;
}

.frames-batch-separator::before,
.frames-batch-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.frames-batch-separator span {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* More images button */
.more-images-btn {
  grid-column: 1 / -1;
  margin-top: 16px;
  padding: 10px 20px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  justify-self: center;
}

.more-images-btn.loading {
  opacity: 0.7;
  cursor: wait;
}

.more-images-btn .btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-secondary);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.more-images-btn .btn-text.hidden,
.more-images-btn .btn-spinner.hidden {
  display: none;
}

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

.frame-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
}

.frame-item:hover {
  transform: scale(1.02);
}

.frame-item.selected {
  border-color: var(--primary-color);
}

.frame-item img {
  width: 100%;
  display: block;
}

.frame-item .frame-number {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.frame-item .frame-timestamp {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.75);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.frame-item .select-count {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--primary-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  cursor: pointer;
}

.frame-item.selected .select-count {
  opacity: 1;
}

.frame-item.selected .select-count:hover {
  background: var(--error);
}

/* Thumbnail Editor */
.thumbnail-editors {
  display: grid;
  gap: 32px;
}

.thumbnail-editor {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  padding: 20px;
  background: var(--background);
  border-radius: 12px;
  position: relative;
}

.thumbnail-editor-header {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  display: flex;
  gap: 6px;
  align-items: center;
}

.thumbnail-trash-btn {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  opacity: 0.7;
}

.thumbnail-trash-btn:hover {
  opacity: 1;
  background: var(--error);
  border-color: var(--error);
}

/* Alignment control - 3x3 grid of dots */
.alignment-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  width: 28px;
  height: 28px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.alignment-control:hover {
  opacity: 1;
}

.alignment-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.15s;
}

.alignment-dot:hover {
  background: var(--primary-color);
  transform: scale(1.3);
}

.alignment-dot.active {
  background: var(--primary-color);
  transform: scale(1.2);
}

.thumbnail-canvas-container {
  position: relative;
}

.thumbnail-canvas {
  width: 100%;
  border-radius: 8px;
  cursor: move;
}

.text-overlay {
  position: absolute;
  background: #ffeb3b;
  color: #000;
  font-weight: 700;
  font-size: 24px;
  padding: 8px 16px;
  cursor: move;
  user-select: none;
  white-space: nowrap;
}

.text-overlay[contenteditable="true"] {
  outline: 2px solid var(--primary-color);
}

.thumbnail-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 500px;
  overflow-y: auto;
}

.thumbnail-options h4 {
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.thumbnail-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.thumbnail-option {
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
  line-height: 1.3;
  word-wrap: break-word;
}

.thumbnail-option:hover {
  background: var(--border-color);
}

.thumbnail-option.active {
  background: #ffeb3b;
  border-color: #ffeb3b;
  font-weight: 600;
}

/* Video Titles Section in Thumbnail Editor */
.video-titles-section {
  grid-column: 1 / -1;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.video-titles-section h4 {
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.video-titles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.video-title-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.video-title-item:hover {
  background: var(--border-color);
}

.video-title-item.copied {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--success);
}

.video-title-text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.video-title-text.editing {
  background: white;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 4px;
  outline: 2px solid var(--primary-color);
  cursor: text;
}

.video-title-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.video-title-copy-btn:hover {
  opacity: 1;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--surface);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 24px;
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.setting-group input,
.setting-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
}

.setting-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

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

.settings-version {
  text-align: center;
  padding: 8px 24px 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Prompts Modal */
.prompts-modal-content {
  max-width: 700px;
}

.prompt-editor-content {
  max-width: 800px;
}

.prompt-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.prompt-tab {
  padding: 8px 16px;
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.prompt-tab:hover {
  background: var(--border-color);
}

.prompt-tab.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.prompt-management {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--background);
  border-radius: 8px;
}

.prompt-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.prompt-selector label {
  font-weight: 500;
  white-space: nowrap;
}

.prompt-selector select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
}

.prompt-actions {
  display: flex;
  gap: 8px;
}

.btn-small {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.btn-danger {
  color: var(--error);
}

.btn-danger:hover {
  background: var(--error);
  color: white;
}

.prompt-preview {
  background: var(--background);
  border-radius: 8px;
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.prompt-preview h4 {
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prompt-preview-field {
  margin-bottom: 16px;
}

.prompt-preview-field:last-child {
  margin-bottom: 0;
}

.prompt-preview-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.prompt-preview-field pre {
  background: var(--surface);
  padding: 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border-color);
  max-height: 150px;
  overflow-y: auto;
}

/* Prompt Editor Fields */
#prompt-fields .setting-group textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

#prompt-fields .setting-group textarea.tall {
  min-height: 150px;
}

/* Video summary above descriptions */
.video-summary {
  margin-bottom: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-left: 3px solid var(--primary-color);
  border-radius: 4px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Heading above description buttons */
.descriptions-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Description radio selector - vertical stack */
.description-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--background);
  border-radius: 8px;
}

.description-radio {
  display: none;
}

.description-label {
  display: block;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  line-height: 1.4;
}

.description-label:hover {
  background: var(--border-color);
}

.description-radio:checked + .description-label {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.description-content {
  padding: 16px;
  background: var(--background);
  border-radius: 8px;
  line-height: 1.6;
}

.description-text p {
  margin-bottom: 1em;
}

.description-text p:last-child {
  margin-bottom: 0;
}

/* Thumbnail editor settings */
.thumbnail-editor-settings {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--background);
  border-radius: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.thumbnail-editor-settings .setting-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thumbnail-editor-settings label {
  font-weight: 500;
  font-size: 0.9rem;
}

.thumbnail-editor-settings select {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.85rem;
}

.thumbnail-editor-settings .color-picker {
  width: 40px;
  height: 30px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
}

/* Updated text overlay for adjustable width and resizable */
.text-overlay {
  position: absolute;
  background: #ffeb3b;
  color: #000;
  font-weight: 700;
  font-size: 24px;
  padding: 0 16px;
  cursor: move;
  user-select: none;
  white-space: nowrap;
  font-family: 'Bebas Neue', sans-serif;
  left: 0;
  width: 100%;
  text-align: center;
  overflow: hidden;
  min-height: 40px;
  /* Use flexbox to vertically center text with equal padding above/below */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Support multi-line with tight spacing when needed */
  flex-direction: column;
  /* Prevent text from ever overflowing */
  box-sizing: border-box;
}

.text-overlay[contenteditable="true"] {
  outline: 2px solid var(--primary-color);
  cursor: text;
  /* Prevent content from causing overflow - scrollbars should never appear */
  overflow: hidden !important;
}

.text-overlay.resizing {
  cursor: ns-resize;
}

/* Resize handles */
.text-overlay-resize-handle-top {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  cursor: ns-resize;
}

.text-overlay-resize-handle-left,
.text-overlay-resize-handle-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 40px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  cursor: ew-resize;
}

.text-overlay-resize-handle-left {
  left: 0;
}

.text-overlay-resize-handle-right {
  right: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .thumbnail-editor {
    grid-template-columns: 1fr;
  }

  .frames-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .video-titles-grid {
    grid-template-columns: 1fr;
  }

  header {
    flex-wrap: wrap;
  }
}

/* Extraction error with retry button */
.extraction-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  width: 100%;
}

.extraction-error .error {
  color: var(--error);
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.extraction-error .retry-extraction-btn {
  margin-top: 8px;
}

/* Billing error with link to add funds */
.billing-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  width: 100%;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  margin: 20px 0;
}

.billing-error .error {
  color: var(--error);
  margin-bottom: 16px;
  font-size: 1rem;
  font-weight: 500;
}

.billing-error .btn {
  margin-top: 8px;
}
