:root {
  --bg: #0b0d14;
  --bg-elevated: #121522;
  --card: #161a29;
  --card-border: #262b40;
  --text: #eef0f7;
  --text-muted: #9aa2b8;
  --accent: #7c5cff;
  --accent-2: #ff4d8d;
  --accent-gradient: linear-gradient(135deg, #7c5cff 0%, #ff4d8d 100%);
  --success: #35d07f;
  --error: #ff5c72;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --max-width: 1120px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, 0.18), transparent),
    radial-gradient(1000px 500px at 100% 0%, rgba(255, 77, 141, 0.14), transparent),
    var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

a { color: inherit; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--card-border);
  background: rgba(11, 13, 20, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-gradient);
  font-size: 0.95rem;
  color: white;
}

.site-nav {
  display: flex;
  gap: 24px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.site-nav a { text-decoration: none; }
.site-nav a:hover { color: var(--text); }

/* Ad slots */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02) 10px, rgba(255,255,255,0.04) 10px, rgba(255,255,255,0.04) 20px);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-sm);
}

.ad-slot--header {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 60px;
}

.ad-slot--infeed {
  height: 100px;
  margin: 28px 0;
}

.ad-slot--sidebar {
  height: 250px;
  margin-bottom: 20px;
}

/* Hero */
.hero {
  text-align: center;
  padding: 64px 24px 32px;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 0 auto 32px;
  max-width: 560px;
}

.url-form {
  display: flex;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
}

#url-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}

#url-input:focus {
  border-color: var(--accent);
}

.form-error {
  color: var(--error);
  max-width: 640px;
  margin: 14px auto 0;
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35);
}

.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 26px rgba(124, 92, 255, 0.5); }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  padding: 8px 14px;
  font-size: 0.85rem;
}

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

.btn-danger-ghost {
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(255, 92, 114, 0.4);
  padding: 6px 12px;
  font-size: 0.8rem;
}

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

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

/* Layout grid */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 860px) {
  .content-grid { grid-template-columns: 1fr; }
  .content-side { order: 2; }
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Result card */
.result-card {
  display: flex;
  gap: 20px;
  padding: 20px;
  margin-top: 8px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .result-card { flex-direction: column; }
}

.result-media {
  position: relative;
  flex-shrink: 0;
  width: 260px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}

@media (max-width: 640px) {
  .result-media { width: 100%; }
}

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

.duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.result-body {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-size: 1.15rem;
  margin: 4px 0 4px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.result-uploader {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.playlist-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Playlist card */
.playlist-card {
  padding: 20px;
  margin-top: 8px;
  animation: fadeIn 0.25s ease;
}

.playlist-card-header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.playlist-card-header img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #000;
  flex-shrink: 0;
}

.playlist-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}

.select-all-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.playlist-truncated-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.playlist-entries {
  list-style: none;
  margin: 0 0 20px;
  padding: 6px;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playlist-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
}

.playlist-entry:hover {
  background: rgba(255, 255, 255, 0.03);
}

.playlist-entry input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.playlist-entry img {
  width: 64px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  flex-shrink: 0;
}

.playlist-entry-title {
  font-size: 0.88rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-entry-duration {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.mode-toggle {
  display: inline-flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--card-border);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.mode-btn.active {
  background: var(--accent-gradient);
  color: white;
}

.option-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.option-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 130px;
}

.option-field select {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
}

.option-field select:focus { border-color: var(--accent); }

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Queue */
.queue-section {
  margin-top: 8px;
}

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

.queue-header h2 {
  font-size: 1.2rem;
  margin: 0;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.queue-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius);
}

.queue-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: fadeIn 0.2s ease;
}

.queue-item img {
  width: 72px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #000;
}

.queue-item-main {
  flex: 1;
  min-width: 0;
}

.queue-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.queue-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 4px;
  transition: width 0.2s ease;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: capitalize;
}

.status-queued { background: rgba(154, 162, 184, 0.15); color: var(--text-muted); }
.status-processing { background: rgba(124, 92, 255, 0.18); color: #b8a6ff; }
.status-completed { background: rgba(53, 208, 127, 0.15); color: var(--success); }
.status-error { background: rgba(255, 92, 114, 0.15); color: var(--error); }
.status-canceled { background: rgba(154, 162, 184, 0.15); color: var(--text-muted); }
.status-expired { background: rgba(255, 92, 114, 0.12); color: var(--error); }

.queue-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* How it works */
.how-it-works {
  margin: 48px 0 24px;
  padding: 24px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
}

.how-it-works h2 {
  margin-top: 0;
  font-size: 1.2rem;
}

.how-it-works ol {
  color: var(--text-muted);
  padding-left: 20px;
}

.how-it-works li { margin-bottom: 6px; }
.how-it-works strong { color: var(--text); }

.disclaimer {
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--card-border);
  padding-top: 12px;
  margin-top: 16px;
  margin-bottom: 0;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--card-border);
  margin-top: 48px;
  padding: 24px 0 40px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.toast.toast-error { border-color: rgba(255, 92, 114, 0.5); color: var(--error); }
.toast.toast-success { border-color: rgba(53, 208, 127, 0.5); color: var(--success); }
