:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c222b;
  --line: #2a313c;
  --text: #e6edf3;
  --muted: #8b95a3;
  --accent: #e50914;
  --accent-2: #ff4d57;
  --blue: #3b82f6;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --violet: #a855f7;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; text-decoration: none; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 20px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-size: 13px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--muted);
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 10px 0; color: var(--muted); font-size: 13px; }
.sidebar-foot button { margin-top: 8px; }

.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

/* ---------- building blocks ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.card h2 { font-size: 15px; margin: 0 0 14px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .hint { color: var(--muted); font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3a4350; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-green { background: #15803d; border-color: #15803d; }
.btn-green:hover { background: #16a34a; }
.btn-danger { color: #fca5a5; }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-link { background: none; border: 0; color: var(--muted); padding: 0; height: auto; font-weight: 500; }
.btn-link:hover { color: var(--text); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], select {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; border: 1px solid; }
.alert-ok { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.35); color: #86efac; }
.alert-err { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.35); color: #fca5a5; }
.error-text { color: #fca5a5; font-size: 13px; margin-top: 4px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td .title { font-weight: 600; }
td .meta { color: var(--muted); font-size: 12.5px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* ---------- status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1px solid currentColor; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-uploading, .s-downloading { color: var(--blue); }
.s-queued, .s-pending { color: var(--muted); }
.s-converting { color: var(--violet); }
.s-review { color: var(--amber); }
.s-ready { color: var(--green); }
.s-failed { color: var(--red); }
.badge.is-active::before { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.progress { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; min-width: 120px; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: inherit; transition: width .4s; }
.progress.converting > span { background: var(--violet); }
.progress-text { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.tabs a.active, .tabs a:hover { color: var(--text); border-color: #3a4350; background: var(--panel-2); }
.tabs .count { opacity: .7; margin-left: 4px; }

/* ---------- pipeline steps ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.step { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.step .n { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.step .t { font-weight: 700; margin-top: 2px; }
.step.done { border-color: rgba(34,197,94,.4); }
.step.done .n { color: var(--green); }
.step.current { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; }
.step.current .n { color: var(--blue); }
.step.failed { border-color: var(--red); }
.step.failed .n { color: var(--red); }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

/* ---------- upload ---------- */
.mode-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.mode-tabs button { flex: 1; }
.mode-tabs button.active { border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; color: var(--muted); cursor: pointer;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: rgba(59,130,246,.05); }
.dropzone strong { color: var(--text); }
.file-chosen { margin-top: 12px; font-weight: 600; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; padding-bottom: 24px; font-size: 20px; }

/* ---------- player ---------- */
.eplayer { background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.eplayer video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.eplayer-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--panel); border-top: 1px solid var(--line);
}
.eplayer-bar select { width: auto; height: 32px; }
.eplayer-bar .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.eplayer-bar .seg button { background: var(--panel-2); color: var(--muted); border: 0; height: 30px; padding: 0 12px; font: inherit; font-weight: 600; cursor: pointer; }
.eplayer-bar .seg button.active { background: var(--accent); color: #fff; }
.eplayer-info { margin-left: auto; color: var(--muted); font-size: 12.5px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  .brand { padding: 0 12px 0 0; }
  .nav { display: flex; gap: 4px; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 20px 16px 48px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .steps { grid-template-columns: 1fr; }
}
