:root {
  --bg: #0d0f14;
  --card: #161920;
  --card-border: #262b36;
  --text: #e8eaf0;
  --muted: #8b93a3;
  --accent: #ff3b47;
  --accent-2: #ff7a45;
  --ok: #3ecf7a;
  --warn: #e8b339;
  --err: #ff5c69;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1100px 500px at 50% -140px, rgba(255, 59, 71, 0.13), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap { max-width: 780px; margin: 0 auto; padding: 40px 20px 60px; }

/* header ------------------------------------------------------------------ */
.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { margin: 10px 0 4px; font-size: 28px; letter-spacing: -0.5px; }
.hero .sub { margin: 0; color: var(--muted); font-size: 14px; }
.logo { display: inline-block; }

/* cards ------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* inputs ------------------------------------------------------------------ */
.url-row { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"], input[type="url"], input[type="password"], input[type="email"], select {
  background: #0f1218;
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
#url { flex: 1; min-width: 200px; }

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.hint b { color: var(--text); font-weight: 600; }

.btn {
  background: #22262f;
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
}
.btn.big { width: 100%; margin-top: 14px; padding: 13px; font-size: 16px; }
.btn.small { padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: transparent; }

/* preview ----------------------------------------------------------------- */
.preview { display: flex; gap: 14px; align-items: center; }
.preview img {
  width: 168px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  background: #0f1218;
  flex-shrink: 0;
}
.p-title { font-weight: 700; font-size: 16px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-channel { color: var(--muted); font-size: 13px; margin-top: 4px; }
.p-extra { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* mode radios --------------------------------------------------------------- */
.mode-row { display: flex; gap: 18px; margin: 14px 2px 2px; flex-wrap: wrap; }
.radio { display: flex; gap: 7px; align-items: center; font-size: 14px; cursor: pointer; }
.radio input { accent-color: var(--accent); }

/* controls ----------------------------------------------------------------- */
.controls { display: flex; gap: 10px; margin-top: 14px; }
.seg {
  display: flex;
  background: #0f1218;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.seg button.active { background: #2a2f3a; color: var(--text); }
select { flex: 1; min-width: 0; }

/* jobs --------------------------------------------------------------------- */
.jobs { display: flex; flex-direction: column; gap: 12px; }
.job {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 15px 18px;
}
.job-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.job-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #22262f;
  color: var(--muted);
}
.badge.downloading { background: rgba(255, 59, 71, 0.15); color: var(--accent); }
.badge.completed { background: rgba(62, 207, 122, 0.15); color: var(--ok); }
.badge.error, .badge.cancelled { background: rgba(255, 92, 105, 0.12); color: var(--err); }

.bar {
  height: 8px;
  background: #0f1218;
  border-radius: 999px;
  margin: 12px 0 10px;
  overflow: hidden;
}
.fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.fill.indeterminate {
  width: 35%;
  animation: slide 1.1s ease-in-out infinite alternate;
}
@keyframes slide { from { margin-left: 0; } to { margin-left: 65%; } }

.job-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.job-detail { color: var(--muted); font-size: 13px; }
.job-actions { display: flex; gap: 8px; }
.job-note { margin-top: 10px; color: var(--warn); font-size: 13px; }
.job-err { margin-top: 10px; color: var(--err); font-size: 13px; word-break: break-word; }

/* misc ---------------------------------------------------------------------- */
.error { color: var(--err); font-size: 14px; margin-top: 10px; word-break: break-word; }
.hidden { display: none !important; }
.footer { text-align: center; color: #565d6b; font-size: 12.5px; margin-top: 30px; }

/* login modal ---------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(5, 6, 9, 0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px;
  width: min(360px, 90vw);
  text-align: center;
}
.modal-card.left {
  text-align: left;
  width: min(440px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
}
.modal-card h2 { margin: 0 0 4px; font-size: 20px; }
.modal-card .sub { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.modal-card input { width: 100%; margin-bottom: 12px; text-align: center; }
.modal-card.left input { text-align: left; }

.cookie-status {
  font-size: 13.5px;
  background: #0f1218;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  color: var(--muted);
}
.cookie-status.ok { color: var(--ok); border-color: rgba(62, 207, 122, 0.35); }
.file-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.file-row input[type="file"] {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  background: #0f1218;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 8px;
}
.file-row input[type="file"]::file-selector-button {
  background: #22262f;
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
  font-size: 12.5px;
}
.instructions {
  font-size: 13px;
  color: var(--muted);
  background: #0f1218;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  line-height: 1.5;
}
.instructions b { color: var(--text); }
.instructions ol { margin: 8px 0 4px; padding-left: 20px; }
.instructions li { margin-bottom: 4px; }

.footer a { color: var(--muted); text-decoration: underline; }

@media (max-width: 560px) {
  .preview { flex-direction: row; }
  .preview img { width: 120px; }
  .controls { flex-direction: column; }
}
