/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #1a1a2e;
  --bg-card: #16162a;
  --bg-elevated: #1e1e3a;
  --color-primary: #6366f1;
  --color-primary-light: #818cf8;
  --color-accent: #22d3ee;
  --color-accent-light: #67e8f9;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #2d2d4a;
  --border-active: #6366f1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-stack);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ===== Step Indicator ===== */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px 12px;
  flex-shrink: 0;
  gap: 0;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}

.step-dot.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.step-dot.completed {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.step-line {
  width: 32px;
  height: 2px;
  background: var(--border-color);
  flex-shrink: 0;
  transition: var(--transition);
}

.step-line.completed {
  background: var(--color-success);
}

/* ===== Step Content ===== */
.step-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 100px;
  opacity: 0;
  transform: translateX(20px);
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 60px;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  -webkit-overflow-scrolling: touch;
}

.step-content.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
}

.step-header {
  margin-bottom: 20px;
}

.step-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-secondary);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.08);
}

.upload-icon {
  color: var(--color-primary);
  margin-bottom: 16px;
}

.upload-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Upload Progress ===== */
.upload-progress {
  margin-top: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.file-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.progress-percent {
  font-size: 14px;
  color: var(--color-accent);
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ===== Frames Grid ===== */
.frames-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.frame-item {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  background: var(--bg-secondary);
}

.frame-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

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

.frame-item.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.frame-item.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  font-weight: 700;
}

.frame-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ===== Pipeline Selector ===== */
.pipeline-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.pipeline-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 100px;
  justify-content: center;
  color: var(--text-primary);
  font-family: var(--font-stack);
}

.pipeline-card:hover {
  border-color: var(--color-primary-light);
}

.pipeline-card.active {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: var(--shadow-glow);
}

.pipeline-icon {
  font-size: 28px;
}

.pipeline-name {
  font-size: 14px;
  font-weight: 600;
}

.pipeline-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  margin-top: 8px;
}

/* ===== Directions Grid ===== */
.directions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.direction-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 80px;
}

.direction-card:hover {
  border-color: var(--color-primary-light);
  transform: translateY(-1px);
}

.direction-card.selected {
  border-color: var(--color-accent);
  background: rgba(34, 211, 238, 0.08);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.25);
}

.direction-icon {
  font-size: 22px;
}

.direction-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.direction-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ===== Talking Extra Uploads ===== */
.talking-extra {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.upload-small {
  background: var(--bg-secondary);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.upload-small:hover {
  border-color: var(--color-primary);
}

.upload-small-icon {
  font-size: 28px;
}

.upload-small p {
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-preview {
  position: absolute;
  inset: 4px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}

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

.audio-name {
  font-size: 12px;
  color: var(--color-accent);
  word-break: break-all;
  padding: 4px;
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-select {
  width: 100%;
  height: 48px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  padding: 0 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: var(--transition);
}

.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  padding: 12px;
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-stack);
  line-height: 1.6;
  transition: var(--transition);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

.textarea-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.char-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Selected Frames Preview ===== */
.selected-frames-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.selected-frames-preview img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--color-primary);
  flex-shrink: 0;
}

/* ===== Collapse Panel ===== */
.collapse-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.collapse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: var(--transition);
}

.collapse-header:hover {
  background: var(--bg-elevated);
}

.collapse-arrow {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.3s ease;
}

.collapse-panel.open .collapse-arrow {
  transform: rotate(180deg);
}

.collapse-body {
  padding: 0 16px 14px;
}

.formula-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  background: var(--bg-elevated);
  padding: 12px;
  border-radius: var(--radius-sm);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-stack);
  width: 100%;
  gap: 8px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

.btn-accent {
  background: linear-gradient(135deg, var(--color-accent), #06b6d4);
  color: #0a0a0f;
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
}

.btn-accent:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(34, 211, 238, 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-light);
}

.btn-small {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  width: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--color-accent);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-stack);
  font-weight: 500;
}

.btn-small:hover {
  background: rgba(34, 211, 238, 0.1);
  border-color: var(--color-accent);
}

.bottom-action {
  position: sticky;
  bottom: 0;
  padding: 16px 0;
  margin-top: 16px;
  background: linear-gradient(to top, var(--bg-primary) 70%, transparent);
}

/* ===== Render Status ===== */
.render-status {
  text-align: center;
  padding: 32px 0;
}

.render-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}

.render-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  transition: var(--transition);
}

.render-step.active {
  color: var(--color-accent);
}

.render-step.completed {
  color: var(--color-success);
}

.render-step-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-color);
  transition: var(--transition);
}

.render-step.active .render-step-dot {
  background: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.5);
  animation: pulse 1.5s infinite;
}

.render-step.completed .render-step-dot {
  background: var(--color-success);
  border-color: var(--color-success);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(34, 211, 238, 0.5); }
  50% { box-shadow: 0 0 20px rgba(34, 211, 238, 0.8); }
}

.render-step-line {
  width: 24px;
  height: 2px;
  background: var(--border-color);
  margin: 0 4px;
  margin-bottom: 22px;
}

.render-progress-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 20px 16px;
}

.render-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: 4px;
  transition: width 0.5s ease;
  position: relative;
}

.render-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 8px,
    rgba(255, 255, 255, 0.1) 8px,
    rgba(255, 255, 255, 0.1) 16px
  );
  animation: stripes 0.8s linear infinite;
}

@keyframes stripes {
  0% { transform: translateX(0); }
  100% { transform: translateX(16px); }
}

.render-hint {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== Render Result ===== */
.render-result {
  padding: 16px 0;
}

.video-preview {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Tab Bar ===== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: stretch;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  font-family: var(--font-stack);
  min-height: 44px;
}

.tab-item:hover {
  color: var(--text-secondary);
}

.tab-item.active {
  color: var(--color-primary-light);
}

.tab-icon {
  font-size: 20px;
  line-height: 1;
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-height: 80vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* ===== Task List ===== */
.task-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.task-item:active {
  background: var(--bg-elevated);
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.task-direction {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.task-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.task-status.completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

.task-status.rendering {
  background: rgba(99, 102, 241, 0.15);
  color: var(--color-primary-light);
}

.task-status.failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-error);
}

.task-status.pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.task-time {
  font-size: 12px;
  color: var(--text-muted);
}

.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.task-actions .btn-small {
  flex: 1;
}

/* ===== About ===== */
.about-body {
  text-align: center;
  padding: 24px 20px;
}

.about-logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.about-body h4 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.about-version {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.about-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.about-features {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-item {
  font-size: 14px;
  color: var(--text-primary);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

/* ===== Loading ===== */
.loading-spinner {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 14px;
  margin-top: 8px;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Cover Generator Styles ===== */
.btn-cover {
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: #fff;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.btn-cover:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
}

.cover-modal-content {
  max-height: 90vh;
}

.cover-modal-body {
  padding: 16px 20px 30px;
}

.cover-section {
  margin-bottom: 18px;
}

.cover-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cover-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.cover-options-row {
  grid-template-columns: repeat(5, 1fr);
}

.cover-opt {
  background: var(--bg-elevated);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-primary);
  font-family: var(--font-stack);
  min-height: 60px;
  justify-content: center;
}

.cover-opt:hover {
  border-color: var(--color-primary-light);
  background: rgba(99, 102, 241, 0.08);
}

.cover-opt.active {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.cover-opt-icon {
  font-size: 20px;
  line-height: 1;
}

.cover-opt-name {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: nowrap;
}

.cover-opt.active .cover-opt-name {
  color: var(--color-primary-light);
}

.cover-opt-text {
  padding: 8px 4px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 500;
}

.cover-color-preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.cover-input {
  width: 100%;
  height: 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  padding: 0 14px;
  font-family: var(--font-stack);
  transition: var(--transition);
}

.cover-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

.cover-ref-frames {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.cover-ref-frame {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  flex-shrink: 0;
  opacity: 0.7;
}

.cover-ref-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-ref-frame:hover {
  opacity: 1;
}

.cover-ref-frame.selected {
  border-color: var(--color-primary);
  opacity: 1;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.btn-cover-gen {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-stack);
  margin-top: 8px;
}

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

.btn-cover-gen:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
}

.cover-preview-area {
  margin-top: 20px;
  text-align: center;
}

.cover-preview-img-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--bg-elevated);
  display: inline-block;
  max-width: 200px;
}

.cover-preview-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

.cover-preview-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.cover-preview-actions .btn-small {
  flex: 0 1 auto;
  min-width: 100px;
}

/* ===== Cover Option Row (inline pill buttons) ===== */
.cover-config {
  margin-bottom: 16px;
}

.cover-option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cover-option-row .cover-opt {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 16px;
  margin: 4px;
  font-size: 13px;
  min-height: auto;
  flex-direction: row;
  gap: 0;
}

.cover-option-row .cover-opt.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.cover-preview-placeholder {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

.cover-preview-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.cover-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 4px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

/* ===== Top Bar ===== */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
  flex-shrink: 0;
}

.app-topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-stack);
}

.btn-logout:hover {
  border-color: var(--color-error);
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.08);
}

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-primary);
  padding: 20px;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 60px rgba(99, 102, 241, 0.1);
}

.login-logo {
  text-align: center;
  font-size: 48px;
  margin-bottom: 12px;
}

.login-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.login-form-group {
  margin-bottom: 20px;
}

.login-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.login-input {
  width: 100%;
  height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  padding: 0 16px;
  font-family: var(--font-stack);
  transition: var(--transition);
  box-sizing: border-box;
}

.login-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

.login-btn {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, var(--color-primary), #4f46e5);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-stack);
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

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

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

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--color-error);
  margin-bottom: 16px;
  display: none;
  text-align: center;
}

.login-error.show {
  display: block;
  animation: shakeX 0.4s ease;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* =============================================
   NEW v2.0 — 5-step flow styles
   ============================================= */

/* ===== Directions Grid v2 (3-col compact) ===== */
.directions-grid-v2 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.direction-card-v2 {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  min-height: 90px;
}

.direction-card-v2:hover {
  border-color: var(--color-primary-light);
  transform: translateY(-1px);
}

.direction-card-v2.selected {
  border-color: var(--color-accent);
  background: rgba(34, 211, 238, 0.08);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.25);
}

.dir-icon {
  font-size: 24px;
  line-height: 1;
}

.dir-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.dir-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Accent Text ===== */
.accent-text {
  color: var(--color-accent);
  font-weight: 600;
}

/* ===== Form Input ===== */
.form-input {
  width: 100%;
  height: 48px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  padding: 0 14px;
  font-family: var(--font-stack);
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

/* ===== Script Textarea ===== */
.script-textarea {
  min-height: 140px;
  line-height: 1.7;
}

.script-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.script-actions .btn {
  height: 44px;
  font-size: 14px;
}

/* ===== AI Loading Animation ===== */
.ai-loading {
  text-align: center;
  padding: 24px 0;
}

.ai-loading p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 12px;
}

.ai-loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.ai-loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: aiPulse 1.4s ease-in-out infinite both;
}

.ai-loading-dots span:nth-child(1) { animation-delay: 0s; }
.ai-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiPulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== Two Button Row ===== */
.two-btn-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}

.btn-back {
  background: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: none !important;
}

.btn-back:hover {
  border-color: var(--color-primary) !important;
  color: var(--text-primary) !important;
}

/* ===== Upload Section ===== */
.upload-section {
  margin-bottom: 20px;
}

.upload-small-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Pipeline Warning ===== */
.pipeline-warn {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--color-warning);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Prompt Textarea ===== */
.prompt-textarea {
  min-height: 120px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0.02em;
}

/* ===== Frames Section ===== */
.frames-section {
  margin-top: 20px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  z-index: 300;
  font-size: 14px;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 90vw;
  text-align: center;
}

.toast.hidden {
  display: none !important;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== Mobile Responsive ===== */
@media (max-width: 380px) {
  .directions-grid-v2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .dir-name {
    font-size: 12px;
  }

  .dir-desc {
    font-size: 10px;
  }
}

@media (min-width: 500px) {
  .directions-grid-v2 {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

@media (min-width: 768px) {
  .directions-grid-v2 {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ============================================================
   v3.0 — 剧情模式样式
   ============================================================ */

/* 模式切换 Tabs */
.mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, #e0e0e0);
}

.mode-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: var(--bg-card, #fff);
  color: var(--text-secondary, #666);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab.active {
  background: var(--accent, #6366f1);
  color: #fff;
}

.mode-tab:hover:not(.active) {
  background: var(--bg-hover, #f5f5f5);
}

.mode-panel {
  animation: fadeIn 0.2s ease;
}

/* 场景卡片列表 */
.drama-scenes {
  margin-top: 16px;
}

.scenes-summary {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary, #666);
  padding: 8px;
  background: var(--bg-soft, #f8f9fa);
  border-radius: 8px;
  margin-bottom: 12px;
}

.scenes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scene-card {
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s;
  background: var(--bg-card, #fff);
}

.scene-card.selected {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 1px var(--accent, #6366f1);
}

.scene-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-soft, #f8f9fa);
  border-bottom: 1px solid var(--border, #e0e0e0);
}

.scene-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.scene-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #6366f1);
}

.scene-id {
  font-weight: 700;
  color: var(--accent, #6366f1);
  font-size: 13px;
}

.scene-name {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.scene-duration {
  font-size: 12px;
  color: var(--text-secondary, #666);
  background: var(--bg-card, #fff);
  padding: 2px 8px;
  border-radius: 12px;
}

.scene-card-body {
  padding: 10px 12px;
}

.scene-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.4;
}

.scene-label {
  color: var(--text-secondary, #999);
  min-width: 36px;
  flex-shrink: 0;
}

.scene-desc, .scene-dialogue, .scene-visual {
  color: var(--text, #333);
}

.scene-char {
  color: var(--accent, #6366f1);
  font-weight: 500;
}

.scene-emotion {
  color: #e67e22;
}

.scene-card-edit {
  padding: 6px 12px;
  border-top: 1px solid var(--border, #eee);
  text-align: right;
}

/* 剧情模式：按场景上传 */
.drama-upload-progress {
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  padding: 10px;
  background: var(--bg-soft, #f8f9fa);
  border-radius: 8px;
  margin-bottom: 12px;
}

.drama-scene-uploads {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scene-upload-card {
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card, #fff);
}

.scene-upload-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-soft, #f8f9fa);
  border-bottom: 1px solid var(--border, #eee);
}

.scene-upload-id {
  font-weight: 700;
  color: var(--accent, #6366f1);
  font-size: 13px;
}

.scene-upload-name {
  flex: 1;
  font-weight: 600;
}

.scene-upload-status {
  font-size: 12px;
}

.scene-upload-status.done { color: #22c55e; }
.scene-upload-status.pending { color: #f59e0b; }

.scene-upload-body {
  padding: 10px 12px;
}

.scene-upload-desc {
  font-size: 13px;
  color: var(--text-secondary, #666);
  margin-bottom: 8px;
}

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

.scene-upload-preview {
  margin-top: 8px;
}

.scene-upload-preview img {
  max-width: 120px;
  max-height: 80px;
  border-radius: 6px;
  object-fit: cover;
}

/* 剧情模式：按场景 Prompt */
.drama-prompt-header {
  margin-bottom: 12px;
}

.drama-scene-prompts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scene-prompt-card {
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card, #fff);
}

.scene-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-soft, #f8f9fa);
  border-bottom: 1px solid var(--border, #eee);
}

.scene-prompt-id {
  font-weight: 600;
  font-size: 13px;
}

.scene-prompt-info {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary, #999);
}

.scene-prompt-textarea {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border, #eee);
  border-radius: 0;
  padding: 10px 12px;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
  font-family: 'SF Mono', Monaco, monospace;
  box-sizing: border-box;
}

.scene-prompt-textarea:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent, #6366f1);
}

/* 剧情模式：渲染进度 */
.drama-render-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.drama-render-scene {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.3s;
}

.drama-render-scene.pending {
  background: var(--bg-soft, #f8f9fa);
  color: var(--text-secondary, #999);
}

.drama-render-scene.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent, #6366f1);
  font-weight: 600;
}

.drama-render-scene.done {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.drs-id {
  font-weight: 700;
  min-width: 24px;
}

.drs-name {
  flex: 1;
}

.drs-status {
  font-size: 14px;
}

/* 小按钮 */
.btn-tiny {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  background: var(--bg-card, #fff);
  color: var(--text, #333);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tiny:hover {
  background: var(--bg-hover, #f5f5f5);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

/* 动画 */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 文案风格选择器 ========== */
.style-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.style-selector::-webkit-scrollbar {
  height: 4px;
}

.style-selector::-webkit-scrollbar-thumb {
  background: var(--border, #e0e0e0);
  border-radius: 2px;
}

.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  background: var(--bg-card, #fff);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 90px;
  flex-shrink: 0;
}

.style-card:hover {
  border-color: var(--accent, #6366f1);
  background: var(--bg-hover, #f5f5f5);
}

.style-card.active {
  border-color: var(--accent, #6366f1);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 1px var(--accent, #6366f1);
}

.style-icon {
  font-size: 20px;
  line-height: 1;
}

.style-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #333);
  white-space: nowrap;
}

.style-card.active .style-name {
  color: var(--accent, #6366f1);
}

.style-desc {
  font-size: 10px;
  color: var(--text-muted, #999);
  white-space: nowrap;
}
