:root {
  --background: #0f172a;
  --surface: #1e293b;
  --muted-surface: #111827;
  --primary: #ff5252;
  --primary-hover: #ff8a65;
  --secondary: #006aa3;
  --accent: #00bfa5;
  --violet: #5c6bc0;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --glass: rgba(255, 255, 255, 0.03);
  --danger: #fca5a5;
  --warning: #fbbf24;
  --focus: #00bfa5;
  color-scheme: dark;
  font-family: Lato, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 1.8rem;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.brand p,
.message,
.empty,
.preview-meta,
.queue-count {
  color: var(--text-muted);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 20px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

.tool-card,
.queue-card,
.preview,
.download-job {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.tool-card,
.queue-card {
  padding: 20px;
}

.url-label,
.tab-panel label:not(.check-row) {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-weight: 700;
}

.url-row {
  display: flex;
  align-items: stretch;
  margin-bottom: 10px;
}

.url-row input {
  min-width: 0;
  flex: 1;
  height: 48px;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: var(--muted-surface);
  color: var(--text);
  padding: 0 14px;
}

.message {
  min-height: 24px;
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.message.error,
.download-error {
  color: var(--danger);
}

.mode-group {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.mode-group legend {
  padding: 0 6px;
  color: var(--text-muted);
  font-weight: 700;
}

.mode-group label,
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-list button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted-surface);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

.tab-list button[aria-selected="true"] {
  border-color: var(--accent);
  background: rgba(0, 191, 165, 0.14);
}

.tab-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: 116px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--glass);
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted-surface);
  color: var(--text);
  padding: 0 12px;
}

#panel-download {
  grid-template-columns: 1fr;
}

.check-row {
  min-height: 32px;
}

.option-row {
  display: grid;
  gap: 4px;
}

.option-description {
  margin: 0 0 4px 26px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.check-row input:disabled + span {
  color: var(--text-muted);
}

.option-warning {
  display: none;
  color: var(--warning);
  font-size: 0.9rem;
}

.option-warning.visible {
  display: inline;
}

.preview {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 164px;
  margin-bottom: 18px;
  padding: 16px;
}

.cover-art,
.job-thumb {
  background: var(--muted-surface);
  object-fit: cover;
}

.cover-art {
  width: 132px;
  height: 132px;
  border-radius: 8px;
}

.preview-name {
  margin-bottom: 12px;
  font-size: 1.15rem;
  font-weight: 800;
}

.preview-status {
  min-height: 24px;
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 800;
}

.preview-progress {
  width: 100%;
  height: 10px;
  margin: 0 0 12px;
  border-radius: 999px;
  background: var(--muted-surface);
  overflow: hidden;
}

.preview-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.preview-progress.indeterminate .preview-progress-fill {
  width: 42%;
  animation: preview-indeterminate 1.1s ease-in-out infinite;
}

@keyframes preview-indeterminate {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(250%);
  }
}

.preview-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.preview-meta div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 8px;
}

.preview-meta dt {
  font-weight: 800;
}

.preview-meta dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.download-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 168px;
  height: 58px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.attached-download {
  flex: 0 0 126px;
  width: 126px;
  height: 48px;
  margin: 0;
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: var(--muted-surface);
}

.download-button img {
  max-width: 112px;
  max-height: 38px;
  object-fit: contain;
}

.download-button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.48;
}

.queue-card {
  align-self: start;
  position: sticky;
  top: 16px;
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.queue-count {
  min-width: 34px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--muted-surface);
  font-weight: 800;
}

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

.download-job {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.job-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
}

.job-title {
  margin: 0 0 6px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.job-meta {
  min-height: 22px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--muted-surface);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.file-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin-top: 10px;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--text);
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .queue-card {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar,
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .tool-card,
  .queue-card {
    padding: 14px;
  }

  .tab-panel,
  .preview {
    grid-template-columns: 1fr;
  }

  .cover-art {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .preview-meta div {
    grid-template-columns: 1fr;
  }

  .attached-download {
    flex-basis: 94px;
    width: 94px;
  }

  .attached-download img {
    max-width: 82px;
  }
}
