:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --accent: #06b6d4;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.app { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }

.header { text-align: center; padding: 1.5rem 0 1.25rem; }
.back-link {
  display: inline-block; color: var(--text-secondary); text-decoration: none;
  font-size: 0.85rem; margin-bottom: 0.75rem;
}
.back-link:hover { color: var(--primary); }
.header-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 0.25rem 0.65rem; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary-bg), #e0f2fe);
  color: var(--primary); margin-bottom: 0.5rem;
}
.header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 0.35rem;
}
.tagline { color: var(--text-secondary); font-size: 0.88rem; }

.alert {
  padding: 0.85rem 1rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem;
}
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

.layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.35rem; box-shadow: var(--shadow);
}
.panel-title {
  font-size: 0.95rem; font-weight: 700; margin-bottom: 1.1rem;
  padding-bottom: 0.65rem; border-bottom: 1px solid var(--border);
}

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text); }
.req { color: var(--danger); }

input[type="text"], input[type="url"], textarea, select {
  width: 100%; padding: 0.65rem 0.8rem; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 0.88rem; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
textarea { resize: vertical; min-height: 88px; }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; margin-bottom: 1rem; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.scene-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
@media (max-width: 480px) { .scene-grid { grid-template-columns: 1fr; } }

.scene-card {
  padding: 0.7rem 0.8rem; border: 1.5px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: all 0.2s; background: var(--bg);
}
.scene-card:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.scene-card.active {
  border-color: var(--primary); background: var(--primary-bg);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
.scene-card strong { display: block; font-size: 0.85rem; margin-bottom: 0.15rem; }
.scene-card span { font-size: 0.72rem; color: var(--text-secondary); line-height: 1.4; }

.link-btn {
  margin-top: 0.4rem; padding: 0; border: none; background: none;
  color: var(--primary); font-size: 0.8rem; cursor: pointer; font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 1.25rem;
  text-align: center; cursor: pointer; transition: all 0.2s; background: var(--bg);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: var(--primary-bg); }
.dz-icon { font-size: 1.5rem; display: block; margin-bottom: 0.35rem; }
.drop-zone span { display: block; font-size: 0.85rem; color: var(--text); }
.drop-zone small { display: block; font-size: 0.72rem; color: var(--text-light); margin-top: 0.25rem; }

.url-input { margin-top: 0.5rem; }

.img-preview {
  position: relative; margin-top: 0.65rem; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); max-height: 180px;
}
.img-preview img { width: 100%; height: 180px; object-fit: contain; background: #f1f5f9; }
.img-clear {
  position: absolute; top: 8px; right: 8px; padding: 0.25rem 0.55rem;
  border: none; border-radius: 6px; background: rgba(0,0,0,0.55); color: white;
  font-size: 0.72rem; cursor: pointer;
}

.checkbox-row {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem;
  color: var(--text-secondary); margin-bottom: 1rem; cursor: pointer;
}

.btn-primary {
  width: 100%; padding: 0.85rem; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: white; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,70,229,0.35); }
.btn-primary:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.55rem 1rem; border: 1.5px solid var(--border); border-radius: 8px;
  background: white; color: var(--text); font-size: 0.82rem; text-decoration: none;
  cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: white;
  border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint { font-size: 0.75rem; color: var(--text-light); margin-top: 0.65rem; line-height: 1.5; }

.status-card {
  text-align: center; padding: 2rem 1rem; border-radius: 12px;
  background: linear-gradient(180deg, var(--primary-bg) 0%, white 100%);
  border: 1px solid var(--border); min-height: 220px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.status-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.status-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.35rem; }
.status-desc { font-size: 0.82rem; color: var(--text-secondary); max-width: 280px; }

.progress-wrap {
  width: 100%; max-width: 260px; height: 6px; background: var(--border);
  border-radius: 999px; margin-top: 1.25rem; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}

.video-wrap { margin-top: 1rem; }
.video-wrap video {
  width: 100%; border-radius: 12px; background: #0f172a;
  border: 1px solid var(--border);
}
.video-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }

.prompt-used {
  margin-top: 1rem; padding: 0.85rem; background: var(--bg);
  border-radius: 10px; border: 1px solid var(--border);
}
.prompt-used label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }
.prompt-used p { font-size: 0.82rem; color: var(--text); margin-top: 0.35rem; line-height: 1.6; }

.footer {
  text-align: center; margin-top: 2rem; font-size: 0.8rem; color: var(--text-light);
}
.footer a { color: var(--primary); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer span { margin: 0 0.35rem; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1e293b; color: white; padding: 0.65rem 1.25rem; border-radius: 999px;
  font-size: 0.85rem; opacity: 0; transition: all 0.3s; z-index: 9999; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.status-card.running .status-icon { animation: pulse 1.5s ease infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.status-card.success { background: linear-gradient(180deg, #ecfdf5 0%, white 100%); }
.status-card.failed { background: linear-gradient(180deg, #fef2f2 0%, white 100%); }
