:root {
  --bg: #0d0f14;
  --surface: #151922;
  --surface-2: #1c212d;
  --border: #272d3b;
  --text: #e9ecf2;
  --muted: #9aa3b5;
  --faint: #6b7489;
  --accent: #f5a524;
  --accent-ink: #1a1203;
  --ok: #3ccf8e;
  --warn: #f5c451;
  --danger: #ff6b6b;
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: rgba(13, 15, 20, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; letter-spacing: 0.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.brand b { color: var(--accent); font-weight: inherit; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.usage-pill { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
main { max-width: 1280px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 6px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; min-height: 40px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: #242a38; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #ffb53d; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.big { padding: 12px 22px; min-height: 48px; font-size: 15px; }
.btn.block { width: 100%; }

/* Forms */
label.field { display: grid; gap: 6px; align-content: start; }
label.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.hint { font-size: 12.5px; color: var(--faint); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 20px; }
.auth-card .brand { justify-content: center; font-size: 18px; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); margin-top: -10px; }

/* Choice cards */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }
.choice {
  position: relative; display: grid; gap: 6px; text-align: left;
  padding: 16px 16px 16px 48px; border-radius: var(--radius);
  background: var(--bg); border: 1.5px solid var(--border); cursor: pointer;
}
.choice:hover { border-color: #3a4256; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice::before {
  content: ""; position: absolute; left: 16px; top: 18px; width: 18px; height: 18px;
  border-radius: 50%; border: 2px solid var(--faint);
}
.choice:has(input:checked) { border-color: var(--accent); background: rgba(245, 165, 36, 0.06); }
.choice:has(input:checked)::before { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice strong { font-size: 15px; }
.choice small { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* Drop zone */
.drop {
  display: grid; place-items: center; gap: 10px; text-align: center;
  padding: 56px 24px; border: 2px dashed var(--border); border-radius: 16px;
  background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(245, 165, 36, 0.05); }
.drop .icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font-size: 26px; }
.drop strong { font-size: 17px; }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.file-chip .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Progress */
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s ease; }
.bar.indeterminate > i { width: 30% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(60, 207, 142, 0.35); background: rgba(60, 207, 142, 0.08); }
.badge.busy { color: var(--accent); border-color: rgba(245, 165, 36, 0.35); background: rgba(245, 165, 36, 0.08); }
.badge.bad { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.busy.dot::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* Job list */
.jobs { display: grid; gap: 10px; }
.job-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text);
}
.job-row:hover { border-color: #3a4256; text-decoration: none; }
.job-row .title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-row .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.job-row .bar { grid-column: 1 / -1; }
.empty { text-align: center; padding: 64px 24px; color: var(--muted); display: grid; gap: 14px; justify-items: center; }

/* Steps */
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--faint); background: var(--bg); border: 1px solid var(--border); }
.step.done { color: var(--ok); }
.step.now { color: var(--accent); border-color: rgba(245, 165, 36, 0.5); }

/* Job page */
.job-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .job-layout { grid-template-columns: 1fr; } .player { position: static; } }
.player { position: sticky; top: 76px; display: grid; gap: 12px; }
.player video { width: 100%; max-height: 62vh; background: #000; border-radius: var(--radius); display: block; }
video::cue { background: rgba(0, 0, 0, 0.6); color: #fff; font-family: var(--font); font-weight: 600; line-height: 1.35; }
.downloads { display: grid; gap: 8px; }
.downloads .btn { justify-content: flex-start; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.warnings { border-color: rgba(245, 196, 81, 0.35); background: rgba(245, 196, 81, 0.06); color: var(--warn); font-size: 14px; }
.warnings ul { margin: 6px 0 0; padding-left: 18px; }
.error-box { border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.07); }

/* Cue editor */
.editor-head { display: flex; align-items: center; gap: 12px; position: sticky; top: 61px; z-index: 5; padding: 12px 0; background: var(--bg); flex-wrap: wrap; }
.cues { display: grid; gap: 8px; }
.cue { display: grid; grid-template-columns: 34px 1fr; gap: 4px 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.cue.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cue .n { color: var(--faint); font-family: var(--mono); font-size: 12px; padding-top: 8px; }
.cue .times { display: flex; gap: 6px; align-items: center; }
.cue .times input { width: 118px; padding: 4px 8px; font-family: var(--mono); font-size: 12.5px; }
.cue .times { flex-wrap: wrap; }
.cue .times button { font-size: 13px; padding: 2px 8px; min-height: 28px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; justify-self: start; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.cue textarea { min-height: 52px; padding: 8px 10px; font-size: 15px; line-height: 1.4; }
.cue .src { color: var(--faint); font-size: 13px; white-space: pre-wrap; }
.cue > :not(.n) { grid-column: 2; }
.cue .n { grid-row: 1 / span 3; }
.cue .cps { font-size: 12px; color: var(--faint); margin-left: auto; }
.cue .cps.over { color: var(--warn); }

/* Admin */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; }
td input[type=number] { width: 96px; padding: 6px 8px; }
.table-wrap { overflow-x: auto; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 10px; background: #2a3142; color: var(--text); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,0.4); transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { border-color: rgba(255, 107, 107, 0.5); }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .who .email { display: none; }
  main { padding: 24px 16px 64px; }
  h1 { font-size: 22px; }
}
