:root {
  color-scheme: dark;
  --font-display: "Geist", "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: var(--font-body);
  font-size: 16px;
  background: #080b10;
  color: #e8ecf1;
  --panel: rgba(15, 19, 27, 0.88);
  --panel-strong: rgba(20, 26, 35, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --text-muted: #aeb8c7;
  --green: #1ed760;
  --blue: #70a6ff;
  --warn: #ffca68;
  /* Shared corner radii — tokenized so cards/artwork stay visually consistent. */
  --radius-card: 14px;
  --radius-art: 10px;
  /* Elevation language — two resting depths so artwork/panels lift consistently
     and a focused card reads as raised toward the viewer. */
  --elev-1: 0 12px 28px rgba(0, 0, 0, 0.45);
  --elev-2: 0 22px 48px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #080b10;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Fine film grain for atmosphere + to break up flat gradient banding on big panels. */
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
input {
  font: inherit;
}

button {
  min-height: 56px;
  padding: 14px 20px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #e8ecf1;
  color: #070a0f;
  font-weight: 800;
}

button.primary {
  background: var(--green);
}

button.subdued {
  background: #202938;
  color: #e8ecf1;
}

[data-phone-only] {
  display: none;
}

.is-phone-pair [data-phone-only] {
  display: inline-block;
}

input {
  width: 100%;
  min-height: 58px;
  padding: 13px 16px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #101722;
  color: #e8ecf1;
}

.focusable {
  /* leave room under the sticky nav / page edges when scrollIntoView lands focus;
     horizontal margin matches the .app safe-area inset so focus never lands on an edge */
  scroll-margin: 96px 48px;
}

.focusable:focus,
.card:focus,
.device-card:focus,
.is-focused {
  outline: 3px solid var(--green);
  outline-offset: 3px;
  border-color: var(--green);
  box-shadow: 0 0 0 6px rgba(30, 215, 96, 0.18);
}

.focusable:focus:not(:focus-visible) {
  /* keep the TV ring; pointer users still see it on click — intentional for remote parity */
}

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(120deg, rgba(30, 215, 96, 0.13), transparent 34%),
    linear-gradient(300deg, rgba(112, 166, 255, 0.12), transparent 42%),
    #080b10;
}

.ambient-bg.has-artwork {
  background-position: center;
  background-size: cover;
  filter: saturate(1.1);
}

.ambient-bg.has-artwork::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.76);
  backdrop-filter: blur(22px);
}

.ambient-bg.skyline {
  background:
    linear-gradient(180deg, #08101f 0%, #172134 48%, #0a0d13 49%, #07090e 100%);
}

.ambient-bg.skyline::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42vh;
  background:
    linear-gradient(90deg, transparent 0 5%, #111722 5% 9%, transparent 9% 12%, #161d2a 12% 19%, transparent 19% 24%, #101724 24% 30%, transparent 30% 36%, #192233 36% 45%, transparent 45% 50%, #111824 50% 57%, transparent 57% 62%, #182032 62% 72%, transparent 72% 77%, #111824 77% 84%, transparent 84% 89%, #192233 89% 96%, transparent 96%),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.5));
}

.app {
  /* 10-foot safe area: inset ~48px L/R at 1080p so no focusable element rides a
     screen edge (overscan-safe). The min-width:2500px block widens this for 4K. */
  width: min(1840px, calc(100vw - 96px));
  margin: 0 auto;
  padding: 38px 0 56px;
}

/* === Exit confirmation dialog === */
.exit-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 4vw, 80px);
}

.exit-dialog[hidden] {
  display: none;
}

/* Solid scrim, not backdrop-filter: large blur is blocky + expensive on TV Blink. */
.exit-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.74);
  animation: exit-fade 200ms ease both;
}

.exit-dialog__panel {
  position: relative;
  width: min(560px, 100%);
  padding: 40px 44px 36px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-strong, #11161f);
  box-shadow: var(--elev-2);
  text-align: center;
  /* Compositor-only entrance — transform + opacity only for the TV GPU. */
  animation: exit-pop 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.exit-dialog__title {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.exit-dialog__body {
  margin: 0 0 28px;
  font-size: 1.12rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.exit-dialog__actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.exit-dialog__btn {
  min-width: 160px;
  padding: 14px 28px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecf1;
  font-family: var(--font-body);
  font-size: 1.12rem;
  font-weight: 700;
  cursor: pointer;
}

.exit-dialog__btn--danger {
  border-color: transparent;
  background: #e2424b;
  color: #fff;
}

@keyframes exit-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes exit-pop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.toast-stack {
  position: fixed;
  bottom: 36px;
  right: 28px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 48px));
  pointer-events: none;
}

body.has-pill .toast-stack {
  bottom: 116px;
}

.toast {
  padding: 12px 16px;
  border: 1px solid rgba(255, 97, 89, 0.32);
  border-left: 4px solid #ff6159;
  border-radius: 12px;
  background: rgba(12, 16, 24, 0.78);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  color: #e8ecf1;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.35;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.error {
  border-left-color: #ff6159;
  border-color: rgba(255, 97, 89, 0.32);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateX(20px);
}

@media (max-width: 900px) {
  .toast-stack {
    bottom: 24px;
    right: 16px;
    width: calc(100vw - 32px);
  }
  body.has-pill .toast-stack {
    bottom: 92px;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: inset 0 0 0 14px #07100a;
}

.eyebrow {
  margin: 0 0 7px;
  color: #9eddb5;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 2.4vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.015em;
}

h2 {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 2.6vw, 3.7rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
}

.shelf-title,
.settings-section__title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav,
.button-row,
.transport {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.nav-item {
  min-width: 116px;
  background: #141b27;
  color: #e8ecf1;
}

.nav-item.is-active {
  background: var(--green);
  color: #07100a;
}

.auth-panel,
.status-strip,
.diagnostics,
.now-layout {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) minmax(360px, 1fr);
  gap: 22px;
  align-items: center;
  margin-bottom: 18px;
  padding: 22px;
}

.auth-copy p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: #d9e0ea;
  font-weight: 800;
}

.pair-card {
  display: grid;
  grid-template-columns: 138px 1fr;
  gap: 18px;
  align-items: center;
  grid-column: 1 / -1;
}

.pair-card img {
  width: 138px;
  height: 138px;
  border-radius: 8px;
  background: #fff;
}

.pair-code {
  margin-bottom: 8px;
  color: #fff;
  font-size: 2.2rem;
  font-weight: 900;
}

.pair-url {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.status-strip {
  display: none;
  gap: 14px;
  margin-bottom: 22px;
  padding: 14px;
  color: #dce5ef;
}

body.debug-on .status-strip {
  display: flex;
}

.status-strip span {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.view {
  display: none;
  min-height: 55vh;
}

.view.is-visible {
  display: block;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 30px 0 16px;
}

/* De-boxed: structure comes from spacing + the two-tier header, not a panel. */
.shelf {
  min-height: 250px;
  margin-bottom: 30px;
  padding: 0;
}

/* Refresh affordance in the section-title header — icon + label pill, styled to
   match the rest of the elevated UI rather than the bare browser button. */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 22px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: #e8ecf1;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.refresh-btn__icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--green);
}

.refresh-btn__label {
  line-height: 1;
}

/* Two-tier header: small uppercase eyebrow over a larger title. */
.shelf-head {
  display: grid;
  gap: 3px;
  margin: 0 6px 14px;
}

.shelf-eyebrow {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.shelf-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2vw, 1.95rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.02;
}

/* Orchestrated entrance: the header and each shelf rise + fade in a quick
   stagger when Home/Library becomes visible. Compositor-only (transform +
   opacity); disabled under the reduced-motion guard below. */
@keyframes view-rise {
  from { opacity: 0; transform: translate3d(0, 12px, 0); }
  to   { opacity: 1; transform: none; }
}

#view-home.is-visible .section-title,
#view-home.is-visible .home-shelves .shelf,
#view-library.is-visible .section-title,
#view-library.is-visible .shelf {
  animation: view-rise 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

#view-home.is-visible .home-shelves .shelf:nth-child(1) { animation-delay: 40ms; }
#view-home.is-visible .home-shelves .shelf:nth-child(2) { animation-delay: 90ms; }
#view-home.is-visible .home-shelves .shelf:nth-child(3) { animation-delay: 140ms; }
#view-home.is-visible .home-shelves .shelf:nth-child(4) { animation-delay: 190ms; }

#view-library.is-visible .shelf:nth-child(2) { animation-delay: 40ms; }
#view-library.is-visible .shelf:nth-child(3) { animation-delay: 90ms; }
#view-library.is-visible .shelf:nth-child(4) { animation-delay: 140ms; }

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(210px, 260px);
  gap: 22px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-padding-inline: 18px;
  /* Generous inset so the focus ring + scale(1.06) of edge cards isn't clipped by
     the scroll container (overflow-x:auto forces overflow-y:auto, clipping top/bottom too).
     The 22px gap reserves enough gutter that a focused, enlarged card never overlaps neighbours. */
  padding: 20px 18px 28px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.card {
  min-height: 320px;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-card);
  background: transparent;
  color: #e8ecf1;
  text-align: left;
  /* TV-safe: animate only transform/opacity. */
  transition: transform 200ms ease;
}

.card:focus,
.card.is-focused {
  transform: scale(1.06);
}

.card img {
  width: 100%;
  height: 232px;
  object-fit: cover;
  border-radius: var(--radius-art);
  background: #111824;
  /* Resting-state affordance: a hairline frame + faint inner highlight so each tile
     reads as a selectable surface even before the green focus ring lands on it.
     Artwork can blend into the dark backdrop otherwise. */
  box-shadow:
    var(--elev-1),
    0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transition: box-shadow 200ms ease;
}

.card:focus img,
.card.is-focused img {
  box-shadow:
    var(--elev-2),
    0 0 0 1px rgba(255, 255, 255, 0.22);
}

.card-title {
  display: -webkit-box;
  min-height: 2.7em;
  margin: 14px 2px 4px;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-family: var(--font-display);
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.card-subtitle {
  display: -webkit-box;
  margin: 0 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.now-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.7fr) 1fr;
  gap: 34px;
  padding: 28px;
}

.art-frame {
  width: 100%;
  max-width: 700px;
  align-self: center;
}

.art-frame img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #111824;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.now-meta {
  align-self: center;
}

.now-meta h2 {
  margin-bottom: 12px;
  font-size: clamp(2.8rem, 5vw, 6rem);
}

.now-meta p {
  color: var(--text-muted);
  font-size: 1.4rem;
}

.progress {
  height: 12px;
  margin: 36px 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 26px;
  color: #d3dbe7;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.device-card {
  min-height: 150px;
  padding: 18px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: var(--panel-strong);
  color: #e8ecf1;
  text-align: left;
}

.device-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.ambient-view {
  --ambient-accent-a: #1ed760;
  --ambient-accent-b: #70a6ff;
  --ambient-accent-c: #ffca68;
  --ambient-art-url: none;
}

/* Ambient is a permanent full-bleed room display (no fullscreen toggle). When
   active we kill any chrome behind the fixed stage — nav, ambient-bg, the pill,
   and any side/bottom padding on .app — so nothing can leak as a bar at the edge. */
body[data-view="ambient"] .nav,
body[data-view="ambient"] .ambient-bg,
body[data-view="ambient"] .np-pill {
  display: none !important;
}

body[data-view="ambient"] {
  /* Hard scroll lock so nothing in .app can scroll out from behind the fixed
     stage and leak a strip of background colour at the viewport edge. */
  overflow: hidden;
  height: 100vh;
}

body[data-view="ambient"] .app {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0 !important;
  overflow: hidden;
}

.ambient-view.is-visible {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #04060b;
}

.ambient-stage {
  /* Parent .ambient-view.is-visible is position:fixed inset:0, so making the
     stage absolute+inset:0 fills the same viewport box without the TV renderer
     having to reconcile two stacked fixed elements (which leaked a bottom bar
     on VIDAA). The stage's absolute-positioned children — controls, scene-np
     card, scrim — continue to work because the stage is their containing block. */
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 0;
  isolation: isolate;
  background: linear-gradient(135deg, #060912, #0c111c 48%, #05080d);
}

.ambient-stage > .ambient-room,
.ambient-stage > .ambient-screensaver,
.ambient-stage > .ambient-visualizer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

.ambient-stage[data-mode="room"] > .ambient-room,
.ambient-stage[data-mode="screensaver"] > .ambient-screensaver,
.ambient-stage[data-mode="visualizer"] > .ambient-visualizer {
  opacity: 1;
}

/* === Room mode: blurred album backdrop + dark scrim, clean centered card === */
.ambient-room {
  background: #06080e;
}

.ambient-room::before {
  content: "";
  position: absolute;
  inset: -8%;
  background-image: var(--ambient-art-url);
  background-size: cover;
  background-position: center;
  filter: blur(44px) saturate(1.3) brightness(0.62);
  transform: scale(1.12);
}

.ambient-room__scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(0, 0, 0, 0.86) 0%, rgba(0, 0, 0, 0.58) 42%, rgba(0, 0, 0, 0.22) 72%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.55), transparent 38%);
}

.ambient-stage[data-mode="room"]:not(.has-artwork) .ambient-room::before {
  display: none;
}

.ambient-stage[data-mode="room"]:not(.has-artwork) .ambient-room {
  /* Fallback first: old VIDAA Blink can't parse color-mix() and drops the whole
     declaration, so without this the panel would render flat near-black. The
     rgba tints match the default green/blue accents used in this no-artwork state. */
  background:
    radial-gradient(circle at 30% 24%, rgba(30, 215, 96, 0.28), transparent 46%),
    radial-gradient(circle at 74% 78%, rgba(112, 166, 255, 0.24), transparent 48%),
    #06080e;
  background:
    radial-gradient(circle at 30% 24%, color-mix(in oklab, var(--ambient-accent-a) 28%, transparent), transparent 46%),
    radial-gradient(circle at 74% 78%, color-mix(in oklab, var(--ambient-accent-b) 24%, transparent), transparent 48%),
    #06080e;
}

.ambient-room-art {
  margin: 0;
  flex-shrink: 0;
  width: 46vh;
  max-width: 44vw;
  aspect-ratio: 1;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(135deg, #1a2231, #0c111b);
  box-shadow:
    0 54px 140px rgba(0, 0, 0, 0.66),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transform: rotate(-1.4deg);
}

.ambient-room-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ambient-stage:not(.has-artwork) .ambient-room-art img {
  opacity: 0;
}

/* === Screensaver mode === */
.ambient-screensaver {
  /* Fallback first (see .ambient-room note): keeps a tinted wash on TV Blink. */
  background:
    radial-gradient(circle at 20% 80%, rgba(112, 166, 255, 0.26) 0%, transparent 42%),
    radial-gradient(circle at 80% 20%, rgba(30, 215, 96, 0.22) 0%, transparent 42%),
    #04060b;
  background:
    radial-gradient(circle at 20% 80%, color-mix(in oklab, var(--ambient-accent-b) 26%, transparent) 0%, transparent 42%),
    radial-gradient(circle at 80% 20%, color-mix(in oklab, var(--ambient-accent-a) 22%, transparent) 0%, transparent 42%),
    #04060b;
}

.drift {
  position: absolute;
  width: 60vw;
  height: 60vw;
  max-width: 980px;
  max-height: 980px;
  background-image: var(--ambient-art-url);
  background-size: cover;
  background-position: center;
  border-radius: 18px;
  filter: blur(40px) saturate(1.3);
  opacity: 0.32;
  will-change: transform;
}

.drift--a {
  top: -14vw;
  left: -12vw;
  animation: drift-a 220s ease-in-out infinite alternate;
}
.drift--b {
  bottom: -16vw;
  right: -10vw;
  width: 52vw;
  height: 52vw;
  opacity: 0.22;
  animation: drift-b 260s ease-in-out infinite alternate;
}
.drift--c {
  top: 30%;
  left: 40%;
  width: 38vw;
  height: 38vw;
  opacity: 0.18;
  animation: drift-c 300s ease-in-out infinite alternate;
}
.drift--d {
  bottom: 20%;
  left: -8vw;
  width: 42vw;
  height: 42vw;
  opacity: 0.14;
  animation: drift-d 340s ease-in-out infinite alternate;
}

@keyframes drift-a { 0%{transform:translate3d(0,0,0)} 100%{transform:translate3d(14vw,8vw,0)} }
@keyframes drift-b { 0%{transform:translate3d(0,0,0)} 100%{transform:translate3d(-12vw,-10vw,0)} }
@keyframes drift-c { 0%{transform:translate3d(0,0,0) scale(1)} 100%{transform:translate3d(-8vw,6vw,0) scale(1.1)} }
@keyframes drift-d { 0%{transform:translate3d(0,0,0) scale(0.95)} 100%{transform:translate3d(10vw,-6vw,0) scale(1.08)} }

.ambient-stage[data-mode="screensaver"]:not(.has-artwork) .drift {
  background-image: none;
  /* Fallback first (see .ambient-room note). */
  background: linear-gradient(135deg, rgba(30, 215, 96, 0.5), rgba(112, 166, 255, 0.5));
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--ambient-accent-a) 50%, transparent),
    color-mix(in oklab, var(--ambient-accent-b) 50%, transparent));
}

/* === Scene now-playing card ===
   A real mini player floating top-right of the Scene view: art + title/artist,
   progress, and transport controls so the user can manage music without leaving
   Scene. Uses solid surfaces (no big backdrop-filter) for the TV GPU. */
.scene-np {
  position: absolute;
  top: 48px;
  right: 48px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(440px, 38vw);
  padding: 18px 20px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(8, 11, 18, 0.72);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5);
}

.scene-np__row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.scene-np__art {
  flex-shrink: 0;
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: #111824;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.scene-np__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scene-np__meta {
  min-width: 0;
  flex: 1;
}

.scene-np__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 800;
  color: #e8ecf1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-np__artist {
  margin: 4px 0 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-np__progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scene-np__track {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.scene-np__fill {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 800ms linear;
}

.scene-np__time {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(232, 236, 241, 0.85);
  font-variant-numeric: tabular-nums;
}

.scene-np__status {
  display: none;
  margin: 4px 0 0;
  padding: 4px 10px;
  border-radius: 999px;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* The audio-strip badge is a diagnostic — only show it in Debug View. */
body.debug-on .scene-np__status {
  display: inline-flex;
}

.scene-np__status[data-state="idle"]   { background: rgba(255,255,255,0.08); color: rgba(232,236,241,0.85); }
.scene-np__status[data-state="strip"]  { background: rgba(30,215,96,0.18);   color: #6fe49a; }
.scene-np__status[data-state="plain"]  { background: rgba(255,200,60,0.18);  color: #ffd97a; }
.scene-np__status[data-state="error"]  { background: rgba(255,80,80,0.18);   color: #ff9a9a; }


/* === Visualizer mode === */
.ambient-visualizer {
  background:
    radial-gradient(circle at 50% 50%, rgba(20, 28, 44, 0.5), transparent 60%),
    linear-gradient(180deg, #04060b, #06090f);
}

.ambient-visualizer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ambient-visualizer__art {
  position: absolute;
  top: 50%;
  left: 50%;
  /* aspect-ratio is weakly supported on the VIDAA browser, so the circle is
     sized with explicit px width + height instead. clamp keeps it responsive
     between 720p and 1080p without relying on aspect-ratio. */
  width: clamp(280px, 34vw, 540px);
  height: clamp(280px, 34vw, 540px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  overflow: visible;
  z-index: 2;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

/* The pulsing ring is a pseudo-element animated with transform + opacity only
   (compositor-only). The original animated box-shadow spread + color-mix(), both
   of which the VIDAA browser cannot render — box-shadow animation janks the GPU
   and an unsupported color-mix() drops the whole declaration. A solid rgba ring
   that scales/fades avoids both problems. */
.ambient-visualizer__art::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(30, 215, 96, 0.5);
  /* Use the accent when it resolves; the rgba above is the guaranteed fallback. */
  border-color: var(--ambient-accent-a, rgba(30, 215, 96, 0.5));
  opacity: 0.5;
  pointer-events: none;
  will-change: transform, opacity;
  animation: pulse-ring 1.8s ease-in-out infinite;
}

.ambient-visualizer__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.ambient-stage[data-mode="visualizer"]:not(.has-artwork) .ambient-visualizer__art {
  background: linear-gradient(135deg, var(--ambient-accent-a), var(--ambient-accent-b));
}

.ambient-stage[data-mode="visualizer"]:not(.has-artwork) .ambient-visualizer__art img {
  opacity: 0;
}

@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: 0.5; }
  50%  { transform: scale(1.2); opacity: 0; }
  100% { transform: scale(1); opacity: 0.5; }
}

.ambient-stage[data-mode="visualizer"] .ambient-content,
.ambient-stage[data-mode="visualizer"] .ambient-progress {
  display: none;
}

/* === Content overlay (room only) — asymmetric gallery wall === */
.ambient-content {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(36px, 6vw, 88px);
  padding: 6vh clamp(48px, 7vw, 110px) 16vh;
  text-align: left;
  font-family: var(--font-display);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}

.ambient-room-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  /* No outer cap — text children carry their own max-widths so the progress bar
     can stretch to its intended ~960px on a 4K TV without being clipped. */
  flex: 1;
}

.ambient-room-meta .eyebrow,
.ambient-room-meta > p:not(.eyebrow) {
  max-width: 46ch;
}

.ambient-stage[data-mode="screensaver"] .ambient-content {
  display: none;
}

.ambient-content .eyebrow {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.32em;
  /* Fallback first: a light green approximating green mixed 64% with white, so
     the eyebrow stays legible where color-mix() is unsupported (TV Blink). */
  color: #8fe7ad;
  color: color-mix(in oklab, var(--ambient-accent-a) 64%, white);
}

.ambient-content h2 {
  margin: 0;
  font-size: clamp(3rem, 6vw, 6.5rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.02em;
  text-wrap: balance;
  max-width: 14ch;
}

.ambient-content p:not(.eyebrow) {
  margin: 0;
  color: #d9e0ea;
  font-family: var(--font-body);
  font-size: clamp(1.1rem, 1.8vw, 1.7rem);
  font-weight: 600;
}

/* Sized in vw clamps so the bar is substantial on a 4K 65" TV but still
   reasonable on smaller screens. The room title above is clamp(3rem,6vw,6.5rem)
   so the bar needs visual weight to belong to it. */
.ambient-progress {
  display: flex;
  align-items: center;
  gap: clamp(20px, 1.8vw, 36px);
  margin-top: clamp(16px, 1.6vw, 30px);
  width: min(960px, 100%);
  font-family: var(--font-body);
  font-style: normal;
}

.ambient-progress__track {
  position: relative;
  flex: 1;
  height: clamp(18px, 1.4vw, 30px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.32);
  overflow: visible;
}

.ambient-progress__fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: #1ed760;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.26),
    0 0 22px rgba(30, 215, 96, 0.5);
}

.ambient-progress__fill::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: clamp(28px, 2.4vw, 44px);
  height: clamp(28px, 2.4vw, 44px);
  transform: translate(50%, -50%);
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.55),
    0 0 0 3px rgba(30, 215, 96, 0.55);
}

.ambient-progress__time {
  font-size: clamp(1.3rem, 1.6vw, 2.1rem);
  font-weight: 700;
  color: #f2f5f9;
  font-variant-numeric: tabular-nums;
  padding: clamp(8px, 0.7vw, 14px) clamp(18px, 1.4vw, 28px);
  border-radius: 999px;
  background: rgba(6, 8, 13, 0.6);
  letter-spacing: 0.02em;
}

.ambient-controls {
  position: absolute;
  left: 56px;
  right: 56px;
  bottom: 40px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  opacity: 1;
  transition: opacity 320ms ease;
}

.ambient-controls.is-dim {
  opacity: 0.18;
}

.ambient-controls.is-dim .focusable:focus,
.ambient-controls.is-dim:focus-within {
  opacity: 1;
}

.ambient-controls:focus-within {
  opacity: 1;
}

button.is-active {
  background: var(--green);
  color: #07100a;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.log {
  display: flex;
  flex-direction: column-reverse;
  gap: 7px;
  max-height: 320px;
  margin: 0;
  padding: 6px;
  overflow: auto;
  list-style: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.log__hint {
  margin: 14px 0 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.log li {
  padding: 9px 11px;
  border-left: 4px solid var(--blue);
  background: #101722;
  color: #dce4ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.log li.error {
  border-left-color: #ff6159;
}

.log li.success {
  border-left-color: var(--green);
}

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

@media (min-width: 2500px) {
  :root {
    font-size: 20px;
  }

  .app {
    width: min(3440px, calc(100vw - 140px));
    padding-top: 58px;
  }

  .rail {
    grid-auto-columns: minmax(290px, 360px);
  }

  .card img {
    height: 320px;
  }

  button {
    min-height: 70px;
  }
}

@media (max-width: 900px) {
  .app {
    width: min(100vw - 28px, 900px);
    padding-top: 22px;
  }

  .topbar,
  .auth-panel,
  .now-layout {
    display: block;
  }

  .nav {
    margin-top: 18px;
  }

  .pair-card {
    margin-top: 18px;
  }
}

/* === Reserve space for the floating NP pill === */
body.has-pill .app {
  padding-bottom: 124px;
}

/* === Floating now-playing pill === */
.np-pill {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(880px, calc(100vw - 80px));
  padding: 6px 12px 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.78);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  transition: opacity 240ms ease, transform 240ms ease;
}

.np-pill[hidden] {
  display: none;
}

.np-pill.is-dim {
  opacity: 0.55;
}

.np-pill.is-dim .np-pill__controls {
  opacity: 0.45;
}

.np-pill:hover,
.np-pill:focus-within {
  opacity: 1;
}

.np-pill:focus-within .np-pill__controls {
  opacity: 1;
}

.np-pill__open {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.np-pill__art {
  display: block;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #111824;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.np-pill__expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.np-pill__expand svg {
  width: 20px;
  height: 20px;
}

.np-pill__open:focus .np-pill__expand,
.np-pill__open:hover .np-pill__expand {
  color: #e8ecf1;
  background: rgba(30, 215, 96, 0.18);
}

.np-pill__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.np-pill__meta {
  display: block;
  flex: 1;
  min-width: 0;
}

.np-pill__title {
  display: block;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #e8ecf1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-pill__artist {
  display: block;
  margin: 2px 0 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-pill__progress {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.np-pill__progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 800ms linear;
}

.np-pill__time {
  display: block;
  margin: 4px 0 0;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(232, 236, 241, 0.9);
  font-variant-numeric: tabular-nums;
}

/* Make it unmistakable when the remote lands on the pill: it lifts, glows, and
   the chevron flips to an accent so the user knows Enter opens Now Playing. */
.np-pill__open:focus-visible,
.np-pill__open:focus {
  outline: none;
  border-color: var(--green);
  background: rgba(30, 215, 96, 0.12);
}

.np-pill:focus-within {
  transform: translateX(-50%) translateY(-4px);
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.66),
    0 0 0 2px var(--green);
}

.np-pill__open:focus .np-pill__expand {
  transform: translateY(2px);
  color: #07100a;
  background: var(--green);
}

.np-pill__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 240ms ease;
}

.np-pill__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: #e8ecf1;
}

.np-pill__btn svg {
  width: 20px;
  height: 20px;
}

.np-pill__btn--primary {
  background: var(--green);
  color: #07100a;
  width: 48px;
  height: 48px;
  min-height: 48px;
}

.np-pill__btn--primary svg {
  width: 24px;
  height: 24px;
}

/* Shuffle/repeat are secondary toggles — smaller than the transport buttons, and
   when on they get an accent ring/tint (reserve the solid green fill for play). */
.np-pill__btn--toggle {
  width: 36px;
  height: 36px;
  min-height: 36px;
}

.np-pill__btn--toggle svg {
  width: 18px;
  height: 18px;
}

.np-pill__btn--toggle svg {
  width: 20px;
  height: 20px;
}

.np-pill__btn.is-active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(30, 215, 96, 0.16);
}

.np-pill__btn--repeat {
  position: relative;
}

@media (max-width: 900px) {
  .np-pill {
    bottom: 16px;
    gap: 12px;
    padding: 10px 14px 10px 10px;
    width: calc(100vw - 24px);
  }

  .np-pill__btn { width: 44px; height: 44px; min-height: 44px; }
  .np-pill__btn--toggle { width: 38px; height: 38px; min-height: 38px; }
  .np-pill__btn--primary { width: 50px; height: 50px; min-height: 50px; }
  .np-pill__controls { gap: 6px; }
}

/* === Settings section + debug toggle === */
.settings-section {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.settings-section__title {
  margin: 0 0 14px;
  font-size: 1.6rem;
}

.settings-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 22px;
  row-gap: 4px;
  align-items: center;
  width: 100%;
  min-height: 80px;
  padding: 18px 22px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: #141b27;
  color: #e8ecf1;
  text-align: left;
}

.settings-toggle[aria-checked="true"] {
  background: rgba(30, 215, 96, 0.12);
  border-color: rgba(30, 215, 96, 0.4);
}

.settings-toggle__label {
  font-size: 1.2rem;
  font-weight: 900;
  grid-column: 1;
}

.settings-toggle__hint {
  grid-column: 1;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.settings-toggle__state {
  grid-row: 1 / span 2;
  grid-column: 2;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.settings-toggle[aria-checked="true"] .settings-toggle__state {
  background: var(--green);
  color: #07100a;
}

/* === Debug diagnostics overlay (when body.debug-on) === */
.diagnostics {
  margin-top: 28px;
  padding: 18px;
}

.diagnostics__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 16px;
}

.diagnostics__col dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
  row-gap: 4px;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.diagnostics__col dt {
  color: var(--text-muted);
}

.diagnostics__col dd {
  margin: 0;
  color: #e8ecf1;
  overflow-wrap: anywhere;
}

.diagnostics__col dd.imgseq-err {
  color: #ff8a8a;
}

.diagnostics__col output {
  display: block;
  padding: 10px;
  border-radius: 6px;
  background: #0a0f17;
  color: #d3dbe7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

body.debug-on .diagnostics {
  position: fixed;
  top: 80px;
  right: 24px;
  bottom: 130px;
  z-index: 25;
  width: min(420px, calc(100vw - 48px));
  margin: 0;
  background: rgba(8, 11, 16, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow-y: auto;
  border: 1px solid rgba(30, 215, 96, 0.3);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

body.debug-on .diagnostics .log {
  max-height: none;
}

/* === Phone pair-auth screen (mobile-first, capped on larger displays) === */
.phone-pair {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(env(safe-area-inset-top, 0px), 28px) 20px max(env(safe-area-inset-bottom, 0px), 24px);
  background:
    radial-gradient(circle at 20% 0%, rgba(30, 215, 96, 0.18), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(112, 166, 255, 0.14), transparent 55%),
    #060a12;
  color: #e8ecf1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.is-phone-pair .phone-pair {
  display: flex;
}

body.is-phone-pair .app,
body.is-phone-pair .ambient-bg,
body.is-phone-pair .toast-stack,
body.is-phone-pair .np-pill,
body.is-phone-pair .diagnostics {
  display: none !important;
}

body.is-phone-pair {
  overflow: hidden;
  background: #060a12;
}

.phone-pair__card {
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: 28px 22px 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: rgba(10, 14, 22, 0.7);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.phone-pair__icon {
  width: 56px !important;
  height: 56px !important;
  margin: 0 auto 18px;
  display: block;
  border-radius: 50%;
}

.phone-pair__panel,
.phone-pair__connecting,
.phone-pair__success,
.phone-pair__error {
  display: none;
}

.phone-pair[data-state="ready"] .phone-pair__panel,
.phone-pair[data-state="connecting"] .phone-pair__connecting,
.phone-pair[data-state="success"] .phone-pair__success,
.phone-pair[data-state="error"] .phone-pair__error {
  display: block;
}

.phone-pair__eyebrow {
  margin: 0 0 10px;
  color: #9eddb5;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.phone-pair__heading {
  margin: 0 0 10px;
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.phone-pair__lede {
  margin: 0 0 22px;
  color: #b6c0cf;
  font-size: 0.96rem;
  line-height: 1.45;
}

.phone-pair__code {
  display: grid;
  gap: 6px;
  margin: 0 0 22px;
  padding: 14px 16px;
  border: 1px solid rgba(30, 215, 96, 0.32);
  border-radius: 14px;
  background: rgba(30, 215, 96, 0.06);
}

.phone-pair__code-label {
  color: #9eddb5;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.phone-pair__code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 0.32em;
  color: #ffffff;
  padding-left: 0.18em;
}

.phone-pair__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 14px 22px;
  border: none;
  border-radius: 999px;
  background: var(--green);
  color: #07100a;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(30, 215, 96, 0.22);
  transition: transform 140ms ease, background 140ms ease;
}

.phone-pair__cta:active {
  transform: scale(0.985);
  background: #25ee6c;
}

.phone-pair__cta:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.phone-pair__cta-mark {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.phone-pair__hint {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.phone-pair__spinner {
  width: 52px;
  height: 52px;
  margin: 4px auto 22px;
  border-radius: 50%;
  border: 4px solid rgba(30, 215, 96, 0.18);
  border-top-color: var(--green);
  animation: phone-pair-spin 900ms linear infinite;
}

@keyframes phone-pair-spin {
  to { transform: rotate(360deg); }
}

.phone-pair__statemark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.phone-pair__statemark svg {
  width: 30px;
  height: 30px;
}

.phone-pair__statemark--ok {
  background: rgba(30, 215, 96, 0.18);
  color: var(--green);
}

.phone-pair__statemark--err {
  background: rgba(255, 97, 89, 0.16);
  color: #ff8a82;
}

.phone-pair__state-heading {
  margin: 0 0 10px;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.phone-pair__state-body {
  margin: 0;
  color: #b6c0cf;
  font-size: 0.96rem;
  line-height: 1.45;
}

.phone-pair__foot {
  width: 100%;
  max-width: 360px;
  margin: 16px auto 0;
  color: rgba(174, 184, 199, 0.55);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-align: center;
}

/* Cap the card on bigger screens (someone testing on a tablet/desktop) */
@media (min-width: 600px) {
  .phone-pair {
    padding: 56px 24px;
  }
  .phone-pair__card {
    max-width: 400px;
    padding: 36px 28px 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .phone-pair__spinner {
    animation-duration: 2.4s;
  }
  .phone-pair__cta {
    transition: none;
  }
}

/* === Iconified transport (Now Playing + Ambient) === */
.transport--icons {
  gap: 18px;
  margin-top: 10px;
}

.transport-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  min-height: 64px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecf1;
  transition: transform 140ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.transport-btn svg {
  width: 26px;
  height: 26px;
}

.transport-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.transport-btn--primary {
  width: 84px;
  height: 84px;
  min-height: 84px;
  border-color: transparent;
  background: var(--green);
  color: #07100a;
  box-shadow: 0 16px 38px rgba(30, 215, 96, 0.32);
}

.transport-btn--primary svg {
  width: 34px;
  height: 34px;
}

/* shuffle / repeat active: tinted accent ring, not a full fill (reserve that for play) */
.transport-btn.is-active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(30, 215, 96, 0.16);
}

.transport-btn--primary.is-active {
  color: #07100a;
  background: var(--green);
}

.transport-btn__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--green);
  color: #07100a;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.transport-btn__badge[hidden] {
  display: none;
}

/* === Ambient control cluster === */
.ambient-controls {
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.ambient-controls__modes,
.ambient-controls__transport,
.ambient-controls__scene {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

/* Scene category + skip controls — only relevant while Scene mode is active. */
.ambient-controls__scene {
  display: none;
}

.ambient-stage[data-mode="screensaver"] .ambient-controls__scene {
  display: flex;
}

.scene-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 10px 22px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.55);
  color: #e8ecf1;
  font-weight: 700;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 140ms ease, background 160ms ease, border-color 160ms ease;
}

.scene-btn:hover {
  background: rgba(20, 26, 38, 0.7);
}

.scene-btn svg {
  width: 22px;
  height: 22px;
}

.scene-btn__label {
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

/* Segmented Nature/City toggle — a single pill split into two flip-between halves. */
.scene-toggle {
  display: inline-flex;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.scene-seg {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px 20px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(232, 236, 241, 0.74);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.scene-seg:hover {
  color: #e8ecf1;
}

.scene-seg.is-active {
  background: var(--green);
  color: #07100a;
}

.scene-seg__icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.ambient-mode-btn {
  min-height: 50px;
  padding: 10px 24px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.55);
  color: #e8ecf1;
  font-weight: 700;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ambient-mode-btn.is-active {
  background: var(--green);
  border-color: transparent;
  color: #07100a;
}

.ambient-controls__transport .transport-btn {
  width: 56px;
  height: 56px;
  min-height: 56px;
}

.ambient-controls__transport .transport-btn svg {
  width: 22px;
  height: 22px;
}

.ambient-controls__transport .transport-btn--primary {
  width: 68px;
  height: 68px;
  min-height: 68px;
}

.ambient-controls__transport .transport-btn--primary svg {
  width: 28px;
  height: 28px;
}

/* === Screensaver video scenery === */
/* A/B crossfade: both clips are stacked; the one matching data-active fades in.
   We animate opacity only (TV-safe) so the swap is seamless. */
.ambient-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 800ms ease;
}

.ambient-screensaver[data-video="on"][data-active="a"] .ambient-video:not(.ambient-video--b),
.ambient-screensaver[data-video="on"][data-active="b"] .ambient-video--b {
  opacity: 1;
}

/* Image-sequence renderer (only shown when data-video="imgseq"). It overlays the
   video elements; data-mode swap keeps just one path visible at a time. */
.ambient-imgseq {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 600ms ease;
}

.ambient-screensaver[data-video="imgseq"] .ambient-imgseq {
  opacity: 1;
}

/* Hide the <video> elements completely when image-sequence is the active
   renderer so they never engage the firmware's video pipeline. */
.ambient-screensaver[data-video="imgseq"] .ambient-video {
  display: none;
}

.ambient-video__scrim {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 800ms ease;
  background: linear-gradient(180deg, rgba(4, 6, 11, 0.4) 0%, transparent 28%, transparent 58%, rgba(4, 6, 11, 0.72) 100%);
}

.ambient-screensaver[data-video="on"] .ambient-video__scrim {
  opacity: 1;
}

/* When real scenery is playing, retire the generative drift fallback. */
.ambient-screensaver[data-video="on"] .drift {
  opacity: 0;
  transition: opacity 800ms ease;
}

/* === Cinematic full-screen Now Playing === */
.view-now.is-visible {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: clamp(28px, 4vw, 80px);
  animation: now-enter 460ms cubic-bezier(0.22, 1, 0.36, 1);
}

.now-backdrop {
  position: absolute;
  inset: -14%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-color: #06080d;
  /* Heavy blur + scale smears the art into a smooth colour wash instead of the
     chunky, over-saturated blobs a light blur leaves on a large surface. The big
     scale/inset keeps the blurred edges off-screen. */
  transform: scale(1.32);
  filter: blur(64px) saturate(0.92) brightness(0.5);
}

.now-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Radial centre-out darkening + a vertical wash for depth so text stays readable
     and the colour stays calm rather than muddy. */
  background:
    radial-gradient(130% 100% at 50% 26%, rgba(6, 8, 13, 0.3), rgba(6, 8, 13, 0.86) 78%),
    linear-gradient(180deg, rgba(6, 8, 13, 0.34) 0%, rgba(6, 8, 13, 0.18) 46%, rgba(6, 8, 13, 0.6) 100%);
}

.view-now .now-layout {
  position: relative;
  z-index: 1;
  width: min(1840px, 100%);
  padding: 0;
  border: none;
  background: transparent;
  animation: now-rise 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.now-back {
  position: absolute;
  top: clamp(20px, 3vw, 40px);
  left: clamp(20px, 3vw, 40px);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 22px 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.5);
  color: #e8ecf1;
  font-weight: 700;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.now-back svg {
  width: 22px;
  height: 22px;
}

@keyframes now-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes now-rise {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}

/* === Collection detail (album / playlist) === */
.view-collection.is-visible {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: clamp(28px, 4vw, 80px);
  animation: now-enter 460ms cubic-bezier(0.22, 1, 0.36, 1);
}

.collection-backdrop {
  position: absolute;
  inset: -8%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-color: #06080d;
  transform: scale(1.16);
  /* Blur the image element directly (not backdrop-filter) — TV browsers
     render element filters far more smoothly than backdrop-filter, which
     comes out blocky/banded on the VIDAA GPU. */
  filter: blur(30px) saturate(1.2) brightness(0.56);
}

.collection-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    rgba(6, 8, 13, 0.74) 0%,
    rgba(6, 8, 13, 0.42) 48%,
    rgba(6, 8, 13, 0.7) 100%
  );
}

.collection-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(300px, 0.62fr) 1fr;
  gap: clamp(28px, 4vw, 64px);
  width: min(1840px, 100%);
  animation: now-rise 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.collection-head {
  position: sticky;
  top: clamp(28px, 4vw, 80px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 18px);
}

.collection-art {
  width: 100%;
  /* Bound art by viewport height so the whole head (art + title + buttons)
     fits on screen — otherwise the sticky head outgrows the viewport and the
     Play/Shuffle buttons get pinned below the fold (worse with TV overscan). */
  max-width: min(420px, 34vh);
}

.collection-art img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: #111824;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.collection-head .eyebrow {
  margin: 8px 0 0;
}

.collection-head h2 {
  margin-bottom: 4px;
  font-size: clamp(1.9rem, 2.6vw, 3.1rem);
  line-height: 1.05;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.collection-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 600;
}

.collection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.collection-play,
.collection-shuffle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 14px 28px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.collection-play svg,
.collection-shuffle svg {
  width: 22px;
  height: 22px;
}

.collection-play {
  border: none;
  background: var(--green);
  color: #07120a;
}

.collection-shuffle {
  border: 2px solid var(--line);
  background: rgba(12, 16, 24, 0.6);
  color: #e8ecf1;
}

.collection-shuffle.is-active {
  border-color: var(--green);
  background: rgba(30, 215, 96, 0.16);
  color: #c8f7d8;
}

.collection-shuffle__state {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.collection-tracks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.collection-track {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  min-height: 64px;
  padding: 10px 18px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: #e8ecf1;
  text-align: left;
}

.collection-track:hover {
  background: rgba(255, 255, 255, 0.07);
}

.collection-track__index {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 24px;
}

.collection-track__num {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.collection-track__eq {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}

.collection-track__eq i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  transform-origin: bottom;
  animation: collection-eq 900ms ease-in-out infinite;
}

.collection-track__eq i:nth-child(2) { animation-delay: 220ms; }
.collection-track__eq i:nth-child(3) { animation-delay: 440ms; }

@keyframes collection-eq {
  0%, 100% { transform: scaleY(0.35); }
  50%      { transform: scaleY(1); }
}

/* Playlists carry per-track art, so the index cell becomes a 48px thumbnail with
   the eq bars overlaid (with a scrim) while that track plays. */
.collection-track__index--art {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background-color: #111824;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.collection-track__index--art .collection-track__eq {
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(4, 6, 10, 0.55);
}

.collection-track__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.collection-track__title {
  overflow: hidden;
  font-size: 1.16rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.collection-track__artist {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 1rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.collection-track__time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 1.02rem;
}

.collection-track.is-playing {
  border-color: rgba(30, 215, 96, 0.5);
  background: rgba(30, 215, 96, 0.1);
}

.collection-track.is-playing .collection-track__title {
  color: var(--green);
}

.collection-track.is-playing .collection-track__num {
  display: none;
}

.collection-track.is-playing .collection-track__eq {
  display: flex;
}

.collection-track.is-paused .collection-track__eq i {
  animation-play-state: paused;
}

.collection-note {
  margin: 0;
  padding: 20px 4px;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.collection-note--error {
  color: var(--warn);
}

/* === Shelf placeholder cards (loading / empty / error) === */
/* The artwork .card is de-boxed/transparent; text-only state cards re-add a
   panel so they stay legible without an image. */
.card--placeholder,
.card--retry {
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.card--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 1.02rem;
  font-weight: 600;
  text-align: center;
  cursor: default;
}

.card--loading {
  animation: card-pulse 1.4s ease-in-out infinite;
}

@keyframes card-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

.card--error {
  border-color: rgba(255, 202, 104, 0.4);
  color: var(--warn);
}

.card--retry {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  border-color: var(--green);
  color: var(--green);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

/* === Signed-out hero (minimal) === */
.signed-out {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: min(48vh, 460px);
  padding: clamp(28px, 5vh, 56px) clamp(24px, 6vw, 80px);
  text-align: center;
}

.signed-out[hidden] {
  display: none;
}

.signed-out__glow {
  display: none;
}

.signed-out__mark {
  display: grid;
  place-items: center;
  width: clamp(52px, 5vw, 64px);
  height: clamp(52px, 5vw, 64px);
  margin-bottom: 4px;
  color: var(--green);
}

.signed-out__mark svg {
  width: 100%;
  height: 100%;
}

.signed-out__eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.16em;
}

.signed-out__title {
  max-width: 20ch;
  margin: 0;
  font-size: clamp(1.7rem, 2.8vw, 2.6rem);
  line-height: 1.08;
}

.signed-out__sub {
  max-width: 44ch;
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(0.98rem, 1.1vw, 1.12rem);
  line-height: 1.5;
}

.signed-out__cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  min-height: 52px;
  padding: 12px 26px;
  border: none;
  border-radius: 999px;
  background: var(--green);
  color: #07120a;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
}

.signed-out__cta svg {
  width: 20px;
  height: 20px;
}

.home-shelves[hidden] {
  display: none;
}

/* === Settings: Playback & Devices === */
.settings-section__lede {
  margin: 0 0 16px;
  max-width: 70ch;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

.settings-section .device-grid {
  margin-top: 18px;
}

/* === #49 Now-view Queue button ===
   Secondary pill under the transport row that opens the queue drawer. */
.now-queue-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  min-height: 52px;
  padding: 12px 24px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.6);
  color: #e8ecf1;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
}

.now-queue-btn svg {
  width: 22px;
  height: 22px;
}

/* === #49 Queue drawer ===
   Right-anchored sheet. Solid scrim (no large backdrop blur — blocky on TV Blink).
   Rows are display-only: the Web API has no "jump to queue index N". */
.queue-drawer {
  position: fixed;
  inset: 0;
  z-index: 110;
}

.queue-drawer[hidden] {
  display: none;
}

.queue-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.74);
  animation: queue-fade 200ms ease both;
}

.queue-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(520px, 92vw);
  padding: 32px 32px 24px;
  border-left: 1px solid var(--line);
  background: var(--panel-strong, #11161f);
  box-shadow: var(--elev-2);
  /* Compositor-only entrance for the TV GPU. */
  animation: queue-slide 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.queue-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.queue-drawer__head .eyebrow {
  margin: 0;
}

.queue-drawer__close {
  min-height: 48px;
  padding: 10px 22px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecf1;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
}

.queue-drawer__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  /* Keep focus/scroll off the very edges; matches .focusable scroll-margin. */
  scroll-padding: 12px 0;
}

.queue-drawer__note {
  margin: 0;
  padding: 24px 4px;
  color: var(--text-muted);
  font-size: 1.04rem;
}

.queue-drawer__note--error {
  color: var(--warn);
}

.queue-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 64px;
  padding: 8px 10px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  font: inherit;
  font-weight: 500;
  text-align: left;
}

.queue-row:hover {
  background: rgba(255, 255, 255, 0.07);
}

.queue-row__art {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background-color: #111824;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.queue-row__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.queue-row__title {
  overflow: hidden;
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.queue-row__artist {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.96rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.queue-row__pos {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}

@keyframes queue-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes queue-slide {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* === #50 Track context menu ===
   Centered focus-trapped sheet (root step + playlist-picker step). */
.track-menu {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 4vw, 80px);
}

.track-menu[hidden] {
  display: none;
}

.track-menu__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.74);
  animation: queue-fade 200ms ease both;
}

.track-menu__panel {
  position: relative;
  width: min(460px, 100%);
  max-height: 80vh;
  padding: 28px 28px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong, #11161f);
  box-shadow: var(--elev-2);
  animation: exit-pop 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow-y: auto;
}

.track-menu__head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.track-menu__art {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: #111824;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.track-menu__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.track-menu__meta {
  min-width: 0;
}

.track-menu__title {
  margin: 0 0 4px;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-menu__artist {
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 1rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-menu__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.track-menu__action {
  width: 100%;
  min-height: 58px;
  padding: 14px 20px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #e8ecf1;
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: left;
}

.track-menu__action--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
}

.track-menu__note {
  margin: 4px 0 0;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 1rem;
}

.track-menu__note--error {
  color: var(--warn);
}

/* === #51 Up-next preview ===
   Non-interactive card, bottom-left, fades/slides in during a song's final ~12s.
   Never focusable, so it can't perturb spatial focus or ambient scroll. */
.up-next {
  position: fixed;
  left: clamp(20px, 3vw, 48px);
  bottom: clamp(20px, 3vw, 48px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(420px, calc(100vw - 48px));
  padding: 14px 20px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong, #11161f);
  box-shadow: var(--elev-2);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 320ms ease, transform 320ms ease;
  pointer-events: none;
}

.up-next[hidden] {
  display: none;
}

.up-next.is-visible {
  opacity: 1;
  transform: translateY(0);
}

body.has-pill .up-next {
  bottom: clamp(96px, 9vw, 128px);
}

.up-next__art {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  background: #111824;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.up-next__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.up-next__meta {
  min-width: 0;
}

.up-next__eyebrow {
  margin: 0 0 4px;
  color: #9eddb5;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.up-next__title {
  margin: 0 0 2px;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.up-next__artist {
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.96rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* === prefers-reduced-motion guard === */
@media (prefers-reduced-motion: reduce) {
  .aurora,
  .drift,
  .ambient-room__art,
  .ambient-visualizer__art,
  .ambient-visualizer__art::after,
  .scene-np {
    animation: none !important;
    transition: opacity 80ms linear !important;
  }

  .np-pill,
  .np-pill__progress-fill {
    transition: none !important;
  }

  .view-now.is-visible,
  .view-now .now-layout,
  #view-home.is-visible .section-title,
  #view-home.is-visible .home-shelves .shelf,
  #view-library.is-visible .section-title,
  #view-library.is-visible .shelf {
    animation: none !important;
  }

  .now-backdrop { transform: none; }

  .queue-drawer__backdrop,
  .queue-drawer__panel,
  .track-menu__backdrop,
  .track-menu__panel {
    animation: none !important;
  }

  .up-next {
    transition: opacity 120ms linear !important;
    transform: none !important;
  }

  html { scroll-behavior: auto; }
}
