:root {
  color-scheme: dark;
  --bg: #06070b;
  --panel: #11141c;
  --line: #272d3c;
  --muted: #8c96aa;
  --text: #f7f8fb;
  --cyan: #4edcff;
  --pink: #ff4fd8;
  --purple: #8d5cff;
  --danger: #ff6475;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans KR", sans-serif;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 44px 44px;
}
button, input { font: inherit; }
button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1a1f2b;
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
}
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(135deg, var(--purple), #6553ff); border: 0; font-weight: 800; }
button.danger { color: var(--danger); }
input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #080a10;
  color: var(--text);
  padding: 0 16px;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(6,7,11,.94);
}
.logo { color: #ff435d; font-weight: 900; letter-spacing: .15em; }
.topbar small { color: var(--muted); margin-left: 8px; }
.status { color: var(--cyan); font-size: 14px; }
main { padding: 10px; }
.panel { background: rgba(17,20,28,.96); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }

.stage { height: 54vh; min-height: 410px; display: grid; grid-template-columns: 1fr; }
.audio-player-shell {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 200px;
  height: 200px;
  overflow: hidden;
  pointer-events: none;
}
#youtube-player, #youtube-player iframe { width: 200px; height: 200px; border: 0; }
.lyrics-shell { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; position: relative; }
.now-playing { padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lyrics { overflow: auto; scroll-behavior: smooth; padding: 16vh 24px; text-align: center; }
.lyric-line { color: rgba(255,255,255,.28); font-size: clamp(20px, 2vw, 32px); line-height: 1.5; padding: 10px; transition: .2s ease; cursor: pointer; }
.lyric-line.previous { color: rgba(255,255,255,.68); }
.lyric-line.active { color: white; font-size: clamp(30px, 3.2vw, 48px); font-weight: 900; text-shadow: 0 0 18px rgba(78,220,255,.55), 0 0 28px rgba(255,79,216,.3); }
.placeholder { color: var(--muted); margin-top: 10vh; }
.transport { min-height: 66px; display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-top: 1px solid var(--line); background: #0b0d13; }
.transport button { min-width: 48px; }
.transport #play-pause { font-size: 22px; }
#seek { min-height: auto; flex: 1; padding: 0; accent-color: var(--purple); }
#time { min-width: 112px; color: var(--muted); font-variant-numeric: tabular-nums; }

.workspace { height: calc(46vh - 82px); min-height: 300px; display: grid; grid-template-columns: 1.45fr 1fr 1fr; gap: 10px; margin-top: 10px; }
.workspace article { display: grid; grid-template-rows: auto auto 1fr; min-height: 0; }
.workspace article:not(.search-panel) { grid-template-rows: auto 1fr; }
h2 { margin: 0; padding: 12px 14px; font-size: 17px; color: var(--pink); border-bottom: 1px solid var(--line); }
.count { display: inline-grid; place-items: center; min-width: 25px; height: 25px; border-radius: 999px; background: var(--purple); color: white; font-size: 13px; }
#search-form { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
#search-input { flex: 1; min-width: 0; }
.list { overflow: auto; padding: 8px; min-height: 0; }
.list.empty { color: var(--muted); display: grid; place-items: center; text-align: center; }
.song-row { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid transparent; border-bottom-color: var(--line); }
.song-row:hover { background: rgba(255,255,255,.035); border-color: #343b4e; border-radius: 10px; }
.song-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.song-title, .song-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-meta { color: var(--muted); font-size: 13px; }
.song-actions { display: flex; gap: 5px; }
.song-actions button { min-height: 38px; padding: 6px 10px; font-size: 13px; }

#lyrics-dialog { width: min(800px, 92vw); max-height: 82vh; background: var(--panel); color: var(--text); border: 1px solid var(--purple); border-radius: 16px; padding: 0; }
#lyrics-dialog::backdrop { background: rgba(0,0,0,.75); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head h2 { border: 0; }
.dialog-head button { margin-right: 12px; }
#lyrics-candidates { max-height: 65vh; }
.candidate { width: 100%; text-align: left; margin-bottom: 8px; }
.candidate small { display: block; color: var(--muted); margin-top: 4px; }

@media (max-width: 900px) {
  .stage { min-height: 520px; }
  .workspace { height: auto; grid-template-columns: 1fr; }
  .workspace article { min-height: 320px; }
}
