:root {
  --bg: #050814;
  --bg-elevated: #111827;
  --bg-elevated-soft: #1f2937;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.15);
  --text: #f9fafb;
  --text-soft: #9ca3af;
  --border-subtle: #1f2937;
  --danger: #ef4444;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #000 100%);
  color: var(--text);
  min-height: 100vh;
}

/* Layout */

#app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  background: linear-gradient(180deg, #020617 0%, #020617 50%, #020617 100%);
  border-right: 1px solid var(--border-subtle);
  padding: 1rem 1rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-circle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #22c55e, #0f766e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
  overflow-y: auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-heading {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  color: var(--text-soft);
}

.nav-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-soft);
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.nav-item:hover {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  transform: translateY(-1px);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-icon {
  width: 22px;
  display: inline-flex;
  justify-content: center;
}

.nav-label {
  flex: 1;
  text-align: left;
}

.nav-playlists,
.nav-categories {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.nav-pill {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.78rem;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-pill span.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.4);
}

.nav-pill:hover {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
}

.nav-pill.active {
  background: var(--accent-soft);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--accent);
}

/* Main */

.main {
  background: radial-gradient(circle at top left, rgba(34, 197, 94, 0.15), transparent 60%),
              radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.12), transparent 60%),
              #020617;
  padding: 1.25rem 1.5rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.main-header-left h1 {
  margin: 0;
  font-size: 1.4rem;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.main-header-right input[type="search"] {
  width: 230px;
  max-width: 100%;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 0.9rem;
}

.main-header-right input::placeholder {
  color: rgba(148, 163, 184, 0.8);
}

.main-header-right input:focus {
  outline: none;
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.4);
}

/* Track list header */

.track-list-header {
  display: grid;
  grid-template-columns: 30px minmax(0, 2.2fr) minmax(0, 1.2fr) minmax(0, 1fr) 140px;
  column-gap: 0.75rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-soft);
  border-bottom: 1px solid rgba(31, 41, 55, 0.8);
}

.track-list-header span:first-child {
  text-align: center;
}

.track-list-header .align-right {
  text-align: right;
}

/* Track rows */

.track-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.track-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 2.2fr) minmax(0, 1.2fr) minmax(0, 1fr) 140px;
  column-gap: 0.75rem;
  align-items: center;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}

.track-row:nth-child(even) {
  background: rgba(15, 23, 42, 0.35);
}

.track-row:hover {
  background: rgba(30, 64, 175, 0.3);
  transform: translateY(-1px);
}

.track-row.active {
  background: var(--accent-soft);
}

.track-index {
  text-align: center;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.track-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist,
.track-category {
  color: var(--text-soft);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
}

/* Buttons */

.mini-button {
  border: none;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
}

.mini-button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-btn {
  border-radius: 999px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-soft);
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pill-btn.primary {
  border-color: rgba(16, 185, 129, 0.7);
  color: var(--accent);
}

.pill-btn:hover {
  background: rgba(31, 41, 55, 0.95);
  color: var(--text);
}

/* Player bar */

.player-bar {
  grid-column: 1 / span 2;
  background: linear-gradient(90deg, #020617, #020617);
  border-top: 1px solid #111827;
  padding: 0.6rem 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  position: sticky;
  bottom: 0;
}

.player-info {
  min-width: 0;
}

.player-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.player-artist {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
}

.player-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-btn:hover {
  background: rgba(31, 41, 55, 1);
}

.primary-btn {
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #022c22;
  font-weight: 600;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.4), 0 12px 30px rgba(22, 163, 74, 0.25);
}

.primary-btn:hover {
  filter: brightness(1.05);
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  max-width: 360px;
  margin: 15vh auto 0;
  background: #020617;
  border-radius: 0.9rem;
  border: 1px solid rgba(31, 41, 55, 1);
  padding: 0.8rem 0.9rem 0.9rem;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1rem;
}

.modal-body {
  margin-top: 0.6rem;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.modal-playlist-item {
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(31, 41, 55, 1);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-playlist-item:hover {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(15, 23, 42, 0.95);
}

.modal-playlist-name {
  font-weight: 500;
}

.modal-playlist-count {
  font-size: 0.75rem;
  color: var(--text-soft);
}

/* Responsive */

@media (max-width: 840px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .sidebar {
    grid-row: 1;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 0.6rem 0.8rem;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .sidebar-header {
    margin-bottom: 0;
    margin-right: 0.8rem;
  }

  .nav-section {
    flex-direction: row;
    gap: 1rem;
  }

  .nav-group {
    min-width: 140px;
  }

  .main {
    grid-row: 2;
  }

  .player-bar {
    grid-column: auto;
    grid-row: 3;
  }
}

@media (max-width: 640px) {
  .track-list-header {
    display: none;
  }

  .track-row {
    grid-template-columns: 26px minmax(0, 1.6fr) minmax(0, 1.4fr);
    grid-template-rows: auto auto;
    row-gap: 0.15rem;
  }

  .track-artist,
  .track-category {
    font-size: 0.78rem;
  }

  .track-row > .track-artist {
    grid-column: 2;
    grid-row: 2;
  }

  .track-row > .track-category {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }

  .track-actions {
    display: none;
  }

  .main-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-header-right {
    width: 100%;
  }

  .main-header-right input[type="search"] {
    width: 100%;
  }

  .player-bar {
    grid-template-columns: minmax(0, 1.8fr) auto;
    grid-template-rows: auto auto;
  }

  .player-controls {
    justify-content: flex-end;
  }

  .player-actions {
    grid-column: 1 / span 2;
    display: flex;
    justify-content: flex-end;
    margin-top: 0.3rem;
  }
}
