:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --border: #e2e2e8;
  --ink: #16161d;
  --muted: #6b6b7b;
  --accent: #6d4aff;
  --accent-ink: #ffffff;
  --accent-soft: #ece7ff;
  --ok: #16a34a;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e13;
    --surface: #17171f;
    --surface-2: #20202a;
    --border: #2c2c38;
    --ink: #ececf2;
    --muted: #9a9aab;
    --accent: #8b70ff;
    --accent-soft: #2a2350;
    --warn: #f59e0b;
    --warn-soft: #2d2210;
    --danger: #f87171;
    --danger-soft: #331616;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
a { color: inherit; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.error { color: var(--danger); margin: 0; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; text-decoration: none; }
.brand svg { width: 28px; height: 28px; color: var(--accent); }
.topnav { display: flex; gap: 4px; }
.topnav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.topnav a.active, .topnav a:hover { color: var(--ink); background: var(--surface-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--danger); }

.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; display: flex; flex-direction: column; gap: 28px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; margin: 40px auto; width: 100%; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 28px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row.center { align-items: center; }
.hero h1 { font-size: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.back { display: inline-block; margin-bottom: -12px; }

.group { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.group legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; padding: 0; }

.input {
  width: 100%; padding: 11px 14px; font: inherit; color: inherit;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.small { width: 90px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 160px; font-size: 14px; }
.field.inline { flex-direction: row; align-items: center; flex: none; min-width: 0; }
.field > span { font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: 0.6; cursor: progress; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 13px 26px; font-size: 16px; }

.tabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; align-self: flex-start; }
.tab { font: inherit; font-weight: 500; border: 0; background: transparent; color: var(--muted); padding: 6px 16px; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  min-height: 130px; padding: 20px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer;
}
.dropzone.over, .dropzone:hover { border-color: var(--accent); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }

.trim summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.trim[open] summary { margin-bottom: 12px; }

.choice-grid { display: grid; gap: 10px; }
.choice-grid.two { grid-template-columns: repeat(2, 1fr); }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice {
  display: flex; gap: 12px; align-items: center; text-align: left;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  font: inherit; color: inherit; cursor: pointer;
}
.choice { min-width: 0; }
.choice:hover { border-color: var(--muted); }
.choice.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.choice strong { display: block; font-size: 14px; }
.choice small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; }
.frame-icon { flex: none; border: 2px solid currentColor; border-radius: 4px; opacity: 0.7; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 13px; cursor: pointer; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: inherit;
}
.chip small { color: var(--muted); margin-left: 4px; }
.chip.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.selected small { color: inherit; opacity: 0.8; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; flex-wrap: wrap; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span {
  flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background 0.15s;
}
.switch > span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.presets.disabled { opacity: 0.4; pointer-events: none; }
.preset {
  font: inherit; color: inherit; cursor: pointer; text-align: left;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 0; overflow: hidden;
}
.preset.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.preset .sample {
  height: 64px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2b2b3a, #45455a); font-weight: 900; font-size: 17px; letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgb(0 0 0 / 0.6);
}
.preset .meta { padding: 8px 10px; }
.preset strong { font-size: 13px; display: block; }
.preset small { color: var(--muted); font-size: 11.5px; line-height: 1.3; display: block; }

.callout { border-radius: 12px; padding: 12px 16px; border: 1px solid; }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }

.submit-row { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap; }
.submit-row .progress { flex: 1; min-width: 200px; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress.thin { height: 6px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; border-radius: inherit; }
.progress.indeterminate > div { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(350%); } }

.job-list { display: flex; flex-direction: column; gap: 10px; }
.job {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  text-decoration: none; color: inherit;
}
.job:hover { border-color: var(--muted); }
.job-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.job-meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.job-actions { display: flex; gap: 6px; justify-content: flex-end; }
.job .progress { grid-column: 1 / -1; }
.job .job-error { grid-column: 1 / -1; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 32px; border: 1px dashed var(--border); border-radius: var(--radius); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.running { background: var(--accent-soft); color: var(--accent); }
.badge.completed { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.failed, .badge.interrupted { background: var(--danger-soft); color: var(--danger); }
.badge.running::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.3; } }

.job-head { display: flex; flex-direction: column; gap: 12px; }
.job-head .row { justify-content: space-between; align-items: flex-start; }
.job-head h1 { word-break: break-word; }
.error-box { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 12px 16px; }
.error-box p { margin: 4px 0 0; color: var(--ink); opacity: 0.8; font-size: 14px; }

.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.clips.landscape { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.clip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.clip video { width: 100%; aspect-ratio: 9 / 16; background: #000; display: block; object-fit: contain; }
.clips.landscape .clip video { aspect-ratio: 16 / 9; }
.clip-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.clip-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.score { font-weight: 800; font-size: 13px; padding: 2px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.clip-summary { font-size: 13.5px; margin: 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.clip-summary.open { -webkit-line-clamp: unset; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 7px; }
.clip-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }

.checks { display: flex; flex-direction: column; padding: 8px 0; }
.check { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); }
.check:last-child { border-bottom: 0; }
.check .detail { margin-left: auto; color: var(--muted); font-size: 14px; text-align: right; }

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  .brand span { display: none; }
  .topnav a { padding: 6px 8px; }
  .container { padding: 20px 16px 60px; }
  .card { padding: 18px 16px; }
  .choice-grid.three { grid-template-columns: 1fr; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset .sample { height: 52px; font-size: 15px; }
  .hero h1 { font-size: 24px; }
  .clips.landscape { grid-template-columns: 1fr; }
  .job { grid-template-columns: 1fr; }
  .job-actions { justify-content: flex-start; }
}
