/* Album palette. No external fonts or services are required. */
:root {
  color-scheme: dark;
  --paper: #ffffff;
  --gold: #ffffff;
  --muted: #c0c0c0;
  --line: #ffffff;
  --bg: #005c1a;
  --player-height: 140px;
  font-family:
    Trebuchet MS,
    Lucida Grande,
    Lucida Sans Unicode,
    Lucida Sans,
    Tahoma,
    sans-serif;
  color: var(--paper);
  background: var(--bg);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-width: 280px;
  padding-bottom: calc(var(--player-height) + 24px);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Cdefs%3E%3Cpattern id='g' width='67' height='67' patternUnits='userSpaceOnUse' patternTransform='rotate(10)'%3E%3Crect width='55' height='55' rx='8' fill='%2364748b' fill-opacity='.16' stroke='%2364748b' stroke-opacity='.35'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='100%25' height='100%25' fill='url(%23g)'/%3E%3C/svg%3E");
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;

  background: radial-gradient(
    ellipse at center,
    transparent 30%,
    rgba(0, 0, 0, 0.26) 100%
  );
}

button,
input {
  font: inherit;
}
button,
a,
input[type='range'] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  color: inherit;
}
button:disabled,
[aria-disabled='true'] {
  opacity: 0.45;
  cursor: default;
}
:focus-visible {
  outline: 2px solid #ffe1a8;
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 10;
  padding: 12px 18px;
  border-radius: 8px;
  color: var(--bg);
  background: var(--gold);
}
.skip-link:focus {
  top: 12px;
}

/* Page layout and collection actions. */

main {
  max-width: 1140px;
  margin: auto;
  padding: 24px max(24px, env(safe-area-inset-right)) 32px max(24px, env(safe-area-inset-left));
}

.collection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}
.collection-play {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: #242015;
  background: var(--gold);
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.4;
  text-align: center;
}
.collection-play.secondary {
  color: var(--paper);
  background: #00000024;
}
.collection-play:hover:not(:disabled) {
  background: #c5c5c5;
}
.collection-play.secondary:hover {
  background: #0000005d;
}

/* Title and performer are the only per-track metadata shown. */
.library {
  margin-top: 32px;
}

.tracks {
  margin: 0;
  padding: 0;
  list-style: none;
}
.track-row {
  display: grid;
  position: relative;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #ffffff19;
  scroll-margin-bottom: calc(var(--player-height) + 16px);
}
.track {
  flex: 1;
  min-width: 0;
  min-height: 72px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
}
.track:hover,
.track.active {
  background: #0000004d;
}
.track.active .track-label strong,
.track.active .track-index {
  color: var(--gold);
}
.track-index {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.track-label,
.now-label {
  min-width: 0;
}
.track-label strong,
.now-label strong {
  display: block;
  font-size: 1rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.track-label small,
.now-label small {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
  margin-top: 3px;
}
.track-download {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  font-size: 0.875rem;
}
.track-download:hover {
  background: #2b3c30;
}
.notice {
  padding: 20px 18px;
  border: 1px dashed #536854;
  border-radius: 12px;
  color: var(--muted);
  margin: 12px 0;
  line-height: 1.5;
}

/* Reorder handles reserve touch gestures; the rest of the row scrolls normally. */

.drag-handle,
.queue-options-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 48px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
}
.drag-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-handle:hover,
.queue-options-toggle:hover {
  background: #0000004d;
  color: var(--paper);
}
.queue-options-toggle[aria-expanded='true'] {
  color: var(--gold);
  background: #0000004d;
}
.queue-options {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 4px 14px;
}
.queue-options button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202d24;
  font-size: 0.875rem;
}
.queue-options button:hover:not(:disabled) {
  background: #344536;
}
.queue-options .track-download {
  min-height: 44px;
  font-size: 0.875rem;
}
.track-row.dragging {
  opacity: 0.35;
}
.track-row.drop-before::before,
.track-row.drop-after::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gold);
  border-radius: 4px;
  pointer-events: none;
}
.track-row.drop-before::before {
  top: -2px;
}
.track-row.drop-after::after {
  bottom: -2px;
}
.drag-ghost {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: #26372bf5;
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 12px 30px #0008;
  list-style: none;
}
.drag-ghost .queue-options {
  display: none;
}
.queue-dragging {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

/* ResizeObserver reserves the actual footer height, including enlarged text. */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  background: #223d20;
  border-top: 1px solid #4a584b;
  box-shadow: 0 -8px 38px #0005;
  padding-bottom: env(safe-area-inset-bottom);
}
.player-inner {
  max-width: 1190px;
  margin: auto;
  padding: 12px max(24px, env(safe-area-inset-right)) 10px max(24px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(285px, 1.4fr) minmax(100px, 0.6fr);
  align-items: center;
  gap: 24px;
}
.now,
.sound {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.cover {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #422825;
}
.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.now-label strong {
  font-size: 0.9375rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.now-label small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sound {
  justify-self: end;
  width: min(100%, 156px);
}
.buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.control {
  display: grid;
  place-items: center;
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  color: #ffffff;
  flex: 0 0 auto;
}
.control:hover:not(:disabled) {
  background: #00000036;
}
.control svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.control.primary {
  background: var(--gold);
  color: #241515;
  width: 56px;
  height: 56px;
}
.control.primary:hover:not(:disabled) {
  background: #c5c5c5;
}
.control.on {
  background: #2a5620;
  color: #b2ffa3;
  border-color: #54955d;
}
.repeat span {
  position: absolute;
  font-size: 10px;
  font-weight: 800;
}
.seek {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
}
.seek span {
  min-width: 2.6rem;
  text-align: center;
}
input[type='range'] {
  width: 100%;
  min-width: 0;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  height: 44px;
  background: transparent;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 8px;
  background: linear-gradient(
    to right,
    var(--gold) var(--progress, 0%),
    #545262 var(--progress, 0%)
  );
}
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--gold);
}
input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 8px;
  background: #526255;
}
input[type='range']::-moz-range-progress {
  height: 4px;
  background: var(--gold);
}
input[type='range']::-moz-range-thumb {
  height: 20px;
  width: 20px;
  background: var(--gold);
  border: 0;
  border-radius: 50%;
}
.error-banner {
  text-align: center;
  color: #ffe3c3;
  background: #633c34;
  padding: 10px 16px;
  font-size: 0.875rem;
  line-height: 1.5;
}

@media (max-width: 900px) {
  :root {
    --player-height: 200px;
  }
  .player-inner {
    grid-template-columns: minmax(0, 1fr) 140px;
    gap: 4px 16px;
  }
  .now {
    grid-column: 1;
    grid-row: 1;
  }
  .sound {
    grid-column: 2;
    grid-row: 1;
  }
  .transport {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
@media (max-width: 650px) {
  main {
    padding-top: 16px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .collection-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    margin-top: 20px;
  }
  .collection-play {
    padding: 10px;
    font-size: 0.875rem;
  }
  #download-collection {
    grid-column: 1 / -1;
  }

  .library {
    margin-top: 26px;
  }

  .track {
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 7px;
    padding: 10px 4px;
  }
  .track-label strong {
    font-size: 0.9375rem;
  }
  .track-download {
    padding: 10px 8px;
    font-size: 0.8125rem;
  }

  .player-inner {
    padding-top: 10px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 6px 10px;
  }
  .cover {
    width: 44px;
    height: 44px;
  }
  .sound {
    width: 48px;
  }
  .sound input {
    display: none;
  } /* Phone hardware buttons own output volume. */
  .buttons {
    gap: 7px;
  }
  .now-label small {
    margin-top: 2px;
  }
}
/* Desktop queue column. The stationary player panel is defined below. */
@media (min-width: 1024px) {
  main {
    max-width: 1480px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 48px;
    align-items: start;
    padding-top: 40px;
  }

  .library {
    margin-top: 0;
    min-width: 0;
  }
}
@media (max-width: 350px) {
  .buttons {
    gap: 2px;
  }
  .control {
    width: 44px;
    height: 44px;
  }
  .control.primary {
    width: 52px;
    height: 52px;
  }
}
/* Keep more of the album visible when a phone is rotated to landscape. */
@media (min-width: 651px) and (max-height: 500px) and (orientation: landscape) {
  .player-inner {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 1.3fr) 48px;
    gap: 16px;
  }
  .now,
  .sound,
  .transport {
    grid-column: auto;
    grid-row: auto;
  }
  .sound {
    width: 48px;
  }
  .sound input {
    display: none;
  }
}

.player-art {
  filter: drop-shadow(4px 6px 10px rgba(0, 0, 0, 0.4));
}

/* One control panel: desktop sidebar, compact phone dock, or native modal. */
.player-art,
.close-player {
  display: none;
}
.now {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  width: 100%;
}
.now:not(:disabled) {
  cursor: pointer;
}
.now:disabled {
  opacity: 1;
}
.library > .collection-actions {
  margin: 0 0 24px;
}
.player-expanded {
  overflow: hidden;
}
#player-dialog {
  margin: 0;
  padding: 0;
  border: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  background: var(--bg);
  color: var(--paper);
  overflow: auto;
}
#player-dialog::backdrop {
  background: #101712;
}
#player-dialog[open] .player {
  position: static;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#player-dialog[open] .close-player {
  display: block;
  align-self: flex-start;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--paper);
  padding: 8px 14px;
  margin-bottom: 20px;
}
#player-dialog[open] .player-art {
  display: block;
  width: min(100%, 440px, 46dvh);
}
.player-art img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
}
#player-dialog[open] .player-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
  width: min(100%, 520px);
  margin: 0;
  padding: 24px 0 0;
}
#player-dialog[open] .cover {
  display: none;
}
#player-dialog[open] .now {
  pointer-events: none;
  justify-content: center;
  text-align: center;
}
#player-dialog[open] .now-label {
  width: 100%;
  font-size: clamp(1.4rem, 5vw, 2rem);
  min-height: calc(3.75em + 2.04rem);
}
#player-dialog[open] .now-label strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  font-size: inherit;
  line-height: 1.25;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
#player-dialog[open] .now-label small {
  font-size: 1.1rem;
  white-space: normal;
  margin-top: 8px;
}
#player-dialog[open] .transport {
  width: 100%;
}
#player-dialog[open] .sound {
  align-self: center;
}
@media (min-width: 1024px) {
  body {
    padding-bottom: 24px;
  }
  main {
    align-items: start;
  }
  /* Fix the panel to the viewport, independently of queue scrolling. Artwork
     depends only on viewport dimensions; two title lines are always reserved. */
  .player {
    position: fixed;
    top: 24px;
    bottom: auto;
    left: max(24px, calc((100% - 1480px) / 2 + 24px));
    right: auto;
    width: calc((min(100%, 1480px) - 96px) / 2);
    height: calc(100dvh - 48px);
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .player-art {
    display: block;
    flex: 0 0 auto;
    width: min(100%, 440px, max(0px, calc(100dvh - 360px)));
    aspect-ratio: 1;
    height: auto;
    overflow: hidden;
    border-radius: 14px;
  }
  .player-art img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    border-radius: inherit;
  }
  .player-inner {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: clamp(8px, 2dvh, 24px);
    width: min(100%, 520px);
    margin: 0;
    padding: clamp(8px, 2dvh, 24px) 0 0;
  }
  .now {
    pointer-events: none;
    justify-content: center;
    text-align: center;
  }
  .now-label {
    width: 100%;
    font-size: clamp(1.5rem, 2.5vw, 2.25rem);
    min-height: calc(2.5em + 2.075rem);
  }
  .now .cover {
    display: none;
  }
  .now-label strong {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    font-size: inherit;
    line-height: 1.25;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .now-label small {
    font-size: 1.125rem;
    white-space: normal;
    margin-top: 8px;
  }
  .transport {
    width: 100%;
  }
  .sound {
    align-self: center;
  }
  .library {
    grid-column: 2;
  }
  .track-row {
    scroll-margin-bottom: 24px;
  }
}

/* Volume shares the transport row; progress remains underneath both groups. */
.media-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.media-row .sound {
  flex: 0 1 140px;
  width: 140px;
  min-width: 48px;
}
@media (max-width: 650px) {
  .media-row {
    gap: 6px;
  }
  .media-row .sound {
    flex: 0 0 48px;
    width: 48px;
  }
}
@media (max-width: 350px) {
  .media-row {
    gap: 2px;
  }
  .media-row .buttons {
    gap: 0;
  }
  .media-row .sound {
    flex-basis: 44px;
    min-width: 44px;
    width: 44px;
  }
}
