:root {
  color-scheme: dark;
  --background: #07111f;
  --surface: #0e1b2d;
  --surface-raised: #15253a;
  --surface-soft: #1b2d45;
  --text: #f8fafc;
  --muted: #9fb0c5;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #5eead4;
  --accent-strong: #2dd4bf;
  --accent-ink: #042f2e;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 80% -10%, rgba(45, 212, 191, 0.18), transparent 35rem),
    linear-gradient(145deg, #07111f 0%, #0b1626 48%, #07111f 100%);
  padding-bottom: 112px;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(94, 234, 212, 0.7);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  transform: translateY(-180%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 112px);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  min-height: calc(100vh - 112px);
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.78);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.brand img {
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(45, 212, 191, 0.2);
}

.brand div {
  display: grid;
  line-height: 1.2;
}

.brand strong {
  font-size: 1.05rem;
}

.brand span {
  color: var(--muted);
  font-size: 0.76rem;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--surface-raised);
  color: var(--text);
}

.nav-item.is-active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 14px 10px;
  border-top: 1px solid var(--border);
}

.privacy-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.main-content {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 32px clamp(22px, 4vw, 58px) 64px;
}

.topbar,
.section-heading,
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar h1,
.section-heading h2,
.status-panel h2,
.dialog-card h2 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
  letter-spacing: -0.05em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.avatar-button,
.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 12px 36px rgba(45, 212, 191, 0.18);
}

.primary-button:hover {
  background: #99f6e4;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface-raised);
}

.secondary-button:hover {
  background: var(--surface-soft);
}

.danger-button {
  background: rgba(251, 113, 133, 0.15);
  color: #fecdd3;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.text-button:hover {
  color: var(--text);
}

.avatar-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(94, 234, 212, 0.35);
  border-radius: 50%;
  background: rgba(94, 234, 212, 0.13);
  color: var(--accent);
  font-weight: 850;
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 36px 0;
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  border: 1px solid rgba(94, 234, 212, 0.22);
  border-radius: 26px;
  background:
    linear-gradient(120deg, rgba(94, 234, 212, 0.13), rgba(21, 37, 58, 0.8)),
    var(--surface);
  box-shadow: var(--shadow);
}

.status-panel p,
.empty-state p,
.section-heading p,
.dialog-card p {
  color: var(--muted);
}

.status-panel p {
  max-width: 720px;
  margin: 8px 0 0;
  line-height: 1.65;
}

.library-toolbar {
  margin: 34px 0 24px;
}

.search-field {
  flex: 1;
  max-width: 620px;
}

.search-field input,
.sort-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(14, 27, 45, 0.86);
  color: var(--text);
}

.search-field input {
  min-height: 46px;
  padding: 11px 15px;
}

.sort-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.sort-field select {
  padding: 9px 34px 9px 12px;
}

.library-section {
  margin-top: 22px;
}

.section-heading {
  margin-bottom: 20px;
}

.section-heading p {
  margin: 5px 0 0;
  font-size: 0.86rem;
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 18px;
}

.track-card {
  min-width: 0;
}

.track-play-target {
  display: block;
  width: 100%;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: rgba(14, 27, 45, 0.74);
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.track-play-target:hover {
  transform: translateY(-3px);
  border-color: var(--border);
  background: var(--surface-raised);
}

.artwork-wrap {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 20%, rgba(94, 234, 212, 0.38), transparent 35%),
    linear-gradient(145deg, #1f3854, #0b1728);
}

.track-artwork {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track-artwork.has-image {
  display: block;
}

.artwork-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.66);
  font-size: 2.6rem;
}

.track-artwork.has-image + .artwork-fallback {
  display: none;
}

.card-play {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  opacity: 0;
  transform: translateY(8px);
  transition: 150ms ease;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

.track-play-target:hover .card-play,
.track-play-target:focus-visible .card-play {
  opacity: 1;
  transform: translateY(0);
}

.track-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 3px 2px;
}

.track-meta strong,
.track-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-title {
  font-size: 0.95rem;
}

.track-artist,
.track-album {
  color: var(--muted);
  font-size: 0.79rem;
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 60px 24px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 22px;
  background: rgba(94, 234, 212, 0.12);
  color: var(--accent);
  font-size: 2rem;
}

.empty-state h3 {
  margin-bottom: 0;
}

.player-bar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.45fr) minmax(180px, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 96px;
  padding: 14px 24px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.94);
  backdrop-filter: blur(24px);
  box-shadow: 0 -14px 50px rgba(0, 0, 0, 0.25);
}

.now-playing {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.player-artwork {
  display: grid;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-raised) center / cover no-repeat;
  color: var(--accent);
}

.track-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.track-copy strong,
.track-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-copy span {
  color: var(--muted);
  font-size: 0.82rem;
}

.transport {
  display: grid;
  gap: 8px;
}

.transport-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.transport-buttons button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.transport-buttons button:hover,
.transport-buttons button[aria-pressed="true"] {
  color: var(--accent);
}

.transport-buttons .play-button {
  width: 44px;
  height: 44px;
  background: var(--text);
  color: #08111e;
}

.transport-buttons button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.timeline {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.timeline input,
.volume-control input {
  accent-color: var(--accent-strong);
}

.volume-control {
  justify-self: end;
}

.volume-control label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.volume-control input {
  width: min(130px, 18vw);
}

#accountDialog {
  width: min(92vw, 460px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

#accountDialog::backdrop {
  background: rgba(2, 8, 18, 0.75);
  backdrop-filter: blur(7px);
}

.dialog-card {
  padding: 6px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-raised);
  font-size: 1.3rem;
}

.dialog-actions {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 118px;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.toast.is-error {
  border-color: rgba(251, 113, 133, 0.45);
}

@media (max-width: 900px) {
  body {
    padding-bottom: 154px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    min-height: auto;
    padding: 16px 18px 0;
    border-right: 0;
    background: transparent;
  }

  .sidebar nav,
  .sidebar-footer {
    display: none;
  }

  .main-content {
    padding-top: 20px;
  }

  .topbar,
  .status-panel {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .status-panel {
    flex-direction: column;
  }

  .player-bar {
    grid-template-columns: 1fr auto;
    min-height: 138px;
    gap: 8px 18px;
  }

  .transport {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .volume-control {
    display: none;
  }
}

@media (max-width: 580px) {
  .main-content {
    padding-right: 16px;
    padding-left: 16px;
  }

  .topbar h1 {
    font-size: 2.3rem;
  }

  .library-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .sort-field {
    justify-content: space-between;
  }

  .track-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .track-play-target {
    padding: 9px;
  }

  .track-album {
    display: none;
  }

  .player-bar {
    padding-right: 14px;
    padding-left: 14px;
  }

  .timeline {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }
}
