/* ==========================================
   1. 기본 변수 및 글로벌 스타일
   ========================================== */
:root {
  color-scheme: light;
  --ink: #253044;
  --muted: #657187;
  --accent: #a93b41;
  --line: #e4e7e9;
  --paper: #fffaf5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f0eb;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Malgun Gothic", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid #a93b41;
  outline-offset: 2px;
}

/* ==========================================
   2. 레이아웃 프레임 (Shell)
   ========================================== */
.shell {
  max-width: 1060px;
  margin: 24px auto;
  background: white;
  border: 1px solid #e8e0d8;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 15px 40px #30251c12;
}

/* 아이프레임(Embedded) 내 삽입 시 외곽선 제거 */
.embedded body {
  background: #fff;
}

.embedded .shell {
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* ==========================================
   3. 상단 헤더 / 배너 (Hero)
   ========================================== */
.hero {
  position: relative;
  background: #465953;
  min-height: 170px;
}

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

.hero h1 {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 30px 25px 16px;
  color: white;
  font-family: Georgia, "Malgun Gothic", serif;
  font-size: clamp(22px, 3vw, 33px);
  background: linear-gradient(transparent, #465953f2);
}

.hero small {
  font: 500 13px system-ui, sans-serif;
  display: block;
  letter-spacing: 0.15em;
}

/* ==========================================
   4. 현재 재생 정보 영역 (Now Playing)
   ========================================== */
.main {
  padding: 22px;
}

.now {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 18px 22px;
  background: linear-gradient(110deg, #edf3ef, #f9fbf9);
  border: 1px solid #dce7df;
  border-left: 5px solid #465953;
  border-radius: 15px;
}

.art {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 12px;
  background: #eee;
  display: block;
}

.art-button {
  border: 0;
  background: transparent;
  padding: 0;
  flex: none;
  border-radius: 12px;
}

.art-button:hover {
  filter: brightness(0.94);
}

.song {
  min-width: 0;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #465953;
  font-weight: 700;
}

.song h2 {
  margin: 3px 0;
  font-size: clamp(18px, 2.4vw, 25px);
  overflow-wrap: anywhere;
}

.song p {
  margin: 0;
  color: var(--muted);
}

/* 재생 상태 배지 */
.playing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e0ebe3;
  color: #355048;
  font-size: 12px;
  font-weight: 700;
}

.playing-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #688d76;
}

.playing-badge.is-playing::before {
  background: #2d9a5b;
  box-shadow: 0 0 0 3px #2d9a5b25;
}

/* ==========================================
   5. 컨트롤러 및 타임라인 (Controls)
   ========================================== */
/* 타임라인 및 슬라이더 */
.timeline {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 9px;
  align-items: center;
  margin: 19px 0 8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.timeline span:last-child {
  text-align: right;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 재생 컨트롤 버튼 */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
}

.controls button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  min-width: 44px;
  min-height: 44px;
  color: var(--ink);
}

.controls button:hover,
.controls button[aria-pressed="true"] {
  background: #f8e8e5;
  color: #842930;
  border-color: #d9a9a4;
}

.controls .primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  min-width: 65px;
  font-size: 21px;
}

.controls .primary:hover {
  background: #842930;
  color: white;
}

/* 볼륨 조절 */
.volume {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
  color: var(--muted);
  font-size: 13px;
}

.volume input {
  width: 86px;
}

/* 상태 메시지 */
.status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  min-height: 22px;
  margin: 8px 0 0;
}

/* ==========================================
   6. 메인 2열 패널 (트랙리스트 & 가사 창)
   ========================================== */
.panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 22px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--paper);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.panel h3 {
  margin: 0;
  font-size: 16px;
}

.panel header span {
  font-size: 12px;
  color: var(--muted);
}

/* 트랙 리스트 영역 */
.list {
  list-style: none;
  padding: 5px;
  margin: 0;
}

.list button {
  display: grid;
  grid-template-columns: 23px 1fr;
  gap: 6px;
  text-align: left;
  align-items: center;
  width: 100%;
  padding: 5px 9px;
  min-height: 31px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--ink);
}

.track-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.track-check {
  width: 16px;
  height: 16px;
  margin: 0 0 0 9px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

.list .track-row button {
  flex: 1;
  min-width: 0;
  padding-left: 3px;
}

.selection-actions {
  display: flex;
  gap: 5px;
}

.selection-actions button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 3px 7px;
  font-size: 12px;
  color: var(--muted);
}

.selection-actions button:hover {
  background: #f5e8df;
}

.list button:hover,
.list button[aria-current="true"] {
  background: #f5e8df;
}

.list button[aria-current="true"] {
  font-weight: 700;
  color: #8e3037;
}

.num {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.list .track-text {
  font-size: 13px;
  line-height: 1.3;
}

.list .track-artist {
  color: var(--muted);
  font-weight: 400;
}

.list button[aria-current="true"] .track-artist {
  color: #8e3037;
}

/* 가사/외부 컨텐츠 프레임 (Lyrics) */
/* 한 개의 가사 iframe이 영역을 정확히 채웁니다. */
.lyrics {
  flex:1; min-height:0; height:460px; padding:0;
  background:white; position:relative; overflow:hidden; box-sizing:border-box;
}
.lyrics iframe {
  display:block; width:100%; height:100%; border:0;
  position:static; inset:auto; margin:0; padding:0;
  min-width:0; min-height:0; box-sizing:border-box;
}

/* ==========================================
   7. 팝업 모달 & 안내 요소
   ========================================== */
.image-dialog {
  border: 0;
  border-radius: 15px;
  padding: 12px;
  background: white;
  max-width: calc(100vw - 30px);
  max-height: calc(100vh - 30px);
  box-shadow: 0 20px 60px #0006;
}

.image-dialog::backdrop {
  background: #161616bc;
}

.image-dialog img {
  display: block;
  max-width: min(900px, calc(100vw - 54px));
  max-height: calc(100vh - 110px);
  object-fit: contain;
}

.dialog-close {
  display: block;
  margin: 0 0 8px auto;
  border: 0;
  background: #f1ebe6;
  border-radius: 7px;
  padding: 6px 12px;
}

.empty {
  padding: 20px;
  color: var(--muted);
}

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

/* ==========================================
   8. 반응형 및 모션 설정
   ========================================== */
@media (max-width: 700px) {
  .shell {
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .main {
    padding: 16px;
  }

  .now {
    padding: 12px;
    gap: 12px;
  }

  .panes {
    grid-template-columns: 1fr;
  }

  .lyrics { min-height:0; height:460px; padding:0; }
  .lyrics iframe { position:static; inset:auto; width:100%; height:100%; }

  .volume {
    width: 100%;
    justify-content: center;
    margin: 4px 0;
  }

  .hero {
    min-height: 150px;
  }

  .hero img {
    height: 150px;
  }

  .hero h1 {
    padding: 25px 16px 13px;
  }

  .art {
    width: 110px;
    height: 110px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button {
    transition: background 0.15s, color 0.15s;
  }
}