:root {
  --bg: #f6f7fb; --card: #ffffff; --text: #0f172a; --muted: #64748b; --border: #e2e8f0;
  --accent: #4f46e5; --accent-text: #ffffff; --ok: #15803d; --err: #b91c1c; --warn: #a16207;
  --err-bg: #fef2f2; --warn-bg: #fefce8; --info-bg: #eef2ff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --card: #131c31; --text: #e2e8f0; --muted: #94a3b8; --border: #26324d;
    --accent: #818cf8; --accent-text: #0b1120; --ok: #4ade80; --err: #f87171; --warn: #facc15;
    --err-bg: #2a1215; --warn-bg: #2a2410; --info-bg: #1b2142;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --card: #131c31; --text: #e2e8f0; --muted: #94a3b8; --border: #26324d;
  --accent: #818cf8; --accent-text: #0b1120; --ok: #4ade80; --err: #f87171; --warn: #facc15;
  --err-bg: #2a1215; --warn-bg: #2a2410; --info-bg: #1b2142;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
.top { max-width: 760px; margin: 0 auto; padding: 20px 16px 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 4px; overflow-wrap: anywhere; }
a { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 14px 0; }
.card.small { font-size: .9rem; color: var(--muted); }
label { display: block; font-weight: 600; margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
input[type=url], input[type=text], select {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
#url { flex: 1; min-width: 0; }
.detect { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: .9rem; }
.detect .dim { color: var(--muted); }
.error-text.inline { margin: 0; }
.error-text.block { display: block; margin: 2px 0 0; font-size: .8rem; }
.entries li.unavailable { opacity: .65; }
button, a.primary {
  min-height: 46px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button.primary, a.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.wide { width: 100%; margin-top: 12px; }
button.small { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.icon-btn { min-height: 40px; width: 40px; padding: 0; font-size: 1.2rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }

.banner { border-radius: 10px; padding: 10px 12px; margin: 12px 0; background: var(--info-bg); }
.banner.error { background: var(--err-bg); color: var(--err); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.error-text { color: var(--err); margin: 8px 0 0; }

.media { display: flex; gap: 14px; align-items: flex-start; }
.media img { width: 128px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: var(--border); flex-shrink: 0; }
.meta { margin: 2px 0; color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--info-bg); color: var(--accent); font-weight: 600; font-size: .8rem; }

.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.options label { font-size: .85rem; }

.list-head { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.check input, .entries input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.entries { list-style: none; padding: 0; margin: 8px 0 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.entries li { border-bottom: 1px solid var(--border); padding: 8px 10px; }
.entries li:last-child { border-bottom: 0; }
.entries .line { display: flex; gap: 10px; align-items: center; font-weight: 400; margin: 0; }
.entries .line span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.entries .dim { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.cands { margin: 8px 0 0 30px; display: grid; gap: 6px; }
.cand { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.cand span { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.job-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.job-title { overflow-wrap: anywhere; }
.pill { font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--info-bg); color: var(--accent); white-space: nowrap; }
.pill.ready { color: var(--ok); }
.pill.failed { color: var(--err); background: var(--err-bg); }
.bar { height: 8px; background: var(--border); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.bar.indeterminate div { width: 30%; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.job-files { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; font-size: .9rem; }
.job-files li { display: flex; gap: 8px; align-items: center; }
.job-files li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.job-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

@media (max-width: 560px) {
  .row { flex-direction: column; }
  .options { grid-template-columns: 1fr 1fr; }
  .media img { width: 96px; }
}
@media (prefers-reduced-motion: reduce) { .bar div { transition: none; } .bar.indeterminate div { animation: none; width: 100%; opacity: .4; } }
