/* YT Downloader - light minimal, YouTube theme (white + red) */
:root {
  --red: #ff0000;
  --red-dark: #cc0000;
  --bg: #ffffff;
  --bg-soft: #f9f9f9;
  --border: #e5e5e5;
  --text: #0f0f0f;
  --muted: #606060;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 20px; margin: 0; }
.brand-badge {
  background: var(--red);
  color: #fff;
  font-size: 14px;
  width: 32px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.health { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #ccc; }
.dot.ok { background: #2ba640; }
.dot.bad { background: var(--red); }

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  border: none;
  background: none;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--red); font-weight: 600; }

/* ---------- layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 24px; }
.panel { display: none; }
.panel.active { display: block; }

.url-row { display: flex; gap: 10px; }
.url-row input {
  flex: 1;
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.url-row input:focus { outline: 2px solid var(--red); border-color: var(--red); }

/* ---------- buttons ---------- */
.btn {
  padding: 12px 20px;
  font-size: 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--red-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- states ---------- */
.hidden { display: none !important; }
.error {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fdecea;
  border: 1px solid #f5c6c2;
  color: #a50e0e;
  border-radius: 8px;
  font-size: 14px;
}
.loading { margin-top: 18px; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner {
  width: 18px; height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.meta { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- single preview ---------- */
.preview {
  margin-top: 20px;
  display: flex;
  gap: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.preview img { width: 360px; max-width: 100%; border-radius: 8px; }
.preview-info h2 { margin: 0 0 4px; font-size: 19px; }
.format-row { display: flex; gap: 18px; margin-top: 14px; font-size: 15px; }
.format-row input { accent-color: var(--red); }

/* ---------- playlist ---------- */
.playlist-head { margin-top: 20px; }
.playlist-head h2 { margin: 0; font-size: 20px; }

.toolbar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.toolbar .format-row { margin-top: 0; }
.select-all { font-size: 15px; }
.select-all input { accent-color: var(--red); }
.selected-count { color: var(--muted); font-size: 14px; }

.grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  position: relative;
  transition: box-shadow 0.15s;
}
.card:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); }
.card.selected { border: 2px solid var(--red); }
.card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #eee; }
.card-body { padding: 10px 12px; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-check {
  position: absolute;
  top: 8px; left: 8px;
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.card.selected .card-check { background: var(--red); border-color: var(--red); }

/* ---------- zip progress ---------- */
.zip-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg-soft);
}
.zip-status { display: flex; justify-content: space-between; font-size: 15px; }
.progress { height: 10px; background: #eee; border-radius: 6px; margin-top: 10px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--red); transition: width 0.3s; }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; border-top: 1px solid var(--border); }

/* ---------- download progress ---------- */
.dl-progress { margin-top: 14px; }
.card-status { font-size: 12px; font-weight: 700; margin: 4px 0 0; }
.card-status.queued { color: var(--muted); }
.card-status.active { color: var(--red); }
.card-status.done { color: #2ba640; }
.card-status.failed { color: var(--red); }

/* ---------- access key prompt ---------- */
.key-prompt {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.key-prompt p { margin: 0 0 12px; font-size: 15px; }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  .url-row { flex-direction: column; }
  .preview { flex-direction: column; }
  main { padding: 16px; }
}
