/* Palette · Chill Rhythm — music page
   色はアプリと同じ（ink #0e0e12 / paper #f7f5f0）。曲ごとの accent は JS が --accent に入れる。 */
:root {
  --ink: #0e0e12;
  --paper: #f7f5f0;
  --mute: rgba(247, 245, 240, 0.55);
  --faint: rgba(247, 245, 240, 0.12);
  --accent: #9fd1ff;
  --accent-rgb: 159, 209, 255;
  --shade: 0.25;               /* 絵の明るさに応じて JS が左上を暗くする量 */
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  --pad: 40px;
  --list-w: 380px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); overflow: hidden; }
body { font-family: var(--sans); font-weight: 300; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { display: block; }

/* ---------- 背景 ---------- */
#bg { position: fixed; inset: 0; z-index: 0; background: var(--ink); }
#bg .layer {
  position: absolute; inset: -4%;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.8s ease;
  will-change: opacity, transform;
  animation: drift 70s ease-in-out infinite alternate;
}
#bg .layer.show { opacity: 1; }
#bg .layer:nth-child(2) { animation-direction: alternate-reverse; }
@keyframes drift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.09) translate(-1.2%, 0.8%); } }
#bg .vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 80% at 18% 28%, rgba(0,0,0,var(--shade)) 0%, rgba(0,0,0,0) 70%),
    radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0) 35%, rgba(0,0,0,0.55) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.42) 0%, rgba(0,0,0,0.05) 35%, rgba(0,0,0,0.25) 70%, rgba(0,0,0,0.72) 100%);
}
@media (prefers-reduced-motion: reduce) { #bg .layer { animation: none; } }

#viz { position: fixed; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; left: var(--pad); top: calc(var(--pad) - 4px); z-index: 3;
  width: min(520px, calc(100vw - 2 * var(--pad)));
  font-family: var(--mono); font-weight: 300; font-size: 13px; line-height: 1.6;
  letter-spacing: 0.08em; text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
#solid { width: 48px; height: 48px; filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.35)); }
.brand .k { font-family: var(--sans); font-weight: 200; font-size: 22px; letter-spacing: 0.42em; line-height: 1; }
.brand .sub { color: var(--mute); font-size: 10px; letter-spacing: 0.28em; margin-top: 7px; white-space: nowrap; }

.row { display: flex; gap: 14px; align-items: baseline; }
.k { color: var(--mute); letter-spacing: 0.24em; font-size: 11px; }
.k.accent { color: var(--accent); }
.v { color: var(--paper); }
#title {
  font-family: var(--sans); font-weight: 300; font-size: 34px; letter-spacing: 0.01em; line-height: 1.15;
  margin: 6px 0 8px; max-width: 100%; word-break: keep-all; overflow-wrap: anywhere;
}
.meta { color: var(--mute); gap: 22px; font-size: 12px; }
.progress {
  position: relative; width: 100%; max-width: 420px; height: 18px; margin-top: 10px; cursor: pointer;
}
.progress::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: rgba(255,255,255,0.14); }
.progress .fill {
  position: absolute; left: 0; top: 8px; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent), #fff);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.55);
}
.progress .knob {
  position: absolute; top: 4px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.8); opacity: 0; transition: opacity 0.2s;
}
.progress:hover .knob, .progress.dragging .knob { opacity: 1; }

.story { margin-top: 26px; max-width: 460px; }
.story p {
  font-family: var(--sans); font-size: 13.5px; line-height: 1.85; letter-spacing: 0.02em;
  color: rgba(247,245,240,0.86); margin: 8px 0 0; max-height: 11.2em; overflow: hidden;
  transition: opacity 0.6s; mask-image: linear-gradient(180deg, #000 80%, transparent 100%);
}
.story p.fade { opacity: 0; }
.story:hover p, .story.open p { max-height: none; mask-image: none; }
.chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em; padding: 3px 9px 2px;
  border: 1px solid rgba(255,255,255,0.22); border-radius: 999px; color: var(--mute); transition: color .2s, border-color .2s;
}
.chip:hover { color: var(--paper); border-color: rgba(255,255,255,0.6); }
.msg { margin-top: 14px; color: #ff8a8a; font-size: 11px; letter-spacing: 0.16em; min-height: 1.6em; }

/* ---------- 操作 ---------- */
#controls {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(14,14,18,0.42); border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1);
  max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none;
}
#controls::-webkit-scrollbar { display: none; }
#controls > * { flex: none; }
.ctl {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  color: var(--paper); opacity: 0.82; transition: opacity .2s, background .2s, transform .15s;
}
.ctl:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.ctl:active { transform: scale(0.94); }
.ctl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.ctl.small { width: 38px; height: 38px; }
.ctl.small svg { width: 18px; height: 18px; }
.ctl.big { width: 56px; height: 56px; border: 1px solid rgba(var(--accent-rgb), 0.75); color: var(--accent); opacity: 1; box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.18) inset; }
.ctl.big svg { width: 24px; height: 24px; stroke-width: 1.3; }
.ctl.big .i-play { fill: currentColor; stroke: none; margin-left: 3px; }
.ctl.big .i-pause { display: none; }
body.playing .ctl.big .i-play { display: none; }
body.playing .ctl.big .i-pause { display: block; }
.ctl.text { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; width: auto; padding: 0 10px; border-radius: 999px; }
.ctl.on { color: var(--accent); opacity: 1; }
.ctl.off { opacity: 0.38; text-decoration: line-through; }
.sep { width: 1px; height: 22px; background: rgba(255,255,255,0.12); margin: 0 6px; }
.vol { display: flex; align-items: center; gap: 8px; padding: 0 6px; color: var(--mute); }
.vol svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.vol input { -webkit-appearance: none; appearance: none; width: 86px; height: 2px; background: rgba(255,255,255,0.22); border-radius: 2px; outline: none; }
.vol input::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); cursor: pointer; }
.vol input::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--paper); cursor: pointer; }
body.ios .vol { display: none; }

/* ---------- 一覧 ---------- */
#list {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 5; width: var(--list-w);
  background: rgba(14,14,18,0.62); border-left: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  transform: translateX(102%); transition: transform 0.45s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column;
}
#list.open { transform: none; }
.list-head {
  display: flex; align-items: center; gap: 12px; padding: calc(22px + env(safe-area-inset-top)) 18px 14px 24px;
  font-family: var(--mono); letter-spacing: 0.3em; font-size: 12px;
}
.list-head .k { flex: none; color: var(--paper); }
#search {
  flex: 1; min-width: 0; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 999px;
  padding: 7px 14px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; outline: none;
}
#search:focus { border-color: rgba(var(--accent-rgb), 0.6); }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }
#songs { list-style: none; margin: 0; padding: 0 0 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
#songs li {
  display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 14px;
  padding: 8px 24px; cursor: pointer; transition: background .15s;
}
#songs li:hover { background: rgba(255,255,255,0.05); }
#songs li.current { background: rgba(var(--accent-rgb), 0.1); }
#songs li.hidden { display: none; }
#songs .art { position: relative; width: 54px; height: 36px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,0.06); }
#songs .art img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .4s; }
#songs .art img.loaded { opacity: 1; }
#songs .art .n {
  position: absolute; left: 4px; top: 2px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.85); text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
#songs .t { font-size: 14px; font-weight: 300; line-height: 1.3; min-width: 0; }
#songs .t small { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--mute); margin-top: 2px; }
#songs li.current .t { color: var(--accent); }
#songs .d { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--mute); }
#songs li.current .d { color: var(--accent); }
#songs li.current .d::before { content: "▶ "; }
.list-foot { padding: 12px 24px calc(16px + env(safe-area-inset-bottom)); font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--mute); border-top: 1px solid rgba(255,255,255,0.08); }
.list-foot a { color: var(--paper); text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.25); }

/* ---------- 最初の一押し ---------- */
#start {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; cursor: pointer;
  background: rgba(10,10,14,0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.7s ease, visibility 0.7s;
}
#start.hidden { opacity: 0; visibility: hidden; }
.start-inner { text-align: center; text-shadow: 0 2px 14px rgba(0,0,0,0.8); }
#startSolid { width: 150px; height: 150px; margin: 0 auto 26px; filter: drop-shadow(0 0 18px rgba(var(--accent-rgb), 0.35)); }
.start-title { font-family: var(--sans); font-weight: 200; font-size: 44px; letter-spacing: 0.5em; margin-left: 0.5em; }
.start-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.34em; color: var(--mute); margin-top: 12px; }
.start-cta {
  display: inline-flex; align-items: center; gap: 12px; margin-top: 42px; padding: 14px 32px;
  border: 1px solid rgba(var(--accent-rgb), 0.8); border-radius: 999px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.34em; color: var(--accent);
  box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.15), 0 0 30px rgba(var(--accent-rgb), 0.12) inset;
}
.start-cta .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- 狭い画面 ---------- */
@media (max-width: 760px) {
  :root { --pad: 20px; --list-w: 100vw; }
  #hud { top: calc(16px + env(safe-area-inset-top)); width: calc(100vw - 2 * var(--pad)); font-size: 12px; }
  .brand { margin-bottom: 16px; gap: 10px; }
  #solid { width: 36px; height: 36px; }
  .brand .k { font-size: 17px; }
  .brand .sub { font-size: 9px; margin-top: 5px; }
  #title { font-size: 26px; margin: 4px 0 6px; }
  .story { margin-top: 16px; }
  .story p { font-size: 12.5px; line-height: 1.75; max-height: 7.2em; }
  #controls { gap: 2px; padding: 6px 8px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: calc(100vw - 16px); }
  .ctl { width: 40px; height: 40px; }
  .ctl.small { width: 34px; height: 34px; }
  .ctl.big { width: 50px; height: 50px; }
  .sep { margin: 0 2px; }
  #viz-toggle { display: none; }
  .vol, .sep { display: none; }
  #list { border-left: 0; }
  .start-title { font-size: 32px; }
  #startSolid { width: 120px; height: 120px; }
}
@media (max-height: 560px) {
  .story { display: none; }
}
