:root {
  --bg: #0b0d12;
  --surface: #141822;
  --surface-2: #1b2130;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f5f8;
  --text-muted: #98a2b3;
  --accent: #ff4d4f;
  --accent-2: #ff7a45;
  --accent-glow: rgba(255, 77, 79, 0.25);
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
}

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

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
}

.bg-glow-1 {
  top: -160px;
  left: -120px;
  background: #ff4d4f;
}

.bg-glow-2 {
  bottom: -180px;
  right: -120px;
  background: #3b82f6;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 36px 20px 64px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 10px 24px var(--accent-glow);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.health-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.health-badge.ready .dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.health-badge.ready {
  color: #d1fae5;
  border-color: rgba(34, 197, 94, 0.25);
}

.health-badge.error .dot {
  background: var(--danger);
}

.health-badge.error {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.3);
}

.card {
  background: rgba(20, 24, 34, 0.88);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.field-label-sm {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.url-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 6px 8px 6px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.url-input-wrap input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.96rem;
  padding: 8px 0;
}

.url-input-wrap input::placeholder {
  color: #64748b;
}

.input-actions {
  display: flex;
  gap: 4px;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
  background: #252d40;
  border-color: var(--border-strong);
}

.preview-box {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.preview-box img {
  width: 112px;
  height: 63px;
  object-fit: cover;
  border-radius: 8px;
  background: #0f131b;
  flex-shrink: 0;
}

.preview-meta {
  min-width: 0;
  flex: 1;
}

.preview-title {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-sub {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preview-loading {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  color: var(--text-muted);
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.alert-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  font-size: 0.86rem;
}

.format-row {
  margin-top: 20px;
}

.format-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
}

.format-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.format-btn small {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.8;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.format-btn:hover {
  color: var(--text);
}

.format-btn.active {
  background: rgba(255, 77, 79, 0.16);
  color: #fff;
  border-color: rgba(255, 77, 79, 0.65);
}

.options-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.pill:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.pill.active {
  background: rgba(255, 77, 79, 0.16);
  color: #fff;
  border-color: var(--accent);
}

.toggles-group {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 4px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.btn-primary {
  margin-top: 22px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px var(--accent-glow);
  transition: transform 0.12s, opacity 0.15s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.btn-primary svg {
  width: 19px;
  height: 19px;
}

.jobs-section {
  margin-top: 28px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.count-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}

.job-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.job-info {
  display: flex;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.job-thumb {
  width: 76px;
  height: 44px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.job-title {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.job-meta {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.job-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 6px;
}

.job-remove:hover {
  color: var(--text);
  background: var(--surface-2);
}

.progress-wrap {
  margin-top: 14px;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-fill.ready {
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

.progress-fill.error {
  background: var(--danger);
}

.progress-stats {
  margin-top: 7px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.job-ready-bar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.job-ready-bar audio {
  flex: 1;
  min-width: 220px;
  height: 38px;
}

.job-ready-bar.video-ready {
  flex-direction: column;
  align-items: stretch;
}

.job-ready-bar video {
  width: 100%;
  max-height: 360px;
  border-radius: 10px;
  background: #000;
}

.job-ready-bar.video-ready .btn-download {
  align-self: flex-end;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  background: #22c55e;
  color: #052e16;
  font-weight: 700;
  font-size: 0.86rem;
  text-decoration: none;
  transition: filter 0.15s;
  flex-shrink: 0;
}

.btn-download:hover {
  filter: brightness(1.08);
}

.job-error-msg {
  margin-top: 10px;
  font-size: 0.84rem;
  color: #fca5a5;
}

.hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .preview-box {
    flex-direction: column;
    align-items: flex-start;
  }
  .preview-box img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}
