:root {
  --bg: #000000;
  --surface: #000000;
  --hover: #202020;
  --border: #2e2e2e;
  --accent: #ff4444;
  --text: #ffffff;
  --muted: #ffffff;
  --radius: 6px;
  --font: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font-family: var(--font); overflow-x: hidden; }

/* player takes up whatever's left after the control bar, capped so it
   never pushes the controls off screen on short viewports */
#player-wrap {
  width: min(92vw, calc((100dvh - 188px) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  position: relative;
  margin: 0 auto;
}
#yt-player { position: absolute; inset: 0; width: 100%; height: 100%; }
#yt-player iframe { width: 100%; height: 100%; border: none; }

#bottom {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--surface);
  position: relative; /* dim-control anchors off this */
}

#ctrl-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
  padding-right: 2.4rem; /* leave room for the dim slider up top-right */
}

#input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
#input-bar label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

#playlist-input {
  flex: 1;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.38rem 0.7rem;
  font-size: 0.88rem;
  outline: none;
}
#playlist-input:focus { border-color: var(--accent); }
#playlist-input::placeholder { color: var(--muted); }

#status-bar { font-size: 0.78rem; color: var(--muted); min-height: 1em; }
#status-bar.error { color: #f87171; }

#playlist-hint {
  font-size: 0.72rem;
  color: #777;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.38rem 0.85rem;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  white-space: nowrap;
  font-family: var(--font);
  backface-visibility: hidden;
  transform: translateZ(0); /* keeps the hover lift from jittering on some GPUs */
}
button:disabled { opacity: .35; cursor: default; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px) translateZ(0);
  box-shadow: 0 6px 18px rgba(255, 68, 68, .4);
}

.btn-secondary { background: #161616; color: var(--text); }
.btn-secondary:hover:not(:disabled) {
  background: #202020;
  transform: translateY(-2px) translateZ(0);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .6);
}

.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled) {
  transform: scale(.96) !important;
  transition: transform .08s ease;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
/* custom checkbox — default one looked out of place against the dark UI */
.check-label input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  background: transparent;
  border: 1px solid #555;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.check-label input[type="checkbox"]:checked { border-color: #888; }
.check-label input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: #ffffff;
}

.panel { display: none; margin-top: 0.5rem; }
.panel.visible { display: block; }

.vid-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.vid-list li {
  padding: 0.28rem 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}
.vid-list li:last-child { border-bottom: none; }
.vid-list li:hover { background: var(--surface); color: var(--text); }
.vid-list li.active { color: var(--accent); font-weight: 600; }
.vid-list .num { color: #ffffff; font-size: 0.74rem; flex-shrink: 0; font-variant-numeric: tabular-nums; }

#search-input-el {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.38rem 0.7rem;
  font-size: 0.88rem;
  outline: none;
  margin-bottom: 0.4rem;
}
#search-input-el:focus { border-color: var(--accent); }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* saved playlists dropdown */
#saved-wrap { position: relative; display: inline-block; }
#saved-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 260px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
#saved-dropdown.open { display: block; }

.saved-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid #1e1e1e;
  font-size: 0.82rem;
}
.saved-item:last-child { border-bottom: none; }
.saved-item-name {
  flex: 1;
  cursor: pointer;
  color: var(--text);
  padding: 0.1rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-item-name:hover { color: var(--accent); }
.saved-item input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  outline: none;
}
.saved-item input:focus { border-color: var(--accent); }

.saved-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  color: var(--muted);
  font-weight: 600;
  transition: color .15s, background .15s;
}
.saved-action-btn:hover { color: var(--text); background: var(--border); }
.saved-action-btn.confirm-del { color: #f87171; }
.saved-action-btn.confirm-del:hover { background: rgba(248, 113, 113, .15); }
.saved-action-btn.confirm-save { color: #4ade80; }
.saved-action-btn.confirm-save:hover { background: rgba(74, 222, 128, .15); }
.saved-empty { padding: 0.5rem 0.7rem; font-size: 0.8rem; color: var(--muted); }

/* brightness slider for the bottom bar - lives outside #bottom-content so
   it never dims itself. slider expands to the left on hover, icon stays put */
#dim-control {
  position: absolute;
  top: 0.7rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  z-index: 5;
}
#dim-icon { font-size: 0.95rem; line-height: 1; user-select: none; order: 2; }
#dim-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 0;
  opacity: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  overflow: hidden;
  order: 1;
  transition: width .25s ease, opacity .2s ease;
}
#dim-control:hover #dim-slider,
#dim-control:focus-within #dim-slider {
  width: 100px;
  opacity: 1;
}
#dim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
#dim-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

#site-footer {
  text-align: center;
  font-size: 0.72rem;
  color: #666;
  padding: 1rem 1rem 1.4rem;
}
#site-footer a { color: #888; text-decoration: underline; }
#site-footer a:hover { color: var(--accent); }
