:root {
  --bg: oklch(19% 0.024 262);
  --bg-raised: oklch(24% 0.026 262);
  --bg-overlay: oklch(29% 0.028 262);
  --border: oklch(34% 0.03 262);
  --border-subtle: oklch(30% 0.028 262);
  --text: oklch(93% 0.012 255);
  --text-muted: oklch(70% 0.03 258);
  --text-faint: oklch(52% 0.028 260);

  --accent: oklch(64% 0.19 259);
  --accent-hover: oklch(58% 0.19 259);
  --accent-soft: oklch(64% 0.14 259 / 16%);

  --success: oklch(68% 0.17 149);
  --success-soft: oklch(68% 0.17 149 / 14%);
  --warning: oklch(75% 0.15 80);
  --warning-soft: oklch(75% 0.15 80 / 14%);
  --danger: oklch(66% 0.19 25);
  --danger-soft: oklch(66% 0.19 25 / 14%);

  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

.muted {
  color: var(--text-muted);
}

[hidden] {
  display: none !important;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-word {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* --- auth screen --------------------------------------------------------- */

.auth-screen {
  min-height: 100vh;
}
.auth-split {
  display: flex;
  min-height: 100vh;
}
.brand-panel {
  flex: 1 1 auto;
  background: var(--bg-raised);
  border-right: 1px solid var(--border-subtle);
  padding: 56px;
  display: flex;
  flex-direction: column;
}
.brand-panel .brand-word {
  font-size: 19px;
}
.brand-copy {
  margin-top: auto;
  margin-bottom: auto;
  max-width: 440px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.brand-copy h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 40px;
  line-height: 1.15;
  margin: 0 0 16px;
}
.brand-copy p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
  max-width: 400px;
}

.pipeline-timeline {
  list-style: none;
  margin: 44px 0 0;
  padding: 0 0 0 4px;
  position: relative;
}
.pipeline-timeline::before {
  content: "";
  position: absolute;
  left: 23px;
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: var(--border-subtle);
}
.pipeline-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 28px;
  position: relative;
}
.pipeline-step:last-child {
  margin-bottom: 0;
}
.pipeline-node {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}
.pipeline-step-upload .pipeline-node {
  border-color: var(--accent);
  color: var(--accent);
}
.pipeline-step-transcode .pipeline-node {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.pipeline-step-play .pipeline-node {
  border-color: var(--success);
  color: var(--success);
}
.pipeline-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.pipeline-text strong {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.form-panel {
  flex: 0 0 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px;
}
.form-panel-inner {
  width: 100%;
  max-width: 360px;
}
.form-panel-inner h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  margin: 0 0 6px;
}
.form-panel-inner > p.muted {
  margin: 0 0 24px;
  font-size: 14px;
}

.field {
  display: block;
  margin-bottom: 16px;
}
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input,
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.field input:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint {
  font-size: 12px;
  color: var(--text-faint);
  margin: -8px 0 16px;
}

.toggle-row {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.link-accent {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  font: inherit;
  cursor: pointer;
}
.link-accent:hover {
  text-decoration: underline;
}

.banner {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 20px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.banner-error {
  background: var(--danger-soft);
  border: 1px solid oklch(66% 0.19 25 / 35%);
  color: var(--text);
}

@media (max-width: 860px) {
  .auth-split {
    flex-direction: column;
  }
  .brand-panel {
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 32px 28px;
  }
  .brand-copy h1 {
    font-size: 28px;
  }
  .pipeline-timeline {
    display: none;
  }
  .form-panel {
    flex: 1 1 auto;
    padding: 32px 28px;
  }
}

/* --- buttons -------------------------------------------------------------- */

.btn-primary {
  padding: 11px 18px;
  background: var(--accent);
  color: oklch(98% 0.005 260);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-primary:disabled {
  background: var(--border);
  cursor: not-allowed;
}
.btn-full {
  width: 100%;
}
.btn-ghost {
  padding: 9px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.btn-ghost:hover {
  background: var(--bg-overlay);
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover {
  background: var(--bg-overlay);
}

/* --- top nav --------------------------------------------------------------- */

#topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 32px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-subtle);
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 36px;
}
#topnav .brand-word {
  font-size: 16px;
}
.nav-links {
  display: flex;
  gap: 2px;
}
.nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition:
    background 0.15s,
    color 0.15s;
}
.nav-link:hover {
  background: var(--bg-overlay);
}
.nav-link.active {
  background: var(--bg-overlay);
  color: var(--text);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.operator-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 999px;
}
.who {
  font-size: 13px;
  color: var(--text-muted);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 40px 64px;
}
.view-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  margin: 0 0 6px;
}
.view-header p {
  margin: 0 0 32px;
  font-size: 14px;
}

/* --- dropzone --------------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 48px 32px;
  text-align: center;
  background: var(--bg-raised);
  margin-bottom: 24px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.dropzone:hover,
.dropzone.over {
  border-color: var(--accent);
  background: var(--bg-overlay);
}
.dropzone.busy {
  opacity: 0.6;
  pointer-events: none;
}
.dropzone-icon {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}
.dropzone-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.dropzone-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.dropzone-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 16px;
}

.status {
  margin: 0 0 24px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

/* --- job card ---------------------------------------------------------------- */

.job-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
}
.job-card-body {
  display: flex;
  gap: 24px;
}
.job-thumb {
  flex-shrink: 0;
  width: 200px;
  height: 118px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--bg-overlay), var(--bg-raised));
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}
.job-detail {
  flex: 1;
  min-width: 0;
}
.job-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.job-filename {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.badge-icon {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}
.badge-queued {
  background: var(--border-subtle);
  color: var(--text-muted);
}
.badge-processing {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-processing .badge-icon {
  animation: pulse 1.1s ease-in-out infinite;
}
.badge-done {
  background: var(--success-soft);
  color: var(--success);
}
.badge-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes sweep {
  0% {
    transform: translateX(-60%);
  }
  100% {
    transform: translateX(220%);
  }
}
.progress-track {
  position: relative;
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-overlay);
  margin-top: 4px;
}
.progress-sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sweep 1.6s ease-in-out infinite;
}

video {
  width: 100%;
  /* A real uploaded video's own aspect ratio is unknown until it plays, and
     an unusually tall source would otherwise blow out the job card's height. */
  max-height: 360px;
  margin-top: 4px;
  border-radius: 8px;
  background: #000;
}

.job-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 900px) {
  .job-card-body {
    flex-direction: column;
  }
  .job-thumb {
    width: 100%;
    height: 160px;
  }
  main {
    padding: 24px;
  }
}

/* --- filter chips ------------------------------------------------------------ */

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.chip {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  font-family: var(--font-body);
  transition:
    background 0.15s,
    color 0.15s;
}
.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

/* --- library grid -------------------------------------------------------------- */

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 32px;
}
.video-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.video-card:has(.playable:hover) {
  border-color: var(--border);
  transform: translateY(-2px);
}
.video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--bg-overlay), var(--bg-raised));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}
.video-thumb .badge {
  position: absolute;
  top: 10px;
  left: 10px;
}
.video-thumb.playable {
  cursor: pointer;
}
.play-overlay {
  position: absolute;
  inset: 0;
  background: oklch(19% 0.024 262 / 0%);
  transition: background 0.15s;
}
.video-thumb.playable:hover .play-overlay {
  background: oklch(19% 0.024 262 / 35%);
}
.play-overlay::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: oklch(98% 0.005 260 / 0%);
  transform: translate(-50%, -50%);
  transition: background 0.15s;
}
.video-thumb.playable:hover .play-overlay::after {
  background: oklch(98% 0.005 260 / 92%);
}
.video-thumb.expanded video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
}
.video-card-body {
  padding: 14px 16px 16px;
}
.video-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.video-filename {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-delete {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.card-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.video-error {
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger);
  line-height: 1.4;
}

.empty-state {
  padding: 48px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}
.page-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.page-btn:hover:not(:disabled) {
  background: var(--bg-overlay);
}
.page-btn:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}
.page-label {
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .video-grid {
    grid-template-columns: 1fr;
  }
}

/* --- admin table ------------------------------------------------------------- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
}
.admin-table thead tr {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-subtle);
}
.admin-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  padding: 12px 20px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-subtle);
  /* A row's preview cell grows tall once its video is playing; without this
     every other cell in that row would centre against the new height. */
  vertical-align: top;
}
.admin-table tbody tr:hover {
  background: var(--bg-overlay);
}
.admin-table tbody tr:last-child td {
  border-bottom: none;
}
.admin-watch {
  padding: 5px 12px;
  font-size: 12px;
}
.admin-table td video {
  display: block;
  width: 220px;
  margin-top: 8px;
}

@media (max-width: 700px) {
  .admin-table {
    display: block;
    overflow-x: auto;
  }
}
