/* Spotify: music slots, in-workout bar position and the full player sheet.
   Colours come only from theme variables (with dark fallbacks until the theme lands). */

/* ── Bar & slots: shared compact row ───────────────────────────────────── */
.music-bar { cursor: pointer; }
.music-meta[data-open], .music-art[data-open], .music-msg[data-open] { cursor: pointer; }
.music-meta:focus-visible, .music-msg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.music-btn { min-width: 44px; min-height: 44px; }
.music-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* A message that may need two lines (Premium notice) plus an "Open Spotify" link. */
.music-msg.music-msg-wrap { white-space: normal; line-height: 1.25; font-size: .72rem; }
.music-msg-wrap > span {
  flex: 1; min-width: 0; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.music-msg > svg { flex: 0 0 auto; }
.music-open-link {
  flex: 0 0 auto; color: var(--accent); font-weight: 700; font-size: .78rem;
  text-decoration: none; padding: .5rem .25rem; white-space: nowrap;
}

.music-slot:empty { display: none; }
.music-slot {
  display: flex; align-items: center; gap: .6rem;
  min-height: 52px; padding: .4rem .5rem .4rem .6rem;
  background: var(--card, #1a1a1f); border: 1px solid var(--border, #303038);
  border-radius: 14px; cursor: pointer;
}
.music-slot .music-msg { min-height: 36px; }

/* Workout screen has no bottom nav: float the bar above its action dock. */
body.in-workout .music-bar {
  left: 16px; right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  border: 1px solid var(--border, #303038); border-radius: 14px;
  box-shadow: var(--shadow-card, 0 6px 20px rgba(0,0,0,.35));
}

/* ── Player sheet ──────────────────────────────────────────────────────── */
body.mp-open { overflow: hidden; }

.mp-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: var(--overlay, rgba(0,0,0,.6));
  display: flex; align-items: flex-end; justify-content: center;
  animation: mp-fade .18s ease;
}
.mp-sheet {
  width: 100%; max-width: 520px; max-height: calc(100% - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--sheet-bg, #1c1c21); color: var(--text, #e8e8e8);
  border-top: 1px solid var(--border, #303038);
  border-radius: 24px 24px 0 0;
  padding: 0 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.35);
  animation: mp-up .22s cubic-bezier(.2,.8,.2,1);
  transition: transform .2s ease;
}
.mp-closing { animation: mp-fade-out .2s ease forwards; }
.mp-closing .mp-sheet { transform: translateY(100%); }
@keyframes mp-fade { from { opacity: 0; } }
@keyframes mp-fade-out { to { opacity: 0; } }
@keyframes mp-up { from { transform: translateY(40%); opacity: .4; } }
@media (prefers-reduced-motion: reduce) {
  .mp-backdrop, .mp-sheet { animation: none; transition: none; }
}

.mp-grab-zone {
  position: sticky; top: 0; z-index: 2; touch-action: none;
  background: var(--sheet-bg, #1c1c21); padding-top: 8px; margin: 0 -20px; padding-left: 12px; padding-right: 12px;
}
.mp-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border, #3a3a44); margin: 0 auto 4px; }
.mp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; }
.mp-from {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: .78rem; font-weight: 600; color: var(--muted, #8b8b9c);
}
.mp-from-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok, #5fd18b); flex: 0 0 auto; }
.mp-icon-spacer { display: block; width: 44px; }

.mp-icon-btn {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 50%; padding: 0;
  color: var(--text, #e8e8e8); cursor: pointer; text-decoration: none;
}
.mp-icon-btn:active { background: var(--bg3, #222228); }
.mp-icon-btn:focus-visible, .mp-big:focus-visible, .mp-pill:focus-visible, .mp-device:focus-visible,
.mp-pl-item:focus-visible, .mp-link-btn:focus-visible, .mp-banner-link:focus-visible {
  outline: 2px solid var(--accent, #ff8c42); outline-offset: 2px;
}

/* Banner (Premium / errors / reconnect) */
.mp-banner {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; padding: 10px 12px;
  border-radius: 12px; font-size: .8rem; line-height: 1.35;
  background: var(--bg3, #222228); border: 1px solid var(--border, #303038); color: var(--text, #e8e8e8);
}
.mp-banner > span { flex: 1; }
.mp-banner-warn { border-color: var(--accent-line, rgba(255,140,66,.4)); background: var(--accent-soft, rgba(255,140,66,.12)); }
.mp-banner-link {
  flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; padding: 0 6px;
  background: none; border: none; color: var(--accent, #ff8c42); font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}

/* Art & track */
.mp-art {
  width: min(260px, 68vw, 34vh); aspect-ratio: 1; margin: 4px auto 18px;
  border-radius: 18px; overflow: hidden; background: var(--bg3, #222228);
  display: flex; align-items: center; justify-content: center; color: var(--muted, #8b8b9c);
  box-shadow: 0 18px 40px rgba(0,0,0,.4);
}
.mp-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-art-empty { box-shadow: none; border: 1px dashed var(--border, #303038); }
.mp-track { display: flex; align-items: center; gap: 10px; }
.mp-track-text { flex: 1; min-width: 0; }
.mp-title { font-size: 1.3rem; font-weight: 800; line-height: 1.2; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-artist { color: var(--muted, #8b8b9c); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-like { color: var(--muted, #8b8b9c); margin-right: -8px; }
.mp-like.on { color: var(--accent, #ff8c42); }
.mp-like.on svg { fill: currentColor; }

.mp-empty { text-align: center; padding: 4px 0 8px; }
.mp-empty .mp-art { width: 140px; margin-bottom: 14px; }
.mp-empty .mp-title { white-space: normal; }
.mp-sub { color: var(--muted, #8b8b9c); font-size: .85rem; margin: 4px 0 12px; }

/* Range inputs: a thin track, a big invisible hit area (44px tall). */
.mp-range {
  --pct: 0%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; display: block;
}
.mp-range:focus-visible { outline: none; }
.mp-range::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--text, #e8e8e8) var(--pct), var(--bg3, #303038) var(--pct));
}
.mp-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -5.5px; border-radius: 50%; border: none;
  background: var(--text, #e8e8e8);
}
.mp-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft, rgba(255,140,66,.35)); }
.mp-range::-moz-range-track { height: 5px; border-radius: 3px; background: var(--bg3, #303038); }
.mp-range::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--text, #e8e8e8); }
.mp-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: none; background: var(--text, #e8e8e8); }

.mp-seek { margin-top: 6px; }
.mp-times {
  display: flex; justify-content: space-between; margin-top: -10px;
  font-size: .75rem; color: var(--muted, #8b8b9c); font-variant-numeric: tabular-nums;
}

/* Transport */
.mp-transport { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 8px; }
.mp-skip { width: 56px; height: 56px; flex-basis: 56px; }
.mp-skip svg, .mp-big svg { fill: currentColor; }
.mp-toggle { color: var(--muted, #8b8b9c); position: relative; }
.mp-toggle.on { color: var(--ok, #5fd18b); }
.mp-toggle.on::after {
  content: ''; position: absolute; bottom: 4px; left: 50%; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: currentColor;
}
.mp-big {
  width: 72px; height: 72px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--text, #e8e8e8); color: var(--bg, #111114);
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s ease;
}
.mp-big:active { transform: scale(.95); }

.mp-vol { display: flex; align-items: center; gap: 12px; color: var(--muted, #8b8b9c); }

/* Device */
.mp-device-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; min-height: 44px; }
.mp-device-now {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: .85rem; font-weight: 600; color: var(--ok, #5fd18b);
}
.mp-device-now span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-device-now svg { flex: 0 0 auto; }
.mp-device-none { color: var(--muted, #8b8b9c); }
.mp-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border, #303038);
  background: var(--bg3, #222228); color: var(--text, #e8e8e8);
  font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; flex: 0 0 auto;
}
.mp-pill-accent {
  background: var(--accent, #ff8c42); color: var(--on-accent, #1a1a1f); border-color: transparent;
  white-space: normal; text-align: center; justify-content: center;
}
.mp-devices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.mp-device {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border, #303038);
  background: var(--card, #1a1a1f); color: var(--text, #e8e8e8);
  font: inherit; font-size: .9rem; text-align: left; cursor: pointer;
}
.mp-device svg { flex: 0 0 auto; color: var(--muted, #8b8b9c); }
.mp-device.on { border-color: var(--ok, #5fd18b); }
.mp-device.on, .mp-device.on svg { color: var(--ok, #5fd18b); }
.mp-device:disabled { opacity: .5; cursor: not-allowed; }
.mp-device-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-device-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 700; }
.mp-link-btn {
  align-self: flex-start; min-height: 44px; padding: 0 2px; background: none; border: none;
  color: var(--accent, #ff8c42); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.mp-note { font-size: .82rem; color: var(--muted, #8b8b9c); line-height: 1.4; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* Playlists */
.mp-label {
  display: flex; align-items: center; gap: 6px; margin: 18px 0 10px;
  font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--muted, #8b8b9c);
}
.mp-pl {
  display: flex; gap: 12px; overflow-x: auto; margin: 0 -20px; padding: 0 20px 6px;
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.mp-pl::-webkit-scrollbar { display: none; }
.mp-pl-item {
  flex: 0 0 100px; width: 100px; padding: 0; background: none; border: none; cursor: pointer;
  color: var(--text, #e8e8e8); text-align: left; scroll-snap-align: start; font: inherit;
}
.mp-pl-cover {
  width: 100px; height: 100px; border-radius: 12px; overflow: hidden; margin-bottom: 6px;
  background: var(--bg3, #222228); color: var(--muted, #8b8b9c);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
}
.mp-pl-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-pl-item.on .mp-pl-cover { border-color: var(--ok, #5fd18b); }
.mp-pl-item.on .mp-pl-name { color: var(--ok, #5fd18b); }
.mp-pl-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: .78rem; font-weight: 600; line-height: 1.25;
}
.mp-pl-skel .mp-pl-cover { animation: mp-pulse 1.2s ease-in-out infinite alternate; }
@keyframes mp-pulse { to { opacity: .5; } }

@media (min-width: 600px) {
  .mp-backdrop { align-items: center; }
  .mp-sheet { border-radius: 24px; border: 1px solid var(--border, #303038); max-height: calc(100% - 48px); }
  .mp-grab-zone { border-radius: 24px 24px 0 0; }
}
