.player {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s var(--ease);
}
.player[hidden] {
  display: none;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player.idle {
  cursor: none;
}
.player.idle .p-top,
.player.idle .p-bottom {
  opacity: 0;
  pointer-events: none;
}

.p-top,
.p-bottom {
  position: absolute;
  left: 0;
  right: 0;
  padding: 20px 26px;
  transition: opacity 0.25s var(--ease);
  z-index: 2;
}
.p-top {
  top: 0;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.85), transparent);
  color: #fff;
}
.p-bottom {
  bottom: 0;
  background: linear-gradient(to top, rgb(0 0 0 / 0.9), transparent);
  color: #fff;
}
.p-title {
  font-size: 19px;
  font-weight: 650;
  line-height: 1.3;
}
.p-sub {
  font-size: 13.5px;
  color: rgb(255 255 255 / 0.68);
  margin-top: 3px;
}
.p-mode {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgb(255 255 255 / 0.14);
  align-self: center;
}
/* Genuine re-encode only — a warm tint flags the one case that's actually slow/CPU-bound. */
.p-mode-transcode {
  background: rgb(255 150 60 / 0.22);
  color: rgb(255 200 150);
}

.p-btn {
  width: 42px;
  height: 42px;
  flex: none;
  border: none;
  border-radius: 10px;
  background: rgb(255 255 255 / 0.1);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.16s var(--ease), transform 0.16s var(--ease);
}
.p-btn:hover {
  background: rgb(255 255 255 / 0.24);
}
.p-btn:active {
  transform: scale(0.94);
}
.p-btn.on {
  background: var(--accent);
}
.p-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}
.p-btn.big {
  width: 54px;
  height: 54px;
  background: var(--accent);
}
.p-btn.big:hover {
  background: #8f74ff;
}

/* Seek bar */
.p-seek {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 6px;
}
.p-seek .track {
  position: relative;
  height: 5px;
  width: 100%;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.24);
  overflow: hidden;
  transition: height 0.15s var(--ease);
}
.p-seek:hover .track {
  height: 8px;
}
.p-seek .buffered,
.p-seek .played {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 99px;
}
.p-seek .buffered {
  background: rgb(255 255 255 / 0.3);
}
.p-seek .played {
  background: var(--accent);
}
.p-seek .knob {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s var(--ease);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.5);
  pointer-events: none;
}
.p-seek:hover .knob {
  transform: translate(-50%, -50%) scale(1);
}
.p-seek .hover-time {
  position: absolute;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.85);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
}
.p-seek:hover .hover-time {
  opacity: 1;
}

.p-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.p-time {
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  color: rgb(255 255 255 / 0.85);
  white-space: nowrap;
}
.p-volume {
  display: flex;
  align-items: center;
  gap: 8px;
}
.p-volume input {
  width: 0;
  opacity: 0;
  transition: width 0.2s var(--ease), opacity 0.2s var(--ease);
  accent-color: var(--accent);
}
.p-volume:hover input,
.p-volume input:focus {
  width: 84px;
  opacity: 1;
}

/* Track menus */
.p-menu {
  position: absolute;
  right: 26px;
  bottom: 96px;
  min-width: 210px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 7px;
  border-radius: 12px;
  background: rgb(18 20 28 / 0.97);
  border: 1px solid rgb(255 255 255 / 0.12);
  box-shadow: var(--shadow-lg);
  z-index: 3;
  animation: fade-in 0.15s var(--ease);
}
.p-menu[hidden] {
  display: none;
}
.p-menu h4 {
  margin: 8px 10px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-mute);
}
.p-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  text-align: left;
}
.p-menu button:hover {
  background: rgb(255 255 255 / 0.09);
}
.p-menu button.sel {
  color: var(--accent-2);
}

.p-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.p-center .bubble {
  padding: 18px;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  opacity: 0;
  transform: scale(0.8);
}
.p-center .bubble.show {
  animation: pulse 0.55s var(--ease);
}
@keyframes pulse {
  0% {
    opacity: 0.95;
    transform: scale(0.8);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

.p-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.p-loading .spin {
  width: 42px;
  height: 42px;
  border-width: 3px;
  border-color: rgb(255 255 255 / 0.2);
  border-top-color: #fff;
}
.p-loading[hidden] {
  display: none;
}

.p-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
  color: #fff;
  background: rgb(0 0 0 / 0.8);
  z-index: 4;
}
.p-error[hidden] {
  display: none;
}
.p-error h3 {
  margin: 0 0 10px;
  font-size: 18px;
}
.p-error p {
  color: rgb(255 255 255 / 0.7);
  max-width: 460px;
  margin: 0 auto 20px;
  font-size: 14px;
}

/* Up-next card */
.p-upnext {
  position: absolute;
  right: 26px;
  bottom: 110px;
  width: 300px;
  padding: 16px;
  border-radius: 14px;
  background: rgb(18 20 28 / 0.96);
  border: 1px solid rgb(255 255 255 / 0.13);
  box-shadow: var(--shadow-lg);
  z-index: 3;
  animation: fade-in 0.25s var(--ease);
}
.p-upnext[hidden] {
  display: none;
}
.p-upnext .label {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.p-upnext .name {
  font-weight: 650;
  margin: 6px 0 14px;
  font-size: 14.5px;
  color: #fff;
}
.p-upnext .actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 640px) {
  .p-top,
  .p-bottom {
    padding: 14px 16px;
  }
  .p-title {
    font-size: 15px;
  }
  .p-volume {
    display: none;
  }
  .p-upnext {
    right: 16px;
    left: 16px;
    width: auto;
  }
}
