:root {
  --pink: #f2a6bd;
  --sage: #a9c4ae;
  --white: #ffffff;
  --ink: #17151a;

  --scrim-top: rgba(10,8,11,.35);
  --scrim-bottom: rgba(8,6,9,.86);
  --panel-bg: rgba(255,255,255,.09);
  --panel-border: rgba(255,255,255,.14);
  --text-main: #fbf8fa;
  --text-soft: rgba(251,248,250,.72);
  --text-mute: rgba(251,248,250,.5);
  --text-faint: rgba(251,248,250,.34);
  --pill-bg: rgba(255,255,255,.10);
  --pill-text: rgba(251,248,250,.75);
  --divider: rgba(255,255,255,.12);
}

/* 라이트 모드: 배경 스크림을 밝게, 텍스트를 어둡게 반전 */
@media (prefers-color-scheme: light) {
  :root {
    --scrim-top: rgba(255,255,255,.42);
    --scrim-bottom: rgba(255,251,248,.90);
    --panel-bg: rgba(23,21,26,.05);
    --panel-border: rgba(23,21,26,.10);
    --text-main: #201d22;
    --text-soft: rgba(32,29,34,.72);
    --text-mute: rgba(32,29,34,.52);
    --text-faint: rgba(32,29,34,.36);
    --pill-bg: rgba(23,21,26,.07);
    --pill-text: rgba(32,29,34,.72);
    --divider: rgba(23,21,26,.10);
  }
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--ink); }

body {
  position: relative;
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text-main);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }

/* ---------- 앨범아트 확대 배경 ---------- */

.art-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.art-bg img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140%;
  height: 140%;
  transform: translate(-50%, -50%);
  object-fit: cover;
  filter: blur(70px) saturate(160%) brightness(.9);
  transition: opacity .6s ease;
}

@media (prefers-color-scheme: light) {
  .art-bg img { filter: blur(70px) saturate(140%) brightness(1.12); }
}

.art-bg-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--scrim-top) 0%, var(--scrim-bottom) 78%);
}

.stage {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  color: var(--ink);
  background: var(--pink);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-name {
  font-size: 13px;
  font-weight: 750;
  letter-spacing: -.01em;
  color: var(--text-soft);
}

.on-air {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--panel-border);
  color: var(--pill-text);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}

.on-air i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef5f7f;
  box-shadow: 0 0 0 4px rgba(239,95,127,.18);
}

.on-air.off i { background: var(--text-faint); box-shadow: none; }

/* ---------- 플레이어 본체 ---------- */

.player {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.art-frame {
  width: min(72vw, 340px);
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 60px -12px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06);
}

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

.meta {
  margin-top: 26px;
  max-width: 100%;
}

.now-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
}

#title {
  margin: 0 0 4px;
  font-size: clamp(24px, 6vw, 30px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -.02em;
  word-break: keep-all;
}

.artist {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 500;
}

/* ---------- EQ: 간결한 5바, 재생 중에만 ---------- */

.visualizer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 18px;
  margin: 20px 0 4px;
}

.visualizer span {
  width: 3px;
  height: 4px;
  border-radius: 999px;
  background: var(--text-soft);
  opacity: .5;
  transition: height .2s ease, opacity .2s ease;
}

.visualizer.active span { opacity: .95; animation: eq 1s ease-in-out infinite; }
.visualizer span:nth-child(1) { --h: 7px;  animation-delay: -.7s; }
.visualizer span:nth-child(2) { --h: 15px; animation-delay: -.2s; }
.visualizer span:nth-child(3) { --h: 10px; animation-delay: -.9s; }
.visualizer span:nth-child(4) { --h: 18px; animation-delay: -.4s; }
.visualizer span:nth-child(5) { --h: 12px; animation-delay: -.05s; }
.visualizer.active span { height: var(--h); }

@keyframes eq {
  0%, 100% { height: calc(var(--h) * .4); }
  50% { height: var(--h); }
}

@media (prefers-reduced-motion: reduce) {
  .visualizer.active span { animation: none; height: var(--h); }
}

/* ---------- 재생 버튼 ---------- */

.transport { margin-top: 22px; }

.play-button {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  padding: 0;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 50%;
  color: #17151a;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(0,0,0,.4), 0 0 0 1px rgba(0,0,0,.06);
  cursor: pointer;
  transition: transform .15s ease;
}

.play-button:hover { transform: scale(1.04); }
.play-button:active { transform: scale(.96); }
.play-button svg { width: 28px; height: 28px; fill: currentColor; margin-left: 2px; }
.play-button.playing svg { margin-left: 0; }
.icon-pause { display: none; }
.play-button.playing .icon-play { display: none; }
.play-button.playing .icon-pause { display: block; }

/* ---------- 볼륨 ---------- */

.volume-row {
  display: grid;
  grid-template-columns: 18px 1fr 36px;
  align-items: center;
  gap: 10px;
  width: min(300px, 100%);
  margin-top: 26px;
}

.vol-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-mute);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.volume-row #volumeValue {
  color: var(--text-mute);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 0;
  accent-color: var(--text-main);
  cursor: pointer;
}

.status-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.status-pill,
.listener-pill {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--panel-border);
  color: var(--pill-text);
  font-size: 10px;
  font-weight: 700;
}

.status-pill.playing { color: var(--text-main); border-color: rgba(255,255,255,.28); }

/* ---------- 최근 재생 ---------- */

.history {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--divider);
}

.history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-heading h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -.01em;
}

.history-heading > span {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: recent;
}

.history-item {
  counter-increment: recent;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--divider);
}

.history-item:last-child { border-bottom: none; }

.history-item::before {
  content: counter(recent, decimal-leading-zero);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.history-copy { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.history-title,
.history-artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-title { color: var(--text-main); font-size: 13px; font-weight: 650; }
.history-artist { color: var(--text-mute); font-size: 11px; flex: 0 1 auto; }
.history-note { color: var(--text-faint); font-size: 9px; font-weight: 700; letter-spacing: .04em; }

.history-empty {
  padding: 16px 4px;
  color: var(--text-mute);
  text-align: center;
  font-size: 12px;
}

footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 26px 10px 0;
  color: var(--text-faint);
  font-size: 10px;
}

@media (max-width: 420px) {
  .stage { padding-top: 16px; }
  .art-frame { width: min(78vw, 300px); border-radius: 15px; }
  #title { font-size: 23px; }
  .play-button { width: 60px; height: 60px; }
  .history-copy { flex-direction: column; align-items: flex-start; gap: 1px; }
}
