:root {
  --bg: #0b0b0f;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.6);
  --accent: #ff2e6a; /* Radio 1 pink-ish */
  --art-size: min(72vw, 360px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  overflow: hidden;
  /* Respect iOS safe areas (notch / home indicator) in standalone mode */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.player {
  position: relative;
  height: 100dvh;
  width: 100%;
  display: flex;
  /* Scroll (rather than clip) when content is taller than the viewport.
     `margin: auto` on .content centers it but, unlike `align-items: center`,
     still lets you scroll to the top edge when it overflows. */
  overflow-y: auto;
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: -10%;
  background-size: cover;
  background-position: center;
  filter: blur(48px) saturate(1.4) brightness(0.5);
  transform: scale(1.2);
  transition: background-image 0.6s ease, opacity 0.6s ease;
  opacity: 0;
}
.backdrop.has-art {
  opacity: 1;
}

.content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  margin: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.art-wrap {
  position: relative;
  width: var(--art-size);
  height: var(--art-size);
}

.artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: block;
}

.live-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--accent);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.is-playing .live-badge {
  opacity: 1;
}

.meta {
  width: 100%;
  min-height: 92px;
}

.title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.artist {
  margin: 6px 0 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
}

.show {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
  opacity: 0.8;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.play-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: none;
  background: var(--fg);
  color: #000;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
  position: relative;
}
.play-btn:active {
  transform: scale(0.94);
}

.play-btn svg {
  width: 34px;
  height: 34px;
  fill: currentColor;
}

/* Toggle which glyph is shown based on body state */
.icon-pause,
.spinner {
  display: none;
}
.is-playing .icon-play {
  display: none;
}
.is-playing .icon-pause {
  display: block;
}
.is-loading .icon-play,
.is-loading .icon-pause {
  display: none;
}
.is-loading .spinner {
  display: block;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 0, 0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.quality {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}

.q-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.q-btn.is-active {
  background: rgba(255, 255, 255, 0.95);
  color: #000;
}

.status {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

/* ---- Station chip -------------------------------------------------------- */

.station-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  padding: 7px 12px 7px 8px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  max-width: 100%;
  transition: background 0.2s ease, transform 0.12s ease;
}
.station-btn:active {
  transform: scale(0.97);
}
.station-btn-logo {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  object-fit: contain;
  flex: none;
}
.station-btn-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.station-btn-chevron {
  width: 18px;
  height: 18px;
  fill: var(--muted);
  flex: none;
}

/* ---- Station picker sheet ------------------------------------------------ */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.sheet-open .sheet {
  display: flex;
}
/* Don't let the player scroll behind the open picker. */
.sheet-open .player {
  overflow: hidden;
}

.sheet-panel {
  width: 100%;
  max-width: 460px;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: #15151c;
  border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  animation: sheet-up 0.28s ease;
}
@keyframes sheet-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 10px;
}
.sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.sheet-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sheet-close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.sheet-search {
  width: 100%;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  padding: 11px 14px;
  margin-bottom: 10px;
}
.sheet-search::placeholder {
  color: var(--muted);
}
.sheet-search:focus {
  outline: 2px solid var(--accent);
}

.sheet-list {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.station-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  text-align: left;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.station-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.station-item.is-active {
  background: rgba(255, 46, 106, 0.18);
  color: var(--fg);
  font-weight: 600;
}
.station-item-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  object-fit: contain;
  flex: none;
}
.station-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
