/* ===== Unified Custom HTML5 Sermon Audio Player + Global Floating Bar ===== */
.bsp,.bsp *{box-sizing:border-box}
.bsp{
  --rd-surface:#ffffff;
  --rd-surface2:#ecebe4;
  --rd-text:#1d1e22;
  --rd-muted:#646b77;
  --rd-line:rgba(20,20,30,.1);
  --rd-accent:#2f6bff;
  --rd-accent-ink:#ffffff;
  --rd-accent-soft:rgba(47,107,255,.12);
  --rd-danger:#e5484d;
  --rd-shadow:0 12px 30px rgba(15,23,42,.18);
  font-family:var(--rd-font-sans,-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,Arial,sans-serif);
  font-variant-numeric:lining-nums tabular-nums;
  font-feature-settings:"lnum" 1,"tnum" 1;
  color:var(--rd-text);
  position:relative;
  user-select:none;
}
@media (prefers-color-scheme:dark){
  html:not([data-rd-theme="light"]) .bsp{
    --rd-surface:#16181d;
    --rd-surface2:#20232b;
    --rd-text:#eaecf0;
    --rd-muted:#98a0ad;
    --rd-line:rgba(255,255,255,.12);
    --rd-accent:#6ea8ff;
    --rd-accent-ink:#071122;
    --rd-accent-soft:rgba(110,168,255,.16);
    --rd-danger:#ff6b70;
    --rd-shadow:0 14px 34px rgba(0,0,0,.55);
  }
}
html[data-rd-theme="dark"] .bsp{
  --rd-surface:#16181d;
  --rd-surface2:#20232b;
  --rd-text:#eaecf0;
  --rd-muted:#98a0ad;
  --rd-line:rgba(255,255,255,.12);
  --rd-accent:#6ea8ff;
  --rd-accent-ink:#071122;
  --rd-accent-soft:rgba(110,168,255,.16);
  --rd-danger:#ff6b70;
  --rd-shadow:0 14px 34px rgba(0,0,0,.55);
}
html[data-rd-theme="light"] .bsp{
  --rd-surface:#ffffff;
  --rd-surface2:#ecebe4;
  --rd-text:#1d1e22;
  --rd-muted:#646b77;
  --rd-line:rgba(20,20,30,.1);
  --rd-accent:#2f6bff;
  --rd-accent-ink:#ffffff;
  --rd-accent-soft:rgba(47,107,255,.12);
}

.bsp [hidden]{display:none!important}
.bsp svg{fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none}
.bsp button,.bsp input{font:inherit;color:inherit}

/* Global persistent bottom bar wrapper (outside .content) */
@keyframes bspBarUp{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:none}}
.bs-gpbar{
  position:fixed;
  left:0;
  right:0;
  margin-inline:auto;
  bottom:max(12px,env(safe-area-inset-bottom,0px));
  width:min(840px,calc(100% - 24px));
  z-index:950;
  animation:bspBarUp .28s both;
}
.bs-gpbar[hidden]{display:none!important}
html:has(body.has-audio-bar){
  scroll-padding-bottom:calc(8.5rem + env(safe-area-inset-bottom,0px));
}
body.has-audio-bar footer{
  padding-bottom:calc(132px + env(safe-area-inset-bottom,0px));
}
body.has-audio-bar .sl-toasts,
body.has-audio-bar .rd-toasts,
body.has-audio-bar .sr-toasts{
  bottom:calc(122px + env(safe-area-inset-bottom,0px))!important;
}

.bsp.bsp-bar{
  background:color-mix(in srgb,var(--rd-surface) 94%,transparent);
  -webkit-backdrop-filter:saturate(180%) blur(18px);
  backdrop-filter:saturate(180%) blur(18px);
  border:1px solid color-mix(in srgb,var(--rd-text) 12%,var(--rd-line));
  border-radius:18px;
  padding:12px 16px;
  box-shadow:0 16px 42px rgba(15,23,42,.22);
}
.bsp.bsp-inline{
  background:var(--rd-surface);
  border:1px solid var(--rd-line);
  border-radius:16px;
  padding:14px 16px;
  box-shadow:0 4px 18px rgba(15,23,42,.05);
}

/* Header */
.bsp-head{
  display:flex;
  align-items:safe center;
  gap:8px 10px;
  margin-bottom:8px;
  min-width:0;
}
.bsp-date{
  background:var(--rd-surface2);
  color:var(--rd-text);
  font-weight:700;
  font-size:12.5px;
  padding:3px 9px;
  border-radius:7px;
  white-space:nowrap;
  flex:none;
}
.bsp-info{
  flex:1 1 auto;
  min-inline-size:0;
  display:flex;
  align-items:baseline;
  gap:8px;
  overflow:hidden;
}
.bsp-title{
  font-weight:700;
  font-size:14.5px;
  line-height:1.3;
  color:var(--rd-text)!important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  text-decoration:none!important;
}
a.bsp-title:hover{color:var(--rd-accent)!important}
.bsp-sub{
  font-size:12.5px;
  color:var(--rd-muted);
  white-space:nowrap;
  flex:none;
}
.bsp-resume{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  color:var(--rd-muted);
  white-space:nowrap;
  min-width:0;
}
.bsp-restart{
  border:1px solid var(--rd-line);
  background:var(--rd-surface2);
  color:var(--rd-text);
  border-radius:7px;
  padding:2px 8px;
  font-size:11.5px;
  font-weight:650;
  cursor:pointer;
  transition:background-color .15s,border-color .15s;
}
.bsp-restart:hover{border-color:var(--rd-accent);background:var(--rd-accent-soft);color:var(--rd-accent)}

.bsp-head-act{
  display:inline-flex;
  align-items:center;
  gap:4px;
  flex:none;
  margin-inline-start:auto;
}
.bsp-textlink{
  display:inline-flex;
  align-items:center;
  gap:4px;
  height:30px;
  padding:0 11px;
  border-radius:9px;
  background:var(--rd-accent-soft);
  color:var(--rd-accent)!important;
  font-size:12.5px;
  font-weight:650;
  white-space:nowrap;
  text-decoration:none!important;
  transition:filter .15s,transform .15s;
}
.bsp-textlink:hover{filter:brightness(1.06);transform:translateY(-1px)}

.bsp-ibtn{
  position:relative;
  width:32px;
  height:32px;
  border-radius:9px;
  border:0;
  background:transparent;
  color:var(--rd-muted);
  display:inline-grid;
  place-items:center;
  cursor:pointer;
  text-decoration:none!important;
  flex:none;
  transition:background-color .15s,color .15s,transform .12s;
}
.bsp-ibtn svg{width:17px;height:17px}
.bsp-ibtn:hover{background:var(--rd-surface2);color:var(--rd-text)}
.bsp-ibtn:active{transform:scale(.94)}
.bsp-ibtn:focus-visible{outline:2px solid var(--rd-accent);outline-offset:2px}
.bsp-close{font-size:21px;line-height:1}

/* Controls row */
.bsp-ctrl{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.bsp-transport{
  display:inline-flex;
  align-items:center;
  gap:4px;
  flex:none;
}
.bsp-ibtn.bsp-skip{
  width:auto;
  min-width:34px;
  height:34px;
  padding:0 7px;
  gap:2px;
  font-size:11.5px;
  font-weight:750;
  color:var(--rd-text);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:10px;
}
.bsp-ibtn.bsp-skip svg{width:15px;height:15px}

.bsp-play{
  position:relative;
  width:42px;
  height:42px;
  border-radius:50%;
  border:0;
  background:var(--rd-accent);
  color:var(--rd-accent-ink);
  display:inline-grid;
  place-items:center;
  cursor:pointer;
  flex:none;
  box-shadow:0 4px 14px var(--rd-accent-soft);
  transition:transform .15s,filter .15s;
}
.bsp-play:hover{transform:scale(1.05);filter:brightness(1.06)}
.bsp-play:active{transform:scale(.94)}
.bsp-play:focus-visible{outline:2px solid var(--rd-accent);outline-offset:3px}
.bsp-play svg{width:18px;height:18px;fill:currentColor;stroke:none}
.bsp-play .bsp-ico-play{margin-left:2px}
.bsp.is-playing .bsp-play .bsp-ico-play{display:none}
.bsp:not(.is-playing) .bsp-play .bsp-ico-pause{display:none}
.bsp.is-muted .bsp-mute .bsp-v-on{display:none}
.bsp:not(.is-muted) .bsp-mute .bsp-v-off{display:none}
.bsp-play .bsp-spin{
  position:absolute;
  inset:3px;
  border-radius:50%;
  border:2px solid transparent;
  border-top-color:currentColor;
  opacity:0;
  pointer-events:none;
}
.bsp.is-loading .bsp-play .bsp-spin{opacity:1;animation:bspSpin .8s linear infinite}
@keyframes bspSpin{to{transform:rotate(360deg)}}

/* Scrubber & Time */
.bsp-scrub{
  flex:1 1 160px;
  min-inline-size:0;
  display:flex;
  align-items:center;
  gap:8px;
}
.bsp-time{
  font-size:12.5px;
  font-weight:600;
  color:var(--rd-muted);
  white-space:nowrap;
  min-width:42px;
  text-align:center;
  flex:none;
}
.bsp-dur{
  border:0;
  background:transparent;
  padding:3px 5px;
  border-radius:6px;
  cursor:pointer;
  color:var(--rd-muted);
  font:inherit;
  font-weight:600;
  font-size:12.5px;
  white-space:nowrap;
  min-width:42px;
  text-align:center;
  flex:none;
  transition:background-color .15s,color .15s;
}
.bsp-dur:hover{background:var(--rd-surface2);color:var(--rd-text)}
.bsp-dur:focus-visible{outline:2px solid var(--rd-accent);outline-offset:1px}

/* Native Range Slider (timeline + volume) */
.bsp-slider{
  --slider-track-size:6px;
  --slider-thumb-size:16px;
  --slider-track-radius:999px;
  --slider-thumb-radius:50%;
  --slider-track-color:#8b929e;
  --slider-fill-color:var(--rd-accent);
  --slider-thumb-color:var(--rd-accent);
  --slider-direction:to right;
  --attr-min:attr(min type(<number>),0);
  --attr-max:attr(max type(<number>),100);
  --control-value:attr(value type(<number>),0);
  --slider-progress:calc(progress(var(--control-value),var(--attr-min),var(--attr-max)) * 100%);

  -webkit-appearance:none;
  appearance:none;
  flex:1 1 auto;
  min-inline-size:60px;
  inline-size:100%;
  block-size:32px;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  cursor:pointer;
}
.bsp-slider:dir(rtl){--slider-direction:to left}
@supports not (opacity: progress(1, 0, 100)){
  .bsp-slider{
    --slider-progress:calc((var(--control-value) - var(--attr-min)) / max(1, (var(--attr-max) - var(--attr-min))) * 100%);
  }
}
@media (prefers-color-scheme:dark){
  html:not([data-rd-theme="light"]) .bsp-slider{--slider-track-color:#69707d}
}
html[data-rd-theme="dark"] .bsp-slider{--slider-track-color:#69707d}

/* WebKit/Blink slider parts */
.bsp-slider::-webkit-slider-runnable-track{
  block-size:var(--slider-track-size);
  border:0;
  border-radius:var(--slider-track-radius);
  background:linear-gradient(
    var(--slider-direction),
    var(--slider-fill-color) var(--slider-progress),
    var(--slider-track-color) var(--slider-progress)
  );
}
.bsp-slider::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  inline-size:var(--slider-thumb-size);
  block-size:var(--slider-thumb-size);
  margin-block-start:calc((var(--slider-track-size) - var(--slider-thumb-size)) / 2);
  border:2px solid var(--rd-surface);
  border-radius:var(--slider-thumb-radius);
  background:var(--slider-thumb-color);
  box-shadow:0 1px 4px rgba(0,0,0,.28);
  transition:transform .12s;
}
.bsp-slider:hover::-webkit-slider-thumb{transform:scale(1.12)}

/* Firefox slider parts (strictly separate rules) */
.bsp-slider::-moz-range-track{
  block-size:var(--slider-track-size);
  border:0;
  border-radius:var(--slider-track-radius);
  background:var(--slider-track-color);
}
.bsp-slider::-moz-range-progress{
  block-size:var(--slider-track-size);
  border-radius:var(--slider-track-radius);
  background:var(--slider-fill-color);
}
.bsp-slider::-moz-range-thumb{
  inline-size:var(--slider-thumb-size);
  block-size:var(--slider-thumb-size);
  border:2px solid var(--rd-surface);
  border-radius:var(--slider-thumb-radius);
  background:var(--slider-thumb-color);
  box-shadow:0 1px 4px rgba(0,0,0,.28);
}

.bsp-slider:focus-visible{
  outline:2px solid var(--slider-fill-color);
  outline-offset:4px;
  border-radius:6px;
}

/* Right tools (quality + speed + volume) */
.bsp-tools{
  display:inline-flex;
  align-items:center;
  gap:6px;
  flex:none;
  position:relative;
}
.bsp-rate-wrap,.bsp-qual-wrap{position:relative}
.bsp-rate,.bsp-qual{
  position:relative;
  height:32px;
  min-width:42px;
  padding:0 9px;
  border-radius:9px;
  border:1px solid var(--rd-line);
  background:var(--rd-surface2);
  color:var(--rd-text);
  font-size:12px;
  font-weight:700;
  cursor:pointer;
  white-space:nowrap;
  transition:background-color .15s,color .15s,border-color .15s;
}
.bsp-rate:hover,.bsp-qual:hover{border-color:var(--rd-accent)}
.bsp-rate.is-active,.bsp-qual.is-active{
  background:var(--rd-accent-soft);
  color:var(--rd-accent);
  border-color:color-mix(in srgb,var(--rd-accent) 40%,var(--rd-line));
}
.bsp-rate:focus-visible,.bsp-qual:focus-visible{outline:2px solid var(--rd-accent);outline-offset:2px}
.bsp-rate-menu,.bsp-qual-menu{
  position:absolute;
  bottom:calc(100% + 8px);
  right:0;
  z-index:30;
  background:var(--rd-surface);
  border:1px solid var(--rd-line);
  border-radius:13px;
  box-shadow:0 12px 30px rgba(0,0,0,.24);
  padding:5px;
}
.bsp-rate-menu{
  display:grid;
  grid-template-columns:repeat(2,minmax(60px,1fr));
  gap:3px;
  min-width:140px;
}
.bsp-qual-menu{
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:196px;
}
.bsp-rate-menu button{
  border:0;
  background:transparent;
  color:var(--rd-text);
  border-radius:8px;
  padding:7px 8px;
  font-size:12.5px;
  font-weight:650;
  cursor:pointer;
  transition:background-color .15s,color .15s;
}
.bsp-rate-menu button:hover{background:var(--rd-surface2)}
.bsp-rate-menu button.on{background:var(--rd-accent);color:var(--rd-accent-ink)}
.bsp-qual-menu button{
  display:flex;
  align-items:center;
  gap:7px;
  width:100%;
  border:0;
  background:transparent;
  color:var(--rd-text);
  border-radius:8px;
  padding:7px 10px;
  font-size:12.5px;
  font-weight:650;
  cursor:pointer;
  text-align:left;
  white-space:nowrap;
  transition:background-color .15s,color .15s;
}
.bsp-qual-menu button:hover{background:var(--rd-surface2)}
.bsp-qual-menu button::before{
  content:"";
  flex:none;
  inline-size:14px;
  font-weight:800;
  color:var(--rd-accent);
}
.bsp-qual-menu button[aria-checked="true"]::before{content:"✓"}
.bsp-qual-menu button[aria-checked="true"]{
  background:var(--rd-accent-soft);
  color:var(--rd-accent);
}
.bsp-qual-menu .bsp-mhint{
  margin-inline-start:auto;
  font-size:11.5px;
  font-weight:500;
  color:var(--rd-muted);
}

.bsp-vol-wrap{display:inline-flex;align-items:center;gap:4px}
.bsp-vol{inline-size:66px;min-inline-size:66px;--slider-thumb-size:13px;--slider-track-size:5px}

/* Error message */
.bsp-err{
  margin-top:8px;
  padding:6px 10px;
  border-radius:9px;
  background:color-mix(in srgb,var(--rd-danger,#e5484d) 12%,transparent);
  color:var(--rd-danger,#e5484d);
  font-size:12.5px;
  font-weight:600;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.bsp-err a{color:inherit;text-decoration:underline}

/* Responsive adjustments */
@media (max-width:720px){
  .bsp-vol-wrap{display:none}
  .bsp-sub{display:none}
}
@media (max-width:560px){
  .bsp.bsp-bar,.bsp.bsp-inline{padding:10px 12px}
  .bsp-head{gap:6px;margin-bottom:6px;flex-wrap:wrap}
  .bsp-info:has(.bsp-resume:not([hidden])) .bsp-title{display:none}
  .bsp-title{font-size:13.5px}
  .bsp-textlink{padding:0 8px;font-size:12px;height:28px}
  .bsp-ctrl{gap:5px}
  .bsp-play{width:36px;height:36px}
  .bsp-ibtn.bsp-skip{min-width:26px;padding:0 3px;font-size:11px;height:32px}
  .bsp-scrub{gap:4px;flex:1 1 80px}
  .bsp-slider{min-inline-size:24px}
  .bsp-time,.bsp-dur{min-width:0;font-size:11px;padding:2px}
  .bsp-tools{gap:4px}
  .bsp-rate,.bsp-qual{min-width:30px;padding:0 6px;font-size:11.5px;height:30px}
}
@media (max-width:480px){
  .bsp-skip-num{display:none}
  .bsp-transport{gap:2px}
}
@media (pointer:coarse){
  .bsp-ibtn::after,.bsp-play::after,.bsp-rate::after,.bsp-qual::after,.bsp-dur::after{
    content:"";
    position:absolute;
    inset:-6px;
  }
  .bsp-slider{block-size:44px}
}
@media (prefers-reduced-motion:reduce){
  .bsp *,.bs-gpbar{transition:none!important;animation:none!important}
}
@media print{.bs-gpbar,.bsp{display:none!important}}
