/* ============================================================
   Divine Revelations Media Player — player.css
   Cinematic dark-mode, fully responsive, no frameworks.
   Compatible: Chrome 70+, Firefox 65+, Safari 12+, Edge 79+
   ============================================================ */

/* ── Google Font ─────────────────────────────────────────── */
/* Fonts are loaded by the <link> in index.php. A duplicate @import here made the browser wait for
   a second, chained request before it could finish parsing this file — slow on mobile networks. */

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* Core palette */
  --bg-base:          #0d0d0f;
  --bg-panel:         #15151a;
  --bg-panel-hover:   #1e1e26;
  --bg-glass:         rgba(21, 21, 26, 0.85);
  --bg-overlay:       rgba(0, 0, 0, 0.55);

  /* Accent — overridable via JS: document.documentElement.style.setProperty */
  --accent:           #f0a500;
  --accent-dim:       rgba(240, 165, 0, 0.18);
  --accent-glow:      rgba(240, 165, 0, 0.35);

  /* Text */
  --text-primary:     #f0f0f5;
  --text-secondary:   #9090a0;
  --text-muted:       #8080a0;

  /* Borders */
  --border:           rgba(255, 255, 255, 0.07);
  --border-accent:    rgba(240, 165, 0, 0.4);

  /* Sizes */
  --radius-sm:        6px;
  --radius-md:        12px;
  --radius-lg:        20px;
  --radius-xl:        28px;

  /* Timing */
  --ease-out:         cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in-out:      cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast:           0.15s;
  --t-med:            0.28s;
  --t-slow:           0.45s;

  /* Touch targets — Apple asks for 44px, Google/Material for 48px */
  --tap-min:          48px;
  --skip-size:        60px;
  --play-size:        76px;

  /* Layout */
  --controls-height:  104px;
  --panel-width:      320px;
  --z-video:          1;
  --z-controls:       10;
  --z-panel:          20;
  --z-modal:          30;
  --z-tooltip:        40;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  overflow: hidden; /* Player owns the whole viewport */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;          /* no iOS long-press callout on the artwork */
  -webkit-tap-highlight-color: transparent;
}

/* The HTML `hidden` attribute must always win over component display rules below */
[hidden] { display: none !important; }

/* Rapid taps on controls must never zoom the page (iOS double-tap-to-zoom) */
button, a, select, input[type="range"], .chip, .chip-btn, #audio-card, #media-video {
  touch-action: manipulation;
}

/* ── Focus styles (accessibility) ───────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ── Player Shell ────────────────────────────────────────── */
#player-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  overflow: hidden;
}

/* ── Ambient Background Art ──────────────────────────────── */
#ambient-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(40px) brightness(0.3) saturate(1.4);
  transform: scale(1.08); /* Prevent blur edges */
  transition: background-image var(--t-slow) var(--ease-out),
              opacity var(--t-slow) var(--ease-out);
  opacity: 0;
}
#ambient-bg.has-art { opacity: 1; }

/* ── Main Content Area ───────────────────────────────────── */
#content-area {
  position: relative;
  z-index: var(--z-video);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 12px 12px;
  transition: padding var(--t-med) var(--ease-out);
}

/* ── Video Element ───────────────────────────────────────── */
#media-video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  border-radius: var(--radius-md);
  background: #000;
  display: block;
  cursor: pointer;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  transition: border-radius var(--t-med) var(--ease-out);
}

/* Fullscreen — no rounding */
:fullscreen #media-video,
:-webkit-full-screen #media-video {
  border-radius: 0;
  max-height: 100vh;
}

/* ── Audio Mode ──────────────────────────────────────────── */
body.audio-mode #content-area {
  flex-direction: column;
  gap: 20px;
}

#audio-card {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 90%;
}
body.audio-mode #audio-card  { display: flex; }
body.audio-mode #media-video { display: none; }

/* Hide the small info-bar title in audio mode — big title shows above thumbnail */
body.audio-mode #media-title { display: none; }

/* ── Holy Fire keyframes for audio title ─────────────────── */
@keyframes title-holy-fire {
  0%, 100% { color: #ffd700; text-shadow: 0 0 22px rgba(255, 215,  0, 0.65); }
  33%       { color: #ff8c00; text-shadow: 0 0 22px rgba(255, 140,  0, 0.65); }
  66%       { color: #ff4500; text-shadow: 0 0 22px rgba(255,  69,  0, 0.65); }
}

/* ── Audio Title Display (above thumbnail, Gabriela font) ─── */
#audio-title-display {
  display: none;
  font-family: 'Gabriela', Georgia, 'Times New Roman', serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: #ffd700;
  text-align: center;
  line-height: 1.3;
  padding: 10px 28px;
  background: rgba(0, 0, 0, 0.62);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  max-width: 100%;
  word-break: break-word;
  letter-spacing: 0.02em;
  animation: title-holy-fire 5s ease-in-out infinite;
}
body.audio-mode #audio-title-display { display: block; }

#audio-art {
  max-width: min(65vw, 700px);
  max-height: 50vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-lg);
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px var(--border);
  cursor: pointer;
  transition: transform var(--t-slow) var(--ease-out),
              box-shadow var(--t-slow) var(--ease-out);
}
#audio-art.playing {
  transform: scale(1.03);
  box-shadow: 0 28px 80px rgba(0,0,0,0.7), 0 0 0 1px var(--border-accent),
              0 0 40px var(--accent-glow);
}
#audio-art-placeholder {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #1e1e30 0%, #2a2a3e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px var(--border);
  cursor: pointer;
  transition: box-shadow var(--t-slow) var(--ease-out);
}
#audio-art-placeholder.playing {
  box-shadow: 0 28px 80px rgba(0,0,0,0.7), 0 0 0 1px var(--border-accent),
              0 0 40px var(--accent-glow);
}
#audio-art-placeholder svg {
  width: 80px;
  height: 80px;
  opacity: 0.3;
}

/* ── Visualizer bars ─────────────────────────────────────── */
#visualizer {
  display: none;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 40px;
  width: 100%;
  max-width: 420px;
}
body.audio-mode #visualizer { display: flex; }

.viz-bar {
  width: 4px;
  min-height: 4px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.7;
  animation: viz-bounce 0.8s ease-in-out infinite alternate;
  transform-origin: bottom;
}
.viz-bar:nth-child(odd)  { animation-duration: 0.7s; }
.viz-bar:nth-child(3n)   { animation-duration: 0.9s; }
.viz-bar:nth-child(4n)   { animation-duration: 0.6s; opacity: 0.5; }

@keyframes viz-bounce {
  from { transform: scaleY(0.15); }
  to   { transform: scaleY(1);    }
}

/* Pause: freeze animation */
body.paused .viz-bar { animation-play-state: paused; }

/* ── Title / Info Bar ────────────────────────────────────── */
#info-bar {
  position: relative;
  z-index: var(--z-controls);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 6px;
  flex-shrink: 0;
}
#media-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  letter-spacing: 0.01em;
}
#playlist-position {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Controls Bar ────────────────────────────────────────── */
#controls-bar {
  position: relative;
  z-index: var(--z-controls);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  flex-shrink: 0;
  order: -1;
  transition: opacity var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
}

/* Auto-hide in video mode — slides up since bar is at top */
body.video-mode.controls-hidden #controls-bar,
body.video-mode.controls-hidden #info-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}
body.video-mode.controls-visible #controls-bar,
body.video-mode.controls-visible #info-bar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ── Progress / Scrubber Row ─────────────────────────────── */
#scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#scrubber-wrap {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

#progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: visible;
  transition: height var(--t-fast) var(--ease-out);
}
#scrubber-wrap:hover #progress-track { height: 6px; }

#progress-buffered {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
  transition: width 0.5s linear;
  pointer-events: none;
}
#progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  transition: none; /* Updated via JS, no transition */
}
#progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  pointer-events: none;
  transition: transform var(--t-fast) var(--ease-out);
  left: 0%;
}
#scrubber-wrap:hover #progress-thumb { transform: translate(-50%, -50%) scale(1); }
#scrubber-wrap.dragging #progress-thumb { transform: translate(-50%, -50%) scale(1.25); }

/* Hover time tooltip — shows below scrubber since bar is at top */
#scrubber-tooltip {
  position: absolute;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: var(--z-tooltip);
  backdrop-filter: blur(8px);
}
#scrubber-wrap:hover #scrubber-tooltip { opacity: 1; }

/* A/B loop region overlay */
#ab-region {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(240, 165, 0, 0.25);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: none;
  display: none;
}
#ab-region.visible { display: block; }

/* Time display */
.time-display {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 88px;
  text-align: right;
}

/* ── Main Controls Row ───────────────────────────────────── */
#controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#controls-left, #controls-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
#controls-right { justify-content: flex-end; }

#controls-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Icon Buttons ────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.07);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active {
  color: var(--accent);
}
.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
.icon-btn svg { display: block; }

/* Play/Pause — larger */
#btn-play {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: background var(--t-fast), transform var(--t-fast),
              box-shadow var(--t-fast);
}
#btn-play:hover {
  background: #ffc107;
  transform: scale(1.07);
  box-shadow: 0 6px 28px var(--accent-glow);
}
#btn-play:active { transform: scale(0.95); }

/* ── Volume Control ──────────────────────────────────────── */
#volume-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
#volume-slider-wrap {
  width: 80px;
  overflow: hidden;
  transition: width var(--t-med) var(--ease-out),
              opacity var(--t-med) var(--ease-out);
}
.vol-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
/* On very small screens, collapse volume slider + label */
@media (max-width: 480px) {
  #volume-slider-wrap { width: 56px; }
}
@media (max-width: 360px) {
  #volume-slider-wrap { width: 0; opacity: 0; }
  .vol-label { display: none; }
}

/* ── Range Input (shared) ────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  height: 20px;
  padding: 0;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5px;
  box-shadow: 0 0 6px var(--accent-glow);
  transition: transform var(--t-fast);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 6px var(--accent-glow);
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.2); }
input[type="range"]:hover::-moz-range-thumb    { transform: scale(1.2); }
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Gradient fill trick for volume/speed.
   background-size/position confine the gradient to a 4px strip in the middle of the input; without
   them it filled the whole 20px-tall input and drew a solid block instead of a thin track. */
#volume-slider {
  --pct: 100%;
  background: linear-gradient(to right,
    var(--accent) 0%,
    var(--accent) var(--pct),
    rgba(255,255,255,0.15) var(--pct),
    rgba(255,255,255,0.15) 100%) no-repeat center / 100% 4px;
  border-radius: 2px;
}
#volume-slider::-webkit-slider-runnable-track { background: transparent; }
#volume-slider::-moz-range-track             { background: transparent; }

/* ── Speed Selector ──────────────────────────────────────── */
#speed-select {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
  min-width: 52px;
  text-align: center;
}
#speed-select:hover  { border-color: var(--border-accent); background: var(--bg-panel-hover); }
#speed-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Slide-in Panels (shared) ────────────────────────────── */
.side-panel {
  position: fixed;
  top: var(--controls-height);
  bottom: 0;
  width: var(--panel-width);
  max-width: 90vw;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  transition: transform var(--t-slow) var(--ease-out),
              opacity var(--t-slow) var(--ease-out),
              visibility 0s linear var(--t-slow);
  overflow: hidden;
  /* A closed panel must not be reachable by Tab / screen readers. visibility flips AFTER the
     slide-out finishes (delay above) and BEFORE the slide-in starts (.open resets the delay). */
  visibility: hidden;
}
.side-panel.open { visibility: visible; transition-delay: 0s; }
.side-panel.panel-right {
  right: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transform: translateX(100%);
  border-right: none;
}
.side-panel.panel-left {
  left: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transform: translateX(-100%);
  border-left: none;
}
.side-panel.open { transform: translateX(0); }

/* Scrim backdrop — starts below the controls bar */
#panel-scrim {
  position: fixed;
  top: var(--controls-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-panel) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out);
}
#panel-scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Settings Panel ──────────────────────────────────────── */
#settings-panel { right: 0; }

.setting-section {
  margin-bottom: 24px;
}
.setting-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}
.setting-row label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--t-fast), background var(--t-fast);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: var(--accent);
}
.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Crossfade slider in settings */
.setting-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.setting-slider-row input[type="range"] { flex: 1; }
.setting-slider-value {
  font-size: 0.78rem;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Loop mode button group */
#loop-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.loop-btn {
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--t-fast);
}
.loop-btn.active {
  background: var(--accent-dim);
  border-color: var(--border-accent);
  color: var(--accent);
}
.loop-btn:hover:not(.active) { border-color: rgba(255,255,255,0.2); color: var(--text-primary); }

/* A/B Loop controls */
#ab-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#ab-status {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  padding: 6px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
#ab-btn-row {
  display: flex;
  gap: 6px;
}
.ab-btn {
  flex: 1;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--t-fast);
}
.ab-btn:hover { border-color: var(--border-accent); color: var(--accent); }
.ab-btn.set   { border-color: var(--border-accent); color: var(--accent); background: var(--accent-dim); }

/* Download button */
#btn-download-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  color: var(--accent);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
#btn-download-full:hover {
  background: rgba(240, 165, 0, 0.28);
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ── Settings Panel: Volume Row ─────────────────────────── */
#settings-volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#settings-volume-row input[type="range"] {
  flex: 1;
  --pct: 100%;
  background: linear-gradient(to right,
    var(--accent) 0%,
    var(--accent) var(--pct),
    rgba(255,255,255,0.15) var(--pct),
    rgba(255,255,255,0.15) 100%) no-repeat center / 100% 4px;
  border-radius: 2px;
}
#settings-volume-row input[type="range"]::-webkit-slider-runnable-track { background: transparent; }
#settings-volume-row input[type="range"]::-moz-range-track             { background: transparent; }
#settings-volume-value {
  font-size: 0.78rem;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Settings Panel: Action Buttons ─────────────────────── */
#settings-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: all var(--t-fast);
}
.settings-action-btn:hover {
  border-color: var(--border-accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.settings-action-btn svg { flex-shrink: 0; }

/* ── Queue / Playlist Panel ──────────────────────────────── */
#queue-panel { right: 0; }

.queue-header-actions {
  display: flex;
  gap: 6px;
}
#queue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
  position: relative;
}
.queue-item:hover  { background: var(--bg-panel-hover); border-color: var(--border); }
.queue-item.active { background: var(--accent-dim); border-color: var(--border-accent); }
.queue-item.active .qi-title { color: var(--accent); }

.qi-num {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.queue-item.active .qi-num {
  color: var(--accent);
  font-weight: 700;
}
.qi-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-panel-hover);
  flex-shrink: 0;
}
.qi-thumb-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.qi-info {
  flex: 1;
  min-width: 0;
}
.qi-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qi-ext {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.qi-drag {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
  flex-shrink: 0;
  opacity: 0.5;
}
.queue-item.dragging { opacity: 0.4; background: var(--accent-dim); }
.queue-item.drag-over { border-top: 2px solid var(--accent); }

/* Shuffle active indicator */
#btn-shuffle.active { color: var(--accent); }

/* ── Keyboard Shortcut Help Panel ────────────────────────── */
#shortcuts-panel {
  left: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  table-layout: fixed;          /* columns can't be pushed wider than the panel by long URLs (LAY-02) */
}
.shortcut-table tr + tr { border-top: 1px solid var(--border); }
.shortcut-table td { padding: 7px 4px; vertical-align: middle; overflow-wrap: anywhere; }
.shortcut-table td:first-child { width: 40%; }

.shortcut-group-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 14px 4px 4px;
}
kbd {
  display: inline-block;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Inter', monospace;
  font-size: 0.72rem;
  color: var(--text-primary);
  white-space: nowrap;
}

/* iframe-mode notice */
#iframe-notice {
  display: none;
  padding: 12px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 12px;
  line-height: 1.5;
}
body.in-iframe #iframe-notice { display: block; }
body.in-iframe .shortcut-table { opacity: 0.45; }

/* ── URL Params section in Shortcuts panel ───────────────── */
.url-params-section {
  margin-top: 20px;
}
.url-params-section code,
.shortcut-table code {
  font-family: 'Inter', monospace;
  font-size: 0.72rem;
  background: var(--bg-panel-hover);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  white-space: normal;          /* was nowrap: a long ?file=… example overflowed the panel */
  overflow-wrap: anywhere;
}

/* ── Panel navigation footer ─────────────────────────────── */
.panel-nav {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  background: var(--bg-panel);
}
.panel-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.panel-nav-btn:hover {
  background: var(--accent-dim);
}
.panel-nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Error / No-File State ───────────────────────────────── */
#error-screen {
  position: absolute;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  gap: 16px;
  padding: 32px;
  padding-top: max(48px, 8vh);
  background: var(--bg-base);
  text-align: center;
}
#error-screen.visible { display: flex; }
#error-params {
  text-align: left;
  max-width: 580px;
  width: 100%;
  margin-top: 8px;
  padding-bottom: 24px;
}
#error-icon { color: rgba(240,165,0,0.5); }
#error-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}
#error-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 380px;
  line-height: 1.6;
}

/* ── Loading Spinner ─────────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-controls) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-med);
}
#loading-overlay.visible { opacity: 1; pointer-events: auto; }
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Live region for screen-reader announcements ─────────── */
#sr-announce {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Toast notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--controls-height) + 8px);
  right: 16px;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.show {
  opacity: 1;
  transform: translateX(0);
}
.toast.toast-accent {
  border-color: var(--border-accent);
  color: var(--accent);
}

/* ── PiP button state ────────────────────────────────────── */
#btn-pip.active { color: var(--accent); }

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .viz-bar { animation: none; transform: scaleY(0.5); }
}

/* ── Responsive tweaks ───────────────────────────────────── */
@media (max-width: 600px) {
  :root { --panel-width: 90vw; }
  #controls-row { gap: 2px; }
  /* NOTE: Rewind / Forward / Speed used to be hidden here, which left phones with no way to skip.
     The phone layout (see "Phone & tablet layout" below) now shows them, large. */
  .time-display { min-width: 70px; font-size: 0.7rem; }

  /* Settings panel: larger text on small screens */
  .setting-label         { font-size: 0.8rem; }
  .setting-row label     { font-size: 0.92rem; }
  .settings-action-btn   { font-size: 0.92rem; }
  .vol-label             { font-size: 0.78rem; }

  /* Queue panel: larger text on small screens */
  .qi-title  { font-size: 0.88rem; }
  .qi-ext    { font-size: 0.76rem; }
  .qi-num    { font-size: 0.76rem; }

  /* Shortcuts panel: larger text on small screens */
  .shortcut-table        { font-size: 0.88rem; }
  .shortcut-group-header { font-size: 0.78rem; }
  kbd                    { font-size: 0.78rem; }

  /* Panel title and nav */
  .panel-title   { font-size: 0.95rem; }
  .panel-nav-btn { font-size: 0.82rem; }
}
@media (max-width: 400px) {
  #audio-art-placeholder { width: 160px; height: 160px; }
  /* Prev / Next used to be hidden here too; they now stay (hidden only for single-item queues). */
  #audio-title-display { font-size: 1.2rem; padding: 7px 16px; }
}

/* Short screens (landscape phone) — shrink art so title+visualizer still fit */
@media (max-height: 560px) {
  #audio-art { max-height: 32vh; }
  #audio-title-display { font-size: 1.1rem; padding: 6px 14px; }
}

/* ============================================================
   v2.0 — MOBILE-FIRST CONTROLS
   Everything below adds the skip buttons, chips, sheets and the
   phone/tablet layout. Desktop keeps the original top bar.
   ============================================================ */

/* ── Skip buttons (back / forward N seconds) ─────────────── */
.skip-btn { padding: 6px; }

/* ── Time display: elapsed / total — the total toggles to "−remaining" ── */
.time-dur {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  border-radius: 4px;
}
.time-dur:hover { color: var(--text-primary); }
.time-display.show-remaining .time-dur { color: var(--accent); }

/* ── Chips (speed / sleep-timer pickers) ─────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
/* Fixed-column grids keep the rows tidy: 10 speeds = 5 × 2, 6 sleep options = 3 × 2 */
#speed-chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
#sleep-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
#speed-chips .chip, #sleep-chips .chip { padding: 0 4px; font-size: 0.85rem; white-space: nowrap; }
.chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.chip:hover:not(.active) { border-color: rgba(255,255,255,0.22); color: var(--text-primary); }
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--accent-dim);
  border-color: var(--border-accent);
  color: var(--accent);
}
#sleep-status {
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  margin-left: 6px;
}

/* ── Quick row (phone/tablet only — hidden on desktop) ───── */
#quick-row { display: none; }
/* Icon above a short label (+ optional small state: "Off", "1.5×"). Stacked, like a bottom tab bar, so
   it still fits when a video playlist shows four chips on a 320px-wide phone. */
.chip-btn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.chip-btn:active { transform: scale(0.96); background: rgba(255,255,255,0.14); }
.chip-btn.active {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-dim);
}
.chip-btn svg { display: block; }
.chip-ico   { display: flex; flex-shrink: 0; }
.chip-text  { display: flex; flex-direction: row; align-items: baseline; justify-content: center; gap: 5px; max-width: 100%; min-width: 0; line-height: 1.15; }
.chip-label { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-state { font-size: 0.72rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.chip-btn:not(.active) .chip-state { color: var(--text-secondary); }
.chip-state:empty { display: none; }

/* ── Skip feedback bubbles ("+15 s") ─────────────────────── */
.skip-flash {
  position: absolute;
  top: 50%;
  z-index: calc(var(--z-controls) + 2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 96px;
  padding: 14px 18px;
  border-radius: 28px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.85);
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out);
}
.skip-flash-left  { left: 6%; }
.skip-flash-right { right: 6%; }
.skip-flash.show  { opacity: 1; transform: translateY(-50%) scale(1); }
.skip-flash .sf-ico { display: flex; color: var(--accent); }

/* ── "Resume at 12:34" offer ─────────────────────────────── */
#resume-pill {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: calc(var(--z-controls) + 2);
  display: flex;
  align-items: stretch;
  max-width: calc(100% - 24px);
  background: var(--accent);
  color: #111;
  border-radius: 28px;
  box-shadow: 0 6px 24px var(--accent-glow);
  overflow: hidden;
}
#resume-pill button {
  background: none;
  border: 0;
  color: inherit;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 48px;
  padding: 0 18px;
  cursor: pointer;
}
#resume-pill button:active { background: rgba(0,0,0,0.12); }
#btn-resume-dismiss { padding: 0 16px; border-left: 1px solid rgba(0,0,0,0.2); }

/* ── Settings: Advanced fold-out + action grid ───────────── */
.advanced-settings { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.advanced-settings > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary::after {
  content: '▾';
  margin-left: auto;
  transition: transform var(--t-fast);
}
.advanced-settings[open] > summary { margin-bottom: 12px; }
.advanced-settings[open] > summary::after { transform: rotate(180deg); }
#settings-actions-help .settings-action-btn { width: 100%; }

/* ── Mode-dependent visibility ───────────────────────────── */
body.audio-mode #btn-pip { display: none; }            /* Picture-in-Picture is video-only */
body.no-volume-control #volume-slider-wrap,
body.no-volume-control .vol-label,
body.no-volume-control #settings-volume-row input[type="range"],
body.no-volume-control #settings-volume-value,
body.no-volume-control #setting-crossfade { display: none; }  /* iOS ignores page-set volume */

/* ── Panel handle (only drawn on phones) ─────────────────── */
.panel-header { position: relative; }

/* ── Touch devices: no sticky :hover after a tap ─────────── */
@media (hover: none) {
  .icon-btn:hover:not(.active):not(#btn-play) { background: none; color: var(--text-secondary); }
  #btn-play:hover { background: var(--accent); transform: none; box-shadow: 0 4px 20px var(--accent-glow); }
  .chip:hover:not(.active)     { border-color: var(--border); color: var(--text-secondary); }
  .time-dur:hover              { color: inherit; }
  #scrubber-wrap:hover #scrubber-tooltip { opacity: 0; }
  #scrubber-wrap.dragging #scrubber-tooltip { opacity: 1; }
}
/* Drag-and-drop reordering needs a mouse; hide the useless handle on touch screens */
@media (hover: none) and (pointer: coarse) {
  .qi-drag { display: none; }
}

/* ============================================================
   PHONE & TABLET LAYOUT
   Applies to narrow windows AND to any touch-first device.
   Controls move to the bottom (thumb zone); panels become
   bottom sheets; everything tappable is >= 48px.
   ============================================================ */
@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  :root { --panel-width: 100vw; }

  /* Order: info bar (top) → content → controls (bottom) */
  #info-bar {
    order: 0;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left));
  }
  #content-area { order: 1; padding: 0 12px 8px; }
  #controls-bar {
    order: 2;
    padding: 6px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border-bottom: 0;
    border-top: 1px solid var(--border);
    border-radius: 24px 24px 0 0;
  }
  body.video-mode.controls-hidden #controls-bar { transform: translateY(8px); }

  /* Scrubber: tall touch area, always-visible knob, time bubble above the finger */
  #scrubber-row { flex-direction: column; align-items: stretch; gap: 0; margin-bottom: 4px; }
  /* flex: 0 0 auto — the base rule's `flex: 1` would otherwise collapse the HEIGHT in a column layout */
  #scrubber-wrap { flex: 0 0 auto; height: 44px; }
  #progress-track,
  #scrubber-wrap:hover #progress-track { height: 6px; border-radius: 3px; }
  #progress-fill, #progress-buffered { border-radius: 3px; }
  #progress-thumb,
  #scrubber-wrap:hover #progress-thumb { width: 20px; height: 20px; transform: translate(-50%, -50%) scale(1); }
  #scrubber-wrap.dragging #progress-thumb { transform: translate(-50%, -50%) scale(1.35); }
  #scrubber-tooltip {
    top: auto;
    bottom: calc(100% - 2px);
    padding: 6px 12px;
    font-size: 0.95rem;
    font-weight: 700;
  }
  #scrubber-wrap.dragging #scrubber-tooltip { opacity: 1; }
  .time-display {
    display: flex;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    margin-top: -8px;
    padding: 0 2px;
    font-size: 0.85rem;
    text-align: left;
  }
  .time-sep { display: none; }
  /* Generous hit area for the "remaining time" toggle without changing the row height */
  .time-dur { padding: 12px 0 12px 28px; margin: -12px 0; }

  /* Transport row: ⏮  ⟲15  ▶  15⟳  ⏭ */
  #controls-row { flex-direction: column; align-items: stretch; gap: 10px; }
  #controls-left, #controls-right { display: none; }
  #controls-center {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    justify-content: space-between;
    gap: 0;
  }
  #btn-prev, #btn-next {
    width: var(--tap-min); height: var(--tap-min);
    border-radius: 50%; padding: 0;
  }
  #btn-rew, #btn-fwd {
    width: var(--skip-size); height: var(--skip-size);
    border-radius: 50%; padding: 0;
    color: var(--text-primary);
  }
  #btn-play { width: var(--play-size); height: var(--play-size); }
  #btn-prev:disabled, #btn-next:disabled { visibility: hidden; }   /* single track: keep ▶ centred */

  /* Quick row: Loop · Queue · (Full screen for video) · More */
  #quick-row { display: flex; gap: 10px; }

  /* Settings / queue / shortcuts → bottom sheets */
  .side-panel,
  .side-panel.panel-right,
  .side-panel.panel-left,
  #settings-panel, #queue-panel, #shortcuts-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 86vh;
    max-height: 86dvh;
    border-radius: 24px 24px 0 0;
    border: 1px solid var(--border);
    border-bottom: 0;
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -12px 40px rgba(0,0,0,0.55);
  }
  /* The ID selectors above (needed to beat #shortcuts-panel's own corner radius) also win over a plain
     `.side-panel.open`, which would leave the sheet parked below the screen — so spell out the open state. */
  .side-panel.open,
  #settings-panel.open, #queue-panel.open, #shortcuts-panel.open { transform: translateY(0); }
  #panel-scrim { top: 0; }
  .panel-header { padding: 22px 12px 10px 20px; }
  .panel-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 44px;
    height: 5px;
    margin-left: -22px;
    border-radius: 3px;
    background: rgba(255,255,255,0.22);
  }
  .panel-close { width: var(--tap-min); height: var(--tap-min); }
  .panel-body { padding: 14px 16px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .panel-nav { display: none; }

  /* Settings content sized for fingers */
  .setting-section { margin-bottom: 22px; }
  .chip { min-height: 46px; }
  .loop-btn { flex: 1; min-height: 46px; font-size: 0.9rem; }
  .ab-btn { min-height: 46px; font-size: 0.9rem; }
  .setting-row { min-height: 48px; }
  .settings-action-btn { min-height: 54px; font-size: 0.92rem; }
  .queue-item { min-height: 60px; padding: 10px; }
  .qi-thumb, .qi-thumb-placeholder { width: 44px; height: 44px; }

  /* Toasts: top-centre, clear of the thumb */
  #toast-container {
    top: max(52px, calc(env(safe-area-inset-top) + 44px));
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
    width: max-content;
    max-width: calc(100vw - 32px);
  }
  .toast { transform: translateY(-12px); }
  .toast.show { transform: translateY(0); }

  /* Audio artwork: as big as fits between the title and the controls */
  body.audio-mode #content-area { gap: 14px; }
  #audio-card { max-width: 100%; gap: 14px; }
  #audio-art {
    max-width: min(80vw, 440px);
    max-height: calc(100vh - 460px);
    max-height: max(120px, calc(100dvh - 460px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }
  #audio-art-placeholder { width: min(60vw, 220px); height: min(60vw, 220px); }
  body.audio-mode #audio-title-display {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: clamp(1.15rem, 5.4vw, 1.7rem);
    padding: 8px 20px;
  }
}

/* Short portrait phones (e.g. iPhone SE): drop the visualizer so the artwork keeps some size */
@media (max-height: 640px) and (max-width: 820px),
       (max-height: 640px) and (hover: none) and (pointer: coarse) {
  body.audio-mode #visualizer { display: none; }
}

/* ── Compact: landscape phones and short embeds (iframe) ──
   One transport row, icon-only chips: ⟲ ⏮ ⟲15 ▶ 15⟳ ⏭ ☰ ⋯              */
@media (max-height: 460px) and (max-width: 820px),
       (max-height: 460px) and (hover: none) and (pointer: coarse) {
  #controls-bar { border-radius: 0; padding-top: 4px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  #scrubber-row { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 2px; }
  #scrubber-wrap { flex: 1 1 auto; height: 36px; }
  .time-display { width: auto; min-width: 96px; margin-top: 0; justify-content: flex-end; font-size: 0.8rem; }
  .time-sep { display: inline; padding: 0 0.35em; }   /* flex items drop the spaces around the "/" */
  .time-dur { padding: 0; margin: 0; }

  #controls-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; }
  #controls-center, #quick-row { display: contents; }     /* flatten so every button is one flex item */
  #btn-loop         { order: 1; }
  #btn-prev         { order: 2; }
  #btn-rew          { order: 3; }
  #btn-play         { order: 4; }
  #btn-fwd          { order: 5; }
  #btn-next         { order: 6; }
  #btn-queue-quick  { order: 7; }
  #btn-fs-quick     { order: 8; }
  #btn-more         { order: 9; }
  #btn-prev, #btn-next { width: 44px; height: 44px; }
  #btn-rew, #btn-fwd   { width: 48px; height: 48px; }
  #btn-play            { width: 56px; height: 56px; }
  .chip-btn { flex: 0 0 auto; min-width: 48px; min-height: 48px; padding: 0; border-radius: 14px; }
  .chip-text { display: none; }
  #audio-art { max-height: max(60px, calc(100dvh - 250px)); }
  #audio-title-display { font-size: 1.1rem; padding: 6px 14px; }
  body.audio-mode #visualizer { display: none; }
}
/* Narrow AND short (small embeds): let the row wrap rather than push buttons off-screen */
@media (max-height: 460px) and (max-width: 520px) {
  #controls-row { flex-wrap: wrap; justify-content: center; }
}
/* Very short (≈200px iframe): no room for artwork or the big title — show the small one-line title */
@media (max-height: 340px) {
  /* !important: updateAudioArt() sets inline display:block, which would otherwise win */
  body.audio-mode #audio-art,
  body.audio-mode #audio-art-placeholder,
  body.audio-mode #visualizer,
  body.audio-mode #audio-title-display { display: none !important; }
  body.audio-mode #media-title { display: block; }
}

/* ── Fullscreen adjustments ──────────────────────────────── */
:fullscreen #player-shell,
:-webkit-full-screen #player-shell {
  background: #000;
}
:fullscreen #content-area,
:-webkit-full-screen #content-area {
  padding: 0;
}
:fullscreen #controls-bar,
:-webkit-full-screen #controls-bar {
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  border: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  order: unset;
}
:fullscreen #info-bar,
:-webkit-full-screen #info-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
  padding-top: 16px;
}
