:root {
  --bg: #0c0e14;
  --panel: #151823;
  --panel-2: #1b1f2e;
  --text: #e8eaf2;
  --muted: #8b90a5;
  --accent: #39c5ff;
  --border: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.brand svg { display: block; }

#song-title {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 32vw;
}

#hdr-progress {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 180px;
  max-width: 280px;
}
#hdr-progress-text {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hdr-progress .bar-track { height: 3px; }
#hdr-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

#track-chips {
  display: flex;
  gap: 6px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
#track-chips::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: rgba(255, 255, 255, 0.2); }
.chip.muted { opacity: 0.38; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.22); }
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #06121a;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }

/* ---------- Stage ---------- */
#stage { position: relative; flex: 1; min-height: 0; }
#viz { position: absolute; inset: 0; display: block; }

/* ---------- Transport ---------- */
footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  height: 56px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex: none;
}

#btn-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #06121a;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
#btn-play:hover { filter: brightness(1.08); }
#btn-play svg { display: block; }

#time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
  min-width: 86px;
  text-align: center;
}

#seek { flex: 1; accent-color: var(--accent); height: 4px; cursor: pointer; }

select, .vol-wrap { background: transparent; color: var(--text); }
#speed {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
}
.model-pick { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
#model-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}
.vol-wrap { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#volume { width: 90px; accent-color: var(--accent); height: 4px; }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 5;
}

#empty-state { pointer-events: none; }  /* keys stay clickable around the card */
#empty-state .card {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
#empty-state h1 { margin: 10px 0 4px; font-size: 22px; }
#empty-state p { margin: 0 0 20px; color: var(--muted); }
#empty-state .actions { display: flex; gap: 10px; justify-content: center; }

#jams-modal { z-index: 8; background: rgba(5, 7, 12, 0.72); }
.jams-card {
  width: 460px;
  max-width: 92vw;
  padding: 20px 22px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.jam-row.pending { cursor: default; }
.jam-row.pending:hover { background: none; }
.jam-row.pending .bar-track { margin-top: 7px; height: 3px; }
#pending-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.jams-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.jams-head h2 { margin: 0; font-size: 17px; }
#jams-list { max-height: 55vh; overflow-y: auto; margin: 0 -8px; }
.jams-empty { color: var(--muted); font-size: 13px; padding: 12px 8px; }
.jam-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.jam-row:hover { background: var(--panel-2); }
.jam-info { flex: 1; min-width: 0; }
.jam-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jam-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.jam-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  flex: none;
}
.jam-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.jam-btn.danger:hover { color: #ff8585; }
.jam-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.jam-btn:disabled:hover { color: var(--muted); background: none; }
.jam-btn.danger.armed {
  color: #ff8585;
  background: rgba(255, 110, 110, 0.12);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

#drop-hint {
  background: rgba(57, 197, 255, 0.08);
  border: 2px dashed rgba(57, 197, 255, 0.6);
  margin: 10px;
  border-radius: 14px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
  pointer-events: none;
  z-index: 10;
}

#toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a1215;
  border: 1px solid #a33;
  color: #ffd7d7;
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 20;
  max-width: 80vw;
}

#loading {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  z-index: 20;
  width: 300px;
}
#loading-text { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.bar-track { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
#loading-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

[hidden] { display: none !important; }
