/* Apple Music の再生画面がベースのフラットデザイン
   背景色はジャケット画像から app.js が --tint に入れる */
:root {
  --tint: #3a2f26;
  --text: #ffffff;
  --text-sub: rgba(255, 255, 255, .62);
  --text-off: rgba(255, 255, 255, .32);
  --fill: rgba(255, 255, 255, .16);
  --fill-strong: rgba(255, 255, 255, .78);
  --radius-art: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: #1c1915; }
html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
svg { display: block; }

.backdrop {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tint) 100%, #000 0%) 0%, color-mix(in srgb, var(--tint) 60%, #000) 100%);
  transition: background 1s;
  z-index: -1;
}

.app {
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 28px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artist {
  font-size: 18px;
  color: var(--text-sub);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-text { min-width: 0; flex: 1; }
.meta-text > span { display: block; }

/* ---------- 再生中（大ジャケット） ---------- */
.now {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.art-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.art {
  width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-art);
  background: var(--fill);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  transition: transform .45s cubic-bezier(.3, 1.4, .5, 1);
}
.art:not([src]) { visibility: hidden; }
/* 一時停止中はジャケットが少し縮む（Apple Music と同じ） */
.app:not(.playing) .art { transform: scale(.86); }
.meta { display: flex; align-items: center; gap: 12px; margin: 28px 0 18px; }

/* ---------- 次に再生（キュー） ---------- */
.queue { display: none; flex: 1; min-height: 0; flex-direction: column; }
.app.show-queue .now { display: none; }
.app.show-queue .queue { display: flex; }

.queue-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.mini-art {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--fill);
  flex-shrink: 0;
}
.mini-art:not([src]) { visibility: hidden; }
.queue-head .title { font-size: 17px; }
.queue-head .artist { font-size: 16px; }

.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mode {
  position: relative;
  height: 40px;
  border-radius: 999px;
  background: var(--fill);
  display: grid;
  place-items: center;
  transition: background .2s, color .2s;
}
.mode svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.mode.on, .mode[aria-pressed="true"] { background: var(--fill-strong); color: color-mix(in srgb, var(--tint) 80%, #000); }
.mode:disabled { opacity: .45; cursor: default; }
.mode .one {
  position: absolute;
  top: 6px;
  right: calc(50% - 20px);
  font-size: 9px;
  font-weight: 800;
  display: none;
}
.mode.repeat-one .one { display: block; }
.mode-label { font-size: 12px; color: var(--text-sub); text-align: center; margin: 8px 0 4px; min-height: 16px; }

.list-head { margin: 14px 0 10px; }
.list-title { font-size: 17px; font-weight: 700; }
.list-sub { font-size: 14px; color: var(--text-sub); margin-top: 2px; }

.tracks {
  list-style: none;
  margin: 0 -28px;
  padding: 0 28px 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(180deg, #000 calc(100% - 48px), transparent);
  overscroll-behavior: contain;
}
.track {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  border-radius: 8px;
  transition: opacity .2s, background .15s;
}
.track-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}
.thumb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--fill);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.track .title { font-size: 17px; font-weight: 500; }
.track .artist { font-size: 15px; }

/* 再生中マーク：ジャケットの上にイコライザー */
.eq {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.eq i { width: 3px; height: 14px; background: #fff; border-radius: 2px; transform-origin: bottom; }
.track.current .eq { display: flex; }
.app.playing .track.current .eq i { animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s !important; }
.eq i:nth-child(3) { animation-delay: -.6s !important; }
@keyframes eq { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
.app:not(.playing) .eq i { transform: scaleY(.5); }

/* 再生除外：グレーアウト */
.track.excluded .thumb, .track.excluded .meta-text { opacity: .32; }
.track.excluded .title { text-decoration: line-through; }

.icon-btn {
  width: 40px;
  height: 44px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--text-sub);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.skip[aria-pressed="true"] { color: var(--text); }
.saved { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex-shrink: 0; margin: 0 2px; }
.saved.on { background: var(--text-off); }

.handle { touch-action: none; cursor: grab; }
.track.dragging {
  background: var(--fill);
  opacity: .95;
}
.app.reordering { cursor: grabbing; user-select: none; -webkit-user-select: none; }

/* ---------- 操作部 ---------- */
.controls { flex-shrink: 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 7px;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(var(--fill-strong), var(--fill-strong)) 0 / var(--pct, 0%) 100% no-repeat, var(--fill);
  outline: none;
  cursor: pointer;
  transition: height .15s;
}
input[type="range"]:active { height: 11px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 1px; height: 11px; opacity: 0; }
input[type="range"]::-moz-range-thumb { width: 1px; height: 11px; border: 0; opacity: 0; }

.seek { padding: 6px 0 0; }
.times {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-off);
  font-variant-numeric: tabular-nums;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  margin: 16px 0 22px;
}
.tbtn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform .12s, background .12s;
}
.tbtn:active { transform: scale(.88); background: var(--fill); }
.tbtn svg { width: 40px; height: 40px; fill: var(--text); }
.tbtn-main svg { width: 46px; height: 46px; }
.tbtn-main .icon-pause { display: none; }
.app.playing .tbtn-main .icon-play { display: none; }
.app.playing .tbtn-main .icon-pause { display: block; }

.volume { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.volume svg { width: 18px; height: 18px; fill: var(--text-sub); flex-shrink: 0; }
.volume svg .wave { fill: none; stroke: var(--text-sub); stroke-width: 1.8; stroke-linecap: round; }
/* スマホは本体の音量ボタンで調整（iOS は JS で音量を変えられない） */
@media (hover: none) and (pointer: coarse) { .volume { display: none; } }

.bottom {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  min-height: 48px;
}
.status { font-size: 11px; font-weight: 700; color: var(--text-sub); }
.status.offline { color: #ff9f8a; }
.status-center { text-align: center; font-size: 13px; font-weight: 600; color: var(--text-sub); }
.status-center.ready { color: var(--text); }
.bbtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-sub);
  justify-self: end;
}
.bbtn svg { width: 24px; height: 24px; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.bbtn[aria-pressed="true"] { background: var(--fill-strong); color: color-mix(in srgb, var(--tint) 80%, #000); }

.progress { height: 3px; border-radius: 2px; background: var(--fill); overflow: hidden; margin-top: 4px; }
.progress .bar { height: 100%; width: 0; background: var(--fill-strong); transition: width .2s; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(0, 0, 0, .7);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- PC：左に再生画面、右にプレイリスト ---------- */
@media (min-width: 900px) {
  .app {
    max-width: 1100px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    column-gap: 64px;
    padding: 40px 48px 20px;
  }
  .now { grid-column: 1; grid-row: 1; display: flex !important; }
  .controls { grid-column: 1; grid-row: 2; }
  .queue { grid-column: 2; grid-row: 1 / span 2; display: flex !important; }
  .queue-head { display: none; }
  .art { max-width: 440px; }
  .bbtn { visibility: hidden; }
  .tracks { margin: 0 -12px; padding: 0 12px 24px; }
}
