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

:root {
  --bg: #0e0e11;
  --surface: #18181c;
  --border: #2a2a32;
  --accent: #7c6ff7;
  --accent-hover: #9b96f9;
  --text: #e8e8f0;
  --muted: #7a7a8e;
  --error: #f0646e;
  --success: #4ade80;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem 4rem;
}

header { text-align: center; margin-bottom: 2.5rem; }
.logo { font-size: 2rem; font-weight: 700; letter-spacing: -0.04em; }
.logo span { color: var(--accent); }
.tagline { color: var(--muted); margin-top: 0.4rem; font-size: 0.95rem; }

main { width: 100%; max-width: 580px; }

/* Tabs */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--muted); font-size: 0.95rem;
  padding: 0.6rem 1.2rem; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 0.15s, border-color 0.15s;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-content { display: flex; flex-direction: column; gap: 1rem; }
.tab-content.hidden { display: none; }

/* Dropzone */
#dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}
#dropzone:hover, #dropzone.dragover { border-color: var(--accent); background: rgba(124,111,247,0.05); }
.drop-icon { font-size: 2.5rem; margin-bottom: 0.5rem; color: var(--accent); }
#dropzone p { color: var(--muted); font-size: 0.9rem; }
#dropzone p:first-of-type { color: var(--text); font-size: 1rem; margin-bottom: 0.25rem; }

/* File list (multi) */
#file-list { display: flex; flex-direction: column; gap: 0.5rem; }
.file-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.65rem 1rem;
}
.file-item-name { flex: 1; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-type { font-size: 0.75rem; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.15rem 0.5rem; }
.file-item-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0.1rem 0.3rem; transition: color 0.15s; }
.file-item-remove:hover { color: var(--error); }
.file-add-more {
  text-align: center; font-size: 0.85rem; color: var(--accent); cursor: pointer;
  padding: 0.5rem; border: 1px dashed var(--border); border-radius: var(--radius);
  transition: border-color 0.2s;
}
.file-add-more:hover { border-color: var(--accent); }

.muted-tag { font-size: 0.8rem; color: var(--muted); font-weight: 400; }

/* URL textarea */
#urlInput {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem;
  padding: 0.85rem 1rem; outline: none; resize: vertical; min-height: 90px;
  transition: border-color 0.2s; font-family: inherit; line-height: 1.5;
}
#urlInput:focus { border-color: var(--accent); }
#urlInput::placeholder { color: var(--muted); }
.url-hint { font-size: 0.8rem; color: var(--muted); }

/* Format / quality row */
.format-row { display: flex; align-items: center; gap: 1rem; }
.format-row label { font-size: 0.9rem; color: var(--muted); white-space: nowrap; }
.format-row select {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.9rem;
  padding: 0.55rem 0.75rem; outline: none; cursor: pointer;
}
.format-row select:focus { border-color: var(--accent); }

/* Buttons */
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; padding: 0.85rem 1.5rem; cursor: pointer;
  transition: background 0.2s, opacity 0.2s; text-decoration: none;
  text-align: center; display: inline-block;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--muted); font-size: 0.9rem; padding: 0.75rem 1.25rem; cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }

.btn-sm {
  font-size: 0.82rem; padding: 0.45rem 0.9rem;
  border-radius: 8px;
}

/* Progress section */
#progress-section { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.job-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.job-card-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.job-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 75%; color: var(--text); }
.job-card-status {
  font-size: 0.75rem; padding: 0.2rem 0.55rem; border-radius: 99px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.status-pending, .status-downloading, .status-processing, .status-submitting { background: rgba(124,111,247,0.15); color: var(--accent); }
.status-done { background: rgba(74,222,128,0.12); color: var(--success); }
.status-error { background: rgba(240,100,110,0.12); color: var(--error); }

.progress-label { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); }
.progress-bar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; width: 0%; transition: width 0.4s ease; }
.progress-fill.done { background: var(--success); }
.progress-fill.error-fill { background: var(--error); }

.job-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.job-error { font-size: 0.82rem; color: var(--error); }
#global-actions { display: flex; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; }

/* History */
#history-list { display: flex; flex-direction: column; gap: 0.75rem; }
.history-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.85rem 1rem; display: flex; justify-content: space-between;
  align-items: center; gap: 1rem; font-size: 0.88rem;
}
.history-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.history-item-meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.2rem; }
.history-badge {
  font-size: 0.75rem; padding: 0.18rem 0.5rem; border-radius: 99px;
  font-weight: 600; text-transform: uppercase; white-space: nowrap;
}
.badge-done { background: rgba(74,222,128,0.12); color: var(--success); }
.badge-error { background: rgba(240,100,110,0.12); color: var(--error); }
.badge-processing, .badge-pending, .badge-downloading { background: rgba(124,111,247,0.12); color: var(--accent); }

/* Preview modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 720px; width: 100%; max-height: 85vh; overflow: auto;
  position: relative; padding: 1.5rem;
}
.modal-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
#preview-content { display: flex; flex-direction: column; gap: 1rem; align-items: center; }
#preview-content audio, #preview-content video { width: 100%; border-radius: 8px; }
#preview-content img { max-width: 100%; max-height: 60vh; border-radius: 8px; object-fit: contain; }
.preview-filename { font-size: 0.85rem; color: var(--muted); word-break: break-all; text-align: center; }

.muted-center { text-align: center; color: var(--muted); padding: 2rem 0; font-size: 0.9rem; }
.error-box { color: var(--error); font-size: 0.9rem; padding: 0.75rem 1rem; background: rgba(240,100,110,0.08); border: 1px solid rgba(240,100,110,0.3); border-radius: var(--radius); }
.hidden { display: none !important; }
