:root {
  --bg: #f6f6f9;
  --card: #ffffff;
  --text: #17171c;
  --muted: #6b6b78;
  --line: #e3e3ea;
  --accent: #6d5dfc;
  --accent-ink: #ffffff;
  --accent-soft: #6d5dfc1f;
  --ok: #1f9d55;
  --warn: #b7791f;
  --err: #d64545;
  --err-soft: #d6454514;
  --skel: #ececf2;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f13;
    --card: #18181e;
    --text: #ececf1;
    --muted: #9a9aa8;
    --line: #2a2a33;
    --accent: #8b7dff;
    --accent-ink: #0f0f13;
    --accent-soft: #8b7dff26;
    --ok: #48c78e;
    --warn: #e0a84f;
    --err: #ff6b6b;
    --err-soft: #ff6b6b1a;
    --skel: #24242c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main, .top { max-width: 680px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; align-items: center; justify-content: space-between; padding-top: 28px; padding-bottom: 12px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

input, select, button, .primary, .ghost { font: inherit; color: inherit; }
input[type=url], input[type=password], input[type=text], select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
  min-width: 0;
}
input:focus-visible, select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

button, .primary, .ghost { cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: 10px 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:disabled { opacity: .5; cursor: default; }
.ghost { background: transparent; border-color: var(--line); }
.ghost:hover { background: var(--accent-soft); }
.danger { color: var(--err); }
.big { width: 100%; padding: 13px; font-size: 16px; margin-top: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 16px; }

.who { background: var(--card); border: 1px solid var(--line); font-size: 13.5px; padding: 6px 12px; border-radius: 999px; }
.who .nas { color: var(--accent); font-weight: 600; margin-left: 4px; }

.url-row { display: flex; gap: 8px; }
.url-row input { font-size: 16px; }

.error { color: var(--err); background: var(--err-soft); padding: 10px 12px; border-radius: 10px; margin-top: 12px; }
.error details { margin-top: 4px; color: var(--muted); }

.preview { display: flex; gap: 12px; margin-top: 14px; align-items: center; }
.thumb { flex: none; width: 120px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--skel); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sm { width: 76px; }
.meta { min-width: 0; flex: 1; }
.title { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.skeleton .bar { height: 12px; border-radius: 6px; background: var(--skel); margin: 6px 0; }
.skeleton .w80 { width: 80%; } .skeleton .w40 { width: 40%; }
.skeleton .thumb, .skeleton .bar { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.presets button { flex-direction: column; gap: 0; background: var(--bg); border-color: var(--line); padding: 9px 4px; font-weight: 600; }
.presets button[aria-checked=true] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.size-block { margin-top: 16px; }
.size-head { display: flex; justify-content: space-between; font-size: 13.5px; }
.size-head output { font-weight: 600; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 8px 0 0; }

.pick { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.pick-label { font-weight: 600; }
.pick-label .warn { color: var(--warn); font-weight: 500; font-size: 13px; }

details > summary { cursor: pointer; color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.adv { display: grid; gap: 10px; margin-top: 10px; font-size: 13.5px; }
.adv label { display: grid; gap: 4px; }
.check { display: flex !important; gap: 8px; align-items: center; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.jobs-wrap { margin-bottom: 24px; }
.foot { text-align: center; font-size: 13px; margin-bottom: 40px; }
.foot a { color: var(--accent); }
.jobs-head { display: flex; align-items: center; gap: 8px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-bottom: 8px; }
.live.on { background: var(--ok); }
.small-btn { margin: 0 0 8px auto; padding: 4px 10px; font-size: 13px; }
.playlist { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; align-items: flex-start !important; }
.playlist input { margin-top: 2px; flex: none; }
.playlist b { font-weight: 600; word-break: break-word; }
.jobs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.empty { text-align: center; padding: 24px 0; }
.job { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; align-items: flex-start; }
.job-main { flex: 1; min-width: 0; }
.job-top { min-width: 0; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.job-title { font-weight: 600; flex: 1; }
.marquee { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.marquee.run { text-overflow: clip; }
.marquee.run > span { display: inline-block; animation: marquee var(--dur) ease-in-out infinite alternate; }
@keyframes marquee { 0%, 20% { transform: translateX(0); } 80%, 100% { transform: translateX(calc(-1 * var(--shift))); } }
@media (prefers-reduced-motion: reduce) { .marquee.run { text-overflow: ellipsis; } .marquee.run > span { display: inline; animation: none; } }

.job-sub { font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.badge { flex: none; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.badge.ready, .badge.done, .badge.saved { color: var(--ok); }
.badge.failed { color: var(--err); }
.badge.fetching, .badge.processing { color: var(--accent); }
.progress { height: 6px; border-radius: 3px; background: var(--skel); overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.progress.indef > div { width: 30% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.progress.hide { display: none; }
.job-err { margin-top: 6px; color: var(--err); font-size: 13.5px; }
.job-err details summary { margin-top: 2px; font-size: 12.5px; }
.job-err code { display: block; color: var(--muted); font-size: 12px; white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
.job-actions { display: flex; gap: 6px; align-items: center; }
.job-actions > * { padding: 7px 12px; font-size: 13.5px; }
.job-actions .x { padding: 7px 10px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); width: min(440px, calc(100vw - 32px)); padding: 20px; }
dialog::backdrop { background: #0006; }
dialog label { display: grid; gap: 4px; margin-top: 12px; font-size: 13.5px; }
.cookies { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.cookies h3 { font-size: 14px; margin: 0 0 4px; }
.cookies p { margin: 4px 0; }
.small { font-size: 12.5px; }
.cookies input[type=file] { flex: 1; min-width: 0; font-size: 12.5px; }
.fix-cookies { margin-top: 6px; padding: 5px 10px; font-size: 13px; }

@media (max-width: 520px) {
  .thumb { width: 96px; }
  .thumb.sm { display: none; }
  .presets small { font-size: 10.5px; }
  .job { flex-wrap: wrap; }
  .job-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
}
