:root {
  --bg: #0b0d12;
  --panel: #14171f;
  --panel-2: #1b1f2a;
  --text: #e8eaf0;
  --muted: #8b91a0;
  --accent: #1db954;      /* Spotify green */
  --accent-2: #7b5cff;
  --warn: #ffb454;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: radial-gradient(1200px 600px at 70% -10%, #1a1f35 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px;
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.user-chip {
  background: var(--panel); border: 1px solid #262b38;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted);
}

main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 12px 20px 60px; }

h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.8px; margin: 18px 0 8px; }
h2 { font-size: 17px; margin-bottom: 12px; }
.lede { color: var(--muted); line-height: 1.55; max-width: 60ch; margin-bottom: 22px; }

.card {
  background: var(--panel); border: 1px solid #232836;
  border-radius: var(--radius); padding: 22px; margin-bottom: 20px;
}

.setup-steps { margin: 0 0 16px 20px; color: var(--muted); line-height: 2; }
.setup-steps code {
  background: var(--panel-2); padding: 2px 8px; border-radius: 6px;
  font-size: 12px; color: var(--accent);
  word-break: break-all;
}
.setup-steps a { color: var(--accent-2); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }

input[type="text"] {
  flex: 1; min-width: 240px;
  background: var(--panel-2); border: 1px solid #2b3040; color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 14px;
}
input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn {
  border: none; cursor: pointer; border-radius: 10px;
  padding: 12px 20px; font-size: 14px; font-weight: 700; color: var(--text);
  background: var(--panel-2); transition: transform .08s ease, opacity .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: #06220f; }
.btn.ghost { background: transparent; border: 1px solid #2b3040; color: var(--muted); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn.big { width: 100%; padding: 15px; font-size: 16px; margin-top: 8px; }

.hint { color: var(--muted); font-size: 12.5px; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; margin-top: 18px;
}
.tile {
  background: var(--panel); border: 1px solid #232836; border-radius: var(--radius);
  padding: 12px; cursor: pointer; text-align: left; color: var(--text);
  transition: transform .1s ease, border-color .15s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.tile-blank {
  width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: var(--muted);
}
.tile-blank.sm { width: 44px; height: 44px; aspect-ratio: auto; font-size: 18px; flex: none; }
.tile-name { font-weight: 700; font-size: 14px; margin-top: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.controls .control { margin-bottom: 16px; }
.controls label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  background: var(--panel-2); border: 1px solid #2b3040; color: var(--muted);
  border-radius: 999px; padding: 8px 16px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.seg button.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

.control-note { color: var(--muted); font-weight: 400; }
#genre-search { width: 100%; margin-bottom: 4px; padding: 9px 12px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-height: 132px; overflow-y: auto; }
.chip {
  background: var(--panel-2); border: 1px solid #2b3040; color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-weight: 600;
  transition: border-color .12s;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #06220f; }
.chip.static { cursor: default; }
.chip.static:hover { border-color: #2b3040; }

.lastfm-row { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.lastfm-row a { color: var(--accent-2); }
.lastfm-row .ok { color: var(--accent); font-weight: 600; }
.lastfm-row .muted { color: #6a7080; }

.row.spread { justify-content: space-between; }
.rule {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-2); border-radius: 10px; padding: 10px 14px; margin: 6px 0;
}
.rule-name { font-weight: 700; font-size: 14px; }
.rule-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.status {
  background: var(--panel); border: 1px solid #232836; border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 12px 16px; margin: 14px 0; font-size: 13.5px; color: var(--muted);
}
.status.warn { border-left-color: var(--warn); }

.setlist { margin-top: 10px; }
.track {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid #232836;
  border-radius: 12px; padding: 10px 16px; margin: 6px 0;
}
.track img { width: 44px; height: 44px; border-radius: 6px; flex: none; }
.pos { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; width: 24px; flex: none; }
.track-meta { flex: 1; min-width: 0; }
.track-name { font-weight: 700; font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-artist { color: var(--muted); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 6px; flex: none; }
.badge {
  font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); white-space: nowrap;
}
.badge.key { color: #9ef0b8; }
.badge.bpm { color: #9db8ff; }
.badge.energy { color: #ffc98a; }

.transition {
  color: var(--accent-2); font-size: 12px; font-weight: 600;
  padding: 2px 0 2px 56px; opacity: .9;
}

#save-row { margin-top: 18px; }
#save-result a { color: var(--accent); }

footer { text-align: center; color: #4d5361; font-size: 12px; padding: 24px; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .badges { display: none; }
  .transition { padding-left: 16px; }
}
