:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface-hover: #252525;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --danger: #e91429;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--surface-hover);
}

.logo {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  transition: color 0.2s;
}

.logo.connected {
  color: var(--accent);
}

.logo.disconnected {
  color: var(--danger);
}

.tagline {
  margin: 0.25rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.host-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.hidden {
  display: none !important;
}

.auth-screen {
  margin: 1.5rem 0;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.auth-screen h2 {
  margin-bottom: 0.25rem;
}

.auth-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  padding: 0.4rem 0.75rem;
  font-family: var(--font);
  font-size: 0.9rem;
  background: var(--surface-hover);
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  background: var(--accent);
  color: #000;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.auth-form input {
  padding: 0.6rem 1rem;
  font-family: var(--font);
  font-size: 1rem;
  border: 1px solid var(--surface-hover);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-guest {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid var(--surface-hover);
}

.auth-guest p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.guest-hint {
  margin-top: 0.35rem !important;
  font-size: 0.8rem !important;
}

.main {
  flex: 1;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.card h2 .count {
  color: var(--text-muted);
  font-weight: 400;
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.now-playing-track {
  font-size: 1rem;
  color: var(--text);
}

.now-playing-empty {
  display: block;
}

.now-playing-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 0;
}

.now-playing-artwork {
  flex-shrink: 0;
  width: 100%;
  max-width: 120px;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-hover);
}

.now-playing-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.now-playing-track .name {
  font-weight: 600;
}

.now-playing-track .artist {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.now-playing-track .duration {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.now-playing-track,
.on-deck-track {
  position: relative;
}

.vote-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.35rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--accent);
  color: #000;
}

.vote-badge.negative {
  background: var(--danger);
  color: #fff;
}

@media (min-width: 400px) {
  .now-playing-artwork {
    max-width: 160px;
  }
}

.on-deck-track {
  font-size: 0.95rem;
  color: var(--text);
}

.on-deck-empty {
  display: block;
}

.on-deck-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.on-deck-artwork-wrap {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-hover);
}

.on-deck-artwork,
.on-deck-artwork-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  display: block;
}

.on-deck-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.on-deck-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.on-deck-artist {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.on-deck-added,
.on-deck-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-row input {
  flex: 1;
  padding: 0.6rem 1rem;
  font-family: var(--font);
  font-size: 1rem;
  border: 1px solid var(--surface-hover);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.search-row input::placeholder {
  color: var(--text-muted);
}

.search-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--surface-hover);
}

.search-results li:last-child {
  border-bottom: none;
}

.search-result-artwork {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-hover);
}

.search-result-artwork-placeholder {
  display: block;
}

.search-results .track-info {
  flex: 1;
  min-width: 0;
}

.search-results .track-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-results .track-artist {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.queue-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--surface-hover);
}

.queue-list li:last-child {
  border-bottom: none;
}

.queue-item-artwork {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-hover);
}

.queue-item-artwork-placeholder {
  display: block;
}

.queue-item-info {
  flex: 1;
  min-width: 0;
}

.queue-item-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.vote-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.vote-controls .vote-count {
  min-width: 1.5rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.vote-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.vote-btn:hover {
  background: var(--accent);
  color: #000;
}

.vote-btn.down:hover {
  background: var(--danger);
  color: #fff;
}

.vote-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vote-btn.remove {
  padding: 0;
}

.vote-btn.remove .icon-trash {
  width: 1rem;
  height: 1rem;
  display: block;
}

.vote-btn.remove:hover {
  background: var(--danger);
  color: #fff;
}

.empty-queue {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 1rem 0;
}

.footer {
  padding: 1rem 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--surface-hover);
}

#user-name {
  color: var(--text);
  font-weight: 600;
}

.btn-link {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: inherit;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  margin-left: 0.25rem;
}

.btn-link:hover {
  color: var(--text);
}

@media (max-width: 480px) {
  .app {
    padding: 0.75rem;
  }

  .search-row {
    flex-direction: column;
  }

  .queue-list li {
    flex-wrap: wrap;
  }

  .vote-controls {
    width: 100%;
    justify-content: flex-end;
  }
}
