* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #0f1115;
  color: #f0f4ff;
}

header {
  background: #151924;
  padding: 20px;
  border-bottom: 1px solid #1f2532;
  text-align: center;
  position: relative;
}

h1 {
  margin: 0;
  font-size: 24px;
}

.header-link {
  display: inline-block;
  margin-top: 8px;
  color: #2f8fed;
  text-decoration: none;
  font-size: 14px;
}

.header-link:hover {
  text-decoration: underline;
}

.self-user {
  position: absolute;
  top: 18px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.self-user-name {
  font-size: 14px;
  color: #f0f4ff;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #2b3242;
  background: #252934;
  color: #f0f4ff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.logout-btn:hover {
  background: #303645;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr 0.8fr;
  gap: 16px;
  padding: 16px;
}

.panel {
  background: #151924;
  border: 1px solid #1f2532;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.panel h2 {
  margin-top: 0;
}

.playlists .playlist-item,
.tracks .track-item {
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #1c2230;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.playlists .playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.playlist-item-title {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-creator {
  font-size: 12px;
  color: #9eadc7;
  white-space: nowrap;
  flex-shrink: 0;
}

.playlists .playlist-item:hover,
.tracks .track-item:hover {
  background: #212a3d;
  transform: translateY(-1px);
}

.playlists .playlist-item.active,
.tracks .track-item.active {
  border: 1px solid #2f8fed;
  box-shadow: 0 0 10px rgba(47, 143, 237, 0.4);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 20px 0;
}

.control-btn {
  border: none;
  background: transparent;
  color: #f0f4ff;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  padding: 0;
}

.control-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(47, 143, 237, 0.4);
}

.control-secondary {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #252934;
  color: #b2b7c6;
}

.control-secondary:hover {
  background: #303645;
  color: #e4e8f3;
}

.control-shuffle {
  position: relative;
  width: 44px;
  height: 44px;
}

.control-shuffle::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f0f4ff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h3c2 0 3 2 5 5s3 5 5 5h3'/%3E%3Cpath d='M15 9l2-2 2 2'/%3E%3Cpath d='M15 15l2 2 2-2'/%3E%3Cpath d='M4 17h3c2 0 3-2 5-5'/%3E%3C/svg%3E");
}

.control-shuffle.is-active::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b0f18' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h3c2 0 3 2 5 5s3 5 5 5h3'/%3E%3Cpath d='M15 9l2-2 2 2'/%3E%3Cpath d='M15 15l2 2 2-2'/%3E%3Cpath d='M4 17h3c2 0 3-2 5-5'/%3E%3C/svg%3E");
}

.control-loop {
  width: 44px;
  height: 44px;
}

.control-toggle {
  border: 1px solid transparent;
}

.control-toggle.is-active {
  background: rgba(47, 143, 237, 0.25);
  color: #f0f4ff;
  border-color: rgba(47, 143, 237, 0.6);
  box-shadow: 0 0 8px rgba(47, 143, 237, 0.35);
}

.control-primary {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #f8f9ff;
  color: #11131b;
  font-size: 30px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.control-primary.is-playing {
  color: #11131b;
}

.control-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.now-playing {
  margin-bottom: 10px;
}

.playlist-name {
  color: #7f8ca8;
  margin: 0 0 4px;
}

.progress {
  margin: 12px 0;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #1f2532;
  border-radius: 10px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2f8fed, #21c7b8);
  transition: width 0.1s linear;
}

.time {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #9eadc7;
  margin-top: 6px;
}

.users ul,
#user-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#user-list li {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #1c2230;
  border-radius: 8px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

#user-list li.is-following-target {
  border-color: rgba(47, 143, 237, 0.8);
  box-shadow: 0 0 10px rgba(47, 143, 237, 0.4);
}

#user-list li.is-self {
  border-color: rgba(33, 199, 184, 0.8);
}

.user-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2f8fed;
  box-shadow: 0 0 8px rgba(47, 143, 237, 0.6);
}

.user-name {
  flex: 1;
  font-weight: 600;
}

.user-badges {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.user-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(47, 143, 237, 0.4);
  background: rgba(47, 143, 237, 0.15);
  color: #d1e7ff;
  white-space: nowrap;
}

.user-badge-self {
  border-color: rgba(33, 199, 184, 0.45);
  background: rgba(33, 199, 184, 0.15);
  color: #21c7b8;
}

.user-badge-following {
  border-color: rgba(47, 143, 237, 0.7);
  color: #8ec2ff;
}

.user-action {
  border: none;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #2f8fed, #21c7b8);
  color: #0b0f18;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.user-action:hover {
  transform: translateY(-1px);
}

.user-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.user-action-stop {
  background: #f04f64;
  color: #0b0f18;
}

#playlists.is-disabled,
#tracks.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.overlay-content {
  background: #151924;
  border: 1px solid #1f2532;
  border-radius: 12px;
  padding: 20px 24px;
  width: 300px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.overlay input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid #2b3242;
  background: #0f1115;
  color: #f0f4ff;
}

.overlay button {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f8fed, #21c7b8);
  color: #0b0f18;
  font-weight: 700;
  cursor: pointer;
}

.tracks {
  margin-top: 12px;
}

.track-title {
  margin: 0;
  font-weight: 600;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .controls {
    gap: 12px;
  }
  .control-primary {
    width: 58px;
    height: 58px;
  }
  .control-secondary {
    width: 38px;
    height: 38px;
  }
}
