:root {
  --black: #000;
  --bg: #121212;
  --card: #181818;
  --card-hover: #282828;
  --elev: #2a2a2a;
  --ink: #fff;
  --muted: #b3b3b3;
  --faint: #6a6a6a;
  --gold: #e3b553;
  --gold-hover: #f0c66a;
  --blue: #3b5bdb;
  --purple: #7b3fa0;
  --scarlet: #c0392b;
  --linen: #f4ecdc;
  --gutter: 16px;
  --bar-h: 60px;
  --np-h: 72px;
  --h: 228; /* panel hue, set per page */
  --side-w: 300px;
  --display: Inter, system-ui, sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.has-np { padding-bottom: calc(var(--np-h) + 24px + env(safe-area-inset-bottom)); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; letter-spacing: -.02em; }
svg { display: block; }
.eyebrow { margin: 0 0 6px; font-size: .8rem; font-weight: 700; letter-spacing: .02em; }

/* ---------- Cover art: a coloured tile per panel ---------- */
.art {
  position: relative; display: block; aspect-ratio: 1; overflow: hidden; flex: none;
  border-radius: 6px; color: #fff;
  background:
    radial-gradient(120% 90% at 0% 0%, hsl(var(--h) 75% 60% / .9), transparent 60%),
    linear-gradient(150deg, hsl(var(--h) 60% 42%), hsl(calc(var(--h) + 30) 55% 16%));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.art-label, .cover-panel {
  position: absolute; top: 9%; left: 9%;
  font-size: .62rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; opacity: .85;
}
.art-num, .cover-num {
  position: absolute; top: 15%; left: 8%;
  font-family: var(--serif); font-weight: 700; line-height: 1; font-size: 3.6rem;
  font-variant-numeric: lining-nums; text-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}
.art-door, .door {
  position: absolute; right: 10%; bottom: 0; width: 34%; height: 40%;
  display: flex; border-radius: 4px 4px 0 0; overflow: hidden;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .18);
}
.art-door i, .door i { flex: 1; }
.art-door i:nth-child(1), .door i:nth-child(1) { background: var(--blue); }
.art-door i:nth-child(2), .door i:nth-child(2) { background: var(--purple); }
.art-door i:nth-child(3), .door i:nth-child(3) { background: var(--scarlet); }
.art-door i:nth-child(4), .door i:nth-child(4) { background: var(--linen); }
.art-sm { width: 48px; border-radius: 4px; box-shadow: none; }
.art-sm .art-label, .art-sm .art-door { display: none; }
.art-sm .art-num { inset: 0; display: grid; place-items: center; font-size: 1.6rem; }
.art-lg { width: clamp(160px, 22vw, 232px); }
.art-lg .art-num { font-size: clamp(5rem, 9vw, 7.5rem); }
.art-xl .cover-num { font-size: clamp(4.5rem, 14vw, 7rem); }
.playing .door { animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px rgba(255, 255, 255, .18), 0 0 50px 10px rgba(227, 181, 83, .45); } }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 10; height: calc(var(--bar-h) + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: env(safe-area-inset-top) var(--gutter) 0;
  background: rgba(18, 18, 18, .55);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }
.switches { display: flex; gap: 8px; }
.seg { display: flex; background: rgba(0, 0, 0, .55); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--black); }
@media (max-width: 420px) { .bar .brand span { display: none; } }

/* Content scrolls under the bar so page gradients start at the very top. */
main { margin-top: calc(-1 * (var(--bar-h) + env(safe-area-inset-top))); }

/* ---------- Home ---------- */
.hero {
  padding: calc(var(--bar-h) + env(safe-area-inset-top) + 32px) var(--gutter) 28px;
  background: linear-gradient(hsl(var(--h) 45% 30%), var(--bg));
}
.hero .eyebrow { color: var(--muted); }
.hero h1 { font-size: clamp(2.4rem, 8vw, 4.75rem); font-weight: 800; letter-spacing: -.04em; }
.hero p:last-child { color: var(--muted); margin: 10px 0 0; max-width: 34em; }

.shelf { padding: 8px var(--gutter) 0; }
.shelf h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pcard { position: relative; padding: 12px; border-radius: 8px; background: var(--card); transition: background .2s; }
.pcard:hover { background: var(--card-hover); }
.pcard-art { position: relative; margin-bottom: 12px; }
.pcard-art .art { width: 100%; }
.pcard-art .fab { position: absolute; z-index: 1; right: 8px; bottom: 8px; }
/* The title link covers the whole card; the play button sits above it. */
.pcard-link { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 700; line-height: 1.3; }
.pcard-link::after { content: ""; position: absolute; inset: 0; }
.pcard small { color: var(--muted); font-size: .85rem; }

.fab {
  width: 48px; height: 48px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: var(--black); box-shadow: 0 8px 16px rgba(0, 0, 0, .35);
  transition: transform .2s, opacity .2s, background .2s;
}
.fab svg { width: 22px; height: 22px; fill: currentColor; }
.fab:hover { background: var(--gold-hover); transform: scale(1.06); }
.foot { padding: 32px var(--gutter); color: var(--muted); font-size: .85rem; }
.foot a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Panel ("playlist") page ---------- */
.phead {
  display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center;
  padding: calc(var(--bar-h) + env(safe-area-inset-top) + 16px) var(--gutter) 24px;
  background: linear-gradient(hsl(var(--h) 50% 38%), hsl(var(--h) 45% 22%));
}
.phead .art-lg { box-shadow: 0 12px 48px rgba(0, 0, 0, .55); }
.phead h1 { font-size: clamp(2rem, 7vw, 4.5rem); font-weight: 800; letter-spacing: -.04em; }
.phead p:last-child { margin: 10px 0 0; color: rgba(255, 255, 255, .75); font-size: .9rem; font-weight: 500; }
.pbody { padding: 20px var(--gutter) 0; background: linear-gradient(hsl(var(--h) 40% 14%), var(--bg) 240px); }
.actions { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.fab-lg { width: 56px; height: 56px; }
.fab-lg svg { width: 26px; height: 26px; }

/* ---------- Track rows ---------- */
.tracks { list-style: none; margin: 0; padding: 0; }
.tracks a {
  display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 14px;
  padding: 8px 12px; border-radius: 6px; transition: background .15s;
}
.tracks a:hover { background: rgba(255, 255, 255, .08); }
.tracks .n { display: grid; place-items: center; height: 32px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tracks .n svg { width: 16px; height: 16px; fill: var(--ink); display: none; }
.tracks a:hover .num { display: none; }
.tracks a:hover .n svg { display: block; }
.tracks .t b { display: block; font-weight: 500; line-height: 1.35; }
.tracks .t small { color: var(--muted); font-size: .82rem; }
.tracks a.now b, .tracks a.now .num { color: var(--gold); }
.eq { display: none; gap: 2px; align-items: end; height: 14px; }
.eq i { width: 3px; background: var(--gold); border-radius: 1px; animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; }
.eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
.is-playing .tracks a.now:not(:hover) .num { display: none; }
.is-playing .tracks a.now:not(:hover) .eq { display: flex; }

/* ---------- Player (track page, where QR codes land) ---------- */
.player {
  padding: calc(var(--bar-h) + env(safe-area-inset-top) + 12px) var(--gutter) 24px;
  background: linear-gradient(hsl(var(--h) 45% 30%), var(--bg) 520px);
}
.cover { width: min(100%, 42vh); min-width: 220px; margin: 0 auto; box-shadow: 0 16px 48px rgba(0, 0, 0, .55); }
.cover .door { width: 38%; height: 46%; right: 50%; transform: translateX(50%); }
.meta { margin-top: 24px; }
.kicker { display: inline-block; color: var(--muted); font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.kicker:hover { color: var(--ink); text-decoration: underline; }
.title { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: -.03em; }

.seek { margin-top: 20px; }
.scrub {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; margin: 0; cursor: pointer;
  background: linear-gradient(to right, var(--ink) var(--p, 0%), rgba(255, 255, 255, .25) var(--p, 0%));
}
.scrub:hover { background: linear-gradient(to right, var(--gold) var(--p, 0%), rgba(255, 255, 255, .25) var(--p, 0%)); }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); opacity: 0; transition: opacity .15s; }
.scrub:hover::-webkit-slider-thumb, .scrub:active::-webkit-slider-thumb { opacity: 1; }
.scrub::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--ink); }
.player .scrub::-webkit-slider-thumb { opacity: 1; }
.times { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 8px; }

.controls { display: flex; align-items: center; justify-content: space-between; max-width: 360px; margin: 8px auto 0; }
.ctl { border: 0; background: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); transition: color .15s, transform .15s; }
.ctl:hover:not(:disabled) { color: var(--ink); transform: scale(1.06); }
.ctl svg { width: 26px; height: 26px; fill: currentColor; }
.ctl text { font: 700 6.5px Inter, sans-serif; fill: currentColor; }
.ctl.prev, .ctl.next { color: var(--ink); }
.ctl:disabled { opacity: .3; cursor: default; }
.ctl.play { position: relative; width: 68px; height: 68px; background: var(--ink); color: var(--black); }
.ctl.play:hover { color: var(--black); }
.ctl.play svg { width: 30px; height: 30px; }
.ctl.play .i-pause, .playing .ctl.play .i-play { display: none; }
.playing .ctl.play .i-pause { display: block; }
.spinner { position: absolute; inset: -5px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--gold); animation: spin .9s linear infinite; display: none; }
.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.extras { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255, 255, 255, .3); background: transparent; border-radius: 999px;
  padding: 6px 14px; font-size: .82rem; font-weight: 700; transition: border-color .15s, transform .15s;
}
.chip:hover { border-color: var(--ink); transform: scale(1.03); }

.text {
  margin-top: 32px; padding: 20px; border-radius: 12px;
  background: hsl(var(--h) 38% 26%);
}
.text h2 { font-size: 1rem; font-weight: 800; margin-bottom: 14px; }
.text-title { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; letter-spacing: 0; margin-bottom: 8px; }
.text-body { margin: 0; font-size: 1.1rem; line-height: 1.7; font-weight: 600; color: rgba(255, 255, 255, .92); }
.more { margin-top: 32px; }
.more h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 8px; }

/* ---------- Now-playing bar ---------- */
.np {
  position: fixed; z-index: 30; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
  height: var(--np-h); padding: 0 10px; border-radius: 10px;
  display: flex; align-items: center; gap: 12px;
  background: hsl(var(--h) 35% 22%); box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.np[hidden] { display: none; }
.np-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.np-art { width: 48px; display: grid; place-items: center; font: 700 1.5rem/1 var(--serif); box-shadow: none; border-radius: 4px; }
.np-text { min-width: 0; display: flex; flex-direction: column; }
.np-title, .np-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-title { font-size: .9rem; font-weight: 700; }
.np-sub { font-size: .76rem; color: rgba(255, 255, 255, .7); }
.np-ctl { display: flex; align-items: center; gap: 4px; }
.np-play { position: relative; width: 40px; height: 40px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--black); transition: transform .15s; }
.np-play:hover { transform: scale(1.06); }
.np-play svg { width: 20px; height: 20px; fill: currentColor; }
.np-play .i-pause, .np.playing .np-play .i-play { display: none; }
.np.playing .np-play .i-pause { display: block; }
.np .ctl { width: 36px; height: 36px; color: var(--ink); }
.np .ctl svg { width: 18px; height: 18px; }
.np-prev, .np-seek, .np-right { display: none !important; }
.np-progress { position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: rgba(255, 255, 255, .2); border-radius: 1px; }
.np-progress span { display: block; height: 100%; width: 0; background: var(--ink); }
/* On a phone the track page already has full controls. */
@media (max-width: 959px) { .on-current .np { display: none; } .on-current.has-np { padding-bottom: 0; } }

/* ---------- Share dialog ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; background: var(--elev); color: var(--ink); box-shadow: 0 16px 48px rgba(0, 0, 0, .6); max-width: min(360px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); }
.share-inner { position: relative; padding: 28px 22px 22px; text-align: center; }
.share-inner h2 { font-size: 1.5rem; font-weight: 800; }
.share-title { color: var(--muted); margin: 6px 0 16px; font-size: .9rem; }
.share-qr { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 8px; }
.share-url { display: block; margin: 12px 0 18px; font-size: .85rem; word-break: break-all; color: var(--gold); }
.share-actions { display: flex; justify-content: center; gap: 10px; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 1.6rem; line-height: 1; color: var(--muted); }
.close:hover { color: var(--ink); }

.notfound { text-align: center; padding: calc(var(--bar-h) + 80px) var(--gutter) 60px; }
.notfound h1 { font-size: 2rem; font-weight: 800; margin-bottom: 12px; }
.notfound a { color: var(--gold); }

/* ---------- Sidebar (desktop only) ---------- */
.sidebar { display: none; }

@media (hover: hover) {
  .pcard .fab { opacity: 0; transform: translateY(8px); }
  .pcard:hover .fab, .pcard .fab:focus-visible { opacity: 1; transform: none; }
}

@media (min-width: 960px) {
  :root { --gutter: 32px; --np-h: 80px; }
  body { background: var(--black); padding: 8px 8px 0; }
  body.has-np { padding-bottom: calc(var(--np-h) + 8px); }

  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    position: fixed; z-index: 20; top: 8px; left: 8px; bottom: 8px; width: var(--side-w);
  }
  .has-np .sidebar { bottom: calc(var(--np-h) + 8px); }
  .sidebar > .brand, .nav, .library { background: var(--bg); border-radius: 8px; }
  .sidebar > .brand { padding: 18px 20px 8px; border-radius: 8px 8px 0 0; margin-bottom: -8px; }
  .nav { padding: 8px 12px 12px; border-radius: 0 0 8px 8px; }
  .nav a { display: flex; align-items: center; gap: 16px; padding: 8px; color: var(--muted); font-weight: 700; transition: color .15s; }
  .nav a:hover, .nav a[aria-current] { color: var(--ink); }
  .nav svg { width: 24px; height: 24px; fill: currentColor; }
  .library { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .library h2 { display: flex; align-items: center; gap: 12px; padding: 16px 20px 8px; font-size: 1rem; font-weight: 700; color: var(--muted); letter-spacing: 0; }
  .library h2 svg { width: 24px; height: 24px; fill: currentColor; }
  #lib { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; }
  #lib a { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 6px; transition: background .15s; }
  #lib a:hover { background: rgba(255, 255, 255, .07); }
  #lib a[aria-current] { background: rgba(255, 255, 255, .12); }
  #lib a[aria-current] b { color: var(--gold); }
  #lib .t { min-width: 0; }
  #lib b { display: block; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #lib small { color: var(--muted); font-size: .8rem; }

  .shell {
    margin-left: calc(var(--side-w) + 8px); min-height: calc(100vh - 16px);
    background: var(--bg); border-radius: 8px; overflow: clip;
  }
  .has-np .shell { min-height: calc(100vh - var(--np-h) - 16px); }
  .bar { top: 0; border-radius: 8px 8px 0 0; justify-content: flex-end; }
  .bar .brand { display: none; }

  .hero { padding-top: calc(var(--bar-h) + 56px); padding-bottom: 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }

  .phead { flex-direction: row; align-items: flex-end; text-align: left; gap: 28px; padding-top: calc(var(--bar-h) + 40px); padding-bottom: 28px; }
  .pbody { padding-top: 24px; }

  .player {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); column-gap: 48px; align-items: start;
    padding-top: calc(var(--bar-h) + 24px); padding-bottom: 40px;
  }
  .stage { position: sticky; top: calc(var(--bar-h) + 16px); }
  .cover { width: min(100%, 40vh); margin: 0; }
  .text { margin-top: 0; padding: 28px 32px; }
  .text-body { font-size: 1.25rem; }

  /* Full-width transport bar along the bottom. */
  .np {
    left: 0; right: 0; bottom: 0; border-radius: 0; padding: 0 16px;
    display: grid; grid-template-columns: minmax(180px, 1fr) minmax(320px, 2fr) minmax(120px, 1fr); gap: 16px;
    background: var(--black); box-shadow: none;
  }
  .np-art { width: 56px; }
  .np-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .np-ctl { gap: 16px; }
  .np-play { width: 34px; height: 34px; }
  .np-play svg { width: 18px; height: 18px; }
  .np .ctl { color: var(--muted); }
  .np .ctl:hover:not(:disabled) { color: var(--ink); }
  .np-prev { display: grid !important; }
  .np-seek { display: flex !important; align-items: center; gap: 8px; width: 100%; max-width: 600px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
  .np-seek .scrub { flex: 1; }
  .np-right { display: flex !important; justify-content: flex-end; }
  .np-progress { display: none; }
}
