/* ══ Sonic Deck — 네온 사이버펑크 HUD ═══════════════════════════════ */
:root {
  --void:      #070b14;
  --void-2:    #050810;
  --panel:     #0d1424;
  --panel-2:   #121c30;
  --panel-3:   #16233c;
  --edge:      #1e2f4d;
  --edge-soft: #17263f;
  --cyan:      #35f0ff;
  --cyan-dim:  #1b7f8c;
  --magenta:   #ff3ba7;
  --magenta-dim:#8c2560;
  --amber:     #ffc247;
  --ink:       #cfe4f5;
  --ink-mid:   #8fa8c4;
  --ink-dim:   #5d7796;
  --ink-faint: #38506e;

  --hud:  "Chakra Petch", "Malgun Gothic", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Consolas", monospace;
  --kr:   "IBM Plex Sans KR", "Malgun Gothic", "맑은 고딕", sans-serif;

  --clip:    polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  --clip-sm: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  padding: 48px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--void);
  color: var(--ink);
  font-family: var(--kr);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 460px at 22% -10%, rgba(53, 240, 255, .11), transparent 70%),
    radial-gradient(700px 400px at 92% 2%, rgba(255, 59, 167, .08), transparent 72%),
    repeating-linear-gradient(0deg, rgba(30, 47, 77, .30) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(90deg, rgba(30, 47, 77, .30) 0 1px, transparent 1px 56px),
    var(--void);
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ══ 덱 ═══════════════════════════════════════════════════════════ */
.deck {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  clip-path: var(--clip);
  background:
    linear-gradient(180deg, rgba(53, 240, 255, .05), transparent 180px),
    var(--panel);
  border: 1px solid var(--edge);
  font-family: var(--hud);
  /* 파형 캔버스가 매 프레임 갱신되므로 조상에 filter / mix-blend-mode 를 걸지 않는다.
     그림자와 발광은 .backdrop 의 방사 그라디언트가 대신한다. */
}

/* 스캔라인 */
.deck::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .032) 0 1px, transparent 1px 3px);
}

/* 코너 브래킷 */
.bracket { position: absolute; inset: 10px; pointer-events: none; z-index: 3; }
.bracket i {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--cyan);
  opacity: .55;
}
.bracket i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.bracket i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.bracket i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.bracket i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* ── 상단 HUD 바 ── */
.deck-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--edge);
  background: linear-gradient(180deg, var(--panel-2), rgba(18, 28, 48, 0));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #eaf6ff;
}
.brand svg { width: 16px; height: 16px; color: var(--cyan); filter: drop-shadow(0 0 6px rgba(53, 240, 255, .8)); }

.readout {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--ink-dim);
}

.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  clip-path: var(--clip-sm);
  border: 1px solid var(--cyan-dim);
  background: rgba(53, 240, 255, .09);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  white-space: nowrap;
}
.state-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.state-chip.is-magenta { border-color: var(--magenta-dim); background: rgba(255, 59, 167, .10); color: var(--magenta); }
.state-chip.is-amber   { border-color: #7a5a1c; background: rgba(255, 194, 71, .10); color: var(--amber); }
.state-chip.is-idle    { border-color: var(--edge); background: rgba(30, 47, 77, .4); color: var(--ink-dim); }

/* 출력 레벨 미터 (실제 RMS 로 구동) */
.level { display: flex; align-items: flex-end; gap: 2px; height: 13px; }
.level i { width: 3px; background: var(--edge); transition: background .09s linear, box-shadow .09s linear; }
.level i:nth-child(1) { height: 40%; }
.level i:nth-child(2) { height: 55%; }
.level i:nth-child(3) { height: 70%; }
.level i:nth-child(4) { height: 85%; }
.level i:nth-child(5) { height: 100%; }
.level i:nth-child(6) { height: 100%; }
.level i:nth-child(7) { height: 100%; }
.level i.on  { background: var(--cyan); box-shadow: 0 0 6px rgba(53, 240, 255, .7); }
.level i.hot { background: var(--amber); box-shadow: 0 0 6px rgba(255, 194, 71, .75); }

/* ── 본문 2단 ── */
.deck-body {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  gap: 30px;
  padding: 30px 26px 26px;
}

/* ══ 좌: 트랜스포트 + 파형 ════════════════════════════════════════ */
.deck-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.transport {
  position: relative;
  width: 118px;
  height: 118px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--cyan);
  font-family: inherit;
}
.transport-plate {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  background: linear-gradient(160deg, var(--panel-3), var(--panel));
  border: 1px solid var(--cyan-dim);
  box-shadow: inset 0 0 26px rgba(53, 240, 255, .12);
}
.transport-glow {
  position: absolute;
  inset: -18px;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  background: radial-gradient(circle, rgba(53, 240, 255, .30), transparent 62%);
  opacity: .8;
  transition: opacity .18s ease;
}
.transport svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  fill: var(--cyan);
  filter: drop-shadow(0 0 12px rgba(53, 240, 255, .85));
}
.transport-label {
  position: absolute;
  left: -34px;
  right: -34px;
  bottom: -24px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .2em;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.transport:hover .transport-glow { opacity: 1; }
.transport:active { transform: scale(.97); }
.transport:focus-visible { outline: 1px solid var(--cyan); outline-offset: 8px; }

.deck.is-playing .transport { color: var(--magenta); }
.deck.is-playing .transport-plate { border-color: var(--magenta-dim); box-shadow: inset 0 0 26px rgba(255, 59, 167, .16); }
.deck.is-playing .transport-glow { background: radial-gradient(circle, rgba(255, 59, 167, .30), transparent 62%); }
.deck.is-playing .transport svg { fill: var(--magenta); filter: drop-shadow(0 0 12px rgba(255, 59, 167, .85)); }
.deck.is-playing .transport-label { color: var(--magenta); }

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

/* 파형 */
.wave-unit { width: 100%; }
.wave-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .18em;
  color: var(--ink-faint);
}
.wave-head b { color: var(--ink-dim); font-weight: 400; }
.deck.is-playing .wave-head b { color: var(--magenta); }

.wave {
  position: relative;
  height: 104px;
  clip-path: var(--clip-sm);
  background: var(--void-2);
  border: 1px solid var(--edge);
  cursor: pointer;
}
.wave canvas { display: block; width: 100%; height: 100%; }

/* 스크럽 */
.scrub { margin-top: 12px; }
.scrub-line {
  position: relative;
  height: 3px;
  background: var(--edge);
  cursor: pointer;
}
.scrub-line::before {
  content: "";
  position: absolute;
  inset: -8px 0;
}
.scrub-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(53, 240, 255, .9);
}
.scrub-fill::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -4px;
  width: 9px;
  height: 9px;
  transform: translateY(-50%) rotate(45deg);
  background: #eafcff;
  box-shadow: 0 0 10px rgba(53, 240, 255, .95);
}
.deck.is-playing .scrub-fill { background: var(--magenta); box-shadow: 0 0 10px rgba(255, 59, 167, .9); }
.deck.is-playing .scrub-fill::after { box-shadow: 0 0 10px rgba(255, 59, 167, .95); }

.scrub-time {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-dim);
}
.scrub-time #timeNow { color: var(--ink); font-weight: 500; }

.notice {
  display: none;
  margin: 12px 0 0;
  padding: 7px 10px;
  clip-path: var(--clip-sm);
  border: 1px solid #7a5a1c;
  background: rgba(255, 194, 71, .08);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: .06em;
  color: var(--amber);
  word-break: break-all;
}
.notice.is-shown { display: block; }

/* ══ 우: 트랙 목록 ════════════════════════════════════════════════ */
.deck-right { display: flex; flex-direction: column; min-width: 0; }

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
}
.list-head h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #dcecfb;
}
.list-head h3 span {
  width: 3px;
  height: 14px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.load-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  clip-path: var(--clip-sm);
  border: 1px solid var(--magenta-dim);
  background: rgba(255, 59, 167, .08);
  color: var(--magenta);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  cursor: pointer;
  white-space: nowrap;
}
.load-btn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.load-btn svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }
.load-btn:hover,
.load-btn:focus-within {
  background: rgba(255, 59, 167, .22);
  color: #ffe6f4;
  box-shadow: 0 0 18px -2px rgba(255, 59, 167, .6);
}
.deck.is-dragging .load-btn {
  background: rgba(255, 59, 167, .22);
  color: #ffe6f4;
  box-shadow: 0 0 18px -2px rgba(255, 59, 167, .6);
}

.list-box {
  position: relative;
  flex: 1;
  min-height: 268px;
  padding: 8px;
  clip-path: var(--clip-sm);
  background: rgba(5, 8, 16, .72);
  border: 1px solid var(--edge);
  overflow: hidden;
}

.tracks {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 336px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}
.tracks::-webkit-scrollbar { width: 6px; }
.tracks::-webkit-scrollbar-thumb { background: var(--edge); }

.item { display: flex; align-items: center; }

.track {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px 11px 12px;
  border: 0;
  border-left: 2px solid transparent;
  background: none;
  color: var(--ink-mid);
  font-family: var(--hud);
  font-size: 13.5px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}
.item:hover .track { background: rgba(53, 240, 255, .045); }
.track:focus-visible { outline: 1px solid var(--cyan); outline-offset: -1px; }

.track .no {
  flex: 0 0 26px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--ink-faint);
}
.track .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .dur {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

.src-tag {
  flex: 0 0 auto;
  padding: 3px 8px;
  clip-path: var(--clip-sm);
  border: 1px solid var(--edge);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  color: var(--ink-dim);
}
.src-tag.is-upload { border-color: var(--magenta-dim); color: var(--magenta); background: rgba(255, 59, 167, .07); }

.item.current .track {
  border-left-color: var(--cyan);
  background: linear-gradient(90deg, rgba(53, 240, 255, .16), rgba(53, 240, 255, .02) 68%, transparent);
  color: #eaf6ff;
  box-shadow: inset 0 0 26px -8px rgba(53, 240, 255, .4);
}
.item.current .track .no { color: var(--cyan); }
.item.current .track .dur { color: #cfeeff; }
.item.current .src-tag { display: none; }

/* 재생 중 행의 미니 이퀄라이저 */
.eq { display: none; align-items: flex-end; gap: 2px; height: 13px; flex: 0 0 auto; }
.item.current .eq { display: flex; }
.eq i { width: 2px; height: 4px; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
@media (prefers-reduced-motion: no-preference) {
  .deck.is-playing .item.current .eq i { animation: eqbounce .82s ease-in-out infinite; }
  .deck.is-playing .item.current .eq i:nth-child(2) { animation-delay: .14s; }
  .deck.is-playing .item.current .eq i:nth-child(3) { animation-delay: .3s; }
  .deck.is-playing .item.current .eq i:nth-child(4) { animation-delay: .46s; }
}
@keyframes eqbounce { 0%, 100% { height: 4px; } 50% { height: 13px; } }

.eject {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}
.eject svg { width: 11px; height: 11px; stroke: currentColor; stroke-width: 2; fill: none; }
.eject:hover { color: var(--magenta); }
.eject:focus-visible { outline: 1px solid var(--magenta); outline-offset: 2px; }

.list-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 11px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--ink-faint);
}

/* 빈 목록 */
.list-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}
.list-empty[hidden] { display: none; }
.list-empty strong {
  font-family: var(--hud);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.list-empty span { font-family: var(--kr); font-size: 12px; color: var(--ink-faint); }

/* 드롭 오버레이 */
.drop-veil {
  position: absolute;
  inset: 6px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  clip-path: var(--clip-sm);
  background: rgba(10, 6, 18, .88);
  border: 1px dashed var(--magenta);
  box-shadow: inset 0 0 60px -10px rgba(255, 59, 167, .35);
  text-align: center;
  pointer-events: none;
}
.deck.is-dragging .drop-veil { display: flex; }
.drop-veil svg {
  width: 34px;
  height: 34px;
  stroke: var(--magenta);
  stroke-width: 1.5;
  fill: none;
  filter: drop-shadow(0 0 10px rgba(255, 59, 167, .8));
}
.drop-veil strong {
  font-family: var(--hud);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #ffe6f4;
}
.drop-veil span {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--ink-mid);
}

/* ══ 반응형 ═══════════════════════════════════════════════════════ */
@media (max-width: 820px) {
  body { padding: 28px 16px; }
  .deck-body { grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 24px 18px 20px; }
  .deck-left { padding-bottom: 6px; }
  .wave { height: 84px; }
  .list-box { min-height: 0; }
  .tracks { max-height: 300px; }
}

@media (max-width: 560px) {
  body { padding: 18px 12px; }
  .deck-top { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  .brand { font-size: 11.5px; letter-spacing: .16em; }
  .readout { gap: 12px; font-size: 9.5px; }
  .transport { width: 96px; height: 96px; }
  .transport svg { width: 34px; height: 34px; }
  .track { gap: 9px; padding: 13px 10px; font-size: 13px; }
  .list-head h3 { font-size: 11.5px; letter-spacing: .16em; }
}
