:root {
  --bg: #0b0b10;
  --bg-raised: #14141c;
  --bg-sunken: #0f0f15;
  --border: #262634;
  --border-strong: #363648;
  --text: #ececf3;
  --text-muted: #9a9ab0;
  --text-faint: #6c6c82;
  --accent: #7c5cff;
  --accent-2: #ff4d8d;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --ok: #32d38a;
  --warn: #ffb547;
  --bad: #ff5d6c;
  --youtube: #ff3b3b;
  --twitch: #9b6bff;
  --tiktok: #25f4ee;
  --kick: #53fc18;
  --upload: #9a9ab0;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6fa;
    --bg-raised: #ffffff;
    --bg-sunken: #efeff5;
    --border: #e2e2ec;
    --border-strong: #cfcfdd;
    --text: #15151d;
    --text-muted: #5d5d72;
    --text-faint: #8a8aa0;
    --accent-soft: rgba(124, 92, 255, 0.1);
    --tiktok: #0fb5b0;
    --kick: #2fb30a;
    --shadow: 0 10px 30px rgba(20, 20, 40, 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px 80px; }
#app:focus { outline: none; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.brand-mark svg { width: 26px; height: 26px; transform: translateY(6px); }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: #fff; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.brand-sub { color: var(--text-muted); font-size: 14px; }
.topbar-status { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-raised);
  font-size: 12.5px; color: var(--text-muted); white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill.warn .dot { background: var(--warn); }
.pill.bad .dot { background: var(--bad); }

/* ---------- hero / intake */
.hero { padding: 56px 0 28px; text-align: center; }
.hero h1 {
  margin: 0 0 10px; font-size: clamp(30px, 5vw, 48px); line-height: 1.08; letter-spacing: -0.035em; font-weight: 800;
}
.hero h1 .grad {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 0 auto; max-width: 620px; color: var(--text-muted); font-size: 16.5px; }

.intake {
  margin: 28px auto 0; max-width: 820px; text-align: left;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 16px;
}
.url-row { display: flex; gap: 10px; }
.url-field {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px;
  transition: border-color .15s;
}
.url-field:focus-within { border-color: var(--accent); }
.url-field input { flex: 1; border: 0; background: transparent; padding: 14px 0; font-size: 16px; outline: none; min-width: 0; }
.platform-chips { display: flex; gap: 6px; margin: 12px 2px 0; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-faint); transition: all .15s;
}
.chip.on { color: var(--bg); border-color: transparent; }
.chip.on[data-p="youtube"] { background: var(--youtube); color: #fff; }
.chip.on[data-p="twitch"] { background: var(--twitch); color: #fff; }
.chip.on[data-p="tiktok"] { background: var(--tiktok); }
.chip.on[data-p="kick"] { background: var(--kick); }
.chip-hint { font-size: 12.5px; color: var(--text-faint); margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong); background: var(--bg-raised);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px;
  text-decoration: none; white-space: nowrap; transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary {
  border: 0; color: #fff; padding: 0 22px; font-size: 15.5px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg-sunken); }
.btn.danger:hover { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; }

details.options { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
details.options summary {
  cursor: pointer; color: var(--text-muted); font-size: 13.5px; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 6px; user-select: none;
}
details.options summary::before { content: "▸"; transition: transform .15s; }
details.options[open] summary::before { transform: rotate(90deg); }
.options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin-top: 14px; }
.field label, .field .label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field.wide { grid-column: 1 / -1; }
.field input[type=text], .field select {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg-sunken); outline: none;
}
.field input[type=text]:focus, .field select:focus { border-color: var(--accent); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg-sunken); padding: 3px; border-radius: 10px; border: 1px solid var(--border); }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 6px 8px; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--text-muted); white-space: nowrap;
}
.seg button.on { background: var(--bg-raised); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); font-weight: 600; }
.toggles { display: flex; gap: 18px; flex-wrap: wrap; padding-top: 4px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.dropzone {
  display: block; margin-top: 14px; padding: 12px; border: 1.5px dashed var(--border-strong); border-radius: 12px;
  text-align: center; color: var(--text-muted); font-size: 13.5px; cursor: pointer; transition: all .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.dropzone input { display: none; }
.upload-progress { height: 4px; background: var(--bg-sunken); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.upload-progress div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- sections and job list */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 44px 0 12px; }
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }

.job-list { display: grid; gap: 10px; }
.job-row {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-raised);
  text-decoration: none; transition: border-color .15s, transform .1s;
}
.job-row:hover { border-color: var(--border-strong); }
.thumb {
  width: 112px; aspect-ratio: 16 / 9; border-radius: 9px; background: var(--bg-sunken) center / cover no-repeat;
  display: grid; place-items: center; color: var(--text-faint); font-size: 12px; overflow: hidden;
}
.job-main { min-width: 0; }
.job-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-sub { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.job-side { display: flex; align-items: center; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase; border: 1px solid currentColor;
}
.badge.youtube { color: var(--youtube); } .badge.twitch { color: var(--twitch); }
.badge.tiktok { color: var(--tiktok); } .badge.kick { color: var(--kick); } .badge.upload { color: var(--upload); }
.status { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--bg-sunken); color: var(--text-muted); }
.status.done { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.status.failed { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.status.active { color: var(--accent); background: var(--accent-soft); }
.bar { height: 5px; border-radius: 5px; background: var(--bg-sunken); overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.empty { padding: 28px; text-align: center; color: var(--text-faint); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- job page */
.back { display: inline-flex; margin: 24px 0 8px; color: var(--text-muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }
.job-header { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: center; margin-bottom: 18px; }
.job-header .thumb { width: 220px; }
.job-header h1 { margin: 6px 0 6px; font-size: clamp(20px, 3vw, 28px); letter-spacing: -0.02em; line-height: 1.2; }
.meta-line { display: flex; gap: 12px; flex-wrap: wrap; color: var(--text-muted); font-size: 14px; align-items: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.progress-card { margin-bottom: 16px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.step { font-size: 13px; color: var(--text-faint); display: flex; align-items: center; gap: 8px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; border: 1px solid var(--border-strong); }
.step.done { color: var(--text-muted); } .step.done .n { background: var(--ok); border-color: var(--ok); color: #06150d; }
.step.now { color: var(--text); font-weight: 600; } .step.now .n { border-color: var(--accent); color: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--accent-soft); } }
.detail { font-size: 13.5px; color: var(--text-muted); margin-top: 8px; display: flex; justify-content: space-between; gap: 12px; }
.error-card { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); margin-bottom: 16px; }
.error-card pre { white-space: pre-wrap; margin: 8px 0 12px; font-size: 13px; color: var(--bad); font-family: ui-monospace, monospace; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 19px; font-weight: 750; margin-top: 2px; letter-spacing: -0.01em; }
.stat .s { font-size: 12.5px; color: var(--text-muted); }

.timeline-card { margin-bottom: 18px; }
.timeline-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.timeline-head h3 { margin: 0; font-size: 15px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.timeline svg { width: 100%; height: 96px; display: block; }
.timeline .clip-mark { fill: var(--accent); opacity: .22; cursor: pointer; }
.timeline .clip-mark:hover { opacity: .45; }
.timeline .axis { font-size: 11px; fill: var(--text-faint); }

.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.clip { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; scroll-margin-top: 80px; }
.clip.flash { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); } }
.clip video { width: 100%; aspect-ratio: 9 / 16; background: #000; display: block; object-fit: cover; }
.clip-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.clip-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.score { font-weight: 800; font-size: 12.5px; padding: 2px 8px; border-radius: 7px; color: #0b0b10; }
.score.hi { background: var(--ok); } .score.mid { background: var(--warn); } .score.lo { background: var(--border-strong); color: var(--text); }
.tag { font-size: 11.5px; color: var(--text-muted); border: 1px solid var(--border); padding: 1px 7px; border-radius: 6px; }
.clip h3 { margin: 0; font-size: 15.5px; line-height: 1.3; letter-spacing: -0.01em; }
.clip .hook { font-size: 13px; color: var(--text); font-weight: 600; }
.clip .reason { font-size: 13px; color: var(--text-muted); }
.clip .sig { font-size: 12px; color: var(--accent); }
.clip-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.clip details { font-size: 13px; color: var(--text-muted); }
.yt-status { line-height: 1.6; }
.clip .strip { width: 100%; border-radius: 6px; display: block; background: var(--bg-sunken); }
.yt-status a { color: var(--accent); }
a.pill { text-decoration: none; }
a.pill:hover { border-color: var(--text-faint); color: var(--text); }
.clip details summary { cursor: pointer; color: var(--text-faint); font-size: 12.5px; }
.clip details p { margin: 6px 0 0; max-height: 160px; overflow: auto; }

.rerun { margin: 22px 0 0; }

/* ---------- toasts */
.toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--bg-raised); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; }
.toast.bad { border-left-color: var(--bad); }

@media (max-width: 720px) {
  .container { padding: 0 16px 60px; }
  .hero { padding-top: 34px; }
  .url-row { flex-direction: column; }
  .btn.primary { padding: 13px; }
  .options-grid { grid-template-columns: 1fr; }
  .job-row { grid-template-columns: 84px minmax(0, 1fr); }
  .job-row .thumb { width: 84px; }
  .job-side { grid-column: 1 / -1; justify-content: space-between; }
  .job-header { grid-template-columns: 1fr; }
  .job-header .thumb { width: 100%; }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .chip-hint { margin-left: 0; width: 100%; }
}
