/* ── Reset & base ─────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root {
  --bg: #0a0a0f;
  --accent: #1db954;
  --text: #ffffff;
  --text-dim: rgba(255,255,255,.55);
  --radius: 20px;
  --transition: 0s;
}

html,body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hidden { display: none !important; }

/* ── Demo mode banner ─────────────────────────────────── */
.demo-banner {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: #0a0a0f;
  background: linear-gradient(135deg, #1db954 0%, #32d169 100%);
  box-shadow: 0 2px 12px rgba(29, 185, 84, .45), 0 0 0 1px rgba(255,255,255,.18) inset;
  pointer-events: none;
  text-transform: uppercase;
  user-select: none;
}

/* ── Blurred background ──────────────────────────────── */
.bg-layer {
  position: fixed; inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(10px) brightness(.45);
  transform: scale(1.1) translateZ(0);
  will-change: transform;
  z-index: 0;
}
/* Server-side pre-blurred bg variant: skip the expensive CSS blur and
   keep only the cheap brightness filter (big win on the Pi 3B+). */
body.bg-preblurred .bg-layer {
  filter: brightness(.45);
}
.bg-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, transparent 0%, rgba(0,0,0,.65) 100%);
  z-index: 1;
}

/* ── Player container ──────── */
.player {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 28px;
  gap: 14px;
  contain: layout style;
}

/* ── Top bar / device badge ──────────────────────────── */
.topbar {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}
.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--accent);
  background: rgba(29,185,84,.12);
  padding: 5px 14px;
  border-radius: 20px;
  letter-spacing: .4px;
}

/* ── Source badge ────────────────────────────────────── */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: .3px;
  text-transform: uppercase;
  cursor: pointer;
}
.source-spotify { color: #1db954; background: rgba(29,185,84,.12); }
.source-cider   { color: #fc3c44; background: rgba(252,60,68,.12); }

/* ── Source dropdown ────────────────────────────────── */
.source-dropdown-wrap { position: relative; }
.source-arrow { opacity: .5; margin-left: 2px; }
.source-dropdown-wrap.open .source-arrow { transform: rotate(180deg); }
.source-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 140px;
  background: rgba(20,20,30,.98);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 4px 0;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
}
.source-dropdown.visible {
  opacity: 1;
  pointer-events: auto;
}
.source-option {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.source-option:hover { background: rgba(255,255,255,.08); }
.source-option[data-source="spotify"]:hover { color: #1db954; }
.source-option[data-source="cider"]:hover   { color: #fc3c44; }

/* ── Settings gear link ─────────────────────────────── */
.settings-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  opacity: .5;
  text-decoration: none;
  padding: 4px;
}
.settings-link:hover { opacity: 1; }

/* ── Album art ───────────────────────────────────────── */
.artwork-wrap {
  position: relative;
  width: min(62vw, 340px);
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  flex-shrink: 0;
  cursor: pointer;
  transform: translateZ(0);
}
.album-art {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* ── Canvas video ── */
.canvas-video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .3s ease;
  z-index: 3;
  pointer-events: none;
  background: transparent;
  will-change: transform, opacity;
  transform: translateZ(0);
}
.canvas-video.active { opacity: 1; }

/* ── Track info ──────────────────────────────────────── */
.track-info {
  width: 100%;
  text-align: center;
  padding: 4px 0;
  min-height: 64px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  contain: layout style;
}
.track-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.track-info.stale { opacity: .45; }
.track-title {
  font-size: clamp(18px, 4.5vw, 26px);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.track-artist {
  font-size: clamp(13px, 3vw, 16px);
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}

/* ── Progress bar ────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  contain: layout style;
}
.time {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,.15);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  touch-action: none;
}
.progress-bar::before {
  content: "";
  position: absolute;
  top: -12px; bottom: -12px;
  left: 0; right: 0;
}
.progress-bar:hover { height: 6px; }

.progress-fill {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px; height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  background: #fff;
  border-radius: 50%;
  --thumb-x: 0px;
  --thumb-scale: 1;
  transform: translateX(var(--thumb-x)) scale(var(--thumb-scale));
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  touch-action: none;
  will-change: transform;
}
.progress-bar:hover .progress-thumb,
.progress-bar:active .progress-thumb {
  --thumb-scale: 1.2;
}

/* ── Controls ────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 28px;
}
.ctrl-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.ctrl-btn svg { width: 28px; height: 28px; }
.ctrl-btn:active { transform: scale(.88); }
.ctrl-btn:hover { background: rgba(255,255,255,.08); }

.ctrl-btn--play {
  background: var(--text);
  color: #000;
  width: 64px; height: 64px;
  border-radius: 50%;
}
.ctrl-btn--play svg { width: 32px; height: 32px; }
.ctrl-btn--play:hover { background: #fff; }
.ctrl-btn--play:active { transform: scale(.94); }

/* ── Volume ──────────────────────────────────────────── */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 60%;
  max-width: 280px;
}
.vol-icon { width: 20px; height: 20px; color: var(--text-dim); flex-shrink: 0; }

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: rgba(255,255,255,.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  cursor: pointer;
}

/* ── Idle / connecting ──────────────────────────────── */
.player.idle .artwork-wrap { opacity: .3; }
.player.idle .track-title { color: var(--text-dim); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.connecting .device-badge { animation: pulse 1.5s infinite; }


/* ══════════════════════════════════════════════════════════
   Cinematic mode
   ══════════════════════════════════════════════════════════ */

.canvas-cinematic .bg-layer,
.canvas-cinematic .bg-overlay {
  cursor: pointer;
  z-index: 4;
}

.canvas-cinematic > .canvas-video {
  position: fixed;
  width: 100vw; height: 100vh;
  object-fit: cover;
  border-radius: 0;
  z-index: 5;
  pointer-events: auto;
  cursor: pointer;
}

.canvas-cinematic.has-canvas .bg-layer   { display: none !important; }
.canvas-cinematic.has-canvas .bg-overlay { display: none !important; }
.has-canvas .artwork-wrap > .album-art   { display: none !important; }

.canvas-cinematic .bg-layer {
  filter: brightness(.72) saturate(1.25) contrast(1.08);
  transform: scale(1.05) translateZ(0);
}
.canvas-cinematic .bg-overlay {
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.3) 40%, transparent 100%);
}

.canvas-cinematic::after {
  content: "";
  position: fixed;
  bottom: 0; left: 0;
  width: 100%; height: 55%;
  background: linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,.3) 50%, transparent 100%);
  z-index: 6;
  pointer-events: none;
}

.canvas-cinematic .player {
  position: fixed;
  z-index: 10;
  bottom: 0; left: 0;
  width: 100%; height: 100%;
  max-width: none;
  padding: 0 36px 32px;
  justify-content: flex-end;
  background: none;
}

.canvas-cinematic .topbar {
  position: fixed;
  top: 0; left: 0; width: 100%;
  z-index: 20;
  padding: 16px 24px;
  justify-content: center;
}

.canvas-cinematic .artwork-wrap {
  width: 0; height: 0;
  min-height: 0;
  position: absolute;
  pointer-events: none;
  overflow: hidden;
  box-shadow: none;
}

.canvas-cinematic .track-info {
  text-align: left;
  padding: 0 0 6px;
  min-height: 0;
}
.canvas-cinematic .track-title {
  font-size: clamp(22px, 5.5vw, 34px);
  text-shadow: 0 0 15px #000, 0 2px 10px rgba(0,0,0,.9);
}
.canvas-cinematic .track-artist {
  font-size: clamp(14px, 3.5vw, 20px);
  color: rgba(255,255,255,.8);
  text-shadow: 0 0 15px #000, 0 1px 8px rgba(0,0,0,.9);
}

.canvas-cinematic .progress-wrap { padding: 2px 0 10px; }
.canvas-cinematic .time { text-shadow: 0 0 15px #000; }
.canvas-cinematic .progress-bar { background: rgba(255,255,255,.25); height: 5px; }
.canvas-cinematic .progress-fill { box-shadow: 0 0 8px var(--accent); }
.canvas-cinematic .progress-thumb { width: 14px; height: 14px; margin-left: -7px; margin-top: -7px; }
.canvas-cinematic .controls { gap: 32px; }
.canvas-cinematic .ctrl-btn--play { box-shadow: 0 4px 20px rgba(0,0,0,.5); }
.canvas-cinematic .volume-wrap { max-width: 220px; }


/* ══════════════════════════════════════════════════════════
   Canvas Background mode
   ══════════════════════════════════════════════════════════ */

.canvas-background .artwork-wrap { overflow: visible; }
.canvas-background .artwork-wrap > .album-art { border-radius: var(--radius); }
.canvas-background .canvas-video {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  object-fit: cover;
  border-radius: 0;
  z-index: -1;
  pointer-events: none;
}
.canvas-background.has-canvas .bg-layer   { display: none !important; }
.canvas-background.has-canvas .bg-overlay { display: none !important; }


/* ── 800x480 kiosk optimisation ──────────────────────── */
@media (max-width: 840px) and (max-height: 520px) {
  .player {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 12px 18px;
    gap: 10px;
  }
  .topbar {
    order: -1; width: 100%;
    padding: 4px 0 2px;
    gap: 10px;
    justify-content: space-between;
  }
  .artwork-wrap { width: 180px; flex-shrink: 0; }
  .track-info,
  .progress-wrap,
  .controls,
  .volume-wrap {
    width: calc(100% - 200px);
    max-width: none;
  }
  .track-info { text-align: left; min-height: auto; }
  .track-title { font-size: 20px; }
  .track-artist { font-size: 13px; }
  .controls { gap: 18px; justify-content: center; }
  .ctrl-btn--play { width: 52px; height: 52px; }
  .volume-wrap { width: calc(100% - 200px); }

  /* Topbar — bigger tap targets, always-on for the HyperPixel */
  .settings-link      { padding: 10px; opacity: .9; }
  .settings-link svg  { width: 24px; height: 24px; }

  .source-badge       { font-size: 12px; padding: 8px 14px; gap: 6px; }
  .source-badge svg   { width: 16px; height: 16px; }
  .source-arrow       { width: 12px; height: 12px; }
  .source-dropdown    { min-width: 160px; padding: 6px 0; }
  .source-option      { padding: 12px 18px; font-size: 14px; }

  .device-badge       { font-size: 12px; padding: 6px 12px; }
  .device-badge svg   { width: 16px; height: 16px; }
}

/* ── Touch-friendly sizing ───────────────────────────── */
@media (pointer: coarse) {
  .ctrl-btn { padding: 16px; }
  .ctrl-btn svg { width: 32px; height: 32px; }
  .ctrl-btn--play { width: 72px; height: 72px; }
  .ctrl-btn--play svg { width: 36px; height: 36px; }
  .volume-slider { height: 8px; }
  .volume-slider::-webkit-slider-thumb { width: 22px; height: 22px; }
  .progress-bar { height: 8px; }

  /* Gear (settings) — bigger tap area, mostly opaque */
  .settings-link      { padding: 12px; opacity: .85; }
  .settings-link svg  { width: 26px; height: 26px; }

  /* Source badge + dropdown — bigger font, bigger tap area */
  .source-badge       { font-size: 13px; padding: 10px 16px; gap: 8px; }
  .source-badge svg   { width: 18px; height: 18px; }
  .source-arrow       { width: 14px; height: 14px; }
  .source-dropdown    { min-width: 180px; padding: 6px 0; }
  .source-option      { padding: 14px 20px; font-size: 15px; }

  /* Device badge — match visual weight */
  .device-badge       { font-size: 13px; padding: 8px 16px; }
  .device-badge svg   { width: 18px; height: 18px; }

  .topbar             { gap: 14px; padding: 6px 0 4px; }
}


/* ══════════════════════════════════════════════════════════
   Settings Page
   ══════════════════════════════════════════════════════════ */

.settings-body { overflow: auto; background: var(--bg); }

.settings-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.settings-header h1 { font-size: 22px; font-weight: 700; }
.settings-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  text-decoration: none;
  padding: 8px;
  border-radius: 50%;
}
.settings-back:hover { background: rgba(255,255,255,.08); }

.settings-section {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.settings-section h2 {
  font-size: 15px; font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 16px;
}

.settings-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }

.settings-input {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 14px; font-size: 14px;
  color: var(--text);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; outline: none;
  font-family: inherit;
}
.settings-input:focus { border-color: var(--accent); }
.settings-input::placeholder { color: rgba(255,255,255,.25); }

select.settings-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.5)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
select.settings-input option {
  background: #1a1a2a;
  color: var(--text);
  padding: 8px 14px;
}

.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.settings-btn {
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; cursor: pointer;
  font-family: inherit;
}
.settings-btn:hover { background: rgba(255,255,255,.14); }
.settings-btn--primary { background: var(--accent); color: #000; border-color: var(--accent); }
.settings-btn--primary:hover { background: #1ed760; }
.settings-btn--danger { color: #ff6b6b; border-color: rgba(255,107,107,.25); }
.settings-btn--danger:hover { background: rgba(255,107,107,.12); }

.settings-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.settings-label-inline { color: var(--text-dim); }

.source-indicator { font-weight: 600; font-size: 13px; }
.source-indicator--spotify { color: #1db954; }
.source-indicator--cider   { color: #fc3c44; }

.settings-range-wrap { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.settings-range {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 5px; background: rgba(255,255,255,.15);
  border-radius: 3px; outline: none; cursor: pointer;
}
.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer;
}
.settings-range-wrap span {
  min-width: 28px; text-align: right;
  font-size: 14px; font-weight: 600; color: var(--text);
}

.settings-toggle-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 10px; cursor: pointer;
}
.settings-checkbox { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.settings-footer { display: flex; justify-content: center; padding-top: 8px; }
.settings-footer .settings-btn--primary { padding: 12px 40px; font-size: 15px; }

.status-bar {
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  text-align: center; margin-bottom: 16px;
}
.status-ok { color: #1db954; background: rgba(29,185,84,.12); border: 1px solid rgba(29,185,84,.2); }
.status-error { color: #ff6b6b; background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.2); }


/* ── Visual Mode tile picker ─────────────────────────── */

.visual-mode-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 16px;
}
.visual-mode-tiles--two { grid-template-columns: repeat(2, 1fr); }
.vm-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 90px;
  padding: 12px 6px;
  color: var(--text);
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.vm-tile:hover { background: rgba(255,255,255,.10); }
.vm-tile-icon {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.vm-tile-icon svg { width: 100%; height: 100%; }
.vm-tile-label { line-height: 1.25; }
.vm-tile--active {
  background: rgba(29,185,84,.16);
  border-color: var(--accent);
  color: var(--text);
}
.vm-tile--active .vm-tile-icon { color: var(--accent); }


/* ── Keyboard / encoder focus ring ───────────────────── */

.kbd-focus {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 10px;
}
.kbd-focus--adjust {
  outline: 3px dashed #ffb84d;
  outline-offset: 3px;
}


/* ── Touchscreen / Pi display — larger targets ───────── */

@media (pointer: coarse), (max-width: 900px) {
  .settings-page    { max-width: 100%; padding: 14px 12px 90px; }
  .settings-section { padding: 16px 14px; margin-bottom: 12px; border-radius: 14px; }
  .settings-section h2 { font-size: 15px; margin-bottom: 14px; }
  .settings-header h1  { font-size: 22px; }

  .settings-label        { font-size: 15px; margin-bottom: 16px; }
  .settings-label-inline { font-size: 15px; }
  .settings-row          { font-size: 15px; margin-bottom: 12px; }

  .settings-input,
  .settings-label > .settings-input { font-size: 17px; padding: 14px 14px; min-height: 52px; }
  select.settings-input { font-size: 17px; min-height: 52px; padding-right: 44px; }

  .settings-btn          { font-size: 16px; min-height: 52px; padding: 12px 20px; border-radius: 10px; }
  .settings-btn--primary { font-size: 18px; min-height: 60px; padding: 16px; }
  .settings-footer .settings-btn--primary { padding: 18px 40px; font-size: 18px; min-width: 220px; }
  .settings-actions { gap: 12px; }

  .settings-checkbox     { width: 28px; height: 28px; }
  .settings-toggle-label { padding: 10px 4px; font-size: 16px; gap: 14px; margin-bottom: 6px; }

  .settings-range        { height: 10px; }
  .settings-range::-webkit-slider-thumb { width: 28px; height: 28px; }
  .settings-range-wrap   { gap: 14px; }
  .settings-range-wrap span { min-width: 52px; font-size: 18px; }

  .settings-back      { min-width: 52px; min-height: 52px; padding: 12px; border-radius: 14px; }
  .settings-back svg  { width: 26px; height: 26px; }

  .visual-mode-tiles  { gap: 10px; }
  .vm-tile            { min-height: 110px; font-size: 14px; padding: 12px 6px; border-radius: 14px; }
  .vm-tile-icon       { width: 40px; height: 40px; }

  .status-bar         { font-size: 15px; padding: 12px 18px; }
}

/* ══════════════════════════════════════════════════════════
   Idle screensaver — minimal UI on top of the idle canvas.
   Only the source toggle, settings link, and "No music playing"
   text remain. All background darkening is removed.
   ══════════════════════════════════════════════════════════ */

body.idle-screensaver.canvas-cinematic::after { display: none !important; }
body.idle-screensaver .bg-overlay             { display: none !important; }

body.idle-screensaver #device-badge,
body.idle-screensaver .artwork-wrap,
body.idle-screensaver .progress-wrap,
body.idle-screensaver .controls,
body.idle-screensaver .volume-wrap,
body.idle-screensaver .track-artist {
  display: none !important;
}

body.idle-screensaver .track-info {
  text-align: center;
  padding: 0 0 28px;
}
body.idle-screensaver .track-title {
  text-align: center;
  letter-spacing: .5px;
  /* Single soft shadow only — avoids the rectangular halo that the
     default cinematic double-shadow creates over light backgrounds. */
  text-shadow: 0 2px 14px rgba(0,0,0,.55);
}


/* ══════════════════════════════════════════════════════════
   Topbar icon buttons (lyrics + library)
   ══════════════════════════════════════════════════════════ */

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  opacity: .6;
  padding: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.topbar-icon-btn:hover, .topbar-icon-btn:active { opacity: 1; color: var(--text); }

@media (max-width: 840px) and (max-height: 520px) {
  .topbar-icon-btn     { padding: 10px; opacity: .9; }
  .topbar-icon-btn svg { width: 24px; height: 24px; }
}
@media (pointer: coarse) {
  .topbar-icon-btn     { padding: 12px; opacity: .85; }
  .topbar-icon-btn svg { width: 26px; height: 26px; }
}


/* ══════════════════════════════════════════════════════════
   Overlays (library + lyrics)
   ══════════════════════════════════════════════════════════ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 14, .97);
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 8px;
  flex-shrink: 0;
}

.overlay-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#library-overlay.library-overlay--over-lyrics {
  z-index: 65;
  background: rgba(8, 8, 14, .94);
}

.overlay-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  background: rgba(255,255,255,.07);
  border: none;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.overlay-close:active { background: rgba(255,255,255,.16); }

/* ── Library tabs ── */
.lib-tabs { display: flex; gap: 8px; }
.lib-tab {
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-dim);
  background: rgba(255,255,255,.06);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lib-tab--active { color: #000; background: var(--accent); }

.lib-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 14px 10px;
}

/* ── Search bar ── */
.lib-searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: rgba(255,255,255,.07);
  border-radius: 12px;
  min-height: 46px;
}
.lib-searchbar-icon { color: var(--text-dim); flex-shrink: 0; }
.lib-query {
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.lib-query-placeholder { color: rgba(255,255,255,.3); }
.lib-query-text { color: var(--text); }
.lib-query-caret {
  display: inline-block;
  width: 2px; height: 20px;
  margin-left: 2px;
  background: var(--accent);
  animation: pulse 1.1s infinite;
}

/* ── Content lists ── */
.lib-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 6px;
}

.lib-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 4px 6px;
}

.lib-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 6px;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lib-row:active { background: rgba(255,255,255,.08); }

.lib-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,.08);
}
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lib-row-main { flex: 1; min-width: 0; }
.lib-row-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-row-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.lib-row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  min-height: 46px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.lib-row-action:active { background: rgba(29,185,84,.2); color: var(--accent); }
.lib-row-chevron { color: rgba(255,255,255,.3); flex-shrink: 0; display: inline-flex; }

.lib-message {
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
  padding: 38px 20px;
}

.lib-spinner {
  width: 30px; height: 30px;
  margin: 36px auto;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: lib-spin .8s linear infinite;
}
@keyframes lib-spin { to { transform: rotate(360deg); } }

.lib-loadmore {
  display: block;
  width: 100%;
  margin: 8px 0 4px;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.lib-loadmore:active { background: rgba(255,255,255,.15); }

/* ── Detail header (playlist/album view) ── */
.lib-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 10px;
  position: sticky;
  top: 0;
  background: rgba(8,8,14,.97);
  z-index: 2;
}
.lib-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px; min-height: 46px;
  background: rgba(255,255,255,.07);
  border: none;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.lib-back-btn:active { background: rgba(255,255,255,.16); }
.lib-detail-main { flex: 1; min-width: 0; }
.lib-detail-title {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-detail-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-playall-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: #000;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.lib-playall-btn:active { background: #1ed760; }
.lib-playall-btn--solo { margin: 0 4px 8px; align-self: flex-start; }

.lib-playmodes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.lib-playmode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 72px;
  padding: 7px 10px;
  border: none;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lib-playmode-btn:active { background: rgba(29,185,84,.35); }
.lib-playmode-btn.kbd-focus { outline: 2px solid var(--accent); }

/* ── On-screen keyboard ── */
.lib-keyboard {
  flex-shrink: 0;
  padding-top: 8px;
  user-select: none;
}
.kb-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  justify-content: center;
}
.kb-key {
  flex: 1;
  max-width: 76px;
  min-height: 44px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: rgba(255,255,255,.09);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.kb-key:active { background: rgba(29,185,84,.35); }
.kb-key--wide  { max-width: 90px; }
.kb-key--space { flex: 4; max-width: none; }
.kb-key--clear { flex: 1.4; max-width: 130px; font-size: 14px; color: var(--text-dim); }

/* 800x480 kiosk: compact the overlay chrome so results keep real estate.
   Full keyboard: 5 rows x ~38px = ~190px, leaving ~170px of results. */
@media (max-width: 840px) and (max-height: 520px) {
  .overlay-header { padding: 6px 10px 4px; }
  .lib-tab { padding: 8px 14px; font-size: 13px; }
  .overlay-close { min-width: 42px; min-height: 42px; }
  .lib-body { padding: 0 10px 6px; }
  .lib-searchbar { min-height: 38px; padding: 6px 12px; margin-bottom: 6px; }
  .lib-query { font-size: 15px; }
  .lib-row { padding: 5px 4px; gap: 10px; }
  .lib-thumb { width: 42px; height: 42px; }
  .lib-row-title { font-size: 14px; }
  .lib-row-sub { font-size: 11.5px; }
  .lib-section-title { padding: 6px 4px 4px; }
  .lib-keyboard { padding-top: 5px; }
  .kb-row { gap: 5px; margin-bottom: 5px; }
  .kb-key { min-height: 33px; font-size: 15px; border-radius: 7px; }
  .lib-playmodes { gap: 3px; }
  .lib-playmode-btn { min-width: 64px; padding: 5px 6px; font-size: 10px; }
  .lib-detail-header { align-items: flex-start; }
}


/* ══════════════════════════════════════════════════════════
   Lyrics overlay
   ══════════════════════════════════════════════════════════ */

/* ── Media background: canvas video / blurred art behind the lyrics ── */

.lyrics-bg {
  display: none;
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.lyrics-scrim {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  /* Light veil — readability without hiding canvas/art */
  background: linear-gradient(to bottom,
    rgba(0,0,0,.32) 0%,
    rgba(0,0,0,.1) 28%,
    rgba(0,0,0,.1) 72%,
    rgba(0,0,0,.38) 100%);
  pointer-events: none;
}
#lyrics-overlay .overlay-header,
#lyrics-overlay .lyrics-content,
#lyrics-overlay .lyrics-transport-wrap {
  position: relative;
  z-index: 3;
}

.lyrics-transport-wrap {
  flex-shrink: 0;
  padding-bottom: 4px;
  background: linear-gradient(to top, rgba(0,0,0,.5) 0%, rgba(0,0,0,.15) 65%, transparent 100%);
}
.lyrics-time {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,.75);
  padding: 6px 0 2px;
  letter-spacing: .02em;
}
.lyrics-time-sep { margin: 0 4px; color: rgba(255,255,255,.35); }

.lyrics-transport {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 4px 20px 12px;
}
.lyrics-transport-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.lyrics-transport-btn svg { width: 28px; height: 28px; pointer-events: none; }
.lyrics-transport-btn--main {
  min-width: 62px;
  min-height: 62px;
  background: var(--text);
  color: #111;
}
.lyrics-transport-btn--main svg { width: 32px; height: 32px; }
.lyrics-transport-btn:active { transform: scale(.92); }
.lyrics-transport-btn--main:active { background: #e0e0e0; }

.lyrics-volume-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(92%, 360px);
  margin: 0 auto;
  padding: 2px 20px 12px;
}
.lyrics-volume-wrap .vol-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: rgba(255,255,255,.75);
}
.lyrics-volume-slider {
  flex: 1;
  min-width: 0;
}

@media (max-width: 840px) and (max-height: 520px) {
  .lyrics-transport { gap: 24px; padding: 6px 16px 10px; }
  .lyrics-volume-wrap { width: calc(100% - 28px); padding: 0 14px 10px; gap: 8px; }
  .lyrics-volume-wrap .vol-icon { width: 18px; height: 18px; }
  .lyrics-transport-btn { min-width: 48px; min-height: 48px; }
  .lyrics-transport-btn svg { width: 26px; height: 26px; }
  .lyrics-transport-btn--main { min-width: 56px; min-height: 56px; }
  .lyrics-transport-btn--main svg { width: 30px; height: 30px; }
  .lyrics-content { padding-bottom: 8px; }
  .lyrics-lines {
    transition: transform .26s ease-out;
    padding: 26vh 0 38vh;
    transform: translateZ(0);
  }
  .lyrics-overlay--media .lyric-line,
  .lyrics-overlay--media .lyric-line--active,
  .lyrics-overlay--media .lyric-word--active {
    text-shadow: none;
  }
}

.lyrics-overlay--media { background: rgba(5, 5, 9, .15); }
.lyrics-overlay--media .lyrics-bg,
.lyrics-overlay--media .lyrics-scrim { display: block; }

/* Canvas behind lyrics: even lighter scrim so the loop stays visible */
.lyrics-overlay--media.lyrics-overlay--canvas { background: transparent; }
.lyrics-overlay--media.lyrics-overlay--canvas .lyrics-scrim {
  background: linear-gradient(to bottom,
    rgba(0,0,0,.2) 0%,
    rgba(0,0,0,.04) 30%,
    rgba(0,0,0,.04) 70%,
    rgba(0,0,0,.22) 100%);
}
.lyrics-overlay--media.lyrics-overlay--canvas .lyrics-transport-wrap {
  background: linear-gradient(to top, rgba(0,0,0,.42) 0%, transparent 100%);
}

/* The borrowed canvas <video> fills the bg layer; beat any mode styles
   (canvas_bg gives .canvas-video position:fixed / z-index:-1). */
.lyrics-overlay--media .lyrics-bg .canvas-video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 0;
  z-index: 1;
  pointer-events: none;
}

/* Text legibility over video / art without heavy glow */
.lyrics-overlay--media .lyric-line {
  color: rgba(255,255,255,.55);
  text-shadow: 0 1px 4px rgba(0,0,0,.65);
}
.lyrics-overlay--media .lyric-line--active {
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.75);
}
.lyrics-overlay--media .lyric-line--gap { color: rgba(255,255,255,.32); }
.lyrics-overlay--media .lyrics-plain {
  color: rgba(255,255,255,.92);
  text-shadow: 0 1px 4px rgba(0,0,0,.65);
}
.lyrics-overlay--media .lyrics-credit { color: rgba(255,255,255,.45); }

.lyrics-overlay--media.lyrics-overlay--canvas .lyric-line {
  text-shadow: 0 1px 3px rgba(0,0,0,.55);
}
.lyrics-overlay--media.lyrics-overlay--canvas .lyric-line--active {
  text-shadow: 0 1px 5px rgba(0,0,0,.7);
}

.lyrics-head { flex: 1; min-width: 0; padding-left: 4px; }
.lyrics-head-title {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lyrics-head-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lyrics-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 6px 26px 16px;
}
/* Synced mode: we drive the position with a transform, not scrolling. */
.lyrics-content--synced { overflow: hidden; }

.lyrics-lines {
  transition: transform .32s ease-out;
  padding: 30vh 0 45vh;
}
.lyric-line {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.45;
  padding: 7px 4px;
  color: rgba(255,255,255,.38);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lyric-line--active { color: var(--text); }
.lyric-line--gap { color: rgba(255,255,255,.2); font-size: 17px; }

/* Word-level karaoke (only when API provides per-word timestamps) */
.lyrics-content--word-sync .lyric-line--karaoke.lyric-line--active {
  color: rgba(255,255,255,.42);
}
.lyric-word {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lyric-word--active {
  color: var(--text);
}
.lyrics-overlay--media .lyric-word--active {
  color: #fff;
  text-shadow: 0 1px 12px rgba(0,0,0,.55);
}

.lyrics-plain {
  white-space: pre-wrap;
  font-size: 17px;
  line-height: 1.65;
  color: rgba(255,255,255,.85);
  padding: 10px 2px 20px;
}

.lyrics-message {
  text-align: center;
  color: var(--text-dim);
  font-size: 16px;
  padding: 60px 20px;
}

.lyrics-credit {
  font-size: 11px;
  color: rgba(255,255,255,.28);
  text-align: center;
  padding: 14px 0 4px;
}


/* ══════════════════════════════════════════════════════════
   Toast
   ══════════════════════════════════════════════════════════ */

.pim-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(25,25,35,.96);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  pointer-events: none;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ══════════════════════════════════════════════════════════
   Spotify-style mode controls (shuffle / repeat / heart)
   ══════════════════════════════════════════════════════════ */

.ctrl-btn--mode {
  position: relative;
  color: var(--text-dim);
}
.ctrl-btn--mode svg { width: 20px; height: 20px; }
.ctrl-btn--mode.ctrl-btn--on { color: var(--accent); }
/* Spotify's little dot under an active shuffle/repeat button */
.ctrl-btn--mode.ctrl-btn--on::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 4px; height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}

.like-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.like-btn svg { width: 22px; height: 22px; }
.like-btn--on { color: var(--accent); }
.like-btn:active { transform: scale(.88); }

/* Queue view: highlight the currently playing row */
.lib-row--current { background: rgba(29,185,84,.08); }
.lib-row--current .lib-row-title { color: var(--accent); }

@media (pointer: coarse) {
  .ctrl-btn--mode svg { width: 24px; height: 24px; }
  .like-btn { min-width: 50px; min-height: 50px; }
  .like-btn svg { width: 26px; height: 26px; }
}

/* Cinematic: keep heart aligned with the left-aligned text block */
.canvas-cinematic .track-info { align-items: center; }
.canvas-cinematic .like-btn { color: rgba(255,255,255,.7); }
.canvas-cinematic .like-btn.like-btn--on { color: var(--accent); }
body.idle-screensaver .like-btn { display: none !important; }