:root {
  --accent: #ffffff;          /* primary/secondary action — white, not neon */
  --live: #FF2F5F;            /* inline error / live */
  --text-secondary: #b9b3c4;  /* inactive tab / muted */
  --text-muted: #8b949e;
  --success: #2EFF8A;
}

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

[hidden] { display: none !important; }

body {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 20% 10%, #1c1726 0%, #0b0810 55%);
  color: #e6edf3;
  padding: 24px;
}

.card {
  width: 100%;
  /* full-screen layout: grids fit as many cards per row as the screen allows */
  max-width: 1800px;
  background: rgba(20, 16, 26, 0.85);
  border: 1px solid #2a2333;
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

h1 { font-size: 2.2rem; letter-spacing: -0.02em; font-weight: 800; color: #fff; }
.tagline { color: #8b949e; margin: 4px 0 24px; }

.row { display: flex; gap: 10px; }

input, select, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid #2a2333;
}

input, select {
  background: #0d0b12;
  color: #e6edf3;
  padding: 12px 14px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(255, 255, 255, 0.28); border-color: #6e7681; }

button {
  background: #1c1826;
  color: #e6edf3;
  padding: 12px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
button:hover { background: #272134; }
button:disabled { opacity: 0.6; cursor: wait; }

/* ---- primary action: solid white, bold ---- */
button.primary {
  width: 100%;
  margin-top: 18px;
  background: #ffffff;
  border: none;
  color: #0b0810;
  font-weight: 700;
  padding: 14px;
}
button.primary:hover { background: #e9e6ef; }

button.primary-gradient {
  background: #ffffff;
  border: none;
  color: #0b0810;
  font-weight: 700;
}
button.primary-gradient:hover { background: #e9e6ef; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.chip {
  background: #0d0b12;
  border: 1px solid #2a2333;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
}
.chip:hover { background: #161320; border-color: #6e7681; }
.chip.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}

.grid-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

/* result count above a grid — prominent, not a muted caption */
.result-count {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.result-card.vertical { flex-direction: column; align-items: stretch; gap: 10px; }
.result-card.vertical button.download { width: 100%; }

.search-section { margin-bottom: 26px; }

.control-group { margin-bottom: 14px; }
.control-label {
  display: block;
  font-size: 0.85rem;
  color: #8b949e;
  margin-bottom: 2px;
}

.saved-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  background: rgba(46, 255, 138, 0.12);
  color: var(--success);
  border: 1px solid rgba(46, 255, 138, 0.4);
  border-radius: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  pointer-events: none;
}

.result-card { position: relative; }

.result-card .rc-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.result-card.vertical .rc-actions {
  flex-direction: row;
  margin-top: auto;
}
.result-card.vertical .rc-actions button { flex: 1; padding: 10px 12px; }

/* ---- tabs: bold white text links ---- */
.tabs {
  display: flex;
  gap: 24px;
  margin: 18px 0 22px;
  border-bottom: 1px solid #2a2333;
}
.tab {
  background: none;
  border: none;
  border-radius: 0;
  padding: 8px 2px 10px;
  margin-bottom: -1px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}
.tab:hover { background: none; color: #fff; }
.tab.active { color: #fff; border-bottom-color: #fff; }

/* ---- disk status ---- */
.disk-status { margin-bottom: 18px; }

.disk-bar {
  height: 6px;
  border-radius: 3px;
  background: #21262d;
  overflow: hidden;
}
.disk-fill {
  height: 100%;
  width: 0%;
  min-width: 2px;
  border-radius: 3px;
  background: #ffffff;
  transition: width 0.3s;
}
.disk-fill.alert { background: var(--live); }

.disk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.disk-text { color: var(--text-muted); font-size: 0.82rem; }
.disk-text.alert { color: var(--live); }
.disk-warn { color: var(--live); font-size: 0.82rem; margin-top: 2px; }

#cleanup-btn { padding: 8px 14px; font-size: 0.82rem; }
#cleanup-result { margin-top: 6px; }

/* ---- library view ---- */
.lib-filter { margin: 0 0 14px; }

.lib-section { margin-top: 26px; }
.lib-section:first-child { margin-top: 10px; }
.lib-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid #2a2333;
}
.lib-section-count {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.lib-summary { color: var(--text-muted); font-size: 0.9rem; }

.lib-card { position: relative; }
.lib-card h3 { padding-right: 54px; }

.card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #d9d4e2;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  pointer-events: none;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.lib-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: #0d0b12;
  border: 1px solid #2a2333;
  border-radius: 12px;
  transition: opacity 0.25s;
}
.lib-card.fade-out { opacity: 0; }
.lib-card h3 {
  font-size: 0.9rem;
  line-height: 1.35;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.lib-actions { display: flex; gap: 8px; margin-top: auto; }
.lib-actions button { flex: 1; padding: 9px 10px; font-size: 0.85rem; }

button.dl-again {
  background: #ffffff;
  border: none;
  color: #0b0810;
  font-weight: 700;
}
button.dl-again:hover { background: #e9e6ef; }

button.btn-delete {
  background: #100d18;
  border: 1px solid #2a2333;
  color: var(--text-secondary);
}
button.btn-delete:hover {
  background: #100d18;
  border-color: var(--live);
  color: var(--live);
}

.confirm-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  font-size: 0.83rem;
  color: var(--text-secondary);
}
.confirm-row button { padding: 7px 12px; font-size: 0.8rem; }
button.confirm-yes {
  background: transparent;
  border: 1px solid var(--live);
  color: var(--live);
}
button.confirm-yes:hover { background: rgba(255, 47, 95, 0.08); }

.lib-empty { text-align: center; color: var(--text-muted); padding: 36px 0 16px; }

/* ---- paste-a-direct-link section ---- */
.paste-section { margin-top: 22px; }

.section-label {
  color: #8b949e;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

/* secondary action: white outline, bold */
button.secondary {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.55);
  font-weight: 700;
  transition: background 0.15s;
}
button.secondary:hover { background: rgba(255, 255, 255, 0.08); }
button.secondary:disabled { opacity: 0.7; cursor: wait; }

.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: #0b0810;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
button.secondary .btn-spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}
@keyframes spin { to { transform: rotate(360deg); } }

.inline-error {
  margin-top: 10px;
  color: var(--live);
  font-size: 0.85rem;
  word-break: break-word;
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  background: #0d0b12;
  border: 1px solid #2a2333;
  border-radius: 12px;
}
.result-card .rc-body { flex: 1; min-width: 0; }
.result-card h3 {
  font-size: 0.95rem;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.result-card .rc-meta {
  color: #8b949e;
  font-size: 0.82rem;
  margin-top: 4px;
}
button.download {
  background: #ffffff;
  border: none;
  color: #0b0810;
  font-weight: 700;
  padding: 10px 16px;
  flex-shrink: 0;
}
button.download:hover { background: #e9e6ef; }

.error {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #3d1d20;
  border: 1px solid #f8514966;
  color: #ff7b72;
  font-size: 0.9rem;
  word-break: break-word;
}

#result { margin-top: 24px; }

.video-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
.video-meta h2 { font-size: 1.05rem; line-height: 1.35; }
.video-meta p { color: #8b949e; font-size: 0.9rem; margin-top: 4px; }

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: #8b949e;
}
.controls small { color: #6e7681; }

.note { margin-top: 12px; color: #8b949e; font-size: 0.85rem; text-align: center; }

@media (max-width: 560px) {
  .card { padding: 24px; }
  .row { flex-direction: column; }
  .controls { grid-template-columns: 1fr; }
  .video-meta { flex-direction: column; align-items: flex-start; }
}
