:root {
  --bg: #232428;
  --bg-raised: #2b2d31;
  --bg-hover: #35373c;
  --border: #3b3d42;
  --text: #e3e5e8;
  --text-dim: #9a9da3;
  --accent: #7aa2f7;
}
* { box-sizing: border-box; }

/* Lucide icons: inherit the text color, never intercept clicks.
   The sprite's symbols are bare paths, so stroke styling lives here. */
.ic {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: -3px;
  pointer-events: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#npControls .ic, #npvBottom .ic { width: 18px; height: 18px; }
.ck .ic { width: 12px; height: 12px; vertical-align: -2px; }
.subArrow .ic, .bSort .ic, #browseBtn > .ic { width: 12px; height: 12px; vertical-align: -2px; }
.mmLink .ic, .hint .ic { width: 12px; height: 12px; }
html { height: 100%; }
body {
  /* min-height (not height): the body must grow with content, or sticky
     header/footer only stick within the first viewport. */
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 14px;
  /* top inset clears the notch / Dynamic Island when installed (env is 0 on desktop) */
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  background: rgba(43, 45, 49, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  will-change: transform;
}
/* One text-input style everywhere; context rules add only layout. */
input[type="text"], input[type="search"], input[type="password"], input:not([type]) {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 10px;
  font-size: 12px;
}
input[type="text"]:focus, input[type="search"]:focus, input[type="password"]:focus,
input:not([type]):focus { outline: none; border-color: var(--accent); }

/* One select style everywhere; context rules add only layout. */
select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 8px;
  font-size: 12px;
}
select:focus { outline: none; border-color: var(--accent); }
#allBtn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 4px 14px;
  cursor: pointer;
  font-size: 12px;
}
#allBtn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #15161a;
  font-weight: 600;
}
#browseWrap { position: relative; }
#browseBtn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#browseBtn .bSort { color: var(--text-dim); font-size: 11px; }
#browseBtn:hover { border-color: var(--accent); }

/* multi-tier dropdown */
.dd {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  min-width: 170px;
  z-index: 45;
}
.dd[hidden] { display: none; }
.dd button, .ddRow {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.dd button:hover, .ddRow:hover { background: var(--bg-hover); }
.ddRow { position: relative; }
.ck { width: 14px; color: var(--accent); flex: none; font-size: 11px; }
.subArrow { margin-left: auto; color: var(--text-dim); padding-left: 16px; }
.dd .sub {
  position: absolute;
  left: 100%;
  top: -1px;
  display: none;
}
.ddRow:hover > .sub { display: flex; }
#tabs { display: flex; gap: 4px; }
#tabs button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 6px 12px 5px;
  font-size: 13px;
  cursor: pointer;
}
#tabs button:hover { color: var(--text); }
#tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.hdrBtn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
}
.hdrBtn:hover { color: var(--text); }
.hdrBtn.on { color: var(--accent); border-color: var(--accent); }

#filterChip {
  background: var(--accent);
  border: none;
  color: #15161a;
  font-weight: 600;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}
#filterChip .fcK { opacity: .65; font-weight: 400; }
#filterChip[hidden] { display: none; }

#cdNow {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
}
#cdNow:hover { border-color: var(--accent); }
#cdNow[hidden] { display: none; }
#cdNow .cdA { color: var(--text-dim); white-space: nowrap; }
#cdNow .cdT {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600;
}

.ddScroll { max-height: 340px; overflow-y: auto; scrollbar-width: thin; }
.ddN { margin-left: auto; color: var(--text-dim); font-size: 10px; padding-left: 12px; }
.ddSep { border-top: 1px solid var(--border); margin: 4px 0; }

/* The queue button carries the auto-margin so it (and the hamburger after it)
   sit together at the right edge, away from the sort/filter cluster. */
#queueBtnTop { margin-left: auto; }
#appMenuWrap { position: relative; }
#appMenu {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
}
#appMenu:hover { color: var(--text); }
#appMenuDrop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  min-width: 160px;
  z-index: 40;
}
#appMenuDrop[hidden] { display: none; }
#appMenuDrop button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
}
#appMenuDrop button:hover { background: var(--bg-hover); }

/* letter rail: faint until hovered, then blurred panel */
#rail {
  position: fixed;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  z-index: 20;
  padding: 10px 2px;
  opacity: .35;
  border: 1px solid transparent;
  transition: opacity .18s ease, background .18s ease, border-color .18s ease;
}
#rail:hover {
  opacity: 1;
  background: rgba(35, 36, 40, .55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: var(--border);
}
#rail:empty { display: none; }
#rail button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.5;
  padding: 0 9px;
  cursor: pointer;
}
#rail button:hover { color: var(--accent); font-weight: 700; }

/* artist group headers */
.ghead {
  grid-column: 1 / -1;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 2px 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 62px;
  width: fit-content;
  cursor: pointer;
}
.ghead:hover { text-decoration: underline; }
.tile { scroll-margin-top: 62px; }
#sources button {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);

  padding: 3px 12px;
  cursor: pointer;
  font-size: 12px;
}
#sources button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #15161a;
  font-weight: 600;
}
#searchWrap { position: relative; display: flex; align-items: center; flex: 1; max-width: 340px; }
#searchWrap .searchIc {
  position: absolute; left: 9px; width: 15px; height: 15px;
  color: var(--text-dim); pointer-events: none;
}
#search {
  flex: 1; min-width: 0; width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 28px 5px 30px; /* room for the magnifier and the clear button */
  outline: none;
}
#search:focus { border-color: var(--accent); }
#search::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
#searchClear {
  position: absolute; right: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0;
  background: none; border: none; color: var(--text-dim); cursor: pointer;
}
#searchClear:hover { color: var(--text); }
#searchClear .ic { width: 14px; height: 14px; }
#searchClear[hidden] { display: none; }
#scan {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);

  padding: 5px 12px;
  cursor: pointer;
}
#scan:hover { border-color: var(--accent); }
#scanStatus { color: var(--text-dim); font-size: 12px; }

main {
  flex: 1;
  padding: 18px 38px 18px 18px; /* right gutter keeps tiles clear of the rail */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 18px 16px;
  align-content: start;
}

.tile { cursor: pointer; min-width: 0; }
.tile .cover {
  position: relative;
  aspect-ratio: 1;

  overflow: hidden;
  background: var(--bg-raised);
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
  /* Apple-TV-style lean: pointer position drives a subtle 3D tilt + sheen. */
  transform: perspective(620px) translateY(var(--lift, 0px))
             rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--sc, 1));
  transition: transform .18s ease, box-shadow .18s ease;
  will-change: transform;
}
.tile:hover .cover {
  --lift: -2px;
  --sc: 1.015;
  box-shadow: 0 6px 16px rgba(0,0,0,.5);
}
.tile .cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%),
              rgba(255,255,255,.08), transparent 48%);
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}
.tile:hover .cover::after { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .tile .cover { transform: none !important; }
  .tile .cover::after { display: none; }
}
.tile.open .cover { outline: 2px solid var(--accent); outline-offset: 2px; }
.varBadge {
  position: absolute; top: 6px; right: 6px;
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(10,11,13,.78); color: #fff;
  font-size: 10px; font-weight: 600; padding: 2px 6px;
  border: 1px solid rgba(255,255,255,.2);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  pointer-events: none; z-index: 1;
}
.varBadge .ic { width: 11px; height: 11px; }
.tile .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .cover .noart {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 34px;
}
.tile .t1 {
  margin-top: 7px;
  font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
.tile .mq { display: inline-flex; white-space: nowrap; }
.tile .mq.scrolling { animation: mq linear infinite alternate; }
.tile .mqBox {
  background: rgba(35, 36, 40, .92);
  padding: 0 5px;
  margin: 0 -5px;
  position: relative;
  z-index: 2;
}
.tile .t1.mqBox { margin-top: 7px; }
/* Marquee captions fade at the right edge to signal the text continues (it
   scrolls on hover). The mask only bites once text reaches the edge, so short,
   non-overflowing captions are untouched. */
.tile .t1, .tile .t2a, #npTitle, #npSub {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), #0000);
  mask-image: linear-gradient(to right, #000 calc(100% - 16px), #0000);
}
.tile .t2 {
  color: var(--text-dim); font-size: 12px;
  display: flex; justify-content: space-between; gap: 8px;
}
/* flex:1 so a short artist fills the cell and ends before the fade zone (rather
   than shrink-wrapping, which would fade its own last letters). */
.tile .t2a { overflow: hidden; white-space: nowrap; min-width: 0; flex: 1; }
.tile .t2y { flex: none; }

/* Metadata fragments: separated by space, never punctuation glyphs. */
.mPart + .mPart { margin-left: 11px; }

/* ---- iTunes-11-style expander ---- */
#expander {
  grid-column: 1 / -1;
  /* Collapsed, the shelf still occupies a grid row, so the #grid row-gap (18px)
     lands both above AND below it — 18px more than when it's removed. We pull
     that extra gap back with a negative margin that animates to the open 6px,
     so the collapse ends at the exact spacing of the gone state (no sudden pop). */
  margin-top: -18px;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 6px 18px rgba(0,0,0,.35);
  scroll-margin-top: 62px; /* clear the sticky header on top-aligned scrolls */
}
/* Accordion: the clip wrapper animates its single row 0fr<->1fr (robust — no
   grid-item min-height / flex-resize quirks), clipping expBody cleanly so the
   fixed-size art is cropped, never distorted. The arrow (a child of #expander,
   outside this clip) fades with the shell. */
#expander { opacity: 0; transition: opacity .2s ease, margin-top .28s ease; }
#expander.open { opacity: 1; margin-top: 6px; }
.expClip {
  display: grid;
  grid-template-rows: 0fr;
  /* One full-width column with a 0 floor: without this the implicit `auto`
     column sizes to the tracklist's max-content and the body spills past the
     shelf. minmax(0,1fr) pins it to the pane and lets inner content clip/wrap. */
  grid-template-columns: minmax(0, 1fr);
  transition: grid-template-rows .28s ease;
}
#expander.open .expClip { grid-template-rows: 1fr; }
/* The clip lives on an inner wrapper, NOT on .expBody — .expBody carries the
   26px padding, which would pin the clipped element to ~52px and never let the
   row fold to 0. The wrapper has no padding, so 0fr collapses to true 0. */
.expClip > .expInner { overflow: hidden; min-height: 0; }
#expander .arrow { opacity: 0; transition: opacity .22s ease; }
#expander.open .arrow { opacity: 1; }
#expander .expBody {
  display: flex;
  gap: 30px;
  padding: 26px 30px;
  position: relative;
}
#expander .arrow {
  position: absolute;
  top: -9px;
  width: 18px; height: 18px;
  transform: rotate(45deg);
  background: inherit;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.06);
}
#expander .bigart {
  width: 300px; height: 300px;
  flex: none;

  object-fit: cover;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  background: rgba(0,0,0,.25);
}
#expander .info { flex: 1; min-width: 0; }
#expander h2 { margin: 0 0 2px; font-size: 24px; font-weight: 700; }
#expander .sub { font-size: 15px; margin-bottom: 4px; }
#expander .meta { font-size: 12px; opacity: .75; margin-bottom: 16px; }
#expander .tracks {
  columns: 2;
  column-gap: 38px;
}
@media (max-width: 1100px) { #expander .tracks { columns: 1; } }
:is(#expander, #avTracks, #arvAlbums) .trk {
  display: flex;
  gap: 10px;
  padding: 4px 6px;

  break-inside: avoid;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
:is(#expander, #avTracks, #arvAlbums) .trk:hover { background: rgba(255,255,255,.08); }
:is(#expander, #avTracks, #arvAlbums) .trk.sel {
  background: rgba(255,255,255,.16);
  box-shadow: inset 3px 0 0 currentColor;
}
:is(#expander, #avTracks, #arvAlbums) .trk.playing { font-weight: 700; }
/* A song opened via a #song/ deep link gets a brief accent-outline flash for
   the eye to land on, then it's left in the persistent .sel state (added in JS).
   The flash animates `outline` only, so it never fights .sel's background/bar. */
:is(#expander, #avTracks, #arvAlbums) .trk.hl { animation: trkHl 1.6s ease; }
@keyframes trkHl {
  0%, 25% { outline: 2px solid var(--accent); outline-offset: -2px; }
  100% { outline: 2px solid transparent; outline-offset: -2px; }
}
:is(#expander, #avTracks, #arvAlbums) .trk .no { width: 20px; text-align: right; opacity: .6; flex: none; }
/* Now playing: speaker glyph replaces the track number (theme-colored via mask).
   The cell becomes a flex box so the icon centers exactly where digits sat. */
:is(#expander, #avTracks, #arvAlbums) .trk.playing .no {
  opacity: 1;
  font-size: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  align-self: center;
}
:is(#expander, #avTracks, #arvAlbums) .trk.playing .no::before {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 9v6h4l6 5V4L7 9H3z"/><path d="M16 8.5a5 5 0 0 1 0 7" fill="none" stroke="black" stroke-width="2.4"/><path d="M18.5 5.5a9 9 0 0 1 0 13" fill="none" stroke="black" stroke-width="2.4"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 9v6h4l6 5V4L7 9H3z"/><path d="M16 8.5a5 5 0 0 1 0 7" fill="none" stroke="black" stroke-width="2.4"/><path d="M18.5 5.5a9 9 0 0 1 0 13" fill="none" stroke="black" stroke-width="2.4"/></svg>') no-repeat center / contain;
}
:is(#expander, #avTracks, #arvAlbums) .trk.playing.paused .no::before { opacity: .5; }
:is(#expander, #avTracks, #arvAlbums) .trk .nm {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden;
  /* truncated titles fade at the right edge, and marquee on hover / when selected */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 14px), #0000);
  mask-image: linear-gradient(to right, #000 calc(100% - 14px), #0000);
}
:is(#expander, #avTracks, #arvAlbums) .trk .nm .mq { display: inline-block; white-space: nowrap; }
:is(#expander, #avTracks, #arvAlbums) .trk .nm .mq.scrolling { animation: mq linear infinite alternate; }
:is(#expander, #avTracks, #arvAlbums) .trk .nm:has(.mq.scrolling) { -webkit-mask-image: none; mask-image: none; }
:is(#expander, #avTracks, #arvAlbums) .trk .trkBy {
  opacity: .6; flex: none; max-width: 36%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
:is(#expander, #avTracks, #arvAlbums) .trk .trkBy:empty { display: none; }
:is(#expander, #avTracks, #arvAlbums) .trk .du { opacity: .6; flex: none; font-variant-numeric: tabular-nums; }
#expander .discHead {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  opacity: .6; padding: 10px 6px 2px; break-inside: avoid;
}

/* ---- player bar ---- */
footer {
  display: flex;
  align-items: center;
  gap: 12px;
  /* bottom inset clears the home indicator when installed */
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(43, 45, 49, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 55; /* stays above the album view */
}
#npArt { width: 42px; height: 42px; object-fit: cover; }
#npMeta[hidden] { display: none; /* author display overrides UA [hidden] */ }
#npMeta {
  /* Flexible, not fixed: shrinks toward the title width (text truncates with the
     right-edge fade) as space runs out, and is hidden entirely at a breakpoint. */
  flex: 0 1 auto; min-width: 0; max-width: 240px;
  padding: 2px 8px;
  margin-left: -8px;
  transition: background .15s ease;
}
#npMeta:hover {
  background: rgba(28, 29, 33, .96); /* solid-ish so scrolling text clears neighbours; no backdrop-filter (it can stall the child marquee in some browsers) */
}
/* While a caption is actively marquee-scrolling, drop the right-edge fade so the
   moving text is fully visible (the fade is only a hint at rest). */
.tile .t1:has(.mq.scrolling), .tile .t2a:has(.mq.scrolling),
#npTitle:has(.mq.scrolling), #npSub:has(.mq.scrolling) {
  -webkit-mask-image: none; mask-image: none;
}
#npTitle { font-weight: 600; white-space: nowrap; overflow: hidden; }
#npSub {
  color: var(--text-dim); font-size: 12px;
  white-space: nowrap; overflow: hidden;
}
#npMeta .mq { display: inline-flex; gap: 10px; white-space: nowrap; }
#npMeta .mq.scrolling { animation: mq linear infinite alternate; }
@keyframes mq {
  0%, 12% { transform: translateX(0); }
  88%, 100% { transform: translateX(var(--mqd, 0)); }
}
#npSub .npAlbum { opacity: .7; }
#npControls { display: flex; gap: 4px; }
#npControls button {
  background: transparent; border: none; color: var(--text);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
}
#npControls button:hover { background: var(--bg-hover); }
#npBar {
  flex: 1 1 auto; min-width: 170px; height: 2px;
  /* sunken into the frosted pane: dark channel with an inner shadow */
  background: rgba(0, 0, 0, .32);
  border-radius: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5), inset 0 -1px 0 rgba(255, 255, 255, .04);
  cursor: pointer;
  position: relative;
  touch-action: none;
}
#npProgress {
  height: 100%; width: 0;
  background: rgba(255, 255, 255, .9);
  border-radius: 3px;
  /* subtle glow trailing the progress */
  box-shadow: 0 0 6px rgba(255, 255, 255, .35);
}
/* small round anchor, centered on the position via transform (size-independent) */
#npThumb {
  position: absolute;
  top: 50%; left: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .2), 0 1px 3px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.55);
  transition: opacity .14s ease, transform .14s ease;
}
#npBar:hover #npThumb, #npBar.dragging #npThumb { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#npTime {
  color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex: none; margin-left: -6px; /* tighter gap to the seek bar */
}

/* Responsive transport bar: the seek bar (#npBar) and controls (#npControls)
   always keep their space; the time collapses first, then the title/album box
   (leaving just the art). Volume is already a popup icon. */
@media (max-width: 720px) { #npTime { display: none; } }
@media (max-width: 520px) { #npMeta { display: none; } }

.empty {
  grid-column: 1 / -1;
  color: var(--text-dim);
  text-align: center;
  padding: 80px 0;
}

/* ---- expander actions ---- */
/* Album actions: a single hamburger floated into the expander's top-right
   dead space, costing no vertical room. */
#expander .actions {
  position: absolute;
  top: 14px;
  right: 16px;
  margin: 0;
}
.menuWrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  left: auto;
  top: calc(100% + 4px);
  background: rgba(43, 45, 49, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  min-width: 150px;
  z-index: 30;
}
.menu[hidden] { display: none; }
.menu button, .menu a {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--bg-hover); }
.act {
  background: rgba(255,255,255,.1);
  color: inherit;
  border: 1px solid rgba(255,255,255,.18);

  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
}
.act:hover { background: rgba(255,255,255,.18); }
a.srcLink { text-decoration: none; display: inline-block; }

/* ---- volume ---- */
#volWrap { flex: none; } /* .menuWrap gives position:relative */
#volBtn {
  background: transparent; border: none; color: var(--text);
  font-size: 18px; cursor: pointer; padding: 4px 8px; /* match #npControls button so .ic's vertical-align lines up */
}
#volBtn:hover { background: var(--bg-hover); }
#volBtn .ic { width: 18px; height: 18px; }
#volPop {
  top: auto; bottom: calc(100% + 8px);
  left: 50%; right: auto; transform: translateX(-50%); /* centered over the icon */
  flex-direction: row; align-items: center; gap: 8px;
  min-width: 0; padding: 10px 12px; z-index: 60;
}
#vol {
  -webkit-appearance: none;
  appearance: none;
  width: 150px;
  height: 4px;

  background: var(--bg); /* filled portion painted via JS gradient */
  outline: none;
  cursor: pointer;
}
#vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 5px;
  height: 14px;

  background: var(--text-dim);
  border: none;
}
#vol::-webkit-slider-thumb:hover { background: var(--text); }
#vol::-moz-range-thumb {
  width: 5px;
  height: 14px;

  background: var(--text-dim);
  border: none;
}
#vol::-moz-range-thumb:hover { background: var(--text); }
#volPct {
  color: var(--text-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  width: 32px;
}

/* ---- modal ---- */
#modal[hidden] { display: none; }
#modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px;
  /* Above every overlay (album/artist 50, npView 60, crumbs 70, drawer 91) so
     modals opened from a nested view aren't hidden behind it; below login. */
  z-index: 97;
}
#modalBox {
  background: var(--bg-raised);
  border: 1px solid var(--border);

  width: min(880px, 100%);
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
}
.mhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.mhead h3 { margin: 0; font-size: 15px; }
.mhSub { color: var(--text-dim); font-weight: 400; margin-left: 10px; }
.mbody h4[title] { cursor: help; }
.anTable th[title] { cursor: help; }
.mhead button {
  background: none; border: none; color: var(--text-dim);
  font-size: 15px; cursor: pointer;
}
.mbody { padding: 14px 18px 18px; overflow-y: auto; overflow-x: hidden; }
.mbody h4 { margin: 14px 0 8px; font-size: 13px; }
.hint { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.warn { color: #e0af68; font-size: 12px; }
.mfoot {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  margin-top: 16px;
}
#mStatus { color: var(--text-dim); font-size: 12px; }
button.primary {
  background: var(--accent);
  color: #15161a;
  border: none;
  padding: 7px 18px;
  font-weight: 600;
  cursor: pointer;
}
button.primary:disabled { opacity: .4; cursor: default; }

.tagTable, .trkTable { width: 100%; border-collapse: collapse; }
.tagTable td, .trkTable td, .trkTable th { padding: 2px 4px; }
.trkTable th {
  text-align: left; font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
}
.tagTable input, .trkTable input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);

  color: var(--text);
  padding: 4px 8px;
}
.tagTable input:focus, .trkTable input:focus { border-color: var(--accent); outline: none; }
.tagTable .tk { font-family: ui-monospace, monospace; text-transform: uppercase; }
.tagTable td:first-child { width: 230px; }
.tagTable td:last-child { width: 30px; }
.tagTable .rm {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
}
.tagTable .rm:hover { color: #f7768e; }
.trkTable .tno { width: 30px; color: var(--text-dim); text-align: right; }
.trkTable .tfile {
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-dim); font-size: 11px;
}
#addTag { margin-top: 6px; }

/* ---- art finder ---- */
.artSearch { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.artSearch input { flex: 1; min-width: 0; }
.artGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  color: var(--text-dim);
}
.artCard { cursor: pointer; }
.artCard img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
 background: var(--bg);
}
.artCard.noimg img { visibility: hidden; }
.artCard.noimg::before { content: "no image"; position: absolute; font-size: 11px; padding: 8px; }
.artCard.busy { opacity: .5; pointer-events: none; }
.artCard:hover img { outline: 2px solid var(--accent); }
.artCard .ac1 {
  font-size: 12px; color: var(--text); font-weight: 600; margin-top: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.artCard .ac2 { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- album view ---- */
#albumView {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  padding: 44px 7vw 130px; /* bottom clears the transport bar */
}
#avBg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none; /* never intercept scroll/clicks */
}
#avBg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(70px) saturate(1.1) brightness(.5);
  transform: scale(1.2);
  opacity: .55;
}
#avBg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(35,36,40,.25), var(--bg) 85%);
}
#avBg img:not([src]) { display: none; }
#albumView[hidden] { display: none; }
html:has(#albumView:not([hidden])) { overflow: hidden; }
#avClose {
  position: absolute;
  top: 50px; right: 20px; /* clear of the self-hiding breadcrumb strip above */
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 11px;
  cursor: pointer;
}
#avClose:hover { color: var(--text); }
#avHead { display: flex; gap: 34px; align-items: flex-end; margin-bottom: 26px; }
#avArt {
  width: min(30vh, 280px);
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-raised);
  box-shadow: 0 14px 40px rgba(0,0,0,.55);
  flex: none;
}
#avInfo { min-width: 0; }
#avTitle { margin: 0 0 4px; font-size: 30px; font-weight: 700; }
#avArtist { font-size: 16px; color: var(--text-dim); cursor: pointer; width: fit-content; }
#avArtist:hover { color: var(--text); }
#avArt:not([src]) { visibility: hidden; }
#expander h2, #expander .sub { cursor: pointer; width: fit-content; }
#expander h2:hover, #expander .sub:hover { text-decoration: underline; }
.tile .t2a { cursor: pointer; }
.tile .t2a:hover { color: var(--text); }
#avMeta { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
#avActions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
#avActions .menu { left: 0; right: auto; }
#avIdentify { max-width: 420px; }
#avTracks {
  column-width: 360px; /* as many full-width columns as fit */
  column-gap: 44px;
}

/* ---- tracks view (flat, column-configurable detailed list) ---- */
/* Author display rules beat the UA [hidden], so toggled elements need these. */
#grid[hidden], #rail[hidden], #tracksView[hidden], .menuWrap[hidden],
#trkShuffle[hidden], #trkCount[hidden] { display: none; }

/* Header-integrated controls (shown only in the tracks view). */
#trkShuffle {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); padding: 5px 10px; font-size: 12px; cursor: pointer;
}
#trkShuffle:hover { color: var(--text); border-color: var(--accent); }
#trkShuffle .ic { width: 15px; height: 15px; }
#trkCount { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

/* The list runs full-screen and the page scrolls, so rows pass behind the
   translucent header and footer exactly like the albums grid. The column headers
   stick just under the header and share its frosted look. */
#tracksView { display: block; padding: 0 0 var(--footerH, 60px); }
#trkScroll { width: 100%; }

#trkTable { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
#trkTable th, #trkTable td {
  padding: 3px 9px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-right: 1px solid rgba(255,255,255,.06); /* vertical separators */
}
#trkTable th.num, #trkTable td.num { text-align: right; }
/* The top bar hides on scroll-down by design, so the column legend sticks to
   the true top (top:0) and takes its place — no gap. At rest it sits just under
   the bar; the bar fades out as it slides, so no z-index fight. */
#trkTable thead th {
  position: sticky; top: 0; z-index: 7;
  background: rgba(43, 45, 49, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--text-dim); font-weight: 600;
  padding: 5px 9px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border);
}
#trkTable thead th:hover { color: var(--text); }
#trkTable thead th .thL { display: block; overflow: hidden; text-overflow: ellipsis; }
#trkTable th .sCar { position: absolute; right: 11px; top: 5px; font-size: 8px; opacity: .85; }
/* draggable resize zone over each header's right edge */
.rzH { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; }
.rzH:hover { background: var(--accent); opacity: .55; }

/* zebra; hover / selection / playing are declared after so they win */
#trkBody tr:nth-child(odd) { background: rgba(255,255,255,.022); }
#trkBody tr:hover { background: rgba(255,255,255,.07); }
#trkBody tr.sel { background: rgba(255,255,255,.15); }
#trkBody tr.playing td { color: var(--accent); font-weight: 600; }

.trkAddCol { width: 38px; text-align: center; padding: 0 !important; border-right: none; }
.trkFill { border-right: none; }
.trkAdd {
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; padding: 2px; border-radius: 4px;
  opacity: 0; display: inline-flex; align-items: center; vertical-align: middle;
}
#trkBody tr:hover .trkAdd, .trkAdd:focus-visible { opacity: 1; }
.trkAdd:hover { color: var(--accent); background: rgba(255,255,255,.12); }
.trkAdd .ic { width: 15px; height: 15px; }
#trkColsMenu { position: fixed; right: auto; min-width: 160px; max-height: 70vh; overflow-y: auto; }

/* ---- toast + buffer health ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  z-index: 70;
  background: rgba(35, 36, 40, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 18px;
  font-size: 13px;
}
#toast[hidden] { display: none; }
#bufHealth {
  color: var(--text-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  width: 62px;
}
#bufHealth.bufLow { color: #e0af68; }

/* ---- breadcrumbs ---- */
#crumbs {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 34px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px;
  background: rgba(24, 25, 28, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  /* collapsed to a sliver unless hovered or freshly navigated */
  transform: translateY(calc(-100% + 7px));
  opacity: .55;
  transition: transform .22s ease, opacity .22s ease;
}
#crumbs:hover, #crumbs.peek { transform: none; opacity: 1; }
#crumbs[hidden] { display: none; }
/* Invisible hover catch below the collapsed sliver. Kept modest so it doesn't
   reach the album/artist close button that sits just below the strip. */
#crumbs::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 12px;
}
.crSeg {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  white-space: nowrap;
}
.crSeg:hover { color: var(--text); }
.crCur {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
.crSep .ic { width: 11px; height: 11px; color: var(--text-dim); vertical-align: -1px; }
.crQueue {
  margin-left: auto;
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 2px 4px; display: inline-flex; align-items: center;
}
.crQueue:hover { color: var(--text); }
.crQueue .ic { width: 15px; height: 15px; }

/* ---- artist view ---- */
#artistView {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  padding: 44px 7vw 130px;
}
#artistView[hidden] { display: none; }
html:has(#artistView:not([hidden])) { overflow: hidden; }
#arvBg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#arvBg img {
  width: 100%; height: 100%; object-fit: cover;
  filter: blur(80px) saturate(1.1) brightness(.4);
  transform: scale(1.25);
  opacity: .5;
}
#arvBg::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(rgba(35,36,40,.3), var(--bg) 80%);
}
#arvBg img:not([src]) { display: none; }
#arvClose {
  position: absolute;
  top: 50px; right: 20px; /* clear of the self-hiding breadcrumb strip above */
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 11px;
  cursor: pointer;
}
#arvClose:hover { color: var(--text); }
#arvName { margin: 0; font-size: 34px; font-weight: 700; }
#arvMeta { color: var(--text-dim); font-size: 13px; margin: 6px 0 30px; }
.arvAlbum {
  display: flex;
  gap: 26px;
  margin-bottom: 38px;
}
.arvArt {
  width: 170px; height: 170px;
  flex: none;
  object-fit: cover;
  background: var(--bg-raised);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  cursor: pointer;
}
.arvRight { flex: 1; min-width: 0; }
.arvTitleRow { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.arvTitle { margin: 0; font-size: 18px; font-weight: 700; cursor: pointer; }
.arvTitle:hover { text-decoration: underline; }
.arvYear { color: var(--text-dim); font-size: 13px; }
.arvPlay { padding: 3px 10px; }
.arvTracks { column-width: 320px; column-gap: 40px; }

/* ---- now playing view ---- */
#npView {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
}
#npView[hidden] { display: none; }
#visCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#npvTop {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 44px 18px 14px; /* top clears the breadcrumb hover zone */
  background: linear-gradient(rgba(0,0,0,.55), transparent);
}
#npvArt { width: 64px; height: 64px; object-fit: cover; background: #111; }
#npvMeta { min-width: 0; }
#npvTitle { font-weight: 700; font-size: 16px; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
#npvSub {
  display: flex; gap: 10px;
  color: #cfd2d8; font-size: 13px;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
#npvSub .npAlbum { opacity: .7; }
/* The static display already shows art + title/artist big and centered, so the
   top-left mini-meta is redundant there; the tools stay. */
#npView.static #npvArt, #npView.static #npvMeta { display: none; }
.lnk { cursor: pointer; }
.lnk:hover { text-decoration: underline; }
#npvTools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#visSel {
  background: rgba(35,36,40,.7);
  backdrop-filter: blur(10px);
}
#visParamsBtn, #npvClose, #lyrBtn, #queueBtn, #fsBtn {
  background: rgba(35,36,40,.7);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
}
#visParams {
  position: absolute;
  top: 134px; left: 18px;       /* below the top bar; left of the lyrics */
  width: 300px;
  max-height: calc(100% - 200px);
  overflow-y: auto;
  scrollbar-width: thin;
  z-index: 3;
  background: rgba(35,36,40,.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#visParams[hidden] { display: none; }
.vpRow { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.vpSel { flex: 1; }
.vpName { width: 90px; flex: none; }
.vpRow input { flex: 1; accent-color: var(--accent); }
.vpVal { width: 48px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); }
#npvBottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
}
#npvBottom button {
  background: none; border: none; color: #fff;
  font-size: 20px; cursor: pointer; padding: 4px 8px;
}
/* modernized to match the transport bar: thin white slider, round thumb */
#npvVol {
  -webkit-appearance: none; appearance: none;
  width: 110px; height: 3px; border-radius: 3px;
  background: rgba(255,255,255,.22); outline: none; cursor: pointer;
}
#npvVol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
#npvVol::-moz-range-thumb {
  width: 12px; height: 12px; border: none; border-radius: 50%; background: #fff;
}
#npvBar {
  flex: 1; height: 2px;
  background: rgba(255,255,255,.18);
  border-radius: 3px;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.4);
  cursor: pointer;
  position: relative;
  touch-action: none;
}
#npvProgress {
  height: 100%; width: 0;
  background: rgba(255,255,255,.92);
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(255,255,255,.4);
}
#npvThumb {
  position: absolute; top: 50%; left: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,.22), 0 1px 3px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -50%) scale(.55);
  transition: opacity .14s ease, transform .14s ease;
}
#npvBar:hover #npvThumb, #npvBar.dragging #npvThumb { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#npvTime { color: #cfd2d8; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#npArt { cursor: pointer; }
#visErr {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 70%;
  color: #f7768e;
  background: rgba(20,20,22,.85);
  border: 1px solid #f7768e;
  padding: 14px 18px;
  font: 12px ui-monospace, monospace;
  white-space: pre-wrap;
}
#visErr[hidden] { display: none; }
#lyrBtn.on, #queueBtn.on { color: var(--accent); border-color: var(--accent); }

/* queue: a right-side slide-out drawer over a dimmed scrim */
/* ---- left nav drawer (mobile menu) ---- */
#navBtn { background: transparent; border: none; color: var(--text); cursor: pointer; padding: 4px 8px; display: none; }
#navBtn .ic { width: 22px; height: 22px; }
#navScrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  z-index: 90;
}
#navScrim[hidden] { display: none; }
#navDrawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(300px, 86vw);
  background: rgba(20, 21, 24, .96);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
  box-shadow: 14px 0 36px rgba(0,0,0,.5);
  z-index: 91;
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .24s ease;
  overflow: hidden;
}
#navDrawer.open { transform: none; }
#navHead {
  display: flex; align-items: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
#navBody { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
#navTitle { font-size: 15px; font-weight: 700; }
#navClose { margin-left: auto; background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 4px; display: inline-flex; }
#navClose:hover { color: var(--text); }
#navBody { overflow-y: auto; flex: 1; padding: 6px 0 20px; }
.navSec { padding: 6px 0; border-top: 1px solid rgba(255,255,255,.06); }
.navSec:first-child { border-top: none; }
.navSecT { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); padding: 8px 18px 4px; }
.navItem {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; color: var(--text);
  padding: 11px 18px; font-size: 14px; text-align: left; cursor: pointer;
}
.navItem:hover, .navItem:focus-visible { background: var(--bg-hover); }
.navItem.on { color: var(--accent); }
.navItem.on .ic { color: var(--accent); }
.navItem .ic { width: 18px; height: 18px; flex: none; color: var(--text-dim); }
.navItem .navN { margin-left: auto; color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.navItem .ck { margin-left: auto; }
.navSub { padding-left: 18px; }
.navSub .navItem { padding-left: 44px; font-size: 13px; }

#queueScrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 90;
}
#queueScrim[hidden] { display: none; }
#queueDrawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(360px, 90vw);
  background: rgba(20, 21, 24, .93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-left: 1px solid var(--border);
  box-shadow: -14px 0 36px rgba(0,0,0,.5);
  z-index: 91;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .24s ease;
}
#queueDrawer.open { transform: none; }
.queueTgl.on { color: var(--accent); }
#queueHead {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  color: var(--text-dim);
  font-size: 12px;
}
#queueTitle { font-size: 13px; font-weight: 650; color: var(--text); }
#queueCount { margin-left: auto; }
#queueDrawerClose {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 2px; display: inline-flex;
}
#queueDrawerClose:hover { color: var(--text); }
#queueList { overflow-y: auto; scrollbar-width: none; padding: 4px 0; }
#queueList::-webkit-scrollbar { display: none; }
.qRow {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  color: #d6d8dc;
  user-select: none; -webkit-user-select: none;
}
.qRow:hover { background: rgba(255,255,255,.08); }
.qRow.past { opacity: .5; }
.qRow.cur { color: #fff; font-weight: 650; }
.qRow .qNo {
  width: 20px; flex: none; text-align: right;
  color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums;
}
.qRow.cur .qNo { color: var(--accent); }
.qNo .ic { width: 12px; height: 12px; }
.qT { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.qTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.qSub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--text-dim); }
.qRm {
  flex: none; background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 0 2px; opacity: 0;
  font-size: 17px; line-height: 1;
}
.qRow:hover .qRm { opacity: 1; }
.qRm:hover { color: #f7768e; }
/* grip dots drawn in CSS (no per-row SVG) */
.qGrip {
  flex: none; width: 10px; height: 16px;
  color: var(--text-dim); cursor: grab;
  opacity: .4; margin-left: -2px; touch-action: none;
  background-image: radial-gradient(currentColor 1.1px, transparent 1.3px);
  background-size: 4px 4px; background-position: center;
}
.qRow:hover .qGrip { opacity: .8; }
.qGrip .ic { width: 14px; height: 14px; }
/* the grabbed row becomes an invisible gap; its clone floats under the pointer */
.qRow.qGhost { visibility: hidden; }
.qFloat {
  position: fixed; z-index: 95; margin: 0;
  background: rgba(34, 36, 41, .98);
  box-shadow: 0 12px 30px rgba(0,0,0,.6);
  cursor: grabbing;
  pointer-events: none;
}
.qFloat .qGrip { opacity: .8; }

/* variants manager */
#variantsView {
  position: fixed; inset: 0; z-index: 52; /* below the transport bar (55) */
  background: var(--bg);
  overflow-y: auto;
  padding: 40px 6vw 120px;
}
#variantsView[hidden] { display: none; }
#variantsView > h2 { margin: 0 0 4px; font-size: 26px; font-weight: 700; }
#varSub { color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }
#varClose {
  position: absolute; top: 24px; right: 24px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); padding: 5px 11px; cursor: pointer;
}
#varClose:hover { color: var(--text); }
.varGroup {
  border: 1px solid var(--border); background: var(--bg-raised);
  margin-bottom: 20px; padding: 16px 18px;
}
.varGroup.confirmed { border-color: var(--accent); }
.varHead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.varTitle { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.varArtist { font-weight: 700; font-size: 16px; }
.varAlbum { color: var(--text-dim); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.varTag { margin-left: auto; font-size: 11px; padding: 2px 8px; border: 1px solid var(--border); white-space: nowrap; }
.varTag.ok { color: var(--accent); border-color: var(--accent); }
.varTag.cand { color: var(--text-dim); }
.varTableWrap { overflow-x: auto; }
.varTable { width: 100%; border-collapse: collapse; font-size: 13px; }
.varTable th {
  text-align: left; font-weight: 500; color: var(--text-dim); font-size: 11px;
  padding: 4px 12px 6px 0; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.varTable td {
  padding: 8px 12px 8px 0; border-bottom: 1px solid rgba(255,255,255,.05);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.varTable tr.prim td { background: rgba(122,162,247,.08); }
.varTable td.hi { color: var(--accent); font-weight: 600; }
.varSel { display: flex; gap: 6px; align-items: center; }
.varPrim, .varInc { cursor: pointer; accent-color: var(--accent); }
.varAct .act { padding: 3px 7px; margin-left: 4px; }
.varFoot { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.varFoot .hint { color: var(--text-dim); font-size: 12px; }
.varFoot .primary {
  margin-left: auto;
  background: var(--accent); color: #0b0d12; border: 1px solid var(--accent);
  padding: 6px 16px; cursor: pointer; font-size: 13px; font-weight: 650;
}
.varFoot .danger { color: #f7768e; border-color: #f7768e; margin-left: auto; }

/* login overlay */
#loginView {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10, 11, 13, .72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#loginView[hidden] { display: none; }
#loginForm {
  width: min(340px, 100%);
  display: flex; flex-direction: column; gap: 12px;
  padding: 30px 28px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
#loginForm h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: .5px; }
#loginSub { margin: 0 0 6px; color: var(--text-dim); font-size: 13px; }
#loginForm input {
  padding: 11px 12px; font-size: 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
}
#loginForm input:focus { outline: none; border-color: var(--accent); }
#loginErr { color: #f7768e; font-size: 12px; }
#loginErr[hidden] { display: none; }
#loginActions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
#loginSubmit {
  background: var(--accent); color: #0b0d12;
  border: 1px solid var(--accent);
  padding: 8px 18px; cursor: pointer; font-size: 13px; font-weight: 650;
}
#loginSubmit:disabled { opacity: .6; cursor: default; }

/* change-password form (inside a modal) */
.pwForm { display: flex; flex-direction: column; gap: 12px; }
.pwForm input {
  padding: 11px 12px; font-size: 14px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.pwForm input:focus { outline: none; border-color: var(--accent); }
.loginErr { color: #f7768e; font-size: 12px; }
.loginErr[hidden] { display: none; }
.pwActions { display: flex; justify-content: flex-end; margin-top: 4px; }
#pwSubmit {
  background: var(--accent); color: #0b0d12; border: 1px solid var(--accent);
  padding: 8px 18px; cursor: pointer; font-size: 13px; font-weight: 650;
}
#pwSubmit:disabled { opacity: .6; cursor: default; }

/* right-click context menu */
#ctxMenu {
  position: fixed;
  right: auto; /* JS sets left/top; without this the inherited right:0 spans the row */
  min-width: 150px;
  z-index: 80;
}
.modeBtn { font-size: 14px !important; width: 40px; }
.modeBtn.on { color: var(--accent) !important; }

/* lyrics panel: blurred card over the visualization */
#lyrPanel {
  position: absolute;
  top: 134px; right: 18px; bottom: 116px;
  width: min(430px, 85vw);
  background: rgba(18, 19, 22, .55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.12);
  overflow-y: auto;
  padding: 18px 22px;
  scrollbar-width: none; /* scrolls, but shows no bar */
}
#lyrPanel::-webkit-scrollbar { display: none; }
#lyrPanel[hidden] { display: none; }
/* When both panels are open, the most recently opened one tucks in just left
   of the other (adjacent, not jammed to the screen edge); arrangeSidePanels()
   sets its `right` inline from the other panel's measured width. */

/* The page scrollbar has no business showing under the fullscreen view. */
html:has(#npView:not([hidden])) { overflow: hidden; }
.lyrLine {
  color: rgba(255,255,255,.42);
  font-size: 16px;
  line-height: 1.65;
  transition: color .25s ease, transform .25s ease;
}
.lyrLine.on {
  color: #fff;
  font-weight: 650;
  transform: scale(1.04);
  transform-origin: left center;
}
.lyrPlain { white-space: pre-wrap; color: #d6d8dc; font-size: 14px; line-height: 1.6; }

/* static "visualization": art + metadata + lyrics over the palette */
#npView.static #visCanvas { display: none; }
#npView.static {
  background: radial-gradient(70% 90% at 32% 42%, var(--stBg, #17181b), #000 92%);
}
#staticView {
  position: absolute;
  inset: 90px 0 96px 0;
  display: flex;
  align-items: center;
  padding: 0 7vw;
}
#staticView[hidden] { display: none; }
#stBlock { max-width: 42vw; }
#stArt {
  width: min(46vh, 420px);
  aspect-ratio: 1;
  object-fit: cover;
  background: #111;
  box-shadow: 0 26px 70px rgba(0,0,0,.65);
}
#stTitle { font-size: 28px; font-weight: 700; margin-top: 24px; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
#stSub { display: flex; gap: 12px; flex-wrap: wrap; font-size: 15px; color: #cfd2d8; margin-top: 6px; }
#stSub .npAlbum { opacity: .7; }
#stFmt { font-size: 12px; color: #8b8e94; margin-top: 10px; }
#npView.static #lyrPanel {
  bottom: 116px; right: 18px;
  width: min(40vw, 560px);
  background: rgba(14, 15, 17, .45);
}

/* ---- analysis ---- */
.anRun { flex-direction: row !important; align-items: center; gap: 12px !important; flex-wrap: wrap; margin-bottom: 10px; }
.anAlbumRow { font-weight: 700; border-bottom: 1px solid var(--border); }
#anCompare { margin-left: auto; max-width: 320px; }
.anTable td { font-variant-numeric: tabular-nums; font-size: 12px; }
.anTable .anT { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anConf { color: var(--text-dim); font-size: 10px; }

/* ---- library export ---- */
#exportBox {
  width: 100%;
  height: 50vh;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px;
  font: 11px ui-monospace, monospace;
  resize: vertical;
  white-space: pre;
}
#exportBox:focus { outline: none; border-color: var(--accent); }

/* ---- history ---- */
.hTs { white-space: nowrap; color: var(--text-dim); font-size: 11px; }
.hOp { color: var(--text-dim); font-size: 11px; }
.hFile { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.hKeys { font-family: ui-monospace, monospace; font-size: 11px; color: #e0af68; }
.hRevert { font-size: 11px; padding: 2px 8px; }

/* ---- metadata match ---- */
#settingsBtn {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 16px; cursor: pointer; padding: 2px 6px;
}
#settingsBtn:hover { color: var(--text); }
#mmCode { width: 130px; flex: none !important; }
#mmMatrix { width: 160px; flex: none !important; }
#mmAlbum, #mmArtist, #mmCode, #mmMatrix {
  flex: 1;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); padding: 6px 10px;
}
.mmResults { max-height: 260px; overflow-y: auto; margin-bottom: 14px; }
.mmRow {
  display: flex; gap: 10px; align-items: center;
  padding: 6px; cursor: pointer;
}
.mmRow:hover { background: var(--bg-hover); }
.mmRow img { width: 44px; height: 44px; object-fit: cover; background: var(--bg); flex: none; }
.mmMain { min-width: 0; }
.mmMain .ac1 { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mmMain .ac2 { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mmArtist { font-weight: 400; color: var(--text-dim); margin-left: 8px; }
.mmExtra {
  font-size: 11px; color: #73daca;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mmNote {
  font-weight: 400; font-size: 11px; color: #e0af68;
  margin-left: 6px;
}
.mmLink {
  margin-left: auto; flex: none;
  color: var(--text-dim); text-decoration: none;
  padding: 4px 8px; font-size: 14px;
}
.mmLink:hover { color: var(--accent); background: var(--bg); }
.dfTable td { vertical-align: top; font-size: 12px; }
.dfKey { font-family: ui-monospace, monospace; white-space: nowrap; }
.dfCur { color: var(--text-dim); max-width: 220px; }
.dfNew { color: #9ece6a; max-width: 220px; }
.dfNew.dfSame { color: var(--text-dim); }
.mmOpts { margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.mmTdiffs { max-height: 140px; overflow-y: auto; margin-top: 4px; }
.mmTd { font-size: 11px; color: var(--text-dim); padding: 1px 0 1px 16px; }
.mmTd b { color: var(--text); }
.mmTd span { color: var(--text); }

/* ===========================================================================
   RESPONSIVE / MOBILE  (desktop-first overrides, consolidated)
   ---------------------------------------------------------------------------
   Breakpoints (use these exact values everywhere for consistency):
     --bp-md: 900px   tablet and below
     --bp-sm: 680px   large phone — rail hidden, grid capped at 3, tighter gaps
     --bp-xs: 430px   phone — grid drops to 2 columns
   Principles:
     1. Density floor: the album grid never shows fewer than 2 covers per row;
        covers scale down instead of collapsing to one.
     2. Drawer-first: secondary controls/menus collapse into slide-out drawers
        (the queue drawer pattern) rather than crowding the top bar. [phase 2]
     3. Touch: primary tap targets ≥ 40px on phones. [phase 2]
     4. No horizontal overflow at any width.
   =========================================================================== */

/* Album/artist grid: keep 3 across on large phones, 2 on small — covers scale
   down within each band instead of ballooning to a single column. */
@media (max-width: 680px) {
  #rail { display: none; }                 /* desktop-only A–Z quick nav */
  main { padding: 14px; gap: 14px 12px; }  /* no rail gutter needed */
  #grid { grid-template-columns: repeat(3, 1fr); }

  /* Top bar collapses to [☰] [search] [queue]; everything else -> nav drawer. */
  #navBtn { display: inline-flex; align-items: center; }
  #tabs, #appMenuWrap, #scanStatus, #filterChip, #trkShuffle, #trkCount,
  .menuWrap:has(#sortBtn), .menuWrap:has(#filterBtn) { display: none; }
  header { gap: 8px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; }
  #navBtn, #queueBtnTop { padding: 8px; } /* comfier tap targets */

  /* Expanded album shelf: stack art over info so the cover isn't squished to a
     sliver by the fixed-width side-by-side layout. */
  #expander .expBody { flex-direction: column; gap: 14px; padding: 16px; }
  #expander .bigart { width: 100%; height: auto; aspect-ratio: 1; }
  #expander .info { min-width: 0; }
}
@media (max-width: 430px) {
  main { padding: 12px; gap: 12px 10px; }
  #grid { grid-template-columns: repeat(2, 1fr); }
}
