:root {
  --bg: #0f1115;
  --panel: #171a21;
  --accent: #6c5ce7;
  --accent-2: #00cec9;
  --text: #e8e8ec;
  --muted: #8a8d98;
  --border: #262a35;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #23263066, var(--bg));
}

.join-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: min(90vw, 380px);
  text-align: center;
}

.join-card h1 { margin-top: 0; color: var(--accent-2); }
.join-card p { color: var(--muted); font-size: 14px; }

.join-card input {
  width: 100%;
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d0f14;
  color: var(--text);
}

.auth-error {
  color: #e74c3c;
  font-size: 13px;
  min-height: 18px;
  text-align: left;
  margin-top: 4px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.auth-actions button { flex: 1; }

.lobby-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: min(90vw, 480px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.lobby-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.lobby-header h1 { margin: 0; color: var(--accent-2); flex: 1; }

#room-search {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d0f14;
  color: var(--text);
}

.room-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
}
.room-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.room-list .room-info { flex: 1; min-width: 0; }
.room-list .room-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.room-list .room-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.room-list .empty { color: var(--muted); text-align: center; padding: 24px 0; border: none; }
.room-list .remove-btn { background: transparent; color: #e74c3c; padding: 4px 8px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  transition: filter 0.15s;
}
button:hover { filter: brightness(1.1); }
button:active { filter: brightness(0.9); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.primary-btn { background: var(--accent-2); color: #06201f; font-weight: 600; }

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 20px; margin: 0; flex: 1; }
.my-name { color: var(--muted); font-size: 14px; }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #e74c3c;
}
.status-dot.connected { background: #2ecc71; }

main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

section, aside {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.now-playing { grid-column: 1; grid-row: 1; }
.add-track { grid-column: 1; grid-row: 2; }
.queue { grid-column: 1; grid-row: 3; }
.sidebar { grid-column: 2; grid-row: 1 / span 3; }

.track-title { font-size: 22px; font-weight: 600; }
.track-meta { color: var(--muted); font-size: 13px; margin-top: 4px; min-height: 18px; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
.progress-row input[type="range"] { flex: 1; }
.progress-row span { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

.controls { display: flex; align-items: center; gap: 10px; }
#loop-btn { background: transparent; border: 1px solid var(--border); color: var(--text); }
#loop-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.volume-row input[type="range"] { width: 100px; }
#volume-icon { font-size: 15px; width: 20px; text-align: center; }

.add-track form { display: flex; gap: 8px; margin-bottom: 10px; }
.add-track input[type="text"] {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d0f14;
  color: var(--text);
}
.add-status { color: var(--muted); font-size: 13px; min-height: 18px; }

.queue ul, .sidebar ul { list-style: none; padding: 0; margin: 0; }
.queue li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.queue li:last-child { border-bottom: none; }
.queue li.draggable { cursor: grab; }
.queue li.dragging { opacity: 0.4; }
.queue .progress-bar {
  height: 4px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.queue .progress-bar > div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.25s ease;
}
.queue .qmeta { color: var(--muted); font-size: 12px; }
.queue .remove-btn { background: transparent; color: #e74c3c; padding: 4px 8px; white-space: nowrap; }

.sidebar h2:first-child { margin-top: 0; }
.sidebar li { padding: 4px 0; font-size: 14px; color: var(--muted); }

h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-top: 0; }

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
  .now-playing, .add-track, .queue, .sidebar { grid-column: 1; }
  .sidebar { grid-row: auto; }

  /* On phones the transport buttons + a tiny 100px slider are cramped, so
     let the row wrap and give the volume its own full-width line with a
     comfortably large, easy-to-drag slider. */
  .controls { flex-wrap: wrap; }
  .volume-row { margin-left: 0; width: 100%; gap: 12px; }
  .volume-row input[type="range"] { width: auto; flex: 1; height: 28px; }
  #volume-icon { font-size: 22px; width: 32px; }
}
