:root {
  color-scheme: dark;
  --bg: #090f1f;
  --bg-deep: #050915;
  --panel: rgba(12, 18, 39, 0.88);
  --panel-strong: rgba(18, 27, 54, 0.94);
  --panel-soft: rgba(255, 255, 255, 0.04);
  --line: rgba(132, 164, 255, 0.18);
  --line-strong: rgba(132, 164, 255, 0.36);
  --text: #f5f7ff;
  --muted: #a4aed2;
  --pink: #ff2f92;
  --violet: #7c3cff;
  --blue: #49a7ff;
  --orange: #ff9b21;
  --yellow: #ffd74d;
  --tidal: #00d4aa;
  --tidal-soft: rgba(0, 212, 170, 0.18);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 47, 146, 0.18), transparent 26rem),
    radial-gradient(circle at top right, rgba(73, 167, 255, 0.18), transparent 28rem),
    radial-gradient(circle at 50% 0%, rgba(255, 215, 77, 0.08), transparent 20rem),
    linear-gradient(180deg, #101a36 0%, var(--bg) 40%, var(--bg-deep) 100%);
}

button, input, select { font: inherit; }
button, select { color: inherit; }
button { border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px; background: var(--panel-soft); padding: 0.78rem 1rem; cursor: pointer; transition: background 160ms, border-color 160ms, transform 160ms, box-shadow 160ms; }
button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--line-strong); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── App shell ─────────────────────────────────────────────────────── */

.app-shell { width: min(1600px, calc(100% - 2rem)); margin: 0 auto; padding: 0.5rem 0; }

/* ── Header ────────────────────────────────────────────────────────── */

.app-header {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 47, 146, 0.12), transparent 25%),
    linear-gradient(225deg, rgba(73, 167, 255, 0.12), transparent 32%),
    rgba(7, 12, 27, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.app-header-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: relative; }
.header-room-name { position: absolute; left: 50%; transform: translateX(-50%); margin: 0; font-size: 3rem; letter-spacing: -0.02em; text-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.header-room-name[hidden] { display: none; }
.browse-source-label { text-align: center; font-size: 1.2rem; font-weight: 800; letter-spacing: 0.03em; margin-bottom: 0.5rem; }
.app-brand { display: flex; align-items: center; gap: 1rem; }
.app-logo { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; box-shadow: 0 4px 20px rgba(255, 47, 146, 0.3); }
body:not(.route-room) .app-logo { width: 176px; height: 176px; }
.app-logo-wide { height: 80px; width: auto; object-fit: contain; }
body:not(.route-room) .app-logo-wide { height: 100px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.app-header h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 0.95; letter-spacing: -0.04em; color: var(--blue); }

.header-actions { display: flex; align-items: center; gap: 0.8rem; }
.header-nav-btns { display: flex; gap: 0.4rem; }
.header-nav-btn { padding: 0.4rem 0.9rem; border: none; border-radius: 20px; font-size: 0.72rem; font-weight: 700; cursor: pointer; letter-spacing: 0.02em; }
.header-nav-sxm { background: #0000ff; color: #fff; }
.header-nav-tidal { background: #000; color: #00d4aa; border: 1px solid #00d4aa; }
.header-nav-pod { background: #9c27b0; color: #fff; }

.home-button { background: var(--orange); border: none; color: #000; font-size: 0.72rem; font-weight: 700; padding: 0.4rem 0.9rem; border-radius: 20px; cursor: pointer; letter-spacing: 0.02em; }
.home-button:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(255, 155, 33, 0.3); }

.home-section-title { font-size: 1.1rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin: 0; }
.app-header .home-section-title { margin-top: 0.5rem; }

.muted, .mini-note { color: var(--muted); line-height: 1.45; margin: 0; }
.eyebrow { margin: 0; color: var(--yellow); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.74rem; font-weight: 700; }

/* ── Room cards (home) ─────────────────────────────────────────────── */

.device-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.device-list[hidden] { display: none; }

.room-home-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, rgba(255, 47, 146, 0.06), transparent 22%), linear-gradient(220deg, rgba(73, 167, 255, 0.08), transparent 24%), var(--panel);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: transform 200ms, border-color 200ms, box-shadow 200ms;
  aspect-ratio: 1;
}


.room-home-card:hover { transform: translateY(-4px); border-color: rgba(255, 215, 77, 0.3); box-shadow: var(--shadow), 0 8px 32px rgba(255, 47, 146, 0.15); }
.room-home-card-playing { border-color: rgba(0, 212, 170, 0.3); }
.room-home-card h2 { margin: 0; font-size: 2.3rem; letter-spacing: -0.02em; }

.room-home-card.room-home-card-has-art { background: rgba(30, 40, 65, 0.95); }
.room-home-art { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; }

.room-home-overlay {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; justify-content: flex-end;
  flex: 1; padding: 0.5rem 0.75rem;
  background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 25%);
}

.room-home-now-playing { display: flex; align-items: center; gap: 0.5rem; max-width: 100%; overflow: hidden; }
.card-vol-row { display: flex; align-items: center; justify-content: center; gap: 0.4rem; width: 100%; padding: 0 0.75rem; box-sizing: border-box; }
.card-vol-slider { width: 286px; flex: none; opacity: 0.8; }
.card-vol-label { font-size: 0.72rem; font-weight: 600; min-width: 2ch; text-align: right; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.room-home-track-info { display: grid; gap: 0.05rem; min-width: 0; text-align: left; }
.room-home-track { margin: 0; font-size: 0.8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.room-home-artist { margin: 0; font-size: 0.72rem; color: rgba(255,255,255,0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }

.room-group-badge { font-size: 0.68rem; color: var(--tidal); font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }

.room-volume-strips { grid-column: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.room-vol-strip {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  display: flex; align-items: center; gap: 0.6rem; justify-content: center;
}
.room-vol-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none; }
.vol-idle-tag { font-size: 0.75rem; font-weight: 700; cursor: pointer; text-decoration: none; }
.room-vol-strip input[type="range"] { width: 286px; flex: none; }

/* Custom slider track + thumb for consistent look */
input[type="range"][data-slider-color] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; outline: none; cursor: pointer; }
input[type="range"][data-slider-color]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.4); cursor: pointer; }
input[type="range"][data-slider-color]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: white; border: none; box-shadow: 0 1px 3px rgba(0,0,0,0.4); cursor: pointer; }
input[type="range"][data-slider-color]::-moz-range-track { background: transparent; height: 6px; }

.follower-vol-label { font-size: 0.72rem; color: var(--muted); min-width: 2ch; text-align: right; }

.room-playing-indicator { display: flex; align-items: flex-end; gap: 2px; flex-shrink: 0; height: 16px; }
.room-home-now-playing .room-playing-indicator { margin-left: auto; }
.room-home-image-wrap { position: relative; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 6px rgba(0,0,0,0.7); margin-bottom: auto; }

.eq-bar { width: 3px; background: currentColor; border-radius: 2px; animation: eq-bounce 0.8s ease-in-out infinite alternate; }
.room-playing-indicator { color: var(--tidal); }
.eq-bar:nth-child(1) { height: 60%; animation-delay: 0s; }
.eq-bar:nth-child(2) { height: 100%; animation-delay: 0.2s; }
.eq-bar:nth-child(3) { height: 40%; animation-delay: 0.4s; }
@keyframes eq-bounce { 0% { height: 30%; } 100% { height: 100%; } }

/* ── SiriusXM page ────────────────────────────────────────────────── */

.sxm-page { max-width: 900px; margin: 0 auto; }
.sxm-controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sxm-room-picker { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.sxm-room-btn { padding: 0.4rem 0.8rem; border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; background: transparent; color: var(--room-color, #ccc); font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.sxm-room-active { background: var(--room-color, #ccc); color: #000; border-color: var(--room-color); }
.sxm-search { flex: 1; min-width: 160px; padding: 0.45rem 0.75rem; border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; background: rgba(255,255,255,0.05); color: #fff; font-size: 0.82rem; outline: none; }
.sxm-search:focus { border-color: rgba(255,255,255,0.3); }
.sxm-breadcrumb { margin-bottom: 0.8rem; font-size: 0.78rem; color: var(--muted); }
.sxm-back { background: none; border: none; color: var(--tidal); font-size: 0.78rem; cursor: pointer; padding: 0; }
.sxm-back:hover { text-decoration: underline; }

.sxm-cat-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.sxm-cat-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem; width: 140px; min-width: 140px; max-width: 140px; padding: 1rem 0; border: 1px solid var(--cat-color, rgba(255,255,255,0.15)); border-radius: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--cat-color) 15%, transparent), transparent); cursor: pointer; transition: transform 150ms, box-shadow 150ms; box-sizing: border-box; }
.sxm-cat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px color-mix(in srgb, var(--cat-color) 25%, transparent); }
.sxm-cat-icon { font-size: 1.4rem; }
.sxm-inline-grid { gap: 0.6rem; justify-content: center; width: 100%; }
.sxm-cat-inline { width: 100%; min-width: 0; max-width: 100%; padding: 0.8rem 0; flex: 1 1 45%; }
.sxm-cat-inline .sxm-cat-icon { font-size: 1.6rem; }
.sxm-cat-inline .sxm-cat-name { font-size: 0.85rem; }
#sxmBrowseContent { max-height: 500px; overflow-y: auto; }
#sxmBrowseContent .sxm-grid { gap: 0.4rem; }
#sxmBrowseContent .sxm-channel { width: 90px; }
#sxmBrowseContent .sxm-channel-img { width: 60px; height: 60px; }
#sxmBrowseContent .sxm-channel-name { font-size: 0.65rem; }
#sxmBrowseContent .sxm-channel-num { font-size: 0.58rem; }
.sxm-cat-name { font-size: 0.78rem; font-weight: 700; color: #fff; text-align: center; }
.sxm-cat-count { font-size: 0.68rem; color: var(--muted); }

.sxm-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.sxm-channel { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 0.6rem; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; background: var(--panel); cursor: pointer; transition: transform 150ms, border-color 150ms; text-align: center; width: 110px; flex-shrink: 0; }
.sxm-channel:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.25); }
.sxm-channel-loading { opacity: 0.5; pointer-events: none; }
.sxm-channel-img { width: 80px; height: 80px; border-radius: 8px; object-fit: contain; }
.sxm-channel-placeholder { width: 80px; height: 80px; border-radius: 8px; background: linear-gradient(135deg, rgba(255,47,146,0.2), rgba(73,167,255,0.2)); }
.sxm-channel-info { display: flex; flex-direction: column; gap: 0.1rem; }
.sxm-channel-name { font-size: 0.72rem; font-weight: 600; color: #fff; }
.sxm-channel-num { font-size: 0.65rem; color: var(--muted); }

/* ── Podcast page ─────────────────────────────────────────────────── */

.pod-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.pod-card-wrap { position: relative; }
.pod-unsub { position: absolute; top: -6px; right: -6px; z-index: 2; width: 20px; height: 20px; border-radius: 50%; border: none; background: #e53935; color: #fff; font-size: 0.8rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 150ms; }
.pod-card-wrap:hover .pod-unsub { opacity: 1; }
.pod-card { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 0.6rem; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; background: var(--panel); cursor: pointer; transition: transform 150ms; text-align: center; width: 130px; flex-shrink: 0; }
.pod-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.25); }
.pod-card-img { width: 100px; height: 100px; border-radius: 10px; object-fit: cover; }
.pod-card-placeholder { background: linear-gradient(135deg, rgba(255,47,146,0.2), rgba(73,167,255,0.2)); }
.pod-card-info { display: flex; flex-direction: column; gap: 0.1rem; }
.pod-card-title { font-size: 0.72rem; font-weight: 600; color: #fff; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pod-card-author { font-size: 0.62rem; color: var(--muted); }

.pod-section-title { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.pod-sub-btn { padding: 0.3rem 0.8rem; border: 1px solid var(--tidal); border-radius: 20px; background: transparent; color: var(--tidal); font-size: 0.7rem; font-weight: 600; cursor: pointer; margin-left: auto; white-space: nowrap; }
.pod-sub-btn.pod-subbed { background: var(--tidal); color: #000; }
#podBrowseContent { max-height: 500px; overflow-y: auto; }
.pod-inline-grid .pod-card { width: 90px; }
.pod-inline-grid .pod-card-img { width: 70px; height: 70px; }
.pod-inline-grid .pod-card-title { font-size: 0.65rem; }
.pod-inline-eps .pod-ep-img { width: 40px; height: 40px; }
.pod-inline-eps .pod-ep-title { font-size: 0.7rem; }
.pod-episodes { display: flex; flex-direction: column; gap: 0.4rem; }
.pod-episode { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem; border: 1px solid rgba(255,255,255,0.06); border-radius: 10px; cursor: pointer; transition: background 150ms; }
.pod-episode:hover { background: rgba(255,255,255,0.05); }
.pod-ep-img { width: 50px; height: 50px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.pod-ep-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.pod-ep-title { font-size: 0.78rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-ep-meta { font-size: 0.65rem; color: var(--muted); }

/* ── Main panel ────────────────────────────────────────────────────── */

.main-panel { display: grid; gap: 0.3rem; padding-bottom: 60px; }
.room-view { display: grid; gap: 1rem; }

/* ── Speaker card (room view) ──────────────────────────────────────── */

.speaker-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  padding: 1.2rem;
  background: linear-gradient(135deg, rgba(255, 47, 146, 0.06), transparent 22%), linear-gradient(220deg, rgba(73, 167, 255, 0.08), transparent 24%), var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.speaker-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.3rem; }
.speaker-card-copy { display: grid; gap: 0.2rem; min-width: 0; }
.speaker-eyebrow { margin: 0; color: var(--blue); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.7rem; font-weight: 700; }
.speaker-card-copy h2 { margin: 0; font-size: clamp(1.55rem, 2.3vw, 2.25rem); letter-spacing: -0.04em; }

.speaker-status { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-end; }
.room-state { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.42rem 0.78rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.05); }
.room-state-play { color: #b9ffd2; border-color: rgba(0, 212, 170, 0.4); background: rgba(0, 212, 170, 0.14); }
.room-state-pause { color: #ffe1a5; border-color: rgba(255, 215, 77, 0.34); background: rgba(255, 215, 77, 0.14); }
.room-state-stop { color: #ffc1db; border-color: rgba(255, 47, 146, 0.32); background: rgba(255, 47, 146, 0.14); }

.speaker-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(260px, 1fr) minmax(260px, 1fr);
  grid-template-areas: "controls media now-playing";
  gap: 1rem;
  align-items: start;
}

.speaker-column { display: grid; gap: 0.5rem; }
.speaker-column-controls { grid-area: controls; display: flex; flex-direction: column; gap: 0.5rem; min-height: 580px; }
.speaker-column-controls .group-subcard { flex: 1; display: flex; flex-direction: column; }

.speaker-column-media .speaker-subcard { min-height: 580px; }
.speaker-column-now-playing .now-playing-card { min-height: 580px; }
.speaker-column-media { grid-area: media; }
#mediaContent { max-height: 420px; overflow-y: auto; }
.speaker-column-now-playing { grid-area: now-playing; }

/* ── Subcards ──────────────────────────────────────────────────────── */

.speaker-subcard {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 0.65rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)), var(--panel-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.subcard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.8rem; }
.subcard-label { margin: 0 0 0.18rem; color: var(--pink); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; font-weight: 700; }
.subcard-header h4 { margin: 0; }

/* ── Transport controls ────────────────────────────────────────────── */

.transport-icons { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.6rem; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.2rem; padding: 0.4rem; font-size: 0.95rem; font-weight: 800; border-radius: 14px;
}

.icon-button.active { border-color: rgba(255, 255, 255, 0.16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04); }
.icon-button.active-play { background: rgba(0, 212, 170, 0.16); color: #b9ffd2; border-color: rgba(0, 212, 170, 0.32); }
.icon-button.active-pause { background: rgba(255, 215, 77, 0.16); color: #ffe39a; border-color: rgba(255, 215, 77, 0.34); }
.icon-button.active-stop { background: rgba(255, 47, 146, 0.16); color: #ffc1db; border-color: rgba(255, 47, 146, 0.28); }

/* ── Volume ────────────────────────────────────────────────────────── */

.volume-stack { display: grid; gap: 0.3rem; margin-top: 0.4rem; }
.volume-stack input[type="range"] { width: 100%; accent-color: var(--pink); }
.volume-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
.volume-value { margin: 0; color: var(--text); font-weight: 600; }
.pill-button { border-radius: 999px; padding: 0.5rem 0.8rem; font-weight: 700; }

.playlist-row { margin-bottom: 0.6rem; }
.playlist-row-inner { display: flex; gap: 0.5rem; align-items: stretch; }
.playlist-select {
  flex: 1; min-width: 0; padding: 0.82rem 0.95rem; border-radius: 16px;
  border: 1px solid rgba(0, 212, 170, 0.26); background: #020806; color: #d6ffe3;
  appearance: none; font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.playlist-select:hover { border-color: rgba(0, 212, 170, 0.5); }
.playlist-select:focus { outline: none; border-color: var(--tidal); box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.15); }
.playlist-select option { background: #020806; color: #d6ffe3; }

/* ── Search ────────────────────────────────────────────────────────── */

.search-section { margin-bottom: 0.5rem; }
.search-bar { display: flex; align-items: center; gap: 0.3rem; }
.search-clear {
  background: none; border: none; color: var(--muted); font-size: 1.2rem;
  cursor: pointer; padding: 0.2rem 0.4rem; line-height: 1; flex-shrink: 0;
}
.search-clear:hover { color: var(--text); }

.search-bar input {
  flex: 1; padding: 0.65rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 999px;
  background: var(--panel); color: var(--text); font-size: 0.9rem; outline: none;
  transition: border-color 200ms; backdrop-filter: blur(12px);
}
.search-bar input:focus { border-color: var(--tidal); box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.15); }

/* ── Playlist grid ─────────────────────────────────────────────────── */

.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }

.playlist-card-wrap { position: relative; }

.album-add-btn {
  position: absolute; top: 0.5rem; right: 0.5rem; z-index: 5;
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(0, 212, 170, 0.4);
  background: rgba(0, 0, 0, 0.7); color: var(--tidal); font-size: 1.2rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; line-height: 1; transition: all 160ms;
}
.album-add-btn:hover { background: var(--tidal); color: #000; transform: scale(1.1); }

.playlist-card {
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 22px; padding: 0.75rem;
  background: linear-gradient(135deg, rgba(255, 47, 146, 0.06), transparent 22%), linear-gradient(220deg, rgba(73, 167, 255, 0.08), transparent 24%), var(--panel);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem;
  cursor: pointer; transition: transform 200ms, border-color 200ms, box-shadow 200ms;
}
.playlist-card:hover { transform: translateY(-4px); border-color: rgba(255, 215, 77, 0.3); box-shadow: var(--shadow), 0 8px 32px rgba(255, 47, 146, 0.15); }

.playlist-cover { width: 100%; aspect-ratio: 1; border-radius: 16px; object-fit: cover; background: linear-gradient(135deg, rgba(255, 47, 146, 0.2), rgba(73, 167, 255, 0.2)); filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.4)); }
.playlist-name { font-size: 0.82rem; font-weight: 700; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.playlist-meta { font-size: 0.7rem; color: var(--muted); }

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

.track-list { display: flex; flex-direction: column; gap: 2px; }

.track-row-with-add {
  grid-template-columns: 32px 44px minmax(0, 1fr) auto auto;
}

.add-to-playlist-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(0, 212, 170, 0.3);
  background: rgba(0, 212, 170, 0.1); color: var(--tidal); font-size: 1.1rem; font-weight: 700;
  cursor: pointer; transition: all 160ms; padding: 0; line-height: 1;
}
.add-to-playlist-btn:hover { background: rgba(0, 212, 170, 0.25); border-color: var(--tidal); transform: scale(1.1); }

.add-playlist-picker {
  position: absolute; right: 0; top: 100%; z-index: 50;
  background: var(--panel-strong); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.4rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.picker-select { font-size: 0.78rem; padding: 0.5rem 0.7rem; min-width: 180px; }

.track-row {
  position: relative;
  display: grid; grid-template-columns: 32px 44px minmax(0, 1fr) auto; gap: 0.6rem;
  align-items: center; text-align: left; padding: 0.5rem 0.7rem;
  border: 1px solid transparent; border-radius: 14px; cursor: pointer; transition: all 160ms;
}
.track-row:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.06); }
.track-row.playing { border-color: rgba(0, 212, 170, 0.35); background: linear-gradient(135deg, rgba(0, 212, 170, 0.12), rgba(73, 167, 255, 0.08)); }

.track-num { text-align: right; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.track-cover { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: rgba(255, 255, 255, 0.08); }
.track-info { display: grid; gap: 0.12rem; min-width: 0; }
.track-title { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-artist { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-duration { font-size: 0.78rem; font-weight: 600; color: var(--muted); }

.playing-indicator { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }

.track-pager { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-top: 0.6rem; }
.track-pager .pill-button { min-width: 5rem; font-size: 0.78rem; padding: 0.4rem 0.7rem; }
.track-pager-info { font-size: 0.75rem; color: var(--muted); font-weight: 600; }

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

.now-playing-card { display: flex; flex-direction: column; height: 100%; }
.now-playing-card .subcard-header { margin-bottom: 0.4rem; }

.now-playing-layout { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 0.5rem; flex: 1; text-align: center; }

.now-playing-cover-wrap { position: relative; width: min(100%, 420px); display: flex; justify-content: center; }
.now-playing-glow { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 28px; filter: blur(60px) saturate(1.8); opacity: 0.45; transform: scale(1.15); z-index: 0; pointer-events: none; }
.now-playing-cover { position: relative; z-index: 1; width: min(100%, 420px); height: auto; aspect-ratio: 1; object-fit: contain; }
.now-playing-cover-placeholder { display: block; width: min(100%, 320px); aspect-ratio: 1; border-radius: 28px; background: linear-gradient(135deg, rgba(255, 47, 146, 0.26), rgba(73, 167, 255, 0.22)); }
.now-playing-idle-logo { width: 90%; height: auto; aspect-ratio: 1; border-radius: 28px; opacity: 0.3; }

.now-playing-body { display: grid; gap: 0.35rem; width: 100%; }
.now-playing-album { margin: 0; color: var(--text); font-size: 0.82rem; font-weight: 600; }
.now-playing-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; margin-left: 6px; vertical-align: middle; }
.now-playing-eq .eq-bar { width: 2.5px; background: var(--tidal); }

.progress-bar-track { position: relative; width: 100%; height: 20px; cursor: pointer; display: flex; align-items: center; }
.progress-bar-track::before { content: ""; position: absolute; left: 0; right: 0; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); top: 50%; transform: translateY(-50%); }
.progress-bar-fill { position: relative; z-index: 1; height: 6px; border-radius: 3px; background: var(--pink); transition: width 1s linear; }

.transport-icons.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.transport-icons.compact-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.refresh-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; border-radius: 14px; font-size: 1.2rem;
  color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.12); background: var(--panel-soft);
  cursor: pointer; transition: all 160ms; padding: 0;
}
.refresh-btn:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }

.shuffle-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1rem; border-radius: 14px; font-weight: 700;
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.12); background: var(--panel-soft);
  cursor: pointer; transition: all 160ms;
}
.shuffle-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.shuffle-btn.active { background: var(--tidal); border-color: var(--tidal); color: #000; }
.shuffle-icon { width: 22px; height: 22px; object-fit: contain; filter: brightness(0) invert(1); }
.shuffle-btn.active .shuffle-icon { filter: brightness(0); }
.shuffle-btn.active .shuffle-label { color: #000; }
.shuffle-label { font-size: 0.8rem; font-weight: 700; }

/* ── Up next ───────────────────────────────────────────────────────── */

.up-next { margin-top: 0.3rem; display: flex; flex-direction: column; gap: 0.3rem; }
.up-next-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.up-next-item { display: flex; align-items: center; gap: 0.5rem; }
.up-next-cover { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.up-next-info { min-width: 0; display: flex; flex-direction: column; gap: 0.05rem; }
.up-next-track { font-size: 0.78rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-next-artist { font-size: 0.68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Now playing bar (bottom, other rooms) ─────────────────────────── */

.now-playing-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--panel-strong); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  padding: 0.5rem 1rem; display: flex; justify-content: center; gap: 2.5rem; flex-wrap: wrap;
}
.now-playing-bar[hidden] { display: none; }

.npb-inner { display: flex; align-items: center; gap: 0.5rem; max-width: 360px; position: relative; padding-bottom: 8px; cursor: pointer; }
.npb-cover { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.npb-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.npb-track { font-size: 0.85rem; font-weight: 600; color: var(--npb-color, var(--text)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npb-meta { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npb-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; flex-shrink: 0; }
.npb-eq .eq-bar { width: 2.5px; background: var(--npb-color, var(--tidal)); }
.npb-progress-track { position: absolute; bottom: 0; left: 6px; right: 6px; height: 2px; background: rgba(255, 255, 255, 0.08); border-radius: 0 0 4px 4px; overflow: hidden; }
.npb-progress-fill { height: 100%; background: var(--npb-color, var(--tidal)); transition: width 1s linear; }
.npb-goto { flex-shrink: 0; padding: 0.3rem 0.75rem; border: none; border-radius: 12px; background: var(--npb-color, var(--tidal)); color: #000; font-size: 0.75rem; font-weight: 700; cursor: pointer; }

/* ── Back / Nav ────────────────────────────────────────────────────── */

.album-detail-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; position: relative; margin-bottom: 0.3rem; }

.back-btn { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; font-weight: 700; color: var(--tidal); background: none; border: none; padding: 0; }
.back-btn:hover { text-decoration: underline; transform: none; }

.add-album-btn {
  font-size: 0.78rem; font-weight: 700; color: var(--tidal); padding: 0.4rem 0.8rem;
  border: 1px solid rgba(0, 212, 170, 0.3); border-radius: 12px; background: rgba(0, 212, 170, 0.1);
  cursor: pointer; transition: all 160ms;
}
.add-album-btn:hover { background: rgba(0, 212, 170, 0.2); border-color: var(--tidal); transform: none; }

.nav-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.75rem; }
.nav-tab { padding: 0.45rem 0.85rem; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px; font-size: 0.8rem; font-weight: 700; color: var(--muted); transition: all 160ms; }
.nav-tab:hover:not(.active) { border-color: var(--line-strong); }
.nav-tab.active { background: var(--tidal); color: #000; border-color: var(--tidal); }

.section-title { margin: 0; color: var(--yellow); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.74rem; font-weight: 700; padding: 0.75rem 0 0.4rem; }

.muted-msg { color: var(--muted); font-size: 0.88rem; padding: 2rem 0; text-align: center; }

/* ── Grouping ──────────────────────────────────────────────────────── */

.group-toggle { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 700; background: none; border: none; padding: 0; }
.group-toggle input { accent-color: var(--orange); }
.group-options { display: grid; gap: 0.7rem; }
.group-option { display: flex; align-items: center; gap: 0.55rem; padding: 0.7rem 0.8rem; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.06); background: rgba(255, 255, 255, 0.03); }
.group-option input { accent-color: var(--violet); }
.group-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-top: 0.6rem; }

.play-all-btn {
  width: 100%; margin-top: auto; padding: 0.65rem 1rem; border-radius: 14px;
  background: var(--tidal); border: 1px solid transparent; color: #000;
  font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: all 160ms;
}
.play-all-btn:hover { box-shadow: 0 6px 16px rgba(0, 212, 170, 0.3); transform: translateY(-1px); }

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .speaker-layout { grid-template-columns: 1fr; grid-template-areas: "controls" "media" "now-playing"; }
  .device-list { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
  .device-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { width: min(100%, calc(100% - 1rem)); }
  .app-header, .speaker-card, .speaker-subcard { padding: 0.95rem; }
  .speaker-card-header, .subcard-header, .volume-meta, .group-actions { flex-direction: column; align-items: stretch; }
  .transport-icons { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .device-list { grid-template-columns: 1fr; }
  .playlist-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.6rem; }
}
