/* ===========================================================
   Music player
   Dark, mobile-first, no external dependencies.
   The accent colour is set in config.php.
   =========================================================== */

:root {
  --accent: #d9a441;
  --bg: #0b0c0e;
  --bg-raise: #141619;
  --bg-hover: #1b1e22;
  --line: #24282d;
  --text: #f2f3f5;
  --text-dim: #a2a9b2;
  --text-faint: #6d757e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgb(0 0 0 / 0.45);
  --wrap: 1060px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --bar-h: 68px;
}

* { box-sizing: border-box; }

/* The browser's own [hidden] rule is scoped to HTML elements, so it never
   reaches inline SVG. This makes hiding work the same way everywhere. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 50% -10%, rgb(255 255 255 / 0.045), transparent 70%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

img { max-width: 100%; display: block; }

button { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--accent); color: #17120a;
  padding: 10px 16px; border-radius: 0 0 8px 8px;
  font-weight: 600; text-decoration: none;
  transition: top .16s var(--ease);
}
.skip:focus { top: 0; }

:where(a, button, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── Notice + masthead ─────────────────────────────────── */

.notice {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.notice p {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 12px 20px;
  font-size: 0.875rem;
  color: color-mix(in srgb, var(--accent) 72%, #fff);
}

.masthead {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 40px 20px 8px;
}
.masthead h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}
.tagline {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.alert {
  max-width: var(--wrap);
  margin: 16px auto;
  padding: 12px 16px;
  background: #2a1c1c;
  border: 1px solid #4a2b2b;
  border-radius: var(--radius-sm);
  color: #f0b8b8;
  font-size: 0.9rem;
}

main { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

/* ── Empty state ───────────────────────────────────────── */

.empty { text-align: center; padding: 72px 20px; }
.empty-art {
  width: 76px; height: 76px; margin: 0 auto 20px;
  display: grid; place-items: center;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--text-faint);
}
.empty-art svg { width: 34px; height: 34px; }
.empty h2 { margin: 0 0 8px; font-size: 1.15rem; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 42ch; color: var(--text-dim); font-size: 0.95rem; }
.empty code {
  background: var(--bg-raise); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 5px; font-size: 0.875em;
}

/* ── Now playing ───────────────────────────────────────── */

.now {
  margin: 24px 0 40px;
  display: grid;
  gap: 24px;
}

.now-art {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: min(258px, 62vw);
  margin-inline: auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raise);
  box-shadow: var(--shadow);
}
.now-art img { width: 100%; height: 100%; object-fit: cover; }
.art-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-faint);
  background: linear-gradient(145deg, #1a1d21, #101214);
}
.art-fallback svg { width: 30%; height: 30%; }
.now-art img:not([hidden]) + .art-fallback { display: none; }

.now-body { min-width: 0; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.now-title {
  margin: 0;
  font-size: clamp(1.35rem, 4.6vw, 1.9rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.now-artist { margin: 4px 0 0; color: var(--text-dim); font-size: 0.98rem; }

/* Seek bar */

.seek {
  display: flex; align-items: center; gap: 12px;
  margin-top: 24px;
}
.time {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  min-width: 38px;
}
.time:last-child { text-align: right; }

.seek-track {
  position: relative;
  flex: 1;
  height: 20px;
  display: flex;
  align-items: center;
}
.seek-track::before {
  content: ""; position: absolute; inset-inline: 0;
  height: 5px; border-radius: 99px; background: #2a2f35;
}
.seek-buffer, .seek-fill {
  position: absolute; left: 0;
  height: 5px; border-radius: 99px;
  pointer-events: none;
}
.seek-buffer { background: #3a4149; width: 0; }
.seek-fill { background: var(--accent); width: 0; }

.seek-track input[type="range"] {
  position: relative;
  width: 100%; height: 20px; margin: 0;
  background: transparent;
  -webkit-appearance: none; appearance: none;
  cursor: pointer;
}
.seek-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; border: 0;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.6);
  opacity: 0;
  transition: opacity .15s var(--ease);
}
.seek-track input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; border: 0; opacity: 0;
}
.seek-track:hover input[type="range"]::-webkit-slider-thumb,
.seek-track input[type="range"]:focus-visible::-webkit-slider-thumb { opacity: 1; }
.seek-track:hover input[type="range"]::-moz-range-thumb,
.seek-track input[type="range"]:focus-visible::-moz-range-thumb { opacity: 1; }

/* Controls */

.controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.ctl {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: transparent;
  border: 0; border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}
.ctl svg { width: 22px; height: 22px; }
.ctl:hover { background: var(--bg-hover); }
.ctl:active { transform: scale(0.94); }

.ctl.ghost { color: var(--text-faint); position: relative; }
.ctl.ghost:hover { color: var(--text); }
.ctl.ghost[aria-pressed="true"] { color: var(--accent); }
.ctl.ghost svg { width: 19px; height: 19px; }

.repeat-one {
  position: absolute; right: 7px; bottom: 6px;
  font-size: 9px; font-weight: 700; line-height: 1;
  background: var(--accent); color: #17120a;
  border-radius: 50%; width: 12px; height: 12px;
  display: grid; place-items: center;
}

.ctl.primary {
  width: 56px; height: 56px;
  background: var(--accent);
  color: #17120a;
  margin-inline: 4px;
  position: relative;
}
.ctl.primary svg { width: 26px; height: 26px; }
.ctl.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #fff); }
.ctl.primary.sm { width: 42px; height: 42px; }
.ctl.primary.sm svg { width: 20px; height: 20px; }

.spinner {
  position: absolute; inset: 0; margin: auto;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgb(23 18 10 / 0.3);
  border-top-color: #17120a;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ctl.primary.loading svg { visibility: hidden; }

.volume { display: none; align-items: center; gap: 6px; margin-left: auto; }
.volume input[type="range"] {
  width: 84px; height: 20px; margin: 0;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.volume input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px; background: #2a2f35;
}
.volume input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 99px; background: #2a2f35;
}
.volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; margin-top: -4px;
  border-radius: 50%; background: var(--text-dim); border: 0;
}
.volume input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-dim); border: 0;
}

.hint { margin: 18px 0 0; font-size: 0.78rem; color: var(--text-faint); display: none; }
.hint kbd {
  background: var(--bg-raise); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 5px; font-family: inherit; font-size: 0.9em;
}

/* ── Track list ────────────────────────────────────────── */

.tracklist { margin-bottom: 56px; }

/* Album pills */

.albums { margin-bottom: 20px; }

.album-pills {
  list-style: none;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0 20px 4px;
  /* Full-bleed scroll on phones so pills can run past the gutter */
  margin-inline: -20px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.album-pills::-webkit-scrollbar { display: none; }
.album-pills li { flex: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 15px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--text-dim);
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}
.pill:hover { background: var(--bg-hover); color: var(--text); }

.pill.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #17120a;
  font-weight: 600;
}

.pill-count {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  background: rgb(255 255 255 / 0.06);
  border-radius: 99px;
  padding: 1px 7px;
}
.pill.is-on .pill-count {
  color: #17120a;
  background: rgb(0 0 0 / 0.16);
}

/* Album header */

.album-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding: 14px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.album-cover {
  position: relative;
  flex: none;
  width: 76px; height: 76px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-cover .art-fallback svg { width: 34%; height: 34%; }
.album-cover img:not([hidden]) + .art-fallback { display: none; }

.album-meta { min-width: 0; }
.album-meta h2 {
  margin: 2px 0 0;
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.album-sub { margin: 2px 0 0; font-size: 0.82rem; color: var(--text-faint); }

.tracklist-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 6px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.tracklist-head h2 {
  margin: 0; font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint);
}
.linkish {
  background: none; border: 0; padding: 4px 2px;
  color: var(--accent); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; border-radius: 6px;
}
.linkish:hover { text-decoration: underline; }

.tracks { list-style: none; margin: 0; padding: 0; }

.track {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 10px 8px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .13s var(--ease);
}
.track:hover { background: var(--bg-hover); }
.track:focus-within { background: var(--bg-hover); }

.track-num {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  text-align: center;
  position: relative;
}
.track:hover .track-num .n { visibility: hidden; }
.track-num .play-cue {
  position: absolute; inset: 0;
  display: none; place-items: center;
  color: var(--text);
}
.track:hover .play-cue { display: grid; }
.play-cue svg { width: 13px; height: 13px; }

.track-main { min-width: 0; }
.track-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-sub {
  margin: 1px 0 0;
  font-size: 0.8rem;
  color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.track-side { display: flex; align-items: center; gap: 2px; }
.track-dur {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  min-width: 40px; text-align: right;
  padding-right: 4px;
}
.track-action {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%;
  color: var(--text-faint); cursor: pointer;
  opacity: 0;
  transition: opacity .13s var(--ease), color .13s var(--ease), background .13s var(--ease);
}
.track-action svg { width: 16px; height: 16px; }
.track-action:hover { color: var(--text); background: #23272c; }
.track:hover .track-action, .track-action:focus-visible { opacity: 1; }

.track[aria-current="true"] { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.track[aria-current="true"] .track-title { color: var(--accent); font-weight: 600; }
.track[aria-current="true"] .track-num .n { visibility: hidden; }

/* Animated bars on the playing track */
.eq { display: none; gap: 2px; align-items: flex-end; height: 13px; justify-content: center; }
.track[aria-current="true"] .eq { display: flex; }
.track[aria-current="true"]:hover .play-cue { display: none; }
.eq i {
  display: block; width: 2px; background: var(--accent); border-radius: 1px;
  animation: eq 1s var(--ease) infinite;
}
.eq i:nth-child(1) { height: 40%; animation-delay: -0.2s; }
.eq i:nth-child(2) { height: 90%; animation-delay: -0.5s; }
.eq i:nth-child(3) { height: 60%; animation-delay: -0.8s; }
@keyframes eq { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
.track.is-paused .eq i { animation-play-state: paused; }

.track.is-error .track-title { color: #e08b8b; }
.track.is-error .track-sub::after { content: " · file could not be loaded"; }

/* ── Mini bar ──────────────────────────────────────────── */

.minibar {
  position: fixed;
  inset-inline: 0; bottom: 0;
  z-index: 40;
  background: rgb(16 18 21 / 0.88);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
  transition: transform .26s var(--ease);
}
.minibar.show { transform: translateY(0); }

.minibar-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  height: var(--bar-h);
  padding: 0 12px 0 16px;
  display: flex; align-items: center; gap: 10px;
}
.minibar img {
  width: 44px; height: 44px; border-radius: 8px;
  object-fit: cover; flex: none; background: var(--bg-raise);
}
.minibar-meta { flex: 1; min-width: 0; }
.mb-title {
  margin: 0; font-size: 0.875rem; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mb-artist {
  margin: 0; font-size: 0.75rem; color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mbPrev, #mbNext { display: none; }

.minibar-progress { height: 2px; background: #23272c; }
.minibar-progress div { height: 100%; width: 0; background: var(--accent); }

/* ── Footer ────────────────────────────────────────────── */

.site-footer {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 28px 20px 40px;
  border-top: 1px solid var(--line);
}
.site-footer p { margin: 0; font-size: 0.8rem; color: var(--text-faint); }

/* ── Larger screens ────────────────────────────────────── */

@media (min-width: 700px) {
  .now {
    grid-template-columns: 260px 1fr;
    align-items: center;
    gap: 32px;
    margin: 36px 0 48px;
  }
  .now-art { max-width: none; }
  .volume { display: flex; }
  .hint { display: block; }
  #mbPrev, #mbNext { display: grid; }
  .track { grid-template-columns: 36px 1fr auto; }
}

@media (min-width: 1000px) {
  .now { grid-template-columns: 300px 1fr; gap: 44px; }
}

/* Touch devices: keep row actions visible, no hover to reveal */
@media (hover: none) {
  .track-action { opacity: 1; }
  .track-num .play-cue { display: none !important; }
  .track[aria-current="true"] .eq { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .minibar { transition: none; }
}

/* ── Playlist pills ─────────────────────────────────────── */

.pill.is-list,
.pill.is-shared { border-style: dashed; }
.pill.is-list.is-on,
.pill.is-shared.is-on { border-style: solid; }

.pill-new {
  color: var(--text-faint);
  border-style: dashed;
  gap: 4px;
  padding-inline: 13px;
}
.pill-new svg { width: 15px; height: 15px; }
.pill-new:hover { color: var(--text); border-color: var(--text-faint); }

/* ── Album / playlist header actions ────────────────────── */

.album-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.mini {
  min-height: 30px;
  padding: 0 11px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .13s var(--ease), color .13s var(--ease), border-color .13s var(--ease);
}
.mini:hover { background: var(--bg-hover); color: var(--text); }
.mini.danger:hover { color: #f0a0a0; border-color: #5a3030; background: #2a1c1c; }

/* ── Track row action sets ──────────────────────────────── */

.acts { display: contents; }
.acts.editing { display: none; }
.tracks.in-playlist .acts.normal { display: none; }
.tracks.in-playlist .acts.editing { display: contents; }

/* ── Sheets (add to playlist, rename, confirm) ──────────── */

dialog.sheet {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  max-width: 420px;
  width: calc(100% - 32px);
  margin: auto;
}
dialog.sheet::backdrop { background: rgb(0 0 0 / 0.62); }

.sheet-inner {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.sheet-inner h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.sheet-sub {
  margin: 5px 0 0;
  font-size: 0.86rem;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.sheet-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
}
.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  margin-bottom: 5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background .13s var(--ease);
}
.sheet-row:hover:not(:disabled) { background: var(--bg-hover); }
.sheet-row:disabled { opacity: 0.5; cursor: default; }
.sheet-meta { font-size: 0.75rem; color: var(--text-faint); flex: none; }

.sheet-empty {
  font-size: 0.85rem;
  color: var(--text-faint);
  padding: 2px 0 6px;
}

.sheet-new { display: flex; gap: 8px; margin-top: 14px; }

.sheet-inner input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.sheet-inner input[type="text"]::placeholder { color: var(--text-faint); }
.sheet-inner input[type="text"]:focus-visible { border-color: var(--accent); }

#dlgName .sheet-inner input[type="text"] { width: 100%; margin-top: 14px; }

.sheet-note {
  margin: 14px 0 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-faint);
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.btn {
  min-height: 42px;
  padding: 0 18px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: #17120a;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 86%, #fff); }

.btn.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
  font-weight: 500;
}
.btn.ghost-btn:hover { background: var(--bg-hover); color: var(--text); }

.btn.danger-btn {
  background: #7d2b2b;
  border-color: #7d2b2b;
  color: #ffe8e8;
}
.btn.danger-btn:hover { background: #8f3232; }

/* ── Footer note ────────────────────────────────────────── */

.footer-note {
  margin: 6px 0 0 !important;
  max-width: 62ch;
  font-size: 0.76rem !important;
  line-height: 1.55;
  color: var(--text-faint);
}

/* Keep playlist rows workable on a narrow phone */
@media (max-width: 560px) {
  .tracks.in-playlist .track-dur { display: none; }
  .tracks.in-playlist .track-action { width: 36px; height: 36px; }
}

/* In a playlist the reorder and remove controls are the point of the
   view, so they stay visible instead of waiting for a hover. */
.tracks.in-playlist .track-action { opacity: 1; }
