@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0a0b10;
  --bg-grad: radial-gradient(1200px 600px at 20% -10%, #1b1540 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #0d2b3a 0%, transparent 55%),
             #0a0b10;
  --panel: #14151d;
  --panel-2: #191b26;
  --border: #272a38;
  --border-soft: #1e2029;
  --text: #f1f2f6;
  --muted: #8d92a3;
  --muted-2: #5f6477;
  --accent: #7c8cff;
  --accent-2: #b26bff;
  --accent-grad: linear-gradient(135deg, #7c8cff 0%, #b26bff 100%);
  --accent-text: #0b0d16;
  --success: #37d399;
  --success-bg: #123427;
  --danger: #ff6b7a;
  --danger-bg: #371620;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -12px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px 100px; }

/* ---------- header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
  margin-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px -4px rgba(124,140,255,.6);
}
.brand .mark svg { width: 16px; height: 16px; }
.header nav { display: flex; align-items: center; gap: 18px; }
.header nav a { color: var(--muted); font-size: 13px; text-decoration: none; }
.header nav a:hover { color: var(--text); }

.steps { display: flex; align-items: center; gap: 6px; margin: 4px 0 28px; }
.step {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted-2); font-weight: 600;
  padding: 7px 14px 7px 10px; border-radius: 999px;
  border: 1px solid var(--border-soft); background: var(--panel);
}
.step .dot {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--border); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.step.active { color: var(--text); border-color: transparent; background: var(--panel-2); box-shadow: inset 0 0 0 1px rgba(124,140,255,.35); }
.step.active .dot { background: var(--accent-grad); color: var(--accent-text); }
.step.done .dot { background: var(--success-bg); color: var(--success); }
.step-sep { width: 20px; height: 1px; background: var(--border); }

/* ---------- type ---------- */
h1 { font-size: 26px; margin: 2px 0 6px; letter-spacing: -0.02em; font-weight: 800; }
.sub { color: var(--muted); margin-top: 0; margin-bottom: 26px; font-size: 14.5px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 13px; }
a { color: var(--accent); }

/* ---------- surfaces ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel-tight { padding: 16px 20px; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 16px 0 7px; text-transform: uppercase; letter-spacing: .04em; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=number], input[type=url] {
  width: 100%;
  background: #0b0c13;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,140,255,.18);
}
input::placeholder { color: var(--muted-2); }

/* ---------- buttons ---------- */
button, .btn {
  background: var(--accent-grad);
  color: var(--accent-text);
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  transition: transform .1s, box-shadow .15s, opacity .15s;
  box-shadow: 0 6px 20px -8px rgba(124,140,255,.7);
}
button:hover, .btn:hover { transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.secondary:hover { border-color: var(--muted-2); }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.error { color: var(--danger); font-size: 13px; margin-top: 12px; padding: 10px 12px; background: var(--danger-bg); border-radius: var(--radius-sm); }

/* ---------- login ---------- */
.login-shell { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; text-align: left; }
.login-card .brand { justify-content: center; margin-bottom: 22px; font-size: 19px; }
.login-card h1 { text-align: center; }
.login-card .sub { text-align: center; }

/* ---------- recent videos grid ---------- */
.vgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 6px;
}
.vcard {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel-2);
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color .15s, transform .15s;
}
.vcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.vcard .cover { width: 100%; aspect-ratio: 9/16; object-fit: cover; display: block; background: #000; }
.vcard .meta { padding: 10px 12px 12px; }
.vcard .meta .title { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vcard .meta .dur { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.empty-state { color: var(--muted); font-size: 13.5px; padding: 10px 2px; }

/* ---------- picker: sticky control bar ---------- */
.controlbar {
  position: sticky; top: 14px; z-index: 5;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.field-inline { display: flex; flex-direction: column; gap: 6px; }
.field-inline label { margin: 0; }
.field-inline input { width: 100px; }

.chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; min-height: 0;
}
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 5px 6px 5px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.chip .n { width: 17px; height: 17px; border-radius: 50%; background: var(--accent-grad); color: var(--accent-text); font-size: 10.5px; display:flex; align-items:center; justify-content:center; font-weight:800; }
.chip .x { cursor: pointer; color: var(--muted); width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.chip .x:hover { color: var(--danger); background: var(--danger-bg); }

details.adv { margin-top: 16px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 6px; }
details.adv summary::before { content: '▸'; font-size: 10px; transition: transform .15s; }
details.adv[open] summary::before { transform: rotate(90deg); }
details.adv summary::-webkit-details-marker { display: none; }

/* ---------- thumb grid ---------- */
.thumbgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 4px;
}
.thumb {
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: #000;
  user-select: none;
  transition: border-color .12s, transform .12s;
}
.thumb:hover { transform: translateY(-2px); border-color: var(--muted-2); }
.thumb img { width: 100%; display: block; aspect-ratio: 9/16; object-fit: cover; }
.thumb .t { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.65); font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 999px; }
.thumb .order {
  position: absolute; top: 6px; right: 6px;
  background: var(--accent-grad); color: var(--accent-text);
  font-size: 12px; font-weight: 800; width: 22px; height: 22px;
  border-radius: 50%; display: none; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.thumb::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent 45%);
  pointer-events: none;
}
.thumb.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,140,255,.22); }
.thumb.selected .order { display: flex; }

/* ---------- spinner / status ---------- */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progresslist { list-style: none; padding: 0; margin: 4px 0 0; }
.progresslist li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--panel-2); font-size: 14px; font-weight: 600;
  margin-bottom: 8px;
}
.status-tag { font-size: 11.5px; font-weight: 700; padding: 4px 11px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.status-queued { background: #2a2c38; color: #aeb2c2; }
.status-running { background: #22284a; color: #9db0ff; }
.status-done { background: var(--success-bg); color: var(--success); }
.status-failed { background: var(--danger-bg); color: var(--danger); }

/* ---------- results grid ---------- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.result-card {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.result-card .rc-head { padding: 12px 14px; font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
video.preview { width: 100%; aspect-ratio: 9/16; object-fit: cover; display: block; background: #000; }
.result-card .rc-foot { padding: 12px 14px; }
.result-card .rc-foot .btn { width: 100%; justify-content: center; }
.result-card.failed .rc-foot { color: var(--danger); font-size: 13px; }

@media (max-width: 560px) {
  .wrap { padding: 0 16px 80px; }
  .header { padding: 16px 0 14px; }
  .controlbar { position: static; }
}
