:root{
  --page-bg: #05060a;
  --screen-bg: #0b0d14;
  --screen-line: #212436;
  --ink: #e7e5f5;
  --ink-dim: #8b88a6;
  --accent: #7c7ff0;
  --accent-warm: #e3b15a;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  font-family: "Noto Sans KR", -apple-system, sans-serif;
  padding: 12px;
}

.page{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.back-link{
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: #6b7280;
  text-decoration: none;
  align-self: flex-start;
  margin-left: 4px;
}
.back-link:hover{ color: var(--accent); }

/* ---- device frame (reused from cnation-dominion / echo) ---- */
.device{
  position: relative;
  width: min(94vw, calc(90vh * 9 / 16), 480px);
  aspect-ratio: 9 / 16;
  border-radius: 34px;
  background-image: url("assets/frame.png"), linear-gradient(165deg, #232b3a 0%, #0d1119 55%, #060809 100%);
  background-size: cover;
  background-position: center;
  box-shadow: 0 30px 70px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
}

/* ---- screen ---- */
.screen{
  position: absolute;
  top: 10.8%;
  left: 22%;
  right: 22.2%;
  bottom: 26.6%;
  border-radius: 10px;
  background: var(--screen-bg);
  border: 1px solid var(--screen-line);
  overflow: hidden;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  --accent: #7c7ff0;
}
.screen::after{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.02) 0px,
    rgba(255,255,255,0.02) 1px,
    transparent 1px,
    transparent 3px
  );
}

.view{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.view[hidden]{ display: none; }

/* ---- standby ---- */
.view-standby{
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 12px;
}
.crest{
  font-family: "Fraunces", serif;
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--ink);
  line-height: 1.5;
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent-warm) 45%, transparent);
}
.crest-sub{
  display: block;
  font-size: 12.5px;
  letter-spacing: 0.24em;
  color: var(--ink-dim);
  text-shadow: none;
  margin-bottom: 4px;
  font-family: "IBM Plex Mono", monospace;
}
.standby-sub{
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}
.standby-hint{
  font-size: 9.5px;
  color: var(--ink-dim);
  margin-top: 18px;
}
.standby-retry{
  margin-top: 18px;
  max-width: 200px;
}
.standby-retry.hidden{ display: none; }
.standby-retry-msg{
  font-size: 9.5px;
  color: var(--accent-warm);
  line-height: 1.6;
  margin-bottom: 12px;
}
.standby-retry-actions{
  display: flex;
  gap: 6px;
  justify-content: center;
}
.standby-retry-btn{
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--screen-line);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
.standby-retry-btn.primary{
  color: var(--screen-bg);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- now playing ---- */
.art{
  flex: 1 1 auto;
  min-height: 0;
  background-image: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 40%, transparent), transparent 68%);
  background-size: cover;
  background-position: center;
  position: relative;
  opacity: 0;
  transition: opacity 500ms ease;
}
.art::after{
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 55%, var(--screen-bg) 100%);
}
.art.no-image{
  display: flex;
  align-items: center;
  justify-content: center;
}
.art-initial{
  font-family: "Fraunces", serif;
  font-size: 15vw;
  max-font-size: 64px;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.np-body{
  flex: 0 0 auto;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.np-head{
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.np-badge{
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 9px;
  white-space: nowrap;
}
.np-title{
  font-family: "Noto Sans KR", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.np-sub{
  font-family: "Noto Sans KR", sans-serif;
  font-size: 10.5px;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.loading-hint{
  display: none;
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.03em;
  animation: loading-pulse 1.1s ease-in-out infinite;
}
.loading-hint.visible{ display: block; }
@keyframes loading-pulse{
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce){
  .loading-hint{ animation: none; }
}
.eq{
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 18px;
  margin: 1px 0;
}
.eq span{
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 0.5px;
  transform: scaleY(0.06);
  transform-origin: bottom;
  transition: transform 200ms ease;
}
/* 실제 음향 분석 대신, 재생 중일 때만 막대마다 다른 주기로 오르내리는 CSS 애니메이션으로
   이퀄라이저 느낌을 낸다 (교차 도메인 mp3를 Web Audio 그래프에 태우지 않기 위함). */
.eq.is-live span{ animation: eq-bounce 900ms ease-in-out infinite; }
.eq.is-live span:nth-child(3n){ animation-duration: 720ms; animation-delay: -80ms; }
.eq.is-live span:nth-child(3n+1){ animation-duration: 1080ms; animation-delay: -260ms; }
.eq.is-live span:nth-child(4n){ animation-duration: 640ms; animation-delay: -420ms; }
.eq.is-live span:nth-child(5n){ animation-duration: 980ms; animation-delay: -140ms; }
@keyframes eq-bounce{
  0%, 100% { transform: scaleY(0.12); }
  50% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce){
  .eq.is-live span{ animation: none; transform: scaleY(0.5); }
}
.progress-hit{
  padding: 9px 0;
  margin: -9px 0;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.progress-track{
  position: relative;
  height: 3px;
  border-radius: 2px;
  background: var(--screen-line);
  transition: height 100ms ease;
}
.progress-hit:hover .progress-track,
.progress-hit.is-seeking .progress-track{
  height: 5px;
}
.progress-fill{
  position: relative;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
}
.progress-fill::after{
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(50%, -50%) scale(0);
  transition: transform 100ms ease;
}
.progress-hit:hover .progress-fill::after,
.progress-hit.is-seeking .progress-fill::after{
  transform: translate(50%, -50%) scale(1);
}
.progress-time{
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--ink-dim);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ---- library ---- */
.view-library{
  padding: 10px 10px 6px;
}
.lib-toolbar{
  flex: 0 0 auto;
  margin-bottom: 8px;
}
.lib-toolbar-row{
  display: flex;
  gap: 5px;
}
.lib-chip{
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.03em;
  color: var(--ink-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--screen-line);
  border-radius: 999px;
  padding: 5px 8px;
  cursor: pointer;
}
.lib-chip.active{
  color: var(--screen-bg);
  background: var(--accent);
  border-color: var(--accent);
}
.lib-chip-repeat{
  margin-left: auto;
  color: var(--accent-warm);
}
.lib-chip-repeat.active{
  color: var(--screen-bg);
  background: var(--accent-warm);
  border-color: var(--accent-warm);
}

.lib-list{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 8px;
}
.lib-row{
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
}
.lib-row:hover{ border-color: var(--screen-line); }
.lib-row.active{
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.lib-thumb{
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: cover;
  flex: 0 0 auto;
  background: linear-gradient(145deg, #3a3d55, #1c1e2c);
}
.lib-thumb-fallback{
  width: 30px;
  height: 30px;
  border-radius: 6px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3a3d55, #1c1e2c);
  font-family: "Fraunces", serif;
  font-size: 12px;
  color: var(--ink-dim);
}
.lib-meta{ min-width: 0; flex: 1 1 auto; }
.lib-title{
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-row.active .lib-title{ color: var(--accent); }
.lib-sub{
  font-size: 9px;
  color: var(--ink-dim);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-playing-mark{
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--accent);
}
.lib-empty{
  font-size: 10.5px;
  color: var(--ink-dim);
  text-align: center;
  padding: 24px 8px;
}

/* ---- controls ---- */
/* frame.png(=echo device.png)에 버튼 아이콘이 이미 그려져 있으므로
   여기서는 클릭 가능한 투명 히트박스만 겹친다. */
.ctrl{
  position: absolute;
  top: 78.7%;
  width: 9.5%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: transparent;
  cursor: pointer;
  padding: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 90ms ease, box-shadow 90ms ease;
}
.ctrl:focus-visible{ box-shadow: 0 0 0 2px rgba(124,127,240,0.6); }
.ctrl.is-pressed{
  background-color: rgba(124,127,240,0.42);
  box-shadow: 0 0 4px rgba(124,127,240,0.55);
}
.ctrl-menu.is-pressed{
  background-color: rgba(227,177,90,0.44);
  box-shadow: 0 0 4px rgba(227,177,90,0.55);
}

.ctrl-prev{ left: 24.55%; }
.ctrl-play{ left: 38.26%; }
.ctrl-next{ left: 52.07%; }
.ctrl-menu{ left: 65.89%; }

.hint-outside{
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: #5b6b7d;
  max-width: 340px;
  text-align: center;
  margin: 0;
}
