:root {
  color-scheme: dark;
  --bg: #0e1621;
  --bg-accent: #17212b;
  --surface: #17212b;
  --surface-strong: #1d2a36;
  --text: #7f91a4;
  --text-strong: #d8e1ea;
  --muted: #6f8399;
  --border: #22303d;
  --primary: #7f91a4;
  --primary-strong: #2e3842;
  --success: #223c3b;
  --success-text: #96d6c9;
  --danger: #8e676b;
  --warning: #735f2a;
  --warning-text: #f3d48a;
  --job-progress-width: 640px;
  --display-font: "Bahnschrift Condensed", "DIN Alternate", "Avenir Next Condensed",
    "Arial Narrow", "Helvetica Neue", sans-serif;
  --body-font: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  font-family: var(--display-font);
  background: var(--primary);
  border: 0;
  border-radius: 14px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
  min-height: 50px;
  padding: 0.95rem 1.2rem;
}

button:hover {
  background: #6f8399;
}

.shell {
  align-content: center;
  display: grid;
  gap: 28px;
  min-height: 100vh;
  padding: 24px;
  width: 100%;
}

.shell.has-results {
  align-content: start;
  gap: 18px;
}

.search-panel {
  margin: 0 auto;
  max-width: 720px;
  transition: max-width 460ms ease, opacity 360ms ease, transform 360ms ease;
  width: 100%;
}

.shell.has-results .search-panel {
  max-width: 1180px;
  opacity: 0.76;
  transform: none;
}

.download-form {
  display: grid;
  gap: 14px;
}

.input-wrap {
  position: relative;
}

input[type="url"] {
  background: #2a343d;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-strong);
  font-family: var(--body-font);
  min-height: 62px;
  padding: 0 18px;
  width: 100%;
}

.shell.has-input input[type="url"] {
  padding-right: 304px;
}

input[type="url"]::placeholder {
  color: var(--muted);
}

input[type="url"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(127, 145, 164, 0.14);
  outline: 0;
}

.input-controls {
  align-items: center;
  display: none;
  gap: 8px;
  inset: 9px 9px 9px auto;
  position: absolute;
}

.shell.has-input .input-controls {
  display: flex;
}

.input-download {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-strong);
  display: inline-flex;
  font-family: var(--display-font);
  font-size: 18px;
  height: 44px;
  justify-content: center;
  line-height: 1;
  min-height: 0;
  min-width: 120px;
  outline: 0;
  padding: 0 22px;
}

.input-download:hover {
  background: #334250;
}

.input-download:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(127, 145, 164, 0.18);
}

.mode-row {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.mode-row label {
  display: inline-flex;
  min-width: 0;
}

.mode-row input {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.mode-row span {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--display-font);
  font-weight: 650;
  min-height: 44px;
  padding: 0 12px;
  white-space: nowrap;
}

.mode-row input:checked + span {
  background: var(--surface-strong);
  border-color: var(--primary);
  color: var(--text-strong);
}

.message {
  color: var(--muted);
  line-height: 1.4;
  margin-top: 10px;
}

.message:empty {
  display: none;
}

.message.error {
  color: #d99a9f;
}

.results[hidden] {
  display: none !important;
}

.results {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(10px);
  animation: resultsFadeIn 720ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  width: min(1180px, 100%);
}

@keyframes resultsFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.results.has-current-job .grid {
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
}

#current-job-panel {
  grid-column: 1 / -1;
}

#current-job-panel[hidden] {
  display: none !important;
}

.results.has-current-job #current-job-panel {
  animation: currentJobIn 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
  min-height: 430px;
}

.results.has-current-job .grid > .panel:not(#current-job-panel) {
  animation: lowerPanelsIn 760ms cubic-bezier(0.16, 1, 0.3, 1) 80ms both;
  min-height: 440px;
}

#current-job-panel .panel-head {
  justify-content: center;
  text-align: center;
}

#job-view {
  align-items: center;
  display: flex;
  flex-direction: column;
  min-height: 340px;
  justify-content: center;
  text-align: center;
  width: 100%;
}

#current-job-panel .progress {
  flex: 0 0 auto;
  max-width: 100%;
  min-width: 0;
  width: var(--job-progress-width);
}

#current-job-panel .meta {
  flex: 0 0 auto;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  width: var(--job-progress-width);
}

.job-media {
  align-items: center;
  display: flex;
  gap: 22px;
  justify-content: center;
  margin: 22px 0 20px;
  max-width: 100%;
  width: min(820px, 100%);
}

.job-thumb {
  aspect-ratio: 16 / 9;
  background: #23303a;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: 0 0 220px;
  height: auto;
  object-fit: cover;
  overflow: hidden;
  width: 220px;
}

.job-copy {
  min-width: 0;
  text-align: left;
}

.job-media-title {
  color: var(--text-strong);
  font-family: var(--display-font);
  font-size: 22px;
  font-weight: 620;
  line-height: 1.24;
  overflow-wrap: anywhere;
}

.job-media-channel {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.quality-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
  max-width: 100%;
  width: min(820px, 100%);
}

.quality-option {
  align-items: flex-start;
  background: #25313c;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 86px;
  padding: 14px 16px;
  text-align: left;
}

.quality-option:not(:disabled):hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.quality-option:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.quality-option span {
  color: var(--text-strong);
  font-family: var(--display-font);
  font-size: 17px;
  font-weight: 620;
}

.quality-option small,
.quality-reason {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.quality-reason {
  color: #d7a47a;
}

@keyframes currentJobIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.995);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes lowerPanelsIn {
  from {
    opacity: 0.58;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel h2 {
  color: var(--text-strong);
  font-family: var(--display-font);
  font-size: 22px;
  font-stretch: condensed;
  font-weight: 650;
  line-height: 1.2;
  margin: 0;
}

.panel-id {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.empty,
.meta {
  color: var(--muted);
}

.meta {
  font-size: 14px;
  line-height: 1.45;
}

.item-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 3px;
  font-size: 15px;
  font-weight: 500;
}

.meta-chip {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  min-width: 0;
}

.meta-icon {
  color: currentColor;
  flex: 0 0 auto;
  height: 14px;
  opacity: 0.72;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  fill: none;
  width: 14px;
}

.media-badge {
  border-radius: 999px;
  display: inline-flex;
  font-family: var(--display-font);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  padding: 5px 8px;
  text-transform: uppercase;
}

.media-badge.video {
  background: rgba(127, 145, 164, 0.2);
  color: #c8d5e2;
}

.media-badge.music {
  background: rgba(150, 214, 201, 0.18);
  color: var(--success-text);
}

.external-link {
  color: var(--text);
  text-decoration: none;
}

.external-link:hover {
  color: var(--text-strong);
  text-decoration: underline;
}

.external-id {
  display: inline-flex;
}

.job-title {
  color: var(--text-strong);
  font-family: var(--display-font);
  font-size: 18px;
  font-weight: 650;
  margin-bottom: 10px;
}

.progress {
  background: #2a343d;
  box-sizing: border-box;
  border-radius: 999px;
  flex: 0 0 auto;
  height: 14px;
  margin: 18px 0 10px;
  overflow: hidden;
  max-width: 100%;
  width: var(--job-progress-width);
}

.progress span {
  background: var(--primary);
  display: block;
  height: 100%;
  transition: width 180ms ease;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-family: var(--display-font);
  font-size: 12px;
  font-weight: 650;
  padding: 5px 10px;
  text-transform: uppercase;
}

.status.queued,
.status.processing {
  background: var(--warning);
  color: var(--warning-text);
}

.status.completed,
.status.available {
  background: var(--success);
  color: var(--success-text);
}

.status.failed,
.status.deleted,
.status.expired {
  background: rgba(142, 103, 107, 0.32);
  color: #f0b1b6;
}

.download-link {
  align-items: center;
  animation: downloadButtonIn 360ms ease forwards;
  background: #2e3842;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-strong);
  display: inline-flex;
  font-family: var(--display-font);
  font-size: 18px;
  font-weight: 650;
  justify-content: center;
  margin-top: 28px;
  min-height: 52px;
  opacity: 0;
  padding: 0 28px;
  text-decoration: none;
  transform: translateY(8px);
}

.download-link:hover {
  background: #26313b;
  color: #ffffff;
}

@keyframes downloadButtonIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.list {
  display: grid;
  gap: 12px;
}

.list-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.list-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.list-item strong {
  display: block;
  font-family: var(--display-font);
  font-size: 18px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.clickable-row {
  cursor: default;
}

.clickable-row:hover {
  background: rgba(127, 145, 164, 0.06);
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--text-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  min-height: 0;
  padding: 0;
  text-align: left;
}

.link-button:hover {
  background: transparent;
  color: #ffffff;
  text-decoration: underline;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: var(--text);
  font-size: 14px;
}

.truncate {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.redirect-shell {
  align-content: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.redirect-panel {
  margin: 0 auto;
  max-width: 520px;
  text-align: center;
  width: 100%;
}

.redirect-panel h1 {
  color: var(--text-strong);
  font-size: 28px;
  margin: 0 0 12px;
}

.redirect-panel p {
  margin: 0;
}

.redirect-button {
  align-items: center;
  background: #2e3842;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-strong);
  display: inline-flex;
  font-family: var(--display-font);
  font-size: 18px;
  font-weight: 650;
  justify-content: center;
  margin-top: 28px;
  min-height: 52px;
  padding: 0 28px;
  text-decoration: none;
}

.redirect-button:hover {
  background: #26313b;
  color: #ffffff;
}

@media (max-width: 820px) {
  .shell {
    padding: 16px;
  }

  .shell.has-input input[type="url"] {
    padding-right: 232px;
  }

  .input-controls {
    gap: 5px;
  }

  .input-download {
    font-size: 15px;
    min-width: 92px;
    padding: 0 14px;
  }

  .mode-row span {
    min-height: 44px;
    padding: 0 9px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
