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

/* ── Google Font ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Gabriela&display=swap');

/* ── 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;

  /* Layout */
  --controls-height:  72px;
  --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;
}

/* ── 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: 12px 12px 0;
  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-top: 1px solid var(--border);
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
  flex-shrink: 0;
  transition: opacity var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
}

/* Auto-hide in video mode */
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;
}

/* Chapters track */
#chapters-track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  pointer-events: none;
}

#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 */
#scrubber-tooltip {
  position: absolute;
  top: -36px;
  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 */
#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;
  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: 0;
  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);
  overflow: hidden;
}
.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 */
#panel-scrim {
  position: fixed;
  inset: 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;
  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: Speed Select ───────────────────────── */
#settings-speed-select {
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  text-align: center;
}
#settings-speed-select:hover  { border-color: var(--border-accent); background: var(--bg-panel); }
#settings-speed-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 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;
}
.shortcut-table tr + tr { border-top: 1px solid var(--border); }
.shortcut-table td { padding: 7px 4px; vertical-align: middle; }
.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: nowrap;
}

/* ── 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: center;
  gap: 16px;
  padding: 32px;
  background: var(--bg-base);
  text-align: center;
}
#error-screen.visible { display: flex; }
#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: 16px;
  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; }
  #btn-rew, #btn-fwd { display: none; }
  #speed-select { display: none; }
  .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; }
  #btn-prev, #btn-next { display: none; }
  #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; }
}

/* ── 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-top: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
}
: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;
}
