:root {
  --bg: #0b0b0c;
  --fg: #f5f5f7;
  --muted: rgb(245 245 247 / 0.62);
  --faint: rgb(245 245 247 / 0.16);
  --glass: rgb(255 255 255 / 0.08);
  --danger: #ff6961;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --art-size: min(84vw, 50dvh);
  color-scheme: dark;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
}

svg {
  fill: currentColor;
}

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* Blurred artwork of the current song, cross-faded behind everything. */
.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.backdrop-layer {
  position: absolute;
  inset: -20%;
  background-position: center;
  background-size: cover;
  filter: blur(72px) saturate(1.5);
  opacity: 0;
  transition: opacity 900ms ease;
}

.backdrop-layer.is-visible {
  opacity: 0.6;
}

.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, transparent, rgb(0 0 0 / 0.5)),
    linear-gradient(to bottom, rgb(0 0 0 / 0.35), transparent 25%, transparent 70%, rgb(0 0 0 / 0.45));
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) max(16px, var(--safe-right)) 10px max(16px, var(--safe-left));
}

.brand {
  flex: none;
  color: var(--fg);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.genres {
  display: flex;
  flex: 1;
  gap: 6px;
  min-width: 0;
  padding: 2px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent);
}

.genres::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--faint);
  border-radius: 999px;
  background: var(--glass);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.chip[aria-pressed='true'] {
  border-color: transparent;
  background: var(--fg);
  color: var(--bg);
}

.chip .count {
  margin-left: 5px;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

.admin-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
}

.round-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--faint);
  border-radius: 50%;
  background: var(--glass);
  cursor: pointer;
}

.round-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.text-button {
  padding: 8px 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

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

/* One song per screen; the feed snaps from one to the next. */
.feed {
  position: relative;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  outline: none;
}

.feed::-webkit-scrollbar {
  display: none;
}

.song {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(18px, 3.5dvh, 36px);
  height: 100dvh;
  padding: calc(var(--safe-top) + 60px) max(24px, var(--safe-right)) calc(var(--safe-bottom) + 36px) max(24px, var(--safe-left));
  scroll-snap-align: start;
  scroll-snap-stop: always;
  --accent: var(--fg);
  --on-accent: var(--bg);
}

.art {
  width: var(--art-size);
  aspect-ratio: 1;
  margin: 0;
  overflow: hidden;
  border-radius: 10px;
  background: var(--glass);
  box-shadow:
    0 32px 80px -24px rgb(0 0 0 / 0.75),
    0 0 0 1px rgb(255 255 255 / 0.06);
}

.art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.info {
  display: flex;
  flex-direction: column;
  width: var(--art-size);
  min-width: 0;
}

.genre-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.genre-label:empty {
  display: none;
}

.title {
  margin: 0;
  font-size: clamp(26px, 7.4vw, 40px);
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.artist {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 550;
}

.album {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.note {
  max-height: 22dvh;
  margin-top: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: rgb(245 245 247 / 0.86);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.note:empty {
  display: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.play {
  --progress: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px 0 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 400ms ease, color 400ms ease;
}

.play svg {
  width: 20px;
}

.play::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: currentColor;
  opacity: 0.4;
  transform: scaleX(var(--progress));
  transform-origin: left;
  transition: transform 250ms linear;
}

.play .icon-pause,
.play.is-playing .icon-play {
  display: none;
}

.play.is-playing .icon-pause {
  display: block;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--faint);
  border-radius: 999px;
  background: var(--glass);
  color: var(--fg);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.status {
  display: grid;
  place-items: center;
  height: 100dvh;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty .title {
  text-align: center;
}

.counter {
  position: fixed;
  right: max(16px, var(--safe-right));
  bottom: calc(var(--safe-bottom) + 12px);
  z-index: 10;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.scroll-hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 6px);
  z-index: 10;
  width: 26px;
  margin-left: -13px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  animation: nudge 2.4s ease-in-out infinite;
  transition: opacity 400ms ease;
}

.scroll-hint.is-hidden {
  opacity: 0;
}

@keyframes nudge {
  50% {
    transform: translateY(4px);
  }
}

/* Side by side when there's room. */
@media (min-aspect-ratio: 5/4) and (min-width: 720px) {
  .song {
    --art-size: min(70dvh, 44vw);
    grid-template-columns: var(--art-size) minmax(0, 440px);
    align-items: center;
    justify-content: center;
    column-gap: clamp(32px, 5vw, 96px);
    padding-top: calc(var(--safe-top) + 72px);
    padding-bottom: 48px;
  }

  .info {
    width: auto;
  }

  .title {
    font-size: clamp(32px, 3.4vw, 56px);
  }

  .artist {
    font-size: 20px;
  }

  .note {
    max-height: 34dvh;
    font-size: 16px;
  }
}

dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--faint);
  border-radius: 18px;
  background: rgb(28 28 30 / 0.94);
  color: var(--fg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

dialog h2 {
  margin: 0 0 18px;
  font-size: 19px;
  letter-spacing: -0.01em;
}

dialog form {
  display: grid;
  gap: 14px;
}

dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

dialog input,
dialog textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--faint);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.06);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
}

dialog textarea {
  resize: vertical;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.dialog-actions .spacer {
  flex: 1;
}

.dialog-actions:not(:has(.spacer)) {
  justify-content: flex-end;
}

.primary-button {
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: 0.5;
}

.danger {
  color: var(--danger);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
