/* Player */
/* 9. Player */
body.has-player{ --player-h: 68px; }

.mini-player {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tg-bottom, 0px) + env(safe-area-inset-bottom, 0px) + 10px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 28px;
  background: color-mix(in srgb, var(--tg-secondary-bg-color, #f5f5f5) 40%, transparent);
  border: 0.5px solid color-mix(in srgb, var(--text-color, #000) 10%, transparent);
  box-shadow: 0 8px 22px rgba(0,0,0,.12) !important;
  z-index: 3200;
  backdrop-filter: blur(var(--glass-blur)) saturate(160%) !important;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%) !important;
  overflow: hidden;
}

body.dark .mini-player{
  background: color-mix(in srgb, var(--tg-secondary-bg-color, #252525) 40%, transparent) !important;
  box-shadow: 0 10px 26px rgba(0,0,0,.35) !important;
}

.mini-player.hidden{ display:none; }
body.keyboard-open .mini-player{
  display: none !important;
}
body.feedback-open .mini-player{
  bottom: calc(var(--tg-bottom, 0px) + env(safe-area-inset-bottom, 0px) + 68px);
}

.mini-player .mp-cover{
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(0,0,0,.06);
}

.mini-player .mp-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mini-player .mp-title{
  font-weight: 700;
  font-size: 14px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tg-text-color, var(--text-color));
}

.mini-player .mp-sub{
  font-size: 12px;
  line-height: 14px;
  color: var(--tg-hint-color, #7c7d7d);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player .mp-btn{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  background: rgba(0,0,0,0.06);
  color: var(--tg-text-color, var(--text-color));
}
body.dark .mini-player .mp-btn{ background: rgba(255,255,255,0.10); }

.mini-player .mp-btn:active{ transform: scale(.96); }

.mini-player .mp-close{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: transparent;
  color: var(--tg-text-color, var(--text-color));
  border: 1px solid rgba(0,0,0,.15);
}

body.dark .mini-player .mp-close {
  border-color: rgba(255,255,255,.18);
}

.mini-player .mp-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

.mp-yt-wrap { margin-top: 8px; }
.mp-yt-wrap.hidden { display: none; }

#mp-yt { width: 100%; aspect-ratio: 16/9; }
#mp-yt iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; }

/* ========= Player overlay ========= */
body.player-open {
  overflow: hidden !important;
  touch-action: none;
}

.player-overlay.hidden { display: none; }

.player-overlay{
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease;
  overscroll-behavior: contain;
}

.player-overlay.is-open{
  pointer-events: auto;
  opacity: 1;
}

.player-overlay .po-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .26s cubic-bezier(.22,.85,.24,1);
}

.player-overlay.is-open .po-backdrop{ opacity: 1; }

.player-overlay .po-sheet{
  --queue-p: 0;
  --queue-peek: 32px;
  position: absolute;
  inset: 0;
  min-height: calc(100dvh - var(--tg-top, 0px));
  background: var(--app-bg);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top, 0px) + 18px) 16px 0;
  transform: translateY(18px);
  transition: transform .26s cubic-bezier(.22,.85,.24,1), opacity .22s ease;
  opacity: 0;
  transform-origin: top left;
  will-change: transform;
  touch-action: none;
  border-radius: 34px 34px 0 0;
  overflow: hidden;
  box-shadow: 0 -18px 60px rgba(0,0,0,.20);
}

.player-overlay.is-open .po-sheet{
  transform: translateY(0);
  opacity: 1;
}

.player-overlay.is-dragging .po-sheet{ transition: none !important; }

.po-grabber{
  position: absolute;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  height: 24px;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 5;
  touch-action: pan-y;
}

.po-grabber::before{
  content:"";
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-color) 22%, transparent);
}

.player-overlay .po-header,
.player-overlay .po-controls,
.player-overlay .po-progress{
  flex: 0 0 auto;
}

.player-overlay .po-header{
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 68px;
  padding-top: 26px;
}

.player-overlay .po-header-cover{
  position: absolute;
  left: 0;
  top: 26px;
  width: 56px;
  height: 56px;
  border-radius: 0;
  object-fit: cover;
  background: rgba(0,0,0,.06);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  display: none !important;
}

.player-overlay .po-meta{
  width: 100%;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.player-overlay .po-title,
.player-overlay .po-sub{
  width: 100%;
  max-width: 100%;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.player-overlay .po-title{
  font-weight: 800;
  font-size: 18px;
  line-height: 1.2;
}

.player-overlay .po-sub{
  margin-top: 4px;
  opacity: .7;
  font-size: 14px;
  line-height: 1.2;
}

.player-overlay .po-title-text,
.player-overlay .po-sub-text{
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  will-change: transform;
}


.player-overlay.is-queue-expanded .po-meta{
  align-items: flex-start;
  padding-left: 84px;
  padding-right: 12px;
}

.player-overlay.is-queue-expanded .po-title,
.player-overlay.is-queue-expanded .po-sub{
  text-align: left;
}

.player-overlay .po-cover-wrap{
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 116px);
  width: min(80vw, 380px);
  aspect-ratio: 1 / 1;
  margin-top: 0;
  display: block;
  pointer-events: none;
  z-index: 3;

  transform:
    translateX(calc(-50% + (var(--queue-p) * -138px)))
    translateY(calc(var(--queue-p) * -190px))
    scale(calc(1 - (var(--queue-p) * .79)));

  transform-origin: center center;
  opacity: 1;
  transition: transform .26s cubic-bezier(.22,.85,.24,1);
}

.player-overlay .po-cover{
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: cover;
  box-shadow: 0 18px 60px rgba(0,0,0,.25);
}

.player-overlay .po-progress{
  position: relative;
  z-index: 2;
  margin-top: calc(420px - (var(--queue-p) * 380px));
  transition: margin-top .26s cubic-bezier(.22,.85,.24,1);
}

.player-overlay .po-times{
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  opacity: .8;
  font-size: 13px;
  margin-bottom: 10px;
}

.player-overlay .po-bar{
  cursor: pointer;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
  background: rgba(0,0,0,0.15);
  margin-top: 0;
  position: relative;
  touch-action: none;
}

body.dark .player-overlay .po-bar{ background: rgba(255,255,255,.12); }

.player-overlay .po-bar::before{
  content:"";
  position:absolute;
  left:0; right:0;
  top:-10px; bottom:-10px;
}

.player-overlay .po-bar.is-scrubbing{ transform: scaleY(1.25); }

.player-overlay .po-bar-fill{
  height: 100%;
  width: 0%;
  background: var(--accent-grad);
  border-radius: 999px;
}

.player-overlay .po-controls{
  position: relative;
  z-index: 2;
  margin-top: calc(22px - (var(--queue-p) * 6px));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 16px;
  width: 100%;
  transition: margin-top .26s cubic-bezier(.22,.85,.24,1);
}

.player-overlay .po-controls .po-side{
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-overlay .po-controls .po-left{ justify-content: flex-start; }
.player-overlay .po-controls .po-right{ justify-content: flex-end; }

.player-overlay .po-play{
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: var(--tg-button-color, var(--accent-color));
  color: var(--tg-button-text-color, #fff);
}

.player-overlay .po-controls .po-btn{
  flex: 0 0 auto;
}

.player-overlay .po-btn{
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 0;
  background: transparent;
  color: var(--text-color);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0;
}

.player-overlay .po-btn svg{
  width: 30px;
  height: 30px;
  display: block;
  fill: currentColor;
}
.player-overlay .po-play svg{
  width: 36px;
  height: 36px;
  display: block;
  fill: currentColor;
}

/* ========= Mini-player tweaks ========= */
.mini-player .mp-play{
  background: transparent !important;
  color: var(--accent-color) !important;
  box-shadow: none !important;
  border: 0 !important;
  box-shadow: none !important;
  width: 44px;
  height: 44px;
  margin-left: 8px;
}
.mini-player .mp-play svg{
  width: 26px;
  height: 26px;
  fill: var(--accent-color) !important;
  stroke: var(--accent-color) !important;
}

#mini-player .mp-play svg *{
  fill: var(--accent-color) !important;
  stroke: var(--accent-color) !important;
}

.mini-player .mp-btn.is-loading svg,
.player-overlay .po-play.is-loading svg,
.play-btn[data-state="loading"] svg{
  animation: spin 0.9s linear infinite;
}

.play-btn[data-state="loading"] svg,
.mini-player .mp-play.is-loading svg,
.player-overlay .po-play.is-loading svg {
  fill: none !important;
}

.play-btn[data-state="loading"] svg *,
.mini-player .mp-play.is-loading svg *,
.player-overlay .po-play.is-loading svg * {
  fill: none !important;
}

.mp-play.is-loading svg,
#po-play.is-loading svg {
  animation: mg-spin 0.9s linear infinite;
}

@keyframes mg-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.player-overlay .po-queue{
  flex: 1 1 auto;
  min-height: 0;
  opacity: calc(.18 + (var(--queue-p) * .82));
  overflow: hidden;
  margin-top: calc(10px + (var(--queue-p) * 8px));
  margin-left: -16px;
  margin-right: -16px;
  transform: translateY(calc((1 - var(--queue-p)) * (100% - var(--queue-peek))));
  transition:
    opacity .22s ease,
    margin-top .26s cubic-bezier(.22,.85,.24,1),
    transform .26s cubic-bezier(.22,.85,.24,1);
  pointer-events: none;
  position: relative;
}

.player-overlay .po-queue::before{
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 38px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--app-bg) 0%,
    color-mix(in srgb, var(--app-bg) 82%, transparent) 45%,
    transparent 100%
  );
  opacity: calc(1 - var(--queue-p));
  transition: opacity .22s ease;
  z-index: 2;
}

.player-overlay.is-queue-expanded .po-queue{
  pointer-events: auto;
}

.player-overlay .po-queue-list{
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
  padding: 0 16px 0;
}

.player-overlay .po-queue-list::-webkit-scrollbar{
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
}

.player-overlay .po-queue-item{
  display:flex;
  align-items:center;
  gap: 12px;
  width: 100%;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.player-overlay .po-queue-item + .po-queue-item{
  border-top: 1px solid rgba(0,0,0,.06);
}
body.dark .player-overlay .po-queue-item + .po-queue-item{ border-top-color: rgba(255,255,255,.06); }

.player-overlay .po-queue-item.is-current{
  position: relative;
  border-radius: 0;
  background: color-mix(in srgb, var(--app-bg) 88%, var(--text-color) 12%);
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

.player-overlay .po-queue-item.is-current + .po-queue-item{ border-top-color: transparent; }

.player-overlay .po-queue-cover{
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  flex: 0 0 56px;
  background: rgba(0,0,0,.06);
}

.player-overlay .po-queue-meta{
  min-width: 0;
  flex: 1 1 auto;
}

.player-overlay .po-queue-item-title{
  font-size: 16px;
  line-height: 1.25;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-overlay .po-queue-item.is-current .po-queue-item-title{
  color: inherit;
}

.player-overlay .po-queue-item-sub{
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.2;
  opacity: .72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-overlay.is-queue-expanded .po-sheet{ padding-bottom: 0; }

.player-overlay.is-dragging .po-sheet,
.player-overlay.is-dragging .po-backdrop,
.player-overlay.is-dragging .po-cover-wrap,
.player-overlay.is-dragging .po-meta,
.player-overlay.is-dragging .po-title,
.player-overlay.is-dragging .po-sub,
.player-overlay.is-dragging .po-progress,
.player-overlay.is-dragging .po-controls,
.player-overlay.is-dragging .po-queue{
  transition: none !important;
}

.po-queue-swipe{
  position: relative;
  overflow: hidden;
  background: var(--app-bg);
}

.po-queue-delete-bg{
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ff3b30;
  color: #fff;
  font-weight: 800;
  z-index: 1;
}

.po-queue-swipe .po-queue-item{
  position: relative;
  z-index: 2;
  background: var(--app-bg) !important;
}

.po-queue-swipe .po-queue-item.is-current{
  background: color-mix(in srgb, var(--app-bg) 88%, var(--text-color) 12%) !important;
}