:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-elevated: #141416;
  --bg-hover: #1c1c1f;
  --text: #e8e8ea;
  --text-muted: #8b8b93;
  --accent: #f5a623;
  --accent-dim: rgba(245, 166, 35, 0.15);
  --border: #2a2a2e;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --player-height: 14.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

body {
  overscroll-behavior: none;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  padding-top: var(--safe-top);
}

.header {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--player-height) + var(--safe-bottom) + 0.5rem);
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-right: 0.5rem;
}

.track-row.is-active {
  background: var(--accent-dim);
}

.track-row:hover,
.track-row:focus-within {
  background: var(--bg-hover);
}

.track-row.is-active:hover,
.track-row.is-active:focus-within {
  background: var(--accent-dim);
}

.track-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  min-height: 3.25rem;
  padding: 0.75rem 0.75rem 0.75rem 1.25rem;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease;
}

.track-row.is-active .track-index {
  color: var(--accent);
}

.track-row.is-active .track-title {
  color: var(--accent);
  font-weight: 600;
}

.btn-download,
.btn-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn-download:disabled,
.btn-download.is-busy {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}

.btn-download svg,
.btn-share svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.btn-download:hover,
.btn-download:focus-visible,
.btn-share:hover,
.btn-share:focus-visible {
  color: var(--accent);
  background: var(--bg-hover);
  outline: none;
}

.btn-download:active,
.btn-share:active {
  transform: scale(0.94);
}

.track-row.is-active .btn-download,
.track-row.is-active .btn-share {
  color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--player-height) + var(--safe-bottom) + 1rem);
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.3;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

.track-index {
  flex-shrink: 0;
  width: 1.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.track-title {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 0.85rem 1.25rem calc(0.85rem + var(--safe-bottom));
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.now-playing {
  margin-bottom: 0.65rem;
}

.now-playing-label {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.now-playing-title {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 2.5rem;
}

.time:last-child {
  text-align: right;
}

.seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.35rem;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--accent);
}

.seek::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--accent);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.volume {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.65rem;
  max-width: 16rem;
  margin-left: auto;
  margin-right: auto;
}

.btn-mute {
  color: var(--text-muted);
}

.btn-mute.is-muted {
  color: var(--accent);
}

.btn-mute.is-muted .icon-volume {
  display: none;
}

.btn-mute.is-muted .icon-muted {
  display: block;
}

.btn-mute:not(.is-muted) .icon-muted {
  display: none;
}

.volume-slider {
  max-width: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.94);
}

.btn svg {
  fill: currentColor;
  display: block;
}

.btn-icon {
  width: 2.75rem;
  height: 2.75rem;
}

.btn-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.btn-play {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #0a0a0b;
}

.btn-play svg {
  width: 1.5rem;
  height: 1.5rem;
}

.btn-play .icon-pause {
  width: 1.35rem;
  height: 1.35rem;
}

.btn-play.is-playing .icon-play {
  display: none;
}

.btn-play.is-playing .icon-pause {
  display: block;
}

.btn-play:not(.is-playing) .icon-pause {
  display: none;
}

.empty-state {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

@media (min-width: 640px) {
  .app {
    max-width: 32rem;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
