:root {
  --bg-start: #2d2d2d;
  --bg-end: #151515;
  --text: #d0d0d0;
  --text-muted: #c3c3c3;
  --text-muted-strong: #a8a8a8;
  --panel-bg: #000;
  --surface: rgba(255, 255, 255, 0.03);
  --control-bg: rgba(255, 255, 255, 0.14);
  --surface-hover: rgba(255, 255, 255, 0.12);
  --surface-strong: rgba(255, 255, 255, 0.25);
  --surface-dark: rgba(0, 0, 0, 0.2);
  --border: rgba(255, 255, 255, 0.05);
  --border-soft: rgba(255, 255, 255, 0.08);
  --primary: #2f78ff;
  --primary-strong: #1d5be7;
  --primary-soft: rgba(47, 120, 255, 0.18);
  --highlight: #ffeb8b;
  --highlight-text: #1d1d1d;
  --control-hover-bg: #fff2;
  --shadow-elevated: 0 8px 16px rgba(0, 0, 0, 0.16);
  --shadow-focus: 0 0 0 3px rgba(47, 120, 255, 0.18);
  --focus-outline: 2px solid rgba(47, 120, 255, 0.8);
  --radius: 6px;
  --radius-small: 4px;
  --radius-pill: 999px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.container {
  align-self: center;

  width: min(720px, calc(100% - 16px));
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: var(--radius);
  background: transparent;
  box-shadow: none;
}

#player {
  display: none;

  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--panel-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.control-pill-group {
  display: flex;
  gap: 2px;
}

.controls button,
.control-pill-group button {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 0;
  cursor: pointer;
  transition: 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--control-bg);
  position: relative;
}

#prev,
#next,
#shuffle {
  border-radius: 999px;
}

#prev {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

#play-pause {
  border-radius: 0;
}

#next {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.controls button img {
  display: block;
  width: 32px;
  height: 32px;
}

.controls button:hover {
  transform: scale(1.1);
  filter: brightness(0.88);
}

.controls button:focus-visible {
  outline: 2px solid rgba(47, 120, 255, 0.8);
  outline-offset: 3px;
}

.control-btn,
.control-btn:hover {
  background: transparent;
}

#search {
  width: 100%;
  margin: 0;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
  background: var(--control-bg);
  color: #f1f1f1;
  font: inherit;
  outline: none;
  box-shadow: none;
  line-height: 1.2;
}

#search:focus {
  background: rgba(255, 255, 255, 0.22);
}

.search-row {
  margin-top: 50px;
}

.search-field-wrap {
  display: flex;
  gap: 0;
  align-items: center;
}

#clear-search {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 20px 0 16px;
  border: none;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  background: var(--primary);
  color: var(--color-white);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-elevated);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  outline: none;
}

#clear-search:hover {
  background: var(--primary-strong);
}

#clear-search:focus {
  outline: none;
}

#search::placeholder {
  color: rgba(208, 208, 208, 0.7);
}

.search-highlight {
  background: var(--highlight);
  color: var(--highlight-text);
  border-radius: var(--radius-small);
  padding: 0 2px;
}

.playlist-empty {
  width: 100%;
  padding: 20px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
  background: var(--surface);
}

.controls button:hover {
  background-color: #fff2;
}

.tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 0.8rem;
  z-index: 10;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.8);
}

.video-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: center;
}

.seek-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0px;
  min-width: 0;
}

#seek-bar {
  width: 100%;
  appearance: none;
  background: var(--control-bg);
  height: 6px;
  border-radius: var(--radius-pill);
  outline: none;
}

#seek-bar:hover {
  cursor: pointer;
}

#seek-bar::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: transparent;
}

#seek-bar::-moz-range-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: transparent;
}

#seek-bar::-webkit-slider-thumb,
#seek-bar::-moz-range-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--color-white);
  cursor: pointer;
  box-shadow: var(--shadow-focus);
}

#seek-bar::-webkit-slider-thumb {
  margin-top: -5px;
}

#current-time,
#duration {
  color: var(--text-muted);
  font-size: 0.85rem;
  min-width: 42px;
  text-align: center;
}

.volume-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.volume-icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

#volume-slider {
  width: 100px;
  appearance: none;
  background: var(--control-bg);
  height: 6px;
  border-radius: var(--radius-pill);
  outline: none;
  cursor: pointer;
}

#volume-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: transparent;
}

#volume-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: transparent;
}

#volume-slider::-webkit-slider-thumb,
#volume-slider::-moz-range-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--color-white);
  cursor: pointer;
  box-shadow: var(--shadow-focus);
}

#volume-slider::-webkit-slider-thumb {
  margin-top: -4px;
}

#playlist {
  width: 100%;
  max-height: 320px;
  margin-top: 0;
  padding: 0;
  border-radius: var(--radius);
  border: none;
  background: var(--surface-dark);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.87rem;
  line-height: 1.2;
  outline: none;
  box-shadow: none;
  overflow-y: auto;
}

.playlist-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border-radius: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.playlist-item:nth-child(odd) {
  background: rgba(0, 0, 0, 0.3);
}

.playlist-item:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.playlist-item:hover {
  background: var(--surface-hover);
}

.playlist-item.active {
  background: var(--surface-strong);
}

.playlist-item-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 4px 6px;
  border-radius: 3px;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
}

.playlist-item-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#status {
  margin: 0;
  font-family: "Roboto Mono", monospace;
  color: var(--text-muted-strong);
  font-size: 0.9rem;
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
}

@media (max-width: 640px) {
  .container {
    width: calc(100% - 8px);
    margin: 12px;
    padding: 16px;
  }

  .controls {
    gap: 8px;
  }
}

#songTitle {
  position: relative;
  text-align: center;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 3.2rem;
}

.song-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.song-loading img {
  width: 100px;
  height: 100px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: translateY(-32px) rotate(0deg);
  }
  to {
    transform: translateY(-32px) rotate(360deg);
  }
}

.song-title-text {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-channel {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.song-channel i {
  font-style: italic;
}
