: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: 1.5; /* the one icon stroke weight, everywhere */
  stroke-linecap: round;
  stroke-linejoin: round;
}
#npControls .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 {
  /* Drop the platform's own control (WebKit otherwise keeps its rounded,
     glossy popup button under our colors) and draw a plain chevron. */
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  background: var(--bg) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%239a9da3" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>') no-repeat right 7px center / 12px;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 26px 5px 9px;
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }
select:disabled { opacity: .45; cursor: default; }
#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;
  color: var(--text-dim);
  padding: 6px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
#tabs button:hover { color: var(--text); }
/* the current tab is lifted off the bar: brighter text, a lighter face, a soft shadow */
#tabs button.on {
  color: #fff;
  font-weight: 650;
  background: #3a3c42;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .09);
  transform: translateY(-1px);
}

.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 .cdNum { font-variant-numeric: tabular-nums; }
#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; }
/* Now-playing shortcut: appears once something is loaded, sits left of the queue button */
#npBtnTop { margin-left: auto; }
#npBtnTop[hidden] { display: none; }
#npBtnTop:not([hidden]) + #queueBtnTop { margin-left: 0; }
#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 (dependable: 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" fill="none" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/></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" fill="none" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/></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);
  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);
  /* 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: 12px; height: 12px;
  border-radius: 50%; /* the one sanctioned round shape: the seek anchor is a dot */
  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.z { background: rgba(255,255,255,.022); }
/* spacer rows stand in for the tracks that aren't rendered (windowed list) */
#trkBody tr.trkPad, #trkBody tr.trkPad:hover {
  /* striped like real rows, so a flick that outruns rendering shows empty rows, not a void */
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.022) 0 var(--trkRowH, 23px), transparent var(--trkRowH, 23px) calc(var(--trkRowH, 23px) * 2));
}
#trkBody tr.trkPad td { padding: 0; border: none; height: inherit; }
#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;
  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); }
/* The plus is drawn in CSS: one sprite <use> per row (thousands) is slow to
   resolve and starves every other icon on the page in WebKit. */
.trkAdd { width: 19px; height: 19px; }
.trkAdd::before {
  content: ""; width: 13px; height: 13px; margin: auto;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat;
}
#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: 96; /* above the drawers: it may carry an Undo for something done in one */
  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; }
.toastAct {
  margin-left: 16px; padding: 3px 10px; cursor: pointer;
  background: transparent; color: var(--accent); border: 1px solid var(--accent); font-size: 12px; font-weight: 600;
}
.toastAct:hover { background: rgba(122, 162, 247, .15); }
#bufHealth {
  color: var(--text-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  width: 62px;
}
#bufHealth.bufLow { color: #e0af68; }
/* playback chain chip: names the output path; hover lays out the whole chain */
#chainWrap { position: relative; flex: none; display: flex; }
#chainChip {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); padding: 2px 7px;
  font-size: 10px; letter-spacing: .06em; white-space: nowrap; cursor: default;
  font-variant-numeric: tabular-nums;
}
#chainChip[hidden], #chainPop[hidden] { display: none; }
#chainChip.direct { color: var(--text); }
#chainChip.exact { color: #9ece6a; border-color: #5d7a45; }
#chainPop {
  position: absolute; right: 0; bottom: calc(100% + 12px); z-index: 60;
  /* one shared grid, so every stage's columns line up and size to their text:
     marker, number, stage, what it does, what comes out of it */
  display: grid; grid-template-columns: 3px auto auto auto auto; column-gap: 12px; row-gap: 0;
  padding-top: 10px; white-space: nowrap; font-size: 12px;
  background: rgba(28, 29, 33, .96);
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
}
.chStage { display: contents; }
.chStage > span { padding: 5px 0; align-self: baseline; }
.chMark { align-self: stretch !important; background: #5d7a45; } /* passes the samples through untouched */
.chStage.alters .chMark { background: #e0af68; }                 /* changes them */
.chN { color: var(--text-dim); font-size: 10px; text-align: right; font-variant-numeric: tabular-nums; }
.chK { color: var(--text-dim); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.chDoes { color: var(--text); padding-right: 14px !important; }
.chOut { color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; padding-right: 16px !important; }
.chStage.alters .chOut { color: #e0af68; }
.chVerdict { grid-column: 1 / -1; margin-top: 8px; padding: 9px 16px; border-top: 1px solid var(--border); color: #e0af68; }
.chVerdict.exact { color: #9ece6a; }
/* a closing line about the play itself (Last.fm): a full-width row on the
   popover's own columns, label under the stage names, text under what they do */
.chNote { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: baseline; margin-top: 8px; padding: 9px 0; border-top: 1px solid var(--border); }
.chVerdict + .chNote { margin-top: 0; }
.chNote .chK { grid-column: 3; }
.chNote > span:last-child { grid-column: 4 / -1; color: var(--text); padding-right: 16px; }
#volBtn:disabled { opacity: .35; cursor: default; }
#setOutFmt { margin-top: 8px; }
#setOutFmt[hidden] { display: none; }
@media (max-width: 680px) { #chainWrap { display: none; } }

/* ---- 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-color: rgba(35,36,40,.7);
  backdrop-filter: blur(10px);
}
#visParamsBtn, #npvClose, #lyrBtn, #npAddBtn, #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); }
/* Now Playing has no transport bar of its own: the real one floats over it
   (same controls, volume pop-out, chain chip, direct-output behaviour), with
   its frosted panel swapped for a fade into the visualization. */
body.npOpen footer {
  z-index: 65; /* above the view (60), below breadcrumbs and drawers */
  background: linear-gradient(transparent, rgba(0, 0, 0, .62));
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border-top: none; /* (a transparent border would show the gradient's repeat as a dark hairline) */
  background-repeat: no-repeat;
  padding-top: 26px;
}
body.npOpen #npArt, body.npOpen #npMeta { display: none; } /* shown at the top of the view */
body.npOpen #npBar { background: rgba(255, 255, 255, .18); }
body.npOpen #npTime, body.npOpen #chainChip:not(.exact) { color: #cfd2d8; }
#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: grab; /* the whole row can be picked up and moved */
  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, .qRow:hover .qAdd { opacity: 1; }
/* add this entry to a playlist (drawn as text, like the remove mark: no per-row SVG) */
.qAdd {
  flex: none; background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 0 4px; opacity: 0;
  font-size: 17px; line-height: 1;
}
.qAdd:hover, .qAdd:focus-visible { color: var(--accent); opacity: 1; }
span.qRm { visibility: hidden; padding: 0 2px; } /* the playing entry has no remove button */
.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; }

/* sign-in: the whole app sits behind it until there is a session */
#signinView {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: var(--bg);
}
#signinView[hidden] { display: none; }
#signinForm {
  width: min(360px, 100%);
  display: flex; flex-direction: column; gap: 10px;
  padding: 30px 28px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
#signinForm h2 { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.siL { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-top: 6px; }
#signinForm input, #signinForm select { padding: 11px 12px; font-size: 14px; }
#signinForm select { padding-right: 30px; }
#signinForm [hidden] { display: none; }
#siErr { color: #f7768e; font-size: 12px; }
#siActions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
#siSubmit {
  background: var(--accent); color: #0b0d12;
  border: 1px solid var(--accent);
  padding: 9px 20px; cursor: pointer; font-size: 13px; font-weight: 650;
}
#siSubmit:disabled { opacity: .6; cursor: default; }

/* accounts table (Settings, admin) */
.usrTable { border-collapse: collapse; width: 100%; }
.usrTable td { padding: 3px 8px 3px 0; }
.usrTable td:last-child { padding-right: 0; }
.usrN { font-weight: 600; white-space: nowrap; }
.usrTable input { width: 100%; min-width: 110px; }
.usrTable .act:disabled { opacity: .35; cursor: default; }
.usrNew td { padding-top: 12px; }
#appMenuDrop button[hidden] { display: none; }

/* 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 */
/* Lyrics float over the visualization with no box around them: a soft dark
   wash that fades out at the top, bottom and inner edge, so lines scroll in and
   out of view instead of being cut off. */
#lyrPanel {
  position: absolute;
  top: 110px; right: 0; bottom: 84px;
  width: min(470px, 88vw);
  background: linear-gradient(to right, rgba(8, 9, 11, 0), rgba(8, 9, 11, .5) 30%, rgba(8, 9, 11, .62));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 80%, transparent), linear-gradient(to right, transparent, #000 22%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 80%, transparent), linear-gradient(to right, transparent, #000 22%);
  mask-composite: intersect;
  overflow-y: auto;
  /* generous top/bottom room so the first and last lines can sit mid-panel */
  padding: 34vh 30px 34vh 110px;
  scrollbar-width: none; /* scrolls, but shows no bar */
}
/* nothing to show: a small note instead of an empty panel */
#lyrPanel.none {
  top: 118px; right: 18px; bottom: auto; width: auto;
  padding: 9px 14px;
  background: rgba(18, 19, 22, .6);
  -webkit-mask-image: none; mask-image: none;
}
#lyrPanel.none .hint { font-size: 12px; }
#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; }
/* three states: already sung (dim), now (bright), still to come (in between) */
.lyrLine {
  color: rgba(255, 255, 255, .62);
  font-size: 17px;
  line-height: 1.4;
  padding: 5px 0;
  cursor: pointer;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
  transition: color .25s ease, transform .25s ease, opacity .25s ease;
  transform-origin: left center;
}
.lyrLine.past { color: rgba(255, 255, 255, .28); }
.lyrLine:hover { color: rgba(255, 255, 255, .92); }
.lyrLine.on {
  color: #fff;
  font-weight: 650;
  transform: scale(1.05);
}
.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:not(.none) { width: min(44vw, 600px); }

/* ---- 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 ≥ 44px on phones; nothing depends on hover
        or right-click (tap plays, long-press opens the context sheet). [phase 3]
     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); }
}

/* Principle 4 backstop: a stray wide child must never scroll the page sideways
   (clip, not hidden, so the sticky header/footer keep working). */
html { overflow-x: clip; }
#fsBtn[hidden] { display: none; }

/* ---- touch input (any width): nothing may depend on hover ---- */
@media (hover: none) {
  body { -webkit-touch-callout: none; }
  .tile, .trk, #trkBody tr, .qRow, .ghead, .navItem, .arvAlbum { -webkit-user-select: none; user-select: none; }
  .tile img, .arvArt, #avArt { -webkit-user-drag: none; }
  .qRm, .qAdd, .trkAdd { opacity: 1; }
  .qGrip { opacity: .8; }
  /* seek bars: a finger-sized hit area around the thin track, anchor always shown */
  #npBar::before {
    content: ""; position: absolute; left: 0; right: 0; top: -16px; bottom: -16px;
  }
  #npThumb { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---- phone: per-view layout + 44px tap targets [phase 3] ---- */
@media (max-width: 680px) {
  /* iOS zooms the page when a focused field is under 16px */
  input, select, textarea { font-size: 16px !important; }
  .act { min-height: 40px; }

  /* top bar */
  #navBtn, #queueBtnTop, #npBtnTop {
    min-width: 44px; min-height: 44px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #queueBtnTop .ic, #npBtnTop .ic { width: 18px; height: 18px; }
  #search { height: 40px; padding-right: 42px; }
  #searchClear { width: 38px; height: 38px; right: 1px; }

  /* nav + queue drawers */
  .navItem { min-height: 46px; }
  #navClose, #queueDrawerClose {
    width: 44px; height: 44px; padding: 0; margin-right: -8px;
    align-items: center; justify-content: center;
  }
  #queueClear { min-height: 40px; }
  .qRow { min-height: 54px; padding: 4px 6px 4px 12px; }
  .qGrip { width: 26px; height: 44px; padding: 14px 8px; margin-left: -8px; background-clip: content-box; background-origin: content-box; }
  .qRm, .qAdd { width: 40px; height: 44px; font-size: 22px; }

  /* transport bar: seek line across the top edge, then art / title / controls */
  footer { flex-wrap: wrap; gap: 0 8px; padding: 0 10px calc(4px + env(safe-area-inset-bottom, 0px)); }
  #npBar {
    order: -1; flex: 0 0 calc(100% + 20px); min-width: 0;
    margin: 0 -10px 5px; height: 3px;
    border-radius: 0; box-shadow: none; background: rgba(255, 255, 255, .12);
  }
  #npProgress { border-radius: 0; }
  #npThumb { opacity: 0; }              /* a plain progress line until it's being dragged */
  #npBar.dragging #npThumb { opacity: 1; }
  #npTime, #volWrap, #bufHealth { display: none; }
  #npArt { width: 44px; height: 44px; }
  #npMeta { display: block; flex: 1 1 0; max-width: none; margin-left: 0; padding: 2px 4px; cursor: pointer; }
  #npControls { margin-left: auto; gap: 0; }
  #npControls button {
    min-width: 44px; min-height: 46px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #npControls .ic { width: 20px; height: 20px; }
  #toast { bottom: calc(var(--footerH, 60px) + 12px); max-width: 92vw; text-align: center; }

  /* track rows everywhere (shelf, album, artist) */
  :is(#expander, #avTracks, #arvAlbums) .trk {
    min-height: 44px; align-items: center; padding: 0 8px; font-size: 14px;
  }
  #expander .tracks { columns: 1; }
  #expander .meta, #avMeta { display: flex; flex-wrap: wrap; gap: 2px 11px; }
  #expander .meta .mPart + .mPart, #avMeta .mPart + .mPart { margin-left: 0; }
  #expander .actions { top: 22px; right: 22px; }
  #expander .actions .act {
    min-width: 44px; min-height: 44px; padding: 0;
    background: rgba(0, 0, 0, .5); color: #fff;
  }

  /* menus become bottom sheets above the transport bar. The ::before is a real
     (tappable) scrim, so dismissing never taps whatever is underneath. */
  #ctxMenu, #albumView .menu, #artistView .menu, #expander .menu {
    position: fixed; left: 0 !important; right: 0 !important; top: auto !important;
    bottom: var(--footerH, 60px);
    min-width: 0; padding: 6px 0;
    background: rgba(28, 29, 33, .97);
    border-width: 1px 0 0;
    box-shadow: none;
    z-index: 80;
  }
  :is(#ctxMenu, #albumView .menu, #artistView .menu, #expander .menu)::before {
    content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 100vh;
    background: rgba(0, 0, 0, .5);
  }
  :is(#ctxMenu, #albumView .menu, #artistView .menu, #expander .menu) :is(button, a) {
    display: flex; align-items: center; gap: 8px;
    min-height: 48px; padding: 0 20px; font-size: 15px;
  }

  /* breadcrumbs: no hover on a phone, so the strip is simply always there */
  #crumbs {
    transform: none; opacity: 1;
    height: calc(44px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 2px 0 8px; gap: 0;
  }
  #crumbs::after { display: none; }
  .crSeg, .crCur {
    padding: 0 5px; line-height: 44px; font-size: 13px;
    overflow: hidden; text-overflow: ellipsis;
  }
  .crSeg { flex: 0 1 auto; min-width: 2.5em; max-width: 32vw; }
  .crCur { flex: 0 1 auto; min-width: 0; }
  .crSep { flex: none; }
  .crQueue { flex: none; min-width: 44px; height: 44px; justify-content: center; }
  .crQueue .ic { width: 18px; height: 18px; }

  /* album + artist pages: stacked, single column */
  #albumView, #artistView {
    padding: calc(60px + env(safe-area-inset-top, 0px)) 14px calc(var(--footerH, 60px) + 36px);
  }
  #avClose, #arvClose {
    top: calc(52px + env(safe-area-inset-top, 0px)); right: 8px;
    width: 44px; height: 44px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(24, 25, 28, .55);
  }
  #avHead { flex-direction: column; align-items: stretch; gap: 18px; margin-bottom: 18px; }
  #avArt { width: min(62vw, 300px); align-self: center; }
  #avTitle { font-size: 22px; line-height: 1.25; overflow-wrap: break-word; }
  #avArtist { font-size: 15px; padding: 4px 0; }
  #avActions { flex-wrap: wrap; margin-top: 14px; }
  #avPlay { min-height: 44px; padding: 0 28px; font-size: 14px; }
  #avMenuBtn, #avRip { min-width: 44px; min-height: 44px; }
  #avIdentify { max-width: 100%; min-height: 44px; flex: 1 1 100%; }
  #avTracks { columns: 1; column-width: auto; }

  #arvName { font-size: 26px; line-height: 1.2; padding-right: 50px; overflow-wrap: break-word; }
  #arvMeta { margin-bottom: 22px; }
  .arvAlbum {
    display: grid; grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px 14px; align-items: center; margin-bottom: 30px;
  }
  .arvArt { width: 92px; height: 92px; }
  .arvRight { display: contents; }
  .arvTitleRow { flex-wrap: wrap; gap: 6px 10px; margin: 0; }
  .arvTitle { flex: 0 0 100%; font-size: 16px; overflow-wrap: break-word; }
  .arvYear { margin-right: auto; }
  .arvPlay, .arvMenuBtn { min-width: 48px; min-height: 44px; padding: 0; }
  .arvTracks { grid-column: 1 / -1; columns: 1; column-width: auto; }

  /* tracks: a two-line list instead of a wide table (rendered by JS) */
  #trkTable.phone thead { display: none; }
  #trkTable.phone td { border-right: none; height: 54px; padding: 0 0 0 14px; }
  #trkTable.phone td.trkDur {
    width: 52px; padding: 0 2px; color: var(--text-dim); font-variant-numeric: tabular-nums;
  }
  #trkTable.phone td.trkAddCol { width: 48px; padding: 0; }
  .trkM1, .trkM2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .trkM1 { font-size: 14px; }
  .trkM2 { font-size: 12px; color: var(--text-dim); font-weight: 400; }
  #trkBody tr.playing .trkM2 { color: inherit; opacity: .75; }
  .trkAdd { width: 44px; height: 44px; }
  .trkAdd::before { width: 15px; height: 15px; }

  /* now playing: a column (tools, title, [params], [static], [lyrics], controls)
     over the canvas, instead of desktop's absolutely placed side panels */
  #npView { display: flex; flex-direction: column; }
  #npView[hidden] { display: none; }
  #npvTop {
    position: relative; flex: none; flex-wrap: wrap; gap: 10px 12px;
    padding: calc(52px + env(safe-area-inset-top, 0px)) 12px 10px;
  }
  #npvTools { order: -1; flex: 0 0 100%; margin: 0; gap: 6px; }
  #visSel { flex: 1; min-width: 0; height: 44px; }
  #visParamsBtn, #npvClose, #lyrBtn, #npAddBtn, #queueBtn, #fsBtn {
    flex: none; width: 44px; height: 44px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #npvTools .ic { width: 18px; height: 18px; }
  #npvArt { width: 48px; height: 48px; }
  #npvMeta { flex: 1; }
  #npvTitle, #npvSub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #npvSub { display: block; }
  #npvSub > * + * { margin-left: 10px; }
  #visParams {
    position: relative; top: auto; left: auto; width: auto;
    flex: 0 1 auto; max-height: 42%; margin: 0 12px 8px;
  }
  .vpRow { min-height: 36px; }
  #staticView {
    position: relative; inset: auto; flex: 1 1 auto; min-height: 0;
    flex-direction: column; justify-content: center; align-items: stretch;
    padding: 0 18px;
  }
  #stBlock { max-width: none; }
  #stArt { display: block; width: min(100%, 42vh); margin: 0 auto; }
  #stTitle { font-size: 22px; margin-top: 18px; }
  #lyrPanel, #npView.static #lyrPanel:not(.none) {
    position: relative; top: auto; right: auto !important; bottom: auto; width: auto;
    flex: 1 1 0; min-height: 0; margin: 0; padding: 30vh 22px;
    background: rgba(8, 9, 11, .45);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 84%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 84%, transparent);
  }
  #lyrPanel.none, #npView.static #lyrPanel.none {
    position: relative; top: auto; right: auto !important; flex: none; align-self: flex-start;
    margin: 0 12px 8px; padding: 9px 14px;
    -webkit-mask-image: none; mask-image: none;
  }
  /* static + lyrics together: the art folds into a compact header row */
  #npView.static:has(#lyrPanel:not([hidden])) #staticView { flex: none; padding-bottom: 10px; }
  #npView.static:has(#lyrPanel:not([hidden])) #stBlock {
    display: grid; grid-template-columns: 72px minmax(0, 1fr); column-gap: 14px; align-content: center;
  }
  #npView.static:has(#lyrPanel:not([hidden])) #stArt { width: 72px; grid-row: 1 / span 2; margin: 0; }
  #npView.static:has(#lyrPanel:not([hidden])) #stTitle { font-size: 17px; margin-top: 8px; }
  #npView.static:has(#lyrPanel:not([hidden])) #stSub { margin-top: 0; font-size: 13px; }
  #npView.static:has(#lyrPanel:not([hidden])) #stFmt { display: none; }
  /* room for the floating transport bar under the column */
  #npView { padding-bottom: var(--footerH, 64px); }
  body.npOpen footer { padding-top: 0; }
  body.npOpen #npControls { margin: 0 auto; }

  /* modals use the whole screen */
  #modal { padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px; }
  #modalBox { max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px)); }
  .mhead button { min-width: 44px; min-height: 44px; margin: -10px -12px -10px 0; }
}


/* ---- nothing may widen the page ---- */
/* Marquee text is wider than its slot by design; its slot must contain it for
   layout purposes too, not just visually (some mobile engines otherwise size the
   page to the unclipped text and zoom out). */
.tile .t1, .tile .t2a, #npTitle, #npSub, :is(#expander, #avTracks, #arvAlbums) .trk .nm { overflow: hidden; contain: paint; }
body { overflow-x: clip; max-width: 100%; }
main, #tracksView, .tile { min-width: 0; }
/* closed drawers are out of layout entirely (see showDrawer/hideDrawer) */
#navDrawer.shut, #queueDrawer.shut { display: none; }

/* ---- links and keyboard focus on tiles ---- */
a.t1, a.t2a, a.ghead { color: inherit; text-decoration: none; }
a.t1 { display: block; }
a.t1:hover .mq, a.t2a:hover .mq { text-decoration: underline; }
.tile .cover:focus-visible, a.t1:focus-visible, a.t2a:focus-visible, a.ghead:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---- album / artist headers hold up at any width ---- */
/* Independent of the phone breakpoint: when the text column would get too
   narrow beside the art, it drops below instead of wrapping letter by letter. */
@media (min-width: 681px) {
  #avHead { flex-wrap: wrap; }
  #avInfo { flex: 1 1 260px; }
  .arvAlbum { flex-wrap: wrap; }
  .arvRight { flex: 1 1 280px; }
}
.arvTitle { min-width: 0; overflow-wrap: break-word; }
#npSub .lnk:hover { color: var(--text); }


/* ---- icon-only buttons carry no box ---- */
/* A lone icon is the control: no border, no fill. Hover and "on" are shown by
   colour (and a faint wash), keyboard focus by the standard outline. */
#filterBtn, #queueBtnTop, #npBtnTop, #appMenu, #navBtn,
#visParamsBtn, #lyrBtn, #npAddBtn, #queueBtn, #fsBtn, #npvClose,
#avClose, #arvClose, #varClose, #avMenuBtn, .arvMenuBtn, .arvPlay,
#expander .actions .act, .usrDel, #queueDrawerClose, #navClose, #searchClear {
  border-color: transparent !important;
  background: transparent !important;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  color: var(--text-dim);
  transition: color .12s ease, background .12s ease;
}
:is(#filterBtn, #queueBtnTop, #npBtnTop, #appMenu, #navBtn, #visParamsBtn, #lyrBtn, #npAddBtn, #queueBtn, #fsBtn, #npvClose,
    #avClose, #arvClose, #varClose, #avMenuBtn, .arvMenuBtn, .arvPlay, #expander .actions .act, .usrDel,
    #queueDrawerClose, #navClose):hover { color: var(--text); background: rgba(255, 255, 255, .08) !important; }
:is(#filterBtn, #queueBtnTop, #npBtnTop, #lyrBtn, #queueBtn, .queueTgl).on { color: var(--accent); }
.hdrBtn .ic, #appMenu .ic { width: 17px; height: 17px; vertical-align: -4px; }
/* over artwork or a visualizer the icon keeps its own contrast */
#npvTools button, #expander .actions .act, #avClose, #arvClose { color: #e3e5e8; }
#npvTools .ic, #expander .actions .ic, #avClose .ic, #arvClose .ic { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .85)); }

/* ---- Now Playing: title block stays readable over any visualization ---- */
#npvMeta {
  padding: 7px 14px 8px;
  background: rgba(8, 9, 11, .5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
#npvSub { color: #e3e5e8; }
#npvSub .npAlbum { opacity: .82; }

/* ---- breadcrumbs ---- */
.crParent .ic { display: none; }

/* ---- keyboard focus is always visible ---- */
:is(button, a, select, [role="button"], [role="slider"], [role="tab"], tr[tabindex], .qRow):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
:is(.trk, #trkBody tr, .qRow):focus-visible { outline-offset: -2px; }
#npBar:focus-visible { outline-offset: 6px; }

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; scroll-behavior: auto !important; }
}

@media (max-width: 680px) {
  /* breadcrumbs on a phone: a back link to the parent and the current place,
     in full, instead of every level truncated */
  .crSeg:not(.crParent), .crSep { display: none; }
  .crParent { max-width: 42vw; display: inline-flex; align-items: center; gap: 2px; flex: 0 1 auto; }
  .crParent .ic { display: inline-block; flex: none; width: 16px; height: 16px; }
  .crCur { flex: 1 1 auto; padding-left: 8px; }

  /* Now Playing gets a real seek bar (grabbable, with its thumb) and the clock */
  body.npOpen footer { padding: 0 16px calc(6px + env(safe-area-inset-bottom, 0px)); }
  body.npOpen #npBar {
    order: -2; flex: 0 0 100%; margin: 14px 0 8px; height: 4px;
    background: rgba(255, 255, 255, .22);
  }
  body.npOpen #npThumb { opacity: 1; width: 16px; height: 16px; }
  body.npOpen #npTime {
    display: block; order: -1; flex: 0 0 100%; margin: 0 0 2px;
    text-align: center; font-size: 12px;
  }
}


/* ---- share link landing ---- */
/* The link's contents are the whole visit: no library around them. */
body.shareMode header, body.shareMode main, body.shareMode #rail, body.shareMode #signinView,
body.shareMode #npBtnTop { display: none !important; }
/* the landing view itself has nowhere to close to */
body.shareHome #crumbs, body.shareHome #avClose, body.shareHome #arvClose, body.shareHome #npvClose { display: none !important; }
/* a single shared track: just the player */
body.shareTrack .queueTgl, body.shareTrack #prev, body.shareTrack #next, body.shareTrack #modeBtn { display: none !important; }
body.shareMode #shareSignin { display: inline-flex; align-items: center; }
#shareSignin[hidden], #shareSignin2[hidden] { display: none; }
body.shareMode:not(.npOpen) #shareSignin2 { display: inline-flex; position: fixed; top: 16px; right: 16px; z-index: 75; }
#sharePlay { margin-top: 22px; padding: 10px 34px; font-size: 14px; }
#sharePlay[hidden] { display: none; }
#shareGone {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--bg);
}
#shareGone[hidden] { display: none; }
#shareGoneBox {
  width: min(360px, 100%); padding: 30px 28px;
  background: var(--bg-raised); border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
#shareGoneBox h2 { margin: 0 0 10px; font-size: 24px; font-weight: 700; letter-spacing: .5px; }
#shareGoneBox p { margin: 0 0 20px; color: var(--text-dim); }
.shA { color: var(--text-dim); white-space: nowrap; font-size: 12px; }
/* with the library hidden nothing pushes the transport bar down: pin it */
body.shareMode footer { position: fixed; left: 0; right: 0; bottom: 0; }

/* ---- the page behind a dialog or drawer does not scroll ---- */
html:has(#modal:not([hidden])), html:has(#navDrawer.open), html:has(#queueDrawer.open),
html:has(#modal:not([hidden])) body, html:has(#navDrawer.open) body, html:has(#queueDrawer.open) body { overflow: hidden; }
/* ...and a scroll that reaches the end of the layer stays in the layer */
.mbody, #navBody, #queueList, #albumView, #artistView, #variantsView, #lyrPanel { overscroll-behavior: contain; }
#navScrim, #queueScrim, #modal { touch-action: none; }
#modalBox, #navDrawer, #queueDrawer { touch-action: auto; }

@media (max-width: 680px) {
  /* accounts: each one a small block (name, then role / password / actions)
     instead of a five-column table wider than the screen */
  .usrTable, .usrTable tbody { display: block; width: 100%; }
  .usrTable tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 0; border-top: 1px solid var(--border); }
  .usrTable tr:first-child { border-top: none; padding-top: 2px; }
  .usrTable td { padding: 0; display: block; }
  .usrTable td:first-child { flex: 0 0 100%; overflow: hidden; text-overflow: ellipsis; }
  /* the delete button shares the name's line rather than taking one of its own */
  .usrTable tr[data-u] td:first-child { flex: 1 1 calc(100% - 60px); order: 0; }
  .usrTable tr[data-u] td:last-child { order: 1; }
  .usrTable tr[data-u] td:nth-child(2), .usrTable tr[data-u] td:nth-child(3), .usrTable tr[data-u] td:nth-child(4) { order: 2; }
  .usrTable td:nth-child(2) { flex: 0 0 auto; }
  .usrTable td:nth-child(3) { flex: 1 1 110px; min-width: 0; }
  .usrTable input { min-width: 0; }
  .usrTable select, .usrTable input, .usrTable .act { min-height: 40px; }
  .usrNew td { padding-top: 0; }
  /* nothing in a dialog may be wider than the dialog */
  .mbody select, .mbody input { max-width: 100%; }
  .artSearch > * { min-width: 0; }
  #setOutFmt { flex-wrap: wrap; }
}


/* ---- phone transport ---- */
@media (max-width: 680px) {
  /* Mini player: no rule across the top. The bar fades in over the content
     (tint and blur both ramp up) and carries no seek line of its own; seeking
     lives in Now Playing, one tap away. */
  body:not(.npOpen) footer {
    background: none; backdrop-filter: none; -webkit-backdrop-filter: none; border-top: none;
    padding-top: 10px;
  }
  body:not(.npOpen) footer::before {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; top: -26px; z-index: -1; pointer-events: none;
    background: linear-gradient(to bottom, rgba(30, 31, 35, 0), rgba(30, 31, 35, .9) 34px);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30px);
    mask-image: linear-gradient(to bottom, transparent, #000 30px);
  }
  body:not(.npOpen) #npBar { display: none; }

  /* Now Playing: seek across the full width with the clock at its two ends,
     then one row of large controls spread across the screen. */
  body.npOpen footer { padding: 0 22px calc(14px + env(safe-area-inset-bottom, 0px)); gap: 0; }
  body.npOpen #npBar { order: -3; flex: 0 0 100%; margin: 18px 0 9px; height: 4px; }
  body.npOpen #npTime {
    order: -2; flex: 0 0 100%; margin: 0 0 6px;
    display: flex; justify-content: space-between; font-size: 12px; text-align: left;
  }
  body.npOpen .npSep { display: none; }
  body.npOpen #npControls { order: -1; flex: 0 0 100%; margin: 0; justify-content: space-between; align-items: center; }
  body.npOpen #npControls button { min-width: 64px; min-height: 64px; }
  body.npOpen #npControls .ic { width: 28px; height: 28px; }
  body.npOpen #toggle .ic { width: 44px; height: 44px; }
  body.npOpen #modeBtn .ic { width: 22px; height: 22px; }
  body.npOpen #chainWrap { display: none; }
}

/* the queue button joins the transport row only in phone Now Playing, where it
   balances the play-mode button at the other end */
#npControls #npQueue { display: none; }
@media (max-width: 680px) {
  body.npOpen #npControls #npQueue { display: inline-flex; }
  body:not(.npOpen) #npControls #modeBtn { display: none; } /* the mini player keeps to previous / play / next */
  body.npOpen #modeBtn { order: -1; }
  body.npOpen #queueBtn { display: none; }
  body.shareTrack.npOpen #npControls { justify-content: center; }
}

/* the mobile version has no visualizers: nothing to choose or tune */
body.noVis #visSel, body.noVis #visParamsBtn, body.noVis #visCanvas { display: none !important; }

/* Mobile Now Playing: cover, title, optional lyrics, transport. With the
   visualizer controls gone the tool row is just the lyrics toggle, which sits
   at the top right instead of taking a row; closing is the back link above. */
@media (max-width: 680px) {
  body.noVis #npvTop {
    position: absolute; top: calc(48px + env(safe-area-inset-top, 0px)); right: 6px; left: auto;
    padding: 0; background: none; z-index: 2; width: auto;
  }
  body.noVis #npvTools { flex: none; margin: 0; }
  body.noVis:not(.shareMode) #npvClose { display: none; }
  body.noVis #npView.static { padding-top: calc(52px + env(safe-area-inset-top, 0px)); }
  body.noVis #staticView { padding: 0 24px; }
  body.noVis #stArt { width: min(100%, 46vh); box-shadow: 0 18px 50px rgba(0, 0, 0, .6); }
  body.noVis #stTitle { font-size: 23px; margin-top: 22px; }
  body.noVis #stSub { font-size: 15px; gap: 4px 12px; }
  /* with lyrics showing, the compact header leaves room for the toggle at its right */
  body.noVis #npView.static:has(#lyrPanel:not([hidden])) #stBlock { padding-right: 44px; }
}

/* unsynced lyrics are read top to bottom, so they start at the top of the panel
   (the big lead-in is only for synced lines, which sit mid-panel) */
#lyrPanel.plain { padding-top: 28px; padding-bottom: 60px; }
@media (max-width: 680px) { #lyrPanel.plain { padding: 22px 22px 60px; } }

@media (max-width: 680px) {
  /* breadcrumbs: the back link keeps its text; the current place gives way first */
  .crParent { flex: 0 0 auto; max-width: 46vw; }
  .crCur { flex: 0 1 auto; min-width: 0; }
  /* the back link (and the back swipe) close a page; a second close button over the art is clutter */
  body:not(.shareMode) #avClose, body:not(.shareMode) #arvClose { display: none; }
  #arvName { padding-right: 0; }
  /* Now Playing has its queue button in the transport row */
  body.npOpen .crQueue { display: none; }
}


/* ---- static view: the cover, blurred, is the backdrop ---- */
#stBack { display: none; }
#npView.static #stBack {
  display: block; position: absolute; inset: -80px; z-index: 0;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  filter: blur(54px) saturate(2.1) brightness(.92);
}
/* darkening where text sits: a vignette plus a floor under the title and lyrics,
   so they read whatever the cover's colours are */
#npView.static::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, .30), rgba(0, 0, 0, .04) 24%, rgba(0, 0, 0, .22) 56%, rgba(0, 0, 0, .70)),
    radial-gradient(120% 90% at 30% 40%, rgba(0, 0, 0, 0), rgba(0, 0, 0, .34));
}
#npView.static > #npvTop, #npView.static > #staticView, #npView.static > #lyrPanel { z-index: 1; }
#npView.static { background: var(--stBg, #17181b); }
#stTitle { color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, .75), 0 0 2px rgba(0, 0, 0, .6); }
#stSub { color: #f1f2f4; text-shadow: 0 1px 10px rgba(0, 0, 0, .8), 0 0 2px rgba(0, 0, 0, .6); }
#stSub .npAlbum { opacity: .86; }
/* A long title must not push the rest of Now Playing around: two lines of
   title, one each of artist, album and year, cut short where they overrun. */
#stTitle { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; padding-bottom: 2px; }
#stSub > * { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stFmt { color: rgba(255, 255, 255, .72); text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }
#npView.static .lyrLine, #npView.static .lyrPlain { text-shadow: 0 1px 10px rgba(0, 0, 0, .85), 0 0 2px rgba(0, 0, 0, .6); }
#npView.static .lyrPlain { color: #f1f2f4; }

/* ---- queue: Clear is an icon ---- */
#queueClear { background: transparent; border: none; color: var(--text-dim); cursor: pointer; padding: 4px; display: inline-flex; }
#queueClear:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
#queueClear .ic { width: 18px; height: 18px; }

/* ---- breadcrumbs: fitted by fitCrumbs(), never squeezed ---- */
.crHide { display: none !important; }
.crBack { display: inline-flex; vertical-align: -3px; margin-right: 2px; }
.crBack .ic { width: 14px; height: 14px; display: inline-block; }
@media (max-width: 680px) {
  .crSeg:not(.crParent), .crSep { display: revert; }
  .crSeg, .crCur { flex: 0 0 auto; max-width: none; overflow: visible; text-overflow: clip; min-width: 0; }
  .crCur { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; padding-left: 5px; }
  .crSep { display: inline-flex; align-items: center; }
  #queueClear { width: 44px; height: 44px; align-items: center; justify-content: center; }
}
#npView { overflow: hidden; }

/* ---- transport: waiting on the stream (loading, buffering, reconnecting) ---- */
#toggle.busy .ic { animation: tBusy 1.1s ease-in-out infinite; }
@keyframes tBusy { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { #toggle.busy .ic { animation: none; opacity: .6; } }

/* ---- phones: the strip behind the clock and Dynamic Island ----
   When the top bar is collapsed, page content would otherwise scroll straight
   under the system status items. A tinted, blurred strip keeps them legible. */
@media (max-width: 680px) {
  html::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 9; pointer-events: none;
    height: env(safe-area-inset-top, 0px);
    background: linear-gradient(to bottom, rgba(24, 25, 28, .94), rgba(24, 25, 28, .72));
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  /* the island already separates the bar from the screen edge: sit close under it */
  header { padding: calc(2px + env(safe-area-inset-top, 0px)) 12px 6px; }
}

/* ---- phones: action sheets run to the bottom edge, over the mini player ----
   (Sitting "above the transport bar" depended on a measured bar height and
   ended up overlapping it.) */
@media (max-width: 680px) {
  #ctxMenu, #albumView .menu, #artistView .menu, #expander .menu {
    bottom: 0; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgb(28, 29, 33);
  }
}
@media (max-width: 680px) {
  /* menus that live inside a view stack below the mini player, so it steps
     aside while one of them is open */
  body:has(:is(#albumView, #artistView, #expander) .menu:not([hidden])) footer { visibility: hidden; }
}

@media (max-width: 680px) {
  /* top bar collapsed: the strip grows a little below the status area and takes
     a tap to bring the bar back (iOS keeps taps on the status area for itself) */
  html.hdrGone::before {
    pointer-events: auto; height: calc(env(safe-area-inset-top, 0px) + 22px);
    background: linear-gradient(to bottom, rgba(24, 25, 28, .94), rgba(24, 25, 28, .78) 70%, rgba(24, 25, 28, 0));
    -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent); mask-image: linear-gradient(to bottom, #000 70%, transparent);
  }
  html.hdrGone::after {
    content: ""; position: fixed; z-index: 9; pointer-events: none;
    top: calc(env(safe-area-inset-top, 0px) + 5px); left: 50%; width: 36px; height: 4px; margin-left: -18px;
    background: rgba(255, 255, 255, .34);
  }
}

/* ---- swipe navigation: the screen follows the finger ---- */
.swiping { box-shadow: -6px 0 22px rgba(0, 0, 0, .38); will-change: transform; }
.swipeUnder { position: fixed; inset: 0; z-index: 49; background: #0e0f11; }
.swipeDim { position: fixed; inset: 0; z-index: 49; background: #000; pointer-events: none; will-change: opacity; }
@keyframes enterLeft { from { transform: translate3d(-18%, 0, 0); opacity: .5; } }
@keyframes enterRight { from { transform: translate3d(100%, 0, 0); } }
@keyframes enterUp { from { transform: translate3d(0, 100%, 0); } }
.enterLeft { animation: enterLeft .26s cubic-bezier(.2, .8, .2, 1) !important; }
.enterRight { animation: enterRight .3s cubic-bezier(.2, .8, .2, 1) !important; box-shadow: -16px 0 36px rgba(0, 0, 0, .55); }
.enterUp { animation: enterUp .32s cubic-bezier(.2, .8, .2, 1) !important; }
@media (max-width: 680px) {
  /* the scrim behind a drawer comes and goes with it */
  #navScrim:not([hidden]), #queueScrim:not([hidden]) { animation: fadeIn .22s ease; }
  /* things pressed give a little */
  .tile .cover:active, .navItem:active, .plCard:active, #trkBody tr[data-ti]:active, .trk:active { opacity: .72; transition: opacity .05s; }
}
@media (prefers-reduced-motion: reduce) { .enterLeft, .enterRight, .enterUp, #navScrim:not([hidden]), #queueScrim:not([hidden]) { animation: none !important; } }
.swipeBelow { z-index: 48 !important; pointer-events: none; }

/* ---- per-account: library scope, save toggles, playlists ---- */
#scopeBtn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text-dim); }
#scopeBtn.on { color: var(--accent); }
#scopeBtn .ic { width: 16px; height: 16px; }
#queueSave { background: transparent; border: none; color: var(--text-dim); cursor: pointer; padding: 4px; display: inline-flex; }
#queueSave:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
#queueSave .ic { width: 18px; height: 18px; }
#avSave, #arvSave { display: inline-flex; align-items: center; }
#avSave.on, #arvSave.on { color: var(--accent); }
#arvSave { margin: 0 0 18px; }

#playlistsView {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 22px 18px;
  padding: 22px 28px 140px;
}
#playlistsView[hidden] { display: none; }
.plCard { background: transparent; border: none; color: inherit; text-align: left; padding: 0; cursor: pointer; min-width: 0; font: inherit; }
.plCard .cover { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--bg-raised); box-shadow: 0 1px 4px rgba(0, 0, 0, .45); }
.plCard .t1 { margin-top: 7px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plCard .t2 { font-size: 12px; color: var(--text-dim); }
.plCard:hover .cover { outline: 1px solid rgba(255, 255, 255, .28); }
.plMosaic { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.plMosaic img { width: 100%; height: 100%; object-fit: cover; display: block; min-width: 0; min-height: 0; }
.plMosaic img:only-child { grid-column: 1 / -1; grid-row: 1 / -1; }
.plMosaic .noart, .plCard .noart { grid-column: 1 / -1; grid-row: 1 / -1; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-dim); }
.plMosaic .noart .ic, .plCard .noart .ic { width: 34px; height: 34px; }

#playlistView { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: 44px 7vw 130px; }
#playlistView[hidden] { display: none; }
html:has(#playlistView:not([hidden])) { overflow: hidden; }
#plClose { position: absolute; top: 50px; right: 20px; background: transparent; border: none; color: var(--text-dim); padding: 6px; cursor: pointer; display: inline-flex; }
#plClose:hover { color: var(--text); }
#plHead { display: flex; gap: 30px; align-items: flex-end; margin-bottom: 26px; }
#plArt { position: relative; width: min(26vh, 220px); aspect-ratio: 1; flex: none; background: var(--bg-raised); box-shadow: 0 2px 14px rgba(0, 0, 0, .5); overflow: hidden; }
#plName { margin: 0 0 6px; font-size: 30px; overflow-wrap: anywhere; }
#plMeta { color: var(--text-dim); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
#plActions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#plActions .act { display: inline-flex; align-items: center; background: transparent; border: none; padding: 7px; color: var(--text-dim); cursor: pointer; }
#plActions .act:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, .08); }
#plActions .act:disabled { opacity: .35; cursor: default; }
#plActions .ic { width: 18px; height: 18px; }
.plRow { display: flex; align-items: center; gap: 12px; padding: 7px 8px; cursor: pointer; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.plRow:hover, .plRow:focus-visible { background: rgba(255, 255, 255, .06); outline: none; }
.plRow.dragging { background: rgba(255, 255, 255, .12); box-shadow: 0 6px 18px rgba(0, 0, 0, .5); position: relative; z-index: 1; }
.plGrip { color: var(--text-dim); cursor: grab; touch-action: none; display: inline-flex; padding: 4px 0; opacity: .55; }
.plGrip .ic { width: 16px; height: 16px; }
.plN { width: 26px; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 13px; flex: none; }
.plT { flex: 1 1 0; min-width: 0; }
.plTitle, .plSub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plSub { font-size: 12px; color: var(--text-dim); }
.plAlbum::before { content: "·"; margin: 0 7px; }
.plDur { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 13px; flex: none; }
.plRm { background: transparent; border: none; color: var(--text-dim); cursor: pointer; padding: 6px; display: inline-flex; opacity: .6; }
.plRm:hover { color: var(--text); opacity: 1; }
.plRm .ic { width: 15px; height: 15px; }
.plEmpty { color: var(--text-dim); padding: 30px 8px; }

.mrow { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
#nameIn { width: 100%; min-width: min(420px, 78vw); box-sizing: border-box; padding: 9px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--border); font: inherit; }
button.primary.danger { background: #e5484d; color: #fff; }
.plPick { display: flex; flex-direction: column; min-width: min(420px, 78vw); padding-top: 8px; }
.plPickWhat { color: var(--text-dim); font-size: 13px; margin: 4px 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plPickRow { display: flex; align-items: center; gap: 12px; background: transparent; border: none; color: inherit; font: inherit; text-align: left; padding: 7px 6px; cursor: pointer; }
.plPickRow:hover { background: rgba(255, 255, 255, .07); }
.plPickArt { position: relative; width: 40px; height: 40px; flex: none; background: var(--bg-raised); display: grid; align-items: center; justify-items: center; overflow: hidden; }
.plPickArt .noart .ic { width: 18px; height: 18px; }
.plPickName { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plPickN { color: var(--text-dim); font-size: 12px; flex: none; }

@media (max-width: 680px) {
  #scopeBtn { display: none; } /* lives in the menu drawer on phones */
  #playlistsView { grid-template-columns: 1fr 1fr; gap: 16px 10px; padding: 12px 12px calc(var(--footerH, 60px) + 40px); }
  #playlistView { padding: calc(52px + env(safe-area-inset-top, 0px)) 12px calc(var(--footerH, 60px) + 40px); }
  #plClose { display: none; } /* the breadcrumb strip is the way back */
  #plHead { flex-direction: column; align-items: flex-start; gap: 14px; }
  #plArt { width: 46vw; }
  #plName { font-size: 22px; }
  #plActions .act { width: 44px; height: 44px; justify-content: center; }
  .plRow { padding: 6px 0; gap: 8px; min-height: 48px; }
  .plRm, .plGrip { width: 40px; height: 44px; align-items: center; justify-content: center; }
  .plN { display: none; }
}
.plPickArt > .ic { width: 18px; height: 18px; color: var(--text-dim); }

/* ---- settings: Last.fm ---- */
#setLastfm .artSearch { flex-wrap: wrap; }
#setLastfm a.act { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
#setLastfm a.act .ic { width: 14px; height: 14px; }
.mCheck { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 auto; }
.mhNote { color: var(--text-dim); font-size: 12px; margin: 6px 0 0; }


/* ================= loading and motion =================
   Things that take a moment show their shape first (placeholders with a slow
   shimmer) and then settle in; screens and layers arrive with a short fade.
   All of it is switched off for people who ask for reduced motion. */
@keyframes skShimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }
.sk {
  background-color: rgba(255, 255, 255, .055);
  background-image: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .075) 50%, rgba(255, 255, 255, 0) 70%);
  background-size: 220% 100%; background-repeat: no-repeat;
  animation: skShimmer 1.5s linear infinite;
}
.skLine { display: block; height: 11px; margin-top: 9px; }
.skRow { display: flex; align-items: center; gap: 14px; padding: 13px 10px; }
.skRow .skLine { margin: 0; flex: none; }
.skRow .skNum { width: 16px; height: 11px; flex: none; }
.skRow .skDur { width: 30px; height: 11px; flex: none; margin-left: auto; }
.tile.skel, .plCard.skel { cursor: default; pointer-events: none; }
.tile.skel .cover { box-shadow: none; }
.arvAlbum.skel .arvArt.sk { aspect-ratio: 1; }
#grid.loading { overflow: hidden; }

/* covers in lists fade in when they have loaded */
.tile .cover img, .plCard .cover img, .plPickArt img, .arvAlbum .arvArt, #queueList img, #plArt img { opacity: 0; transition: opacity .3s ease; }
.tile .cover img.ld, .plCard .cover img.ld, .plPickArt img.ld, .arvAlbum .arvArt.ld, #queueList img.ld, #plArt img.ld { opacity: 1; }
.arvAlbum .arvArt.sk { opacity: 1; }

@keyframes riseIn { from { opacity: 0; transform: translate3d(0, 10px, 0); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.97); } }
@keyframes sheetUp { from { transform: translate3d(0, 100%, 0); } }
@keyframes dropIn { from { opacity: 0; transform: translate3d(0, -6px, 0); } }

/* first paint of the library: tiles settle in, a row at a time */
#grid.fresh .tile { animation: riseIn .38s cubic-bezier(.2, .7, .2, 1) backwards; }
#grid.fresh .tile:nth-child(n+2) { animation-delay: .02s; } #grid.fresh .tile:nth-child(n+4) { animation-delay: .05s; }
#grid.fresh .tile:nth-child(n+7) { animation-delay: .08s; } #grid.fresh .tile:nth-child(n+11) { animation-delay: .11s; }
#grid.fresh .tile:nth-child(n+16) { animation-delay: .14s; } #grid.fresh .tile:nth-child(n+22) { animation-delay: .17s; }
#grid.fresh .tile:nth-child(n+40) { animation: none; }
/* switching tabs */
.tabIn { animation: fadeIn .22s ease; }
#tracksView.fresh tbody tr { animation: fadeIn .3s ease; }
/* tracks tab while its list loads: the shape of rows */
#tracksView.loading > * { display: none; }
#tracksView.loading::after {
  content: ""; display: block; height: 70vh; margin: 22px 18px 0;
  background-image:
    linear-gradient(100deg, rgba(35, 36, 40, 0) 30%, rgba(255, 255, 255, .05) 50%, rgba(35, 36, 40, 0) 70%),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, .055) 0 12px, transparent 12px 38px);
  background-size: 220% 100%, 100% 38px; background-repeat: no-repeat, repeat-y;
  animation: skShimmer 1.5s linear infinite;
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent); mask-image: linear-gradient(to bottom, #000 40%, transparent);
}

/* screens that open over the library */
#albumView:not([hidden]), #artistView:not([hidden]), #playlistView:not([hidden]), #variantsView:not([hidden]) { animation: fadeIn .2s ease; }
#albumView:not([hidden]) #avHead, #playlistView:not([hidden]) #plHead, #artistView:not([hidden]) #arvName { animation: riseIn .32s cubic-bezier(.2, .7, .2, 1) backwards; }
#npView:not([hidden]) { animation: fadeIn .24s ease; }
.swipeBelow, .swipeBelow * { animation: none !important; }
/* track lists replacing their placeholders */
#avTracks.filled > *, #plTracks.filled > *, #arvAlbums.filled > .arvAlbum { animation: fadeIn .28s ease backwards; }
#albumView.loading #avPlay { opacity: .5; pointer-events: none; }

/* dialogs, menus, notices */
#modal:not([hidden]) { animation: fadeIn .16s ease; }
#modal:not([hidden]) #modalBox { animation: popIn .2s cubic-bezier(.2, .8, .2, 1); }
#toast:not([hidden]) { animation: fadeIn .2s ease; } /* (it positions itself with a transform, so it only fades) */
.dd:not([hidden]), #appMenuDrop:not([hidden]), .menu:not([hidden]), #chainPop:not([hidden]) { animation: dropIn .14s ease-out; }
#ctxMenu:not([hidden]) { animation: fadeIn .12s ease-out; }
#signinView:not([hidden]) .siBox, #signinView:not([hidden]) form { animation: riseIn .3s cubic-bezier(.2, .7, .2, 1) backwards; }
#lyrPanel .lyrLine { transition: opacity .35s ease, color .35s ease; }
#npArt, #stArt, #avArt { transition: opacity .25s ease; }
#avArt:not([src]), #stArt:not([src]) { opacity: 0; }
@media (max-width: 680px) {
  /* action sheets come up from the bottom edge */
  #ctxMenu:not([hidden]), :is(#albumView, #artistView, #expander) .menu:not([hidden]) { animation: sheetUp .22s cubic-bezier(.2, .8, .2, 1); }
  :is(#ctxMenu, #albumView .menu, #artistView .menu, #expander .menu)::before { animation: fadeIn .22s ease; }
}

@media (prefers-reduced-motion: reduce) {
  .sk, #tracksView.loading::after { animation: none; }
  #grid.fresh .tile, .tabIn, #tracksView.fresh tbody tr,
  #albumView:not([hidden]), #artistView:not([hidden]), #playlistView:not([hidden]), #variantsView:not([hidden]), #npView:not([hidden]),
  #albumView:not([hidden]) #avHead, #playlistView:not([hidden]) #plHead, #artistView:not([hidden]) #arvName,
  #avTracks.filled > *, #plTracks.filled > *, #arvAlbums.filled > .arvAlbum,
  #modal:not([hidden]), #modal:not([hidden]) #modalBox, #toast:not([hidden]),
  .dd:not([hidden]), #appMenuDrop:not([hidden]), .menu:not([hidden]), #chainPop:not([hidden]), #ctxMenu:not([hidden]),
  #signinView:not([hidden]) .siBox, #signinView:not([hidden]) form,
  :is(#ctxMenu, #albumView .menu, #artistView .menu, #expander .menu)::before { animation: none !important; }
  .tile .cover img, .plCard .cover img, .plPickArt img, .arvAlbum .arvArt, #queueList img, #plArt img { transition: none; opacity: 1; }
}
#avSave[hidden], #arvSave[hidden], #scopeBtn[hidden], #queueSave[hidden] { display: none; }

/* the toast leaves the way it came */
#toast { transition: opacity .25s ease; }
#toast.leaving { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }


/* ---- Match library ---- */
#matchView { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: 44px 5vw 130px; }
#matchView[hidden] { display: none; }
html:has(#matchView:not([hidden])) { overflow: hidden; }
#matchView:not([hidden]) { animation: fadeIn .2s ease; }
#matchView h2 { margin: 0 0 4px; font-size: 26px; }
#mtClose { position: absolute; top: 50px; right: 20px; background: transparent; border: none; color: var(--text-dim); padding: 6px; cursor: pointer; display: inline-flex; }
#mtClose:hover { color: var(--text); }
#mtSub { color: var(--text-dim); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
#mtBar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
#mtBar select { background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); padding: 7px 10px; font: inherit; }
#mtProg { color: var(--text-dim); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mtProg.busy { animation: tBusy 1.4s ease-in-out infinite; }
#mtTabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
#mtTabs button { background: transparent; border: none; color: var(--text-dim); font: inherit; padding: 9px 14px; cursor: pointer; display: inline-flex; gap: 8px; align-items: baseline; }
#mtTabs button.on { color: var(--text); font-weight: 600; background: var(--bg-raised); box-shadow: 0 -2px 10px rgba(0, 0, 0, .35); }
#mtTabs button:disabled { opacity: .4; cursor: default; }
.mtN { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-dim); font-weight: 400; }
#mtOpts { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px 10px; position: sticky; top: -44px; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--border); }
#mtOpts[hidden] { display: none; }
#mtOpts .mCheck { flex: none; font-size: 13px; }
#mtOpts.rejecting .mtWrite, #mtOpts.rejecting .mtWrite ~ .mCheck { display: none; }
.mtWrite { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-left: 10px; }
.mtSpacer { flex: 1 1 0; }
.mtRow { display: grid; grid-template-columns: 22px 48px minmax(0, 1fr) 20px minmax(0, 1.5fr) 48px auto; gap: 14px; align-items: start; padding: 12px 10px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.mtRow.sel { background: rgba(255, 255, 255, .045); }
.mtRow:hover { background: rgba(255, 255, 255, .03); }
.mtCk { margin-top: 15px; }
.mtArt { width: 48px; height: 48px; object-fit: cover; background: var(--bg-raised); display: block; }
.mtLT { background: transparent; border: none; color: inherit; font: inherit; font-weight: 600; padding: 0; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.mtLT:hover, .mtCT:hover { text-decoration: underline; }
.mtCT { color: inherit; text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
.mtCT .ic { width: 12px; height: 12px; display: inline-block; vertical-align: -1px; color: var(--text-dim); }
.mtMeta, .mtWhy { color: var(--text-dim); font-size: 12px; display: flex; gap: 4px 10px; flex-wrap: wrap; margin-top: 3px; }
.mtWhy { color: #8fc79a; }
.mtFlags { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; font-size: 12px; color: #e6b450; }
.mtFlags span { display: inline-flex; gap: 6px; align-items: flex-start; }
.mtFlags .ic { width: 13px; height: 13px; flex: none; margin-top: 2px; }
.mtEdits { display: flex; gap: 4px 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--text-dim); }
.mtE.mtChg { color: #e6b450; }
.mtE.mtKeep { opacity: .7; }
.mtE[title] { cursor: help; border-bottom: 1px dotted rgba(255, 255, 255, .25); }
.mtArrow { color: var(--text-dim); margin-top: 14px; display: inline-flex; }
.mtArrow .ic { width: 16px; height: 16px; }
.mtScore { font-variant-numeric: tabular-nums; font-size: 13px; text-align: right; margin-top: 14px; color: var(--text-dim); }
.mtActs { display: flex; gap: 2px; margin-top: 6px; }
.mtActs .act { background: transparent; border: none; padding: 8px; color: var(--text-dim); cursor: pointer; display: inline-flex; }
.mtActs .act:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.mtActs .ic { width: 16px; height: 16px; }
#mtList .skRow { padding: 22px 10px; }
@media (max-width: 680px) {
  #matchView { padding: calc(52px + env(safe-area-inset-top, 0px)) 12px calc(var(--footerH, 60px) + 40px); }
  #mtClose { display: none; }
  #mtOpts { top: calc(-52px - env(safe-area-inset-top, 0px)); gap: 8px 14px; padding: 10px 2px; }
  .mtRow { grid-template-columns: 22px 40px minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px 2px; }
  .mtArt { width: 40px; height: 40px; }
  .mtArrow { display: none; }
  .mtCand { grid-column: 2 / -1; grid-row: 2; }
  .mtScore { grid-column: 4; grid-row: 1; margin-top: 4px; }
  .mtActs { grid-column: 2 / -1; grid-row: 3; }
  .mtActs .act { width: 44px; height: 40px; justify-content: center; }
}

/* ---- Upload ---- */
#uploadView { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: 44px 5vw 130px; }
#uploadView[hidden] { display: none; }
html:has(#uploadView:not([hidden])) { overflow: hidden; }
#uploadView:not([hidden]) { animation: fadeIn .2s ease; }
#uploadView h2 { margin: 0 0 4px; font-size: 26px; }
#uploadView.dropping { outline: 2px dashed var(--accent); outline-offset: -10px; }
#upClose { position: absolute; top: 50px; right: 20px; background: transparent; border: none; color: var(--text-dim); padding: 6px; cursor: pointer; display: inline-flex; }
#upClose:hover { color: var(--text); }
#upSub { color: var(--text-dim); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; min-height: 18px; margin-bottom: 16px; }
#upBar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.upField { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.upField select { background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); padding: 7px 10px; font: inherit; font-size: 14px; text-transform: none; letter-spacing: 0; min-width: 150px; }
#upBar button:disabled, .upField select:disabled { opacity: .45; }
#upProg { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
#upProg[hidden] { display: none; }
#upProgBar { height: 4px; background: rgba(255, 255, 255, .1); }
#upProgBar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
#upProgText { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#upOpts { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px 10px; position: sticky; top: -44px; z-index: 2; background: var(--bg); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
#upOpts[hidden] { display: none; }
#upOpts .mCheck { flex: none; font-size: 13px; }
#upOpts .mtWrite { margin-left: 0; }
.upArt { display: flex; align-items: center; justify-content: center; color: var(--text-dim); }
.upArt .ic { width: 20px; height: 20px; }
.upRow .mtLT { cursor: default; }
.upRow .mtLT:hover { text-decoration: none; }
.upBusy { display: flex; flex-direction: column; }
.upBusy .skLine:first-child { margin-top: 4px; }
.mtActs .act.on { color: var(--accent); }
#upDrop { margin-top: 18px; padding: 54px 20px; border: 1px dashed var(--border); color: var(--text-dim); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
#upDrop .ic { width: 30px; height: 30px; }
#upDrop.small { padding: 18px 20px; flex-direction: row; justify-content: center; }
#upDrop.small .ic { width: 18px; height: 18px; }
#usList { margin-top: 12px; display: flex; flex-direction: column; min-width: min(640px, 80vw); max-height: 52vh; overflow-y: auto; }
.usRow { background: transparent; border: none; border-bottom: 1px solid rgba(255, 255, 255, .06); color: inherit; font: inherit; text-align: left; padding: 9px 6px; cursor: pointer; display: flex; flex-direction: column; }
.usRow:hover { background: rgba(255, 255, 255, .07); }
.usT { font-weight: 600; }
@media (hover: none) and (pointer: coarse) { #upDrop { display: none; } }
@media (max-width: 680px) {
  #uploadView { padding: calc(52px + env(safe-area-inset-top, 0px)) 12px calc(var(--footerH, 60px) + 40px); }
  #upClose { display: none; }
  #upOpts { top: calc(-52px - env(safe-area-inset-top, 0px)); gap: 8px 14px; padding: 10px 2px; }
  .upField select { min-width: 0; }
}

/* ---- album page: versions of the same album ---- */
#avVersions { display: flex; flex-direction: column; gap: 2px; margin: 0 0 16px; max-width: 640px; }
#avVersions[hidden] { display: none; }
.avVT { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 4px; }
.avV { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: baseline; text-align: left; background: transparent; border: 1px solid transparent; color: var(--text-dim); font: inherit; font-size: 13px; padding: 6px 9px; cursor: pointer; }
.avV:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.avV.on { color: var(--text); font-weight: 600; background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .22); cursor: default; }
.avVMain, .avVMarks { display: inline-flex; gap: 4px 10px; flex-wrap: wrap; }
.avVMarks { color: var(--accent); font-weight: 400; font-size: 12px; }
@media (max-width: 680px) { .avV { min-height: 44px; align-items: center; } }
#avVersions { margin-top: 14px; }

/* ---- upload: albums the library already had ---- */
#upFound { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--border); }
#upFound[hidden] { display: none; }
.upFoundRow { display: flex; gap: 6px 12px; align-items: baseline; flex-wrap: wrap; padding: 5px 0; }
.upFoundRow .ic { width: 15px; height: 15px; color: #8fc79a; flex: none; align-self: center; }
.upFoundT { font-weight: 600; }
.upFoundRow .mtMeta { margin-top: 0; }

/* ---- settings: API tokens ---- */
.tokDim { color: var(--text-dim); white-space: nowrap; }
.tokFresh { margin-top: 8px; }
.tokFresh input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------- settings: groups, and a screen of its own on phones ---------- */
.setTabs { display: flex; gap: 2px; margin: 0 0 6px; border-bottom: 1px solid var(--border); }
.setTabs button {
  background: transparent; border: 1px solid transparent; border-bottom: none; color: var(--text-dim);
  font: inherit; font-size: 13px; padding: 7px 14px; margin-bottom: -1px; cursor: pointer;
}
.setTabs button:hover { color: var(--text); }
.setTabs button[aria-selected="true"] { color: var(--text); background: var(--bg-hover); border-color: var(--border); }
.setPane:not([hidden]) { animation: fadeIn .16s ease; }
.setPane > h4:first-child, .setPane > div:first-child > h4:first-child { margin-top: 12px; }
.setBody #mStatus { display: block; min-height: 18px; margin-top: 10px; color: var(--text-dim); font-size: 12px; }
#modalBox .setBody { min-height: min(420px, 60vh); }
#settingsView { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: 44px 5vw 130px; }
#settingsView[hidden] { display: none; }
html:has(#settingsView:not([hidden])) { overflow: hidden; }
#settingsView:not([hidden]) { animation: fadeIn .2s ease; }
#settingsView h2 { margin: 0 0 14px; font-size: 26px; }
#settingsView .setBody { max-width: 760px; }
#settingsView h4 { margin: 18px 0 8px; font-size: 13px; }
#setClose { position: absolute; top: 50px; right: 20px; background: transparent; border: none; color: var(--text-dim); padding: 6px; cursor: pointer; display: inline-flex; }
#setClose:hover { color: var(--text); }
@media (max-width: 680px) {
  #settingsView { padding: calc(52px + env(safe-area-inset-top, 0px)) 12px calc(var(--footerH, 60px) + 40px); }
  #setClose { display: none; }
  #settingsView h2 { font-size: 22px; }
  .setTabs { margin: 0 -12px 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
  .setTabs::-webkit-scrollbar { display: none; }
  .setTabs button { flex: 1 0 auto; min-height: 44px; font-size: 14px; padding: 0 14px; }
  #settingsView select, #settingsView input[type="text"], #settingsView input[type="password"] { font-size: 16px; min-height: 44px; }
  #settingsView .artSearch > select, #settingsView .setPane > select { width: 100%; }
  #settingsView .artSearch .act, #settingsView .artSearch .primary { min-height: 44px; }
  .setPane:not([hidden]) { animation: none; }
}
@media (prefers-reduced-motion: reduce) { .setPane:not([hidden]), #settingsView:not([hidden]) { animation: none; } }

@media (max-width: 680px) {
  /* On phones a screen's arrival is one of enterRight / enterLeft / enterUp,
     set as it is shown; the plain fade would only run again when that
     finished. (Last in the file, to come after the rules it replaces.) */
  #albumView:not([hidden]), #artistView:not([hidden]), #playlistView:not([hidden]), #variantsView:not([hidden]),
  #matchView:not([hidden]), #uploadView:not([hidden]), #settingsView:not([hidden]), #npView:not([hidden]) { animation: none; }
}
.plPickRow:disabled { cursor: default; color: var(--text-dim); }
.plPickRow:disabled:hover { background: transparent; }

/* ---------- ripping a CD (the app) ---------- */
#cdRipBody .cdOpts { margin-bottom: 10px; }
#cdRipBody .cdOpts select { flex: none; }
#cdRipBody .cdOpts .mtMeta { margin: 0 0 0 auto; }
#cdRows .cdSt {
  width: 190px; white-space: nowrap; text-align: right;
  color: var(--text-dim); font-size: 12px;
}
#cdRows .cdSt > * + * { margin-left: 9px; }
#cdRows .cdSt .ic { width: 14px; height: 14px; vertical-align: -2px; }
#cdRows .cdSt .ic + span { margin-left: 5px; }
#cdRows tr.cdOn .cdSt { color: var(--text); }
#cdRows .cdOk { color: #9ece6a; }
#cdRows .cdWarn { color: #e0af68; }
#cdRows .cdBad { color: #f7768e; }
.cdNum { font-variant-numeric: tabular-nums; }
#cdRows .cdX { display: inline-block; min-width: 34px; }
.cdBar { height: 4px; background: rgba(255, 255, 255, .1); margin-top: 14px; }
.cdBar[hidden] { display: none; }
.cdBar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
#cdRipBody .mfoot #mStatus { margin-right: auto; }
#cdRipBody .mfoot [hidden] { display: none; }
#cdRipBody input:disabled, #cdRipBody select:disabled { opacity: .75; }
@media (max-width: 680px) {
  #cdRows .cdSt { width: 120px; }
}
#cdFind { margin: -4px 0 12px; padding: 10px 0 0; border-top: 1px solid var(--border); }
#cdFind[hidden] { display: none; }
#cdFind .artSearch { margin-bottom: 0; }
#cdFind select { flex: none; }
#cdFindList { display: flex; flex-direction: column; max-height: 30vh; overflow-y: auto; margin-top: 8px; }

/* sign-in: the privacy link, and the warning for a server without https */
#siActions .siLink { margin-right: auto; background: none; border: none; padding: 0; color: var(--text-dim); font-size: 12px; cursor: pointer; }
#siActions .siLink:hover, #siActions .siLink:focus-visible { color: var(--text); }
#siErr.siWarn { color: #e0af68; }
/* destructive actions with a label */
button.act.danger { color: #f7768e; border-color: rgba(247, 118, 142, .45); }
button.act.danger:hover { background: rgba(247, 118, 142, .12); }
.delWhat { margin: 0 0 14px; max-width: 460px; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.privacyBody { max-width: 640px; font-size: 13px; line-height: 1.55; }
.privacyBody h2 { font-size: 14px; margin: 18px 0 6px; }
.privacyBody p, .privacyBody li { color: var(--text-dim); margin: 0 0 8px; }
.privacyBody ul { padding-left: 18px; margin: 0 0 8px; }
.privacyBody a { color: var(--accent); }

.delAlbums { display: block; margin: 0 0 12px; font-size: 13px; line-height: 1.45; }
.delAlbums input { margin-right: 6px; vertical-align: -2px; }
.siHelp { margin: 4px 0 10px; font-size: 12px; line-height: 1.45; color: var(--dim, #9a9da3); }
.siHelp a { color: inherit; text-decoration: underline; }
