:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #1b1f26;
  --line: #262b34;
  --text: #e9edf2;
  --muted: #8e98a6;
  --accent: #1db954;
  --accent-soft: rgba(29, 185, 84, 0.15);
  --radius: 10px;
  --np-height: 92px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }

/* ---------- login / error ---------- */
.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #16311f 0%, var(--bg) 60%);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px;
  max-width: 400px;
  text-align: center;
}
.card h1 { margin: 12px 0 8px; font-size: 24px; }
.logo { font-size: 44px; }
.btn {
  display: inline-block;
  margin-top: 20px;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: pointer;
}
.btn-spotify { background: var(--accent); color: #06210f; border-color: transparent; font-weight: 600; }
.btn-spotify:hover { filter: brightness(1.08); }
.fineprint { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ---------- app shell ---------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 1fr var(--np-height);
  grid-template-areas: "sidebar main" "now now";
  height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  min-height: 0;
}
.brand { font-weight: 700; padding: 0 10px 18px; font-size: 15px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.is-active { color: var(--text); background: var(--accent-soft); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
}
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.who { min-width: 0; flex: 1; }
.who-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-plan { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.who-plan.is-premium { color: var(--accent); }
.who-plan.is-free { color: #d9a441; }
.logout { color: var(--muted); padding: 4px; }
.logout:hover { color: #e05a5a; }

/* ---------- main ---------- */
.main { grid-area: main; overflow-y: auto; min-height: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: rgba(11, 13, 16, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.search { flex: 1; max-width: 460px; }
.search input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.device-state { margin-left: auto; font-size: 12px; color: var(--muted); }
.device-state.is-ready { color: var(--accent); }
.device-state.is-error { color: #e05a5a; }

.banner {
  margin: 16px 24px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(217, 164, 65, .12);
  border: 1px solid rgba(217, 164, 65, .3);
  font-size: 13px;
}

.content { padding: 20px 24px 32px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.section-title { margin: 4px 0 16px; font-size: 20px; font-weight: 700; }
.section-sub { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); }

/* card grid (playlists, albums, artists) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: background .15s;
}
.tile:hover { background: var(--panel-2); }
.tile img, .tile .ph {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 6px; background: var(--panel-2); display: block;
}
.tile .ph { display: grid; place-items: center; font-size: 28px; color: var(--muted); }
.tile-name { margin-top: 10px; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* track rows */
.tracks { display: flex; flex-direction: column; }
.track {
  display: grid;
  grid-template-columns: 28px 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.track:hover { background: var(--panel-2); }
.track.is-current { background: var(--accent-soft); }
.track.is-current .track-title { color: var(--accent); }
.track-idx { color: var(--muted); font-size: 12px; text-align: right; }
.track img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; }
.track-main { min-width: 0; }
.track-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-artist { font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-dur { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.back {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 14px; cursor: pointer; margin-bottom: 14px;
}
.back:hover { color: var(--text); }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }

/* ---------- now playing bar ---------- */
.nowplaying {
  grid-area: now;
  display: grid;
  grid-template-columns: 1fr minmax(320px, 2fr) 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.np-track { display: flex; align-items: center; gap: 12px; min-width: 0; }
.np-art { width: 52px; height: 52px; border-radius: 6px; object-fit: cover;
  background: var(--panel-2); }
.np-meta { min-width: 0; }
.np-title { font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-artist { font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.np-controls { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.np-buttons { display: flex; align-items: center; gap: 14px; }
.icon {
  background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 4px;
}
.icon:hover { color: var(--text); }
.icon.is-on { color: var(--accent); }
.icon-play {
  background: var(--text); color: var(--bg);
  width: 34px; height: 34px; border-radius: 50%; font-size: 13px;
}
.icon-play:hover { color: var(--bg); transform: scale(1.06); }

.np-scrub { display: flex; align-items: center; gap: 8px; width: 100%; }
.time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  min-width: 34px; text-align: center; }

.np-right { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.np-right input { width: 110px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 4px; border-radius: 2px;
  background: var(--line); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%; background: var(--text);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text);
}
input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent); }

.toast {
  position: fixed; bottom: calc(var(--np-height) + 16px); left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  z-index: 50; max-width: 80vw; text-align: center;
}
.toast.is-error { border-color: #e05a5a; color: #ffb4b4; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "main" "now"; }
  .sidebar { display: none; }
  .nowplaying { grid-template-columns: 1fr auto; gap: 10px; }
  .np-right { display: none; }
  .np-scrub { display: none; }
}
