:root {
  --accent: #ff4d6d;
  --accent2: #7c5cff;
  --text: #f3f4fb;
  --muted: #a3a8c3;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }          /* the player never scrolls */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text); background: #0b0d16; -webkit-font-smoothing: antialiased;
}
.bg {
  position: fixed; inset: -60px; background-size: cover; background-position: center;
  filter: blur(60px) saturate(1.4); transform: scale(1.1); transition: background-image .8s; z-index: -2;
}
.bg-overlay { position: fixed; inset: 0; background: linear-gradient(180deg, rgba(11,13,22,.55), rgba(11,13,22,.92)); z-index: -1; }

/* One screen: header / stage (flexes to the space left) / "previously" bar */
.player {
  height: 100vh; height: 100dvh;
  max-width: 820px; margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1.25rem max(.9rem, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: clamp(.4rem, 1.6vh, 1rem);
}

.station { display: flex; align-items: center; gap: .85rem; flex: none; }
.logo { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 1.35rem; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 6px 20px rgba(255,77,109,.35); }
.station-text { min-width: 0; }
.station-name { font-weight: 700; font-size: 1.1rem; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-tag { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live { margin-left: auto; font-size: .72rem; font-weight: 700; letter-spacing: 1.5px; color: var(--muted); display: flex; align-items: center; gap: .4rem;
  padding: .3rem .7rem; border-radius: 99px; background: rgba(255,255,255,.07); flex: none; }
.live span { width: 8px; height: 8px; border-radius: 50%; background: #666; }
.live.on { color: #fff; }
.live.on span { background: #ff3b3b; box-shadow: 0 0 0 0 rgba(255,59,59,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(255,59,59,0); } 100% { box-shadow: 0 0 0 0 rgba(255,59,59,0); } }

.stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; justify-content: center;
  gap: clamp(.5rem, 2.4vh, 1.5rem);
}

.now { display: flex; gap: clamp(1rem, 3vw, 1.75rem); align-items: center; flex: none; }
.cover-wrap { flex: none; width: clamp(110px, 36vh, 300px); height: clamp(110px, 36vh, 300px); position: relative; }
.cover { width: 100%; height: 100%; object-fit: cover; border-radius: 20px; box-shadow: 0 22px 50px rgba(0,0,0,.55); background: #1a1d2e; transition: opacity .3s; }
.cover.swap { opacity: 0; }
.meta { min-width: 0; }
.label { font-size: .7rem; letter-spacing: 2px; color: var(--accent); font-weight: 700; margin-bottom: .5rem; }
h1 { margin: 0 0 .3rem; font-size: clamp(1.25rem, 3.4vh + 1vw, 2.2rem); line-height: 1.15; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.artist { font-size: clamp(1rem, 2vh + .4vw, 1.2rem); color: #e6e8f6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album { color: var(--muted); margin-top: .2rem; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album:empty { display: none; }

.wave { width: 100%; height: clamp(44px, 13vh, 120px); display: block; flex: none; }

.progress-area { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; flex: none; }
.bar { flex: 1; height: 6px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width .5s linear; }

.controls { display: flex; align-items: center; justify-content: center; position: relative; flex: none; }
.play-btn { --s: clamp(56px, 10vh, 76px); width: var(--s); height: var(--s); border-radius: 50%; border: 0; cursor: pointer; font-size: calc(var(--s) * .52); color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 12px 30px rgba(255,77,109,.4); transition: transform .15s; }
.play-btn:hover { transform: scale(1.06); }
.play-btn:active { transform: scale(.96); }
.play-btn.loading i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.volume { display: flex; align-items: center; gap: .5rem; position: absolute; right: 0; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 1.4rem; cursor: pointer; padding: .25rem; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 110px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.2); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: #fff; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 15px; height: 15px; border: 0; border-radius: 50%; background: #fff; cursor: pointer; }
.status { text-align: center; height: 1.1rem; color: var(--muted); font-size: .82rem; flex: none; line-height: 1.1rem; }

/* "Previously" bar */
.prev-bar {
  flex: none; display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .65rem .9rem; border: 0; border-radius: 14px; cursor: pointer; text-align: left;
  color: var(--text); background: rgba(255,255,255,.07); backdrop-filter: blur(8px); font: inherit; font-size: .88rem;
}
.prev-bar:hover { background: rgba(255,255,255,.11); }
.prev-bar .prev-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prev-label { color: var(--muted); text-transform: uppercase; font-size: .68rem; letter-spacing: 1.5px; font-weight: 700; margin-right: .4rem; }
.prev-bar i { color: var(--muted); }

/* Recently played panel */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; opacity: 0; transition: opacity .25s; }
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 11; width: min(560px, 100%); max-height: min(72dvh, 560px);
  transform: translate(-50%, 105%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  background: rgba(20,22,36,.97); border: 1px solid rgba(255,255,255,.08); border-bottom: 0; border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem .4rem; flex: none; }
.sheet-head h2 { margin: 0; font-size: .8rem; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sheet ul { list-style: none; margin: 0; padding: .3rem 1rem .8rem; display: grid; gap: .5rem; overflow-y: auto; min-height: 0; }
.sheet li { display: flex; align-items: center; gap: .8rem; padding: .5rem .6rem; border-radius: 14px; background: rgba(255,255,255,.05); }
.sheet li img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #1a1d2e; flex: none; }
.sheet .t { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet .a { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet .tx { min-width: 0; flex: 1; }
.sheet time { color: var(--muted); font-size: .75rem; flex: none; }
.sheet .empty { color: var(--muted); text-align: center; padding: 1.2rem 0; }
.sheet-foot { text-align: center; color: var(--muted); font-size: .72rem; padding: 0 0 .8rem; flex: none; }

/* Narrow screens: stack cover above the text */
@media (max-width: 640px) {
  .player { padding-left: 1rem; padding-right: 1rem; }
  .now { flex-direction: column; text-align: center; gap: clamp(.4rem, 1.4vh, .9rem); }
  .cover-wrap { width: clamp(100px, 27vh, 72vw); height: clamp(100px, 27vh, 72vw); }
  .meta { max-width: 100%; }
  h1 { -webkit-line-clamp: 2; font-size: clamp(1.2rem, 3vh, 1.7rem); }
  .wave { height: clamp(40px, 10vh, 100px); }
  .volume input[type=range] { width: 70px; }
  .station-tag { display: none; }
}

/* Short screens (landscape phones, small laptops' windows): tighten everything */
@media (max-height: 740px) and (max-width: 640px) {
  .album { display: none; }
}
@media (max-height: 640px) {
  .station-tag, .album, .label { display: none; }
  .logo { width: 36px; height: 36px; font-size: 1.15rem; }
  .prev-bar { padding: .5rem .8rem; }
}
@media (max-height: 520px) {
  .cover-wrap { width: clamp(80px, 27vh, 200px); height: clamp(80px, 27vh, 200px); }
  .wave { height: clamp(28px, 9vh, 56px); }
  .play-btn { --s: 48px; }
  .stage { gap: .4rem; }
}
@media (max-height: 520px) and (min-width: 641px) {
  .player { padding-top: .6rem; padding-bottom: .5rem; }
  .status { display: none; }
}
@media (max-height: 520px) and (max-width: 640px) {
  .status { display: none; }
}

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

/* ------------------------------------------------------------ request a song */
.request-wrap { flex: none; margin-top: .55rem; }
.req-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem .9rem; border: 0; border-radius: 14px; cursor: pointer; font: inherit; font-size: .88rem; font-weight: 600;
  color: #0b0d16; background: linear-gradient(135deg, #ff5f9e, #b06cff);
  box-shadow: 0 6px 20px rgba(176,108,255,.28);
}
.req-btn:hover { filter: brightness(1.08); }
.req-btn[disabled] { opacity: .55; cursor: default; }

.by-request { text-align: center; font-size: .8rem; color: var(--muted); flex: none; }
.by-request b { color: #ff9ec4; font-weight: 600; }

.req-sheet { max-width: 560px; }
.req-body { padding: .2rem 1rem 1rem; display: flex; flex-direction: column; min-height: 0; }
.req-hint { color: var(--muted); font-size: .82rem; margin: 0 0 .7rem; }
.req-search { position: relative; flex: none; }
.req-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; }
.req-search input {
  width: 100%; padding: .65rem .8rem .65rem 2.3rem; border-radius: 12px; font: inherit; font-size: .95rem;
  color: var(--text); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
}
.req-search input:focus { outline: none; border-color: #b06cff; background: rgba(255,255,255,.1); }
.req-results { list-style: none; margin: .6rem 0 0; padding: 0; overflow-y: auto; min-height: 0; display: grid; gap: .4rem; }
.req-results li button {
  width: 100%; display: flex; align-items: baseline; gap: .5rem; padding: .55rem .7rem; text-align: left;
  border: 0; border-radius: 12px; cursor: pointer; font: inherit; color: var(--text); background: rgba(255,255,255,.05);
}
.req-results li button:hover { background: rgba(255,255,255,.11); }
.req-results .t { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-results .a { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-results .dur { margin-left: auto; color: var(--muted); font-size: .75rem; flex: none; }
.req-results .empty { color: var(--muted); text-align: center; padding: 1.1rem .4rem; font-size: .85rem; }
.req-note { flex: none; min-height: 1.3rem; margin-top: .6rem; font-size: .85rem; text-align: center; }
.req-note.ok { color: #7ee2a8; }
.req-note.err { color: #ff8fa8; }
