/* Same token system as public.css (the marketing site) - kept duplicated
   rather than shared via @import so this stays a single static file with
   no extra request, but the values must stay identical for the player to
   feel like the same product as the rest of music.project-5.com. */
:root {
  --bg: #0b0d12;
  --bg-raised: #12151c;
  --bg-card: #161a22;
  --bg-card-hover: #1e2430;
  --text: #eef1f6;
  --text-dim: #8d94a3;
  --brand: #0078d7;
  --brand-dark: #005fa8;
  --brand-light: #3ea6ff;
  --accent: #22d3ee; /* cyan - the second half of the "futuristic" gradient pairing */
  --brand-grad: linear-gradient(135deg, var(--brand) 0%, var(--accent) 130%);
  --brand-wash: rgba(0, 120, 215, 0.14);
  --brand-glow: 0 0 0 1px rgba(62, 166, 255, 0.25), 0 4px 24px rgba(0, 120, 215, 0.35);
  --border: #262b36;
  --border-soft: rgba(255, 255, 255, 0.06);
  --glass: rgba(18, 21, 28, 0.72);
  --radius: 12px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", -apple-system, sans-serif;
  overflow: hidden;
}

body {
  /* A faint two-tone glow fixed to the viewport (not scrolled content) -
     the "futuristic" wash that keeps the otherwise-flat near-black from
     reading as plain utilitarian dark mode. Subtle on purpose: this sits
     behind real UI panels almost everywhere, so it only actually shows
     through gaps/edges. */
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(0, 120, 215, 0.16), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(34, 211, 238, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

::selection { background: rgba(0, 120, 215, 0.35); color: #fff; }

/* Thin, rounded, brand-tinted scrollbars (webkit) instead of the default
   chunky OS ones - a small detail that matters a lot for "professional". */
#track-list::-webkit-scrollbar, #queue-list::-webkit-scrollbar,
#sidebar::-webkit-scrollbar, .cat-panel::-webkit-scrollbar,
#page-content::-webkit-scrollbar, #libraries-list::-webkit-scrollbar {
  width: 9px; height: 9px;
}
#track-list::-webkit-scrollbar-track, #queue-list::-webkit-scrollbar-track,
#sidebar::-webkit-scrollbar-track, .cat-panel::-webkit-scrollbar-track,
#page-content::-webkit-scrollbar-track, #libraries-list::-webkit-scrollbar-track {
  background: transparent;
}
#track-list::-webkit-scrollbar-thumb, #queue-list::-webkit-scrollbar-thumb,
#sidebar::-webkit-scrollbar-thumb, .cat-panel::-webkit-scrollbar-thumb,
#page-content::-webkit-scrollbar-thumb, #libraries-list::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box;
}
#track-list:hover::-webkit-scrollbar-thumb, #queue-list:hover::-webkit-scrollbar-thumb,
#sidebar:hover::-webkit-scrollbar-thumb, .cat-panel:hover::-webkit-scrollbar-thumb,
#page-content:hover::-webkit-scrollbar-thumb, #libraries-list:hover::-webkit-scrollbar-thumb {
  background: #3a4151; background-clip: padding-box;
}

/* ---------------- Shared app chrome (nav + status + account) ----------------
   Identical markup in index.html and templates/library/layout.html, so this
   is what every one of Library/Devices/Shares/Account looks like at the top
   of the page. */

#app-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 18px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  z-index: 2;
}
/* A hairline gradient instead of a flat border - catches the eye without
   being loud, the same trick used on #player-bar below. */
#app-nav::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(62, 166, 255, 0.5), transparent);
}

.app-nav-brand {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
}
.app-nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}
.app-nav-links a:hover { color: var(--text); }
.app-nav-links a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 16px rgba(34, 211, 238, 0.45);
}

.status-pill {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e05a4e;
  display: inline-block;
  box-shadow: 0 0 8px rgba(224, 90, 78, 0.6);
}
.status-dot.connected { background: #3ddc84; box-shadow: 0 0 8px rgba(61, 220, 132, 0.65); }

.toolbar-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.toolbar-btn:hover { background: var(--bg-card-hover); border-color: #3a4151; }
.toolbar-btn:active { background: var(--bg-raised); transform: scale(0.97); }
.toolbar-btn-primary { border-color: var(--brand); color: #fff; }
.toolbar-btn:disabled { opacity: 0.5; cursor: default; }

.account-name {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------------- Library-only toolbar (search/category/libraries) ---------------- */

#library-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#search-input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text);
  padding: 7px 14px;
  width: 360px;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search-input:focus { outline: none; border-color: var(--brand-light); box-shadow: var(--brand-glow); }

#search-category {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 8px;
  font-size: 12px;
}

#library-toolbar #btn-refresh-library { margin-left: auto; }

@keyframes toolbar-btn-spin { to { transform: rotate(360deg); } }
.toolbar-btn.spinning { pointer-events: none; opacity: 0.7; }
.toolbar-btn.spinning .icon { display: inline-block; animation: toolbar-btn-spin 0.7s linear infinite; }

/* ---------------- Main split ---------------- */

#main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  font-size: 12px;
  padding-bottom: 8px;
}

.section-title {
  padding: 14px 14px 6px;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cat-row {
  padding: 7px 14px 7px 20px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 6px;
  transition: background 0.12s, color 0.12s;
}
.cat-row:hover, .cat-header:hover { background: var(--bg-card-hover); }
.cat-row.selected {
  background: linear-gradient(90deg, var(--brand-wash), transparent);
  color: var(--brand-light);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

.cat-header {
  padding: 7px 14px 7px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 6px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.cat-header .arrow { color: var(--text-dim); font-size: 10px; transition: transform 0.15s; }
.cat-header.open .arrow { transform: rotate(90deg); display: inline-block; }

.cat-panel {
  display: none;
  background: var(--bg-card);
  max-height: 220px;
  overflow-y: auto;
  margin: 2px 6px 4px;
  border-radius: var(--radius-sm);
}
.cat-panel.open { display: block; }
.cat-panel .value-row {
  padding: 5px 10px 5px 24px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-panel .value-row:hover { background: var(--bg-card-hover); }
.cat-panel .value-row.selected {
  background: linear-gradient(90deg, var(--brand-wash), transparent);
  color: var(--brand-light);
  box-shadow: inset 2px 0 0 var(--accent);
}
.cat-panel .value-count { color: var(--text-dim); font-size: 10px; margin-left: 4px; }

#playlist-list .cat-row { padding-left: 14px; }

/* ---------------- Track list (virtualized div-grid, not a <table>) ----------------
   .track-header and .track-row share the same column layout via
   --track-grid-cols so a real <table>'s column alignment is preserved
   without actually being a <table> - rows need to be absolutely positioned
   for virtualization, which a real <tr> can't do without losing its grid. */

:root { --track-grid-cols: 30px minmax(120px,1.4fr) minmax(120px,1.4fr) 40px minmax(140px,1.8fr) 56px minmax(90px,1fr) 70px; }

#table-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0; /* flex items default to min-height:auto (content-sized), which
                    would let #track-list's absolutely-positioned (tall) spacer
                    push #table-container past the viewport instead of clipping
                    it via #track-list's own overflow:auto - matters most in the
                    mobile column layout, where this axis is the one that scrolls. */
}

.track-header, .track-row {
  display: grid;
  grid-template-columns: var(--track-grid-cols);
  align-items: center;
  gap: 0;
}

.track-header {
  background: var(--bg);
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0 10px;
  height: 26px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.track-header > div, .track-row > div {
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#track-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}
#track-list-spacer {
  position: relative;
  width: 100%;
}
.track-row {
  position: absolute;
  left: 0;
  right: 0;
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.track-row:hover { background: var(--bg-card-hover); }
.track-row.now-playing {
  color: var(--brand-light);
  background: linear-gradient(90deg, var(--brand-wash), rgba(34, 211, 238, 0.05) 70%, transparent);
  border-left-color: var(--accent);
}
.col-fav { text-align: center; }
.fav-star { cursor: default; color: var(--text-dim); }
.fav-star.active { color: #ffd24a; text-shadow: 0 0 8px rgba(255, 210, 74, 0.6); }

/* ---------------- Queue panel ---------------- */

#queue-panel {
  width: 360px;
  flex-shrink: 0;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#queue-panel .section-title { flex-shrink: 0; }

#queue-list {
  flex: 1;
  min-height: 0; /* see #track-list's comment - same flex min-height:auto trap */
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 11px;
  position: relative;
}
#queue-list-spacer {
  position: relative;
  width: 100%;
}
.queue-row {
  position: absolute;
  left: 0;
  right: 0;
  height: 20px;
  padding: 2px 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  box-sizing: border-box;
}
.queue-row:hover { background: var(--bg-card-hover); }
.queue-row.now-playing { color: var(--brand-light); text-shadow: 0 0 12px rgba(34, 211, 238, 0.3); }
.queue-row .queue-row-artist { color: var(--text-dim); }

#queue-stats {
  flex-shrink: 0;
  padding: 8px 14px 2px;
  color: var(--text-dim);
  font-size: 10px;
}
#queue-buttons {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 8px 14px 14px;
}
#queue-buttons .toolbar-btn { flex: 1; font-size: 11px; padding: 6px 4px; }

/* ---------------- Context menu ---------------- */

.context-menu {
  position: fixed;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 0;
  min-width: 160px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.context-menu.hidden { display: none; }
.context-menu-item {
  padding: 7px 14px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.context-menu-item:hover { background: var(--brand-grad); color: #fff; }

/* ---------------- Pairing modal ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 9, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 360px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-soft) inset;
}
.modal h3 { margin: 0 0 10px; color: var(--text); font-size: 16px; }
.modal-hint { color: var(--text-dim); font-size: 12px; line-height: 1.4; min-height: 16px; }
.modal input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 16px;
  letter-spacing: 2px;
  text-align: center;
  margin: 10px 0;
}
.modal input:focus { outline: none; border-color: var(--brand); }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ---------------- Libraries modal ---------------- */

#libraries-list { max-height: 320px; overflow-y: auto; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.library-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
}
.library-row {
  transition: background 0.15s, border-color 0.15s;
}
.library-row:hover { background: var(--bg-card-hover); }
.library-row.active { border-color: var(--brand-light); box-shadow: var(--brand-glow); }
.library-row.disabled { opacity: 0.5; cursor: default; }
.library-row-dot { width: 8px; height: 8px; border-radius: 50%; background: #e05a4e; flex-shrink: 0; }
.library-row-dot.connected { background: #4caf50; }
.library-row-name { flex: 1; color: var(--text); font-size: 13px; }
.library-row-owner { color: var(--text-dim); font-size: 11px; }
.library-row-status { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.library-row-empty { color: var(--text-dim); font-size: 12px; padding: 10px 0; }

/* ---------------- Player bar ---------------- */

#player-bar {
  flex-shrink: 0;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-top: 1px solid var(--border);
  padding: 6px 16px;
  position: relative;
  z-index: 2;
}
#player-bar::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(62, 166, 255, 0.5), transparent);
}

#seek-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.time-label { width: 42px; color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
#time-remaining { text-align: right; }

/* --progress (set in app.js's _onTimeUpdate/the input handler) paints the
   played portion as a gradient up to the thumb - a plain <input
   type=range> has no concept of "played" on its own. */
#seek-bar {
  --progress: 0%;
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) var(--progress), var(--border) var(--progress));
  outline: none;
}
#seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(62, 166, 255, 0.4), 0 0 10px rgba(34, 211, 238, 0.6);
  cursor: pointer;
}
#seek-bar::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(62, 166, 255, 0.4), 0 0 10px rgba(34, 211, 238, 0.6);
  cursor: pointer;
}

#main-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 6px;
  height: 80px;
}

#player-art {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-raised));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-size: cover;
  background-position: center;
  transition: box-shadow 0.3s;
}
#player-bar:not(.idle) #player-art {
  border-color: rgba(62, 166, 255, 0.4);
  box-shadow: 0 0 0 1px rgba(62, 166, 255, 0.15), 0 4px 18px rgba(0, 120, 215, 0.3);
}

#player-info {
  width: 240px;
  flex-shrink: 0;
  overflow: hidden;
}
#player-title-row { display: flex; align-items: baseline; gap: 4px; }
#player-title { color: var(--text); font-weight: 600; font-size: 13px; }
#player-bar.idle #player-title { color: var(--text-dim); font-weight: normal; font-style: italic; }
#player-bar.idle #player-fav { display: none; }
#player-fav { color: var(--text-dim); font-size: 20px; cursor: pointer; flex-shrink: 0; }
#player-fav.active { color: #ffd24a; }
#player-artist { color: var(--text-dim); font-size: 11.5px; }
#player-album { color: var(--text-dim); font-size: 11px; opacity: 0.8; }

.marquee-clip {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
  width: 100%;
}
#player-title-row .marquee-clip { flex: 1; width: auto; }
.marquee-text {
  display: inline-block;
  white-space: nowrap;
}

#player-center { flex: 1; display: flex; justify-content: center; }
#player-transport {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 5px 18px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 4px 16px rgba(0, 0, 0, 0.25);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, transform 0.1s;
}
.icon-btn svg { display: block; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); transform: scale(1.08); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn.active { color: var(--accent); filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.5)); }
.icon-btn-play {
  font-size: 18px;
  width: 40px;
  height: 40px;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: var(--brand-glow);
}
.icon-btn-play:hover { color: #fff; background: var(--brand-grad); transform: scale(1.06); filter: brightness(1.1); }
.icon-btn-play:active { transform: scale(0.96); }
@keyframes icon-btn-play-pulse {
  0%, 100% { box-shadow: var(--brand-glow); }
  50% { box-shadow: 0 0 0 7px rgba(34, 211, 238, 0.14), var(--brand-glow); }
}
.icon-btn-play.playing { animation: icon-btn-play-pulse 2.4s ease-in-out infinite; }

#btn-eq { font-size: 15px; }

/* ---------------- EQ modal ---------------- */
.eq-modal {
  width: 460px;
  max-width: calc(100vw - 32px);
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, var(--bg-raised), var(--bg-card));
}
.eq-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(34, 211, 238, 0.12), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(62, 166, 255, 0.12), transparent 55%);
  pointer-events: none;
}
.eq-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.eq-modal-header h3 {
  margin: 0;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 17px;
  letter-spacing: 0.3px;
}
.modal-close { color: var(--text-dim); font-size: 13px; }
.modal-close:hover { color: var(--text); }

.eq-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  z-index: 1;
}
#eq-preset-select {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12.5px;
  padding: 7px 10px;
  cursor: pointer;
}
#eq-preset-select:focus { outline: none; border-color: var(--brand); }
.eq-reset-btn { font-size: 11.5px; padding: 7px 14px; }

#eq-bands {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.eq-band {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 6px;
}
.eq-band-value { font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.eq-band .eq-slider-wrap {
  height: 140px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eq-band label { font-size: 10.5px; color: var(--text-dim); font-weight: 600; }
#eq-bands .vertical-slider { height: 140px; width: 5px; }
#eq-bands .vertical-slider::-webkit-slider-thumb,
#eq-bands .vertical-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(62, 166, 255, 0.4), 0 0 10px rgba(34, 211, 238, 0.6);
}

.vertical-slider {
  writing-mode: vertical-lr;
  direction: rtl;
  -webkit-appearance: none;
  appearance: none;
  width: 4px;
  height: 52px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.vertical-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.vertical-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
/* --progress (set in app.js's setVolFill) paints a brand->accent fill from
   the bottom up - gradient directions are physical, not writing-mode
   relative, so "to top" lines up with direction:rtl's bottom-is-minimum
   convention above regardless of the inline-axis trickery. */
#volume-slider {
  --progress: 80%;
  background: linear-gradient(to top, var(--brand) 0%, var(--accent) var(--progress), var(--border) var(--progress));
}
#volume-slider::-webkit-slider-thumb { background: #fff; box-shadow: 0 0 0 1px rgba(62, 166, 255, 0.4), 0 0 8px rgba(34, 211, 238, 0.5); }
#volume-slider::-moz-range-thumb { background: #fff; box-shadow: 0 0 0 1px rgba(62, 166, 255, 0.4), 0 0 8px rgba(34, 211, 238, 0.5); }

#player-volume {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 30px;
  flex-shrink: 0;
}
#player-volume .icon-btn { font-size: 13px; }

/* ---------------- Mobile bottom tab bar - hidden entirely on desktop ---------------- */

#mobile-tabs { display: none; }

/* ======================================================================
   Pages that aren't the player (Devices/Shares/Account) - a single
   scrollable column instead of the player's 3-pane split, still inside
   the same #app flex shell so #player-bar pins to the bottom identically.
   ====================================================================== */

.app-non-player #page-content {
  flex: 1;
  overflow-y: auto;
  width: 100%;
}
.app-non-player .library-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  color: var(--text);
}
.app-non-player .library-page h1 { color: var(--text); font-size: 20px; }
.app-non-player .library-page table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.app-non-player .library-page th, .app-non-player .library-page td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.app-non-player .library-page .btn {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.app-non-player .library-page .btn-primary { background: var(--brand-grad); border-color: transparent; color: #fff; }
.app-non-player .library-page a.btn { display: inline-block; text-decoration: none; }
.page-flash { font-size: 13px; }
.page-flash-ok { color: #4caf50; }
.page-flash-error { color: #e05a4e; }

/* ========================================================================
   Mobile - below this width the player becomes a 3-tab app (Library / Now
   Playing / Queue) instead of a cramped copy of the desktop 3-pane layout,
   matching the Android app's own screen split. #app's data-mobile-tab
   attribute (set by app.js's initMobileTabs()) picks which of #main (as
   the Library tab)/#queue-panel/#player-bar (as Now Playing) is visible;
   a mini #player-bar persists above the tab bar on the other two tabs.
   ======================================================================== */

@media (max-width: 760px) {
  /* 4 visible columns on mobile (fav/artist/title/duration) - album, track
     number, year, and genre are hidden below, and this must match that
     count or the grid auto-places the extra visible column onto a second
     row. */
  :root { --track-grid-cols: 26px minmax(0,1fr) minmax(0,1.6fr) 54px; }

  #app-nav { gap: 12px; padding: 10px 12px; }
  .app-nav-brand { font-size: 13px; }
  .app-nav-links { gap: 12px; }
  .app-nav-links a { font-size: 12px; }
  .account-name { display: none; }
  #status-text { display: none; } /* the dot alone is enough room for on a phone header */

  #library-toolbar { flex-wrap: wrap; padding: 8px 10px; display: none; }
  #app[data-mobile-tab="library"] #library-toolbar { display: flex; }
  #search-input { width: auto; flex: 1; min-width: 0; }
  #library-toolbar #btn-libraries { margin-left: 0; }

  .app-non-player .library-page { padding: 20px 16px 40px; }

  /* --- Library/Queue tabs: #sidebar, #table-container, and #queue-panel
         are all siblings inside #main (so desktop can lay them out as one
         flex row) - on mobile, #main stays put and just toggles which of
         its own children are visible per tab, instead of hiding #main
         itself (that would hide #queue-panel too, since it's one of
         #main's children, not a sibling of it). #main only collapses
         entirely on the Now Playing tab, so #player-bar's flex:1 isn't
         fighting it for space. */
  #main { flex-direction: column; }
  #app[data-mobile-tab="nowplaying"] #main { display: none; }
  #sidebar, #table-container, #queue-panel { display: none; }
  #app[data-mobile-tab="library"] #sidebar { display: block; }
  #app[data-mobile-tab="library"] #table-container { display: flex; }
  #app[data-mobile-tab="queue"] #queue-panel { display: flex; }

  #sidebar {
    width: 100%;
    max-height: 32vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .track-header > div:nth-child(3),
  .track-row > div:nth-child(3) { display: none; } /* album */
  .track-header > div:nth-child(4),
  .track-row > div:nth-child(4) { display: none; } /* track number */
  .track-header > div:nth-child(6),
  .track-row > div:nth-child(6) { display: none; } /* year */
  .track-header > div:nth-child(7),
  .track-row > div:nth-child(7) { display: none; } /* genre */

  /* Desktop gives #queue-panel a fixed width (it's a ROW item there, with
     #main's cross-axis stretch doing the height for free) and no
     flex-grow since it never needed to - on mobile #main is COLUMN
     direction, so #queue-panel's *height* is now its main axis, and
     without an explicit flex-grow it just auto-sizes to its real (huge,
     virtualized) content height instead of sharing #main's space. */
  #queue-panel { width: 100%; border-left: none; flex: 1; min-height: 0; }

  /* --- Player bar: a slim mini-bar above the tab bar on Library/Queue,
         a full-screen Now Playing view on its own tab. Tapping the mini
         bar (app.js) switches to the nowplaying tab. `order` keeps the
         mini bar docked directly above the tab bar regardless of which of
         #main/#queue-panel happens to be visible (DOM order alone would
         put #mobile-tabs - earlier in the markup - above the mini bar). */
  #main { order: 1; } /* #app's actual flex child - #queue-panel is nested inside it */
  #player-bar { order: 2; }
  #mobile-tabs { order: 3; }

  #player-bar {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  #seek-row, #btn-eq, #player-volume { display: none; }
  #main-row { height: auto; gap: 10px; }
  #player-art { width: 42px; height: 42px; }
  #player-center { display: none; }
  #player-info { width: auto; flex: 1; }

  #app[data-mobile-tab="nowplaying"] #player-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
  }
  #app[data-mobile-tab="nowplaying"] #seek-row,
  #app[data-mobile-tab="nowplaying"] #player-volume { display: flex; }
  #app[data-mobile-tab="nowplaying"] #btn-eq { display: inline-flex; }
  #app[data-mobile-tab="nowplaying"] #player-volume { flex-direction: row; }
  #app[data-mobile-tab="nowplaying"] #main-row {
    flex-direction: column;
    height: auto;
    gap: 20px;
    padding: 24px 0;
  }
  #app[data-mobile-tab="nowplaying"] #player-art { width: min(64vw, 280px); height: min(64vw, 280px); margin: 0 auto; border-radius: var(--radius); }
  #app[data-mobile-tab="nowplaying"] #player-info { width: 100%; text-align: center; }
  #app[data-mobile-tab="nowplaying"] #player-title-row { justify-content: center; }
  #app[data-mobile-tab="nowplaying"] #player-center { display: flex; justify-content: center; order: 3; }
  #app[data-mobile-tab="nowplaying"] #player-transport { gap: 28px; }
  #app[data-mobile-tab="nowplaying"] #btn-eq,
  #app[data-mobile-tab="nowplaying"] #player-volume { order: 4; }
  #app[data-mobile-tab="nowplaying"] #player-volume { justify-content: center; }
  #app[data-mobile-tab="nowplaying"] #btn-eq { align-self: center; font-size: 22px; width: 38px; height: 38px; }

  #mobile-tabs {
    display: flex;
    flex-shrink: 0;
    background: var(--glass);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 8px 0 10px;
    font-size: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    transition: color 0.15s;
  }
  .mobile-tab-btn.active { color: var(--accent); filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.45)); }

  #app[data-mobile-tab="nowplaying"] #player-art {
    box-shadow: 0 0 0 1px rgba(62, 166, 255, 0.3), 0 12px 50px rgba(0, 120, 215, 0.35);
  }
}
