/* ================================================================
   Reel Studio — dark, editor-grade UI.
   One accent colour, generous type, no decoration for its own sake.
   ================================================================ */

:root {
  --bg: #0b0d10;
  --bg-raised: #12151a;
  --bg-input: #171b21;
  --line: #232830;
  --line-bright: #313844;
  --text: #e8ebf0;
  --text-dim: #949cab;
  --text-faint: #616a78;
  --accent: #4a9eff;
  --accent-dim: #1d3a5c;
  --good: #3ecf8e;
  --warn: #e2b344;
  --bad: #ef5f5f;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { text-wrap: balance; margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────── */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  height: 60px;
  background: rgba(11, 13, 16, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brandmark {
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 15px;
  white-space: nowrap;
}
.brandmark span { color: var(--text-faint); font-weight: 400; }

nav.tabs { display: flex; gap: 4px; margin-left: 8px; }
nav.tabs button {
  background: none;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  padding: 7px 13px;
  border-radius: 7px;
  cursor: pointer;
}
nav.tabs button:hover { color: var(--text); background: var(--bg-raised); }
nav.tabs button[aria-selected="true"] { color: var(--text); background: var(--bg-input); }

.spacer { flex: 1; }
.whoami { font-size: 13px; color: var(--text-dim); white-space: nowrap; }

main { max-width: 1320px; margin: 0 auto; padding: 28px; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
}

/* ── Cards + form ─────────────────────────────────────────────── */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.card + .card { margin-top: 20px; }

.card > h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.card > h2 + .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }

label.field { display: block; margin-bottom: 16px; }
label.field > span.lbl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
label.field > span.hint {
  display: block;
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 5px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], textarea, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
}
textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.14);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* Chip rows: formats, lengths, language */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  background: var(--bg-input);
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  padding: 6px 14px;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--text-faint); }
.chip[aria-pressed="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

/* Preset picker */
.presets { display: grid; gap: 8px; }
.preset {
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--line-bright);
  border-radius: 9px;
  padding: 11px 13px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}
.preset:hover { border-color: var(--text-faint); }
.preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-dim); }
.preset .p-label { font-weight: 600; font-size: 14px; }
.preset .p-best { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.preset[aria-pressed="true"] .p-best { color: #cfe2fb; }

/* Buttons */
button.primary {
  width: 100%;
  background: var(--accent);
  border: 0;
  border-radius: 9px;
  color: #04121f;
  font: inherit;
  font-weight: 650;
  font-size: 15px;
  padding: 12px 16px;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

button.ghost {
  background: var(--bg-input);
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 7px 13px;
  cursor: pointer;
}
button.ghost:hover { border-color: var(--text-faint); }
button.ghost.danger:hover { border-color: var(--bad); color: var(--bad); }

/* Toggle */
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { appearance: none; margin: 0; width: 38px; height: 22px; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--line-bright); position: relative; cursor: pointer; }
.toggle input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--text-faint); transition: transform 0.15s, background 0.15s;
}
.toggle input:checked { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); background: var(--accent); }
.toggle input:disabled { opacity: 0.4; cursor: not-allowed; }
.toggle .t-text { font-size: 14px; }
.toggle .t-note { font-size: 12.5px; color: var(--text-faint); }

/* Box link status */
.boxstatus { font-size: 13px; margin-top: 7px; display: flex; gap: 7px; align-items: flex-start; }
.boxstatus.ok { color: var(--good); }
.boxstatus.warn { color: var(--warn); }
.boxstatus.bad { color: var(--bad); }
.boxstatus.busy { color: var(--text-dim); }

/* ── Job list ─────────────────────────────────────────────────── */
.joblist { display: grid; gap: 14px; }

.job {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.job .thumb {
  width: 92px;
  aspect-ratio: 9 / 16;
  border-radius: 7px;
  background: #05070a center/cover no-repeat;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 11px;
  overflow: hidden;
}
.job.landscape .thumb { aspect-ratio: 16 / 9; }
.job.square .thumb { aspect-ratio: 1; }
.job .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.job .j-title { font-weight: 600; font-size: 14.5px; }
.job .j-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.job .j-stage { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }
.job .j-error { font-size: 12.5px; color: var(--bad); margin-top: 6px; word-break: break-word; }
.job .j-actions { display: flex; flex-direction: column; gap: 7px; align-items: stretch; }

.bar { height: 4px; background: var(--bg-input); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width 0.4s ease; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
}
.pill.queued  { color: var(--text-dim); border-color: var(--line-bright); }
.pill.running { color: var(--accent);  border-color: var(--accent-dim); }
.pill.claimed { color: var(--accent);  border-color: var(--accent-dim); }
.pill.done    { color: var(--good);    border-color: #1d4a37; }
.pill.failed  { color: var(--bad);     border-color: #5c2626; }
.pill.cancelled { color: var(--text-faint); border-color: var(--line); }

.empty {
  border: 1px dashed var(--line-bright);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-faint);
}

/* ── Admin tables ─────────────────────────────────────────────── */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}
table.grid td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
.swatch { width: 16px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid var(--line-bright); vertical-align: -3px; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 6, 9, 0.82);
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal .box {
  background: var(--bg-raised);
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal .box.wide { max-width: 460px; }
.modal video { width: 100%; border-radius: 9px; background: #000; display: block; }
.modal h3 { font-size: 16px; margin-bottom: 14px; }
.modal .row { display: flex; gap: 9px; margin-top: 16px; }
.modal .row button { flex: 1; }

/* ── Toast ────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-input);
  border: 1px solid var(--line-bright);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 11px 18px;
  font-size: 14px;
  z-index: 80;
  max-width: 90vw;
}
#toast[hidden] { display: none; }
#toast.bad { border-color: var(--bad); color: #ffd9d9; }
#toast.good { border-color: var(--good); color: #d6f7e8; }

/* ── Login ────────────────────────────────────────────────────── */
body.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 21px; letter-spacing: -0.02em; margin-bottom: 5px; }
.login-card .sub { color: var(--text-dim); font-size: 13.5px; margin-bottom: 24px; }
.login-card .err { color: var(--bad); font-size: 13.5px; margin-bottom: 14px; min-height: 19px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
