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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-hover: #242424;
  --border: #2a2a2a;
  --text: #e4e4e4;
  --text-muted: #888;
  --primary: #6366f1;
  --primary-hover: #5558e6;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
}

.login-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.google-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #333;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: box-shadow 0.2s;
}

.google-login-btn:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* Main */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
}

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

/* Buttons */
.btn {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  width: 100%;
  font-weight: 500;
}

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

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

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

/* Task Card */
.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.task-card:last-child {
  margin-bottom: 0;
}

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

.task-prompt {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}

.task-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-queued { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-generating { background: rgba(99,102,241,0.15); color: var(--primary); }
.status-completed { background: rgba(34,197,94,0.15); color: var(--success); }
.status-error { background: rgba(239,68,68,0.15); color: var(--error); }
.status-pending { background: rgba(136,136,136,0.15); color: var(--text-muted); }

/* Video Preview */
.video-preview {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.video-preview video {
  width: 100%;
  display: block;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

/* Section description */
.section-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* Image result */
.img-result {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

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

.img-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
}

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

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

.toggle-label input { display: none; }

.toggle-switch {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-switch {
  background: var(--primary);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(18px);
}

.toggle-hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}

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

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.upload-icon {
  font-size: 28px;
  font-weight: 300;
  color: var(--primary);
  line-height: 1;
}

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

.upload-preview {
  position: relative;
}

.upload-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  display: block;
  background: #000;
}

.upload-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-remove:hover {
  background: var(--error);
}

.upload-or {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin: 8px 0;
}

/* Credit badge */
.credit-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

.credit-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* Cost display */
.cost-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 8px;
  font-size: 14px;
}

#cost-value {
  font-weight: 600;
  color: var(--primary);
  font-size: 15px;
}

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

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: var(--surface-hover);
  color: var(--text);
}

.btn-download::before {
  content: '\2913';
  font-size: 16px;
}

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

/* Progress bar for generating state */
.generating-progress {
  margin-top: 8px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.generating-progress::after {
  content: '';
  display: block;
  height: 100%;
  width: 30%;
  background: var(--primary);
  border-radius: 2px;
  animation: progress 1.5s ease-in-out infinite;
}

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

/* Type badge */
.type-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(99,102,241,0.1);
  color: var(--primary);
  margin-right: 8px;
}

/* Responsive */
@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header h1 {
    font-size: 16px;
  }

  .header-right {
    gap: 8px;
  }

  #user-name {
    display: none;
  }

  .card {
    padding: 16px;
  }

  .task-header {
    flex-direction: column;
    gap: 6px;
  }
}
