:root {
  --bg: #f7f5f0;
  --ink: #1c1b19;
  --muted: #8b8780;
  --line: #e4e0d8;
  --wave: #d8d3ca;
  --hover: rgba(28, 27, 25, 0.035);
  --current: rgba(28, 27, 25, 0.065);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.3, .6, .2, 1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.4; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.masthead { padding: clamp(40px, 8vw, 96px) 24px clamp(32px, 6vw, 72px); text-align: center; }
.masthead h1 { margin: 0; font: 400 clamp(1.15rem, 3.2vw, 1.9rem)/1.2 var(--serif); letter-spacing: .28em; }

main { max-width: 1120px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 96px; }

/* Player */
.player { display: grid; grid-template-columns: minmax(240px, 380px) 1fr; gap: clamp(28px, 5vw, 64px); align-items: center; padding-bottom: clamp(40px, 6vw, 72px); }
.art { position: relative; aspect-ratio: 1; background: #ece8e0; box-shadow: 0 18px 40px -22px rgba(28, 27, 25, .35); overflow: hidden; }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .35s var(--ease); }
.art.is-changing img { opacity: 0; }
.art.is-missing img { display: none; }
.art__placeholder { position: absolute; inset: 0; display: none; place-items: center; font: 400 3rem var(--serif); letter-spacing: .2em; color: #b9b3a8; }
.art.is-missing .art__placeholder { display: grid; }

.player__body { min-width: 0; }
.meta__number { margin: 0 0 10px; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta__title { margin: 0; font: 400 clamp(1.6rem, 3.4vw, 2.4rem)/1.15 var(--serif); overflow-wrap: anywhere; }
.meta__artist { margin: 8px 0 0; font-size: .95rem; color: var(--muted); }
.meta__status { margin: 8px 0 0; min-height: 1.2em; font-size: .8rem; color: var(--muted); }

.wave { position: relative; height: 84px; margin-top: 22px; cursor: pointer; touch-action: none; }
.wave canvas { width: 100%; height: 100%; display: block; }
.times { display: flex; justify-content: space-between; margin-top: 6px; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 22px; flex-wrap: wrap; }
.controls__main { display: flex; align-items: center; gap: 10px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; }
.btn { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; transition: background .2s, color .2s, transform .2s var(--ease); }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.94); }
.btn--toggle { color: var(--muted); }
.btn--toggle[aria-pressed="true"] { color: var(--ink); background: var(--current); }
.btn--play { width: 56px; height: 56px; margin: 0 6px; background: var(--ink); color: var(--bg); position: relative; }
.btn--play:hover { background: #3a3835; }
.btn--play svg { position: absolute; transition: opacity .2s, transform .25s var(--ease); }
.btn--play .icon-pause { opacity: 0; transform: scale(.7); }
.is-playing .btn--play .icon-play { opacity: 0; transform: scale(.7); }
.is-playing .btn--play .icon-pause { opacity: 1; transform: scale(1); }

.volume { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.volume input { width: 110px; height: 20px; accent-color: var(--ink); cursor: pointer; }

/* Track table */
.library { width: 100%; border-collapse: collapse; border-top: 1px solid var(--line); }
.library tr { border-bottom: 1px solid var(--line); cursor: pointer; transition: background .2s; }
.library tr:hover { background: var(--hover); }
.library tr.is-current { background: var(--current); }
.library td { padding: 10px 0; vertical-align: middle; }
.library .num { width: 64px; text-align: center; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; position: relative; }
.library .thumb-cell { width: 64px; }
.library .dur { width: 80px; text-align: right; padding-right: 16px; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.library .name { padding: 0 16px; font-size: 1rem; overflow-wrap: anywhere; transition: color .2s; }
.library tr.is-current .name { font-weight: 600; }
.library tr.is-unavailable .name { color: var(--muted); }
.thumb { width: 44px; height: 44px; background: #ece8e0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.is-missing img { display: none; }

.num > * { transition: opacity .2s; }
.num-play { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; opacity: 0; color: var(--ink); }
.num-play .fill { fill: currentColor; }
.library tr:hover .num-text { opacity: 0; }
.library tr:hover .num-play { opacity: 1; }
.eq { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; display: none; align-items: flex-end; gap: 2px; }
.eq i { flex: 1; height: 100%; background: var(--ink); transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.4s; }
.eq i:nth-child(3) { animation-delay: -.8s; }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
.library tr.is-playing .eq { display: flex; }
.library tr.is-playing .num-text, .library tr.is-playing .num-play { opacity: 0; }

@media (max-width: 760px) {
  .player { grid-template-columns: 1fr; }
  .art { width: 100%; max-width: 420px; margin: 0 auto; }
  .meta { text-align: center; }
  .controls { flex-direction: column; align-items: stretch; gap: 14px; }
  .controls__main { justify-content: space-between; }
  .btn { width: 48px; height: 48px; }
  .btn--play { width: 60px; height: 60px; }
  .volume { justify-content: center; }
  .volume input { width: 60%; max-width: 240px; }
  .library .num, .library .thumb-cell { width: 44px; }
  .library .dur { width: 56px; padding-right: 4px; }
  .library .name { padding: 0 10px; font-size: .95rem; }
  .thumb { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
}
