:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --card-2: #22263320;
  --border: #2c3040;
  --text: #e8eaf0;
  --muted: #9aa0b0;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --error: #ff6b6b;
  --ok: #3ecf8e;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #dde0e8;
    --text: #1a1d27;
    --muted: #5b6170;
    --accent: #2563eb;
    --accent-hover: #1d4fd8;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

header { margin-bottom: 20px; }
h1 { font-size: 1.6rem; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 0.9rem; }

.input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#url-input {
  flex: 1 1 240px;
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
#url-input:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: wait; }

.status { margin-top: 16px; color: var(--muted); }

.error {
  margin-top: 16px;
  padding: 14px;
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.error .error-detail { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

.hidden { display: none !important; }

.media-card {
  display: flex;
  gap: 14px;
  margin-top: 24px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: flex-start;
}
.media-card img {
  width: 140px;
  max-width: 35%;
  border-radius: 6px;
  flex-shrink: 0;
}
.media-meta h2 { font-size: 1.05rem; margin-bottom: 4px; word-break: break-word; }
.media-meta p { color: var(--muted); font-size: 0.85rem; }
.drm-warning { color: var(--error) !important; margin-top: 6px; }

.format-group { margin-top: 20px; }
.format-group h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 10px 12px; text-align: left; white-space: nowrap; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
}
tr + tr td { border-top: 1px solid var(--border); }
td.dim { color: var(--muted); }

.dl-btn { padding: 7px 14px; font-size: 0.85rem; }
.mp3-btn {
  padding: 7px 10px; font-size: 0.8rem;
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent);
}
.mp3-btn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

#downloads-section { margin-top: 28px; }
#downloads-section h3 { font-size: 1rem; margin-bottom: 10px; }

.job {
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 0.88rem;
}
.job .job-label { word-break: break-word; margin-bottom: 6px; }
.job .job-stats { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.job .job-error { color: var(--error); margin-top: 4px; }
.job a.save-link { color: var(--ok); font-weight: 600; }

.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-fill.indeterminate {
  width: 30% !important;
  animation: slide 1.2s linear infinite;
}
@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(400%); }
}

footer { margin-top: 40px; color: var(--muted); font-size: 0.78rem; }
