/* ===== Video Player ===== */
.pp {
  --pp-ease: cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  container-type: size;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  isolation: isolate;
}

.pp {
  contain: layout paint;
}

.pp.is-fs,
.pp:fullscreen {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.pp.is-playing:not(.controls-on) {
  cursor: none;
}

.pp-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.pp-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: pan-y;
  -webkit-touch-callout: none;
}

/* ---------- swipe-to-seek ---------- */
.pp-swipe {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.7);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.12s;
}

.pp-swipe.is-on {
  opacity: 1;
}

.pp-swipe-delta {
  font-size: 22px;
  font-weight: 700;
}

.pp-swipe-time {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}

.pp.is-swiping .pp-center,
.pp.is-swiping .pp-spinner {
  visibility: hidden;
}

.pp button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---------- gradient scrims ---------- */
.pp::before,
.pp::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s var(--pp-ease);
}

.pp::before {
  top: 0;
  height: 90px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent);
}

.pp::after {
  bottom: 0;
  height: 130px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.45) 55%, transparent 100%);
}

.pp.controls-on.has-started::after,
.pp.controls-on.is-fs::before {
  opacity: 1;
}

@media (pointer: coarse) {
  .pp.controls-on.has-started .pp-layer {
    background: rgba(0, 0, 0, 0.32);
  }
}

/* ---------- top bar ---------- */
.pp-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: none;
  padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 0 calc(18px + env(safe-area-inset-left));
  pointer-events: none;
  transition: opacity 0.25s var(--pp-ease);
}

.pp.is-fs .pp-top {
  display: block;
}

.pp:not(.controls-on) .pp-top {
  opacity: 0;
}

.pp-title {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* ---------- center cluster ---------- */
.pp-center {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 12cqw, 90px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--pp-ease);
}

.pp.controls-on .pp-center {
  opacity: 1;
}

.pp.controls-on .pp-center-btn {
  pointer-events: auto;
}

.pp.is-ended .pp-center {
  display: none;
}

.pp-center-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  transition: transform 0.15s var(--pp-ease), background 0.15s, opacity 0.2s;
}

.pp-center-btn:active {
  transform: scale(0.9);
}

.pp-center-play {
  width: 68px;
  height: 68px;
  background: rgba(0, 0, 0, 0.6);
}

.pp-center-skip {
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.35);
}

.pp-center-skip span {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -38%);
}

.pp:not(.has-started) .pp-center-skip {
  visibility: hidden;
}

.pp.is-waiting .pp-center-play {
  opacity: 0;
  pointer-events: none;
}

@media (pointer: fine) {
  .pp-center-skip {
    display: none;
  }

  .pp.is-playing .pp-center {
    display: none;
  }

  .pp-center-play {
    width: 72px;
    height: 72px;
  }

  .pp-center-play:hover {
    background: var(--accent);
  }
}

/* ---------- spinner ---------- */
.pp-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  pointer-events: none;
  animation: spin 0.8s linear infinite;
}

.pp.is-waiting .pp-spinner {
  display: block;
  animation: spin 0.8s linear infinite, pp-spinner-in 0.2s ease-out 0.35s both;
}

@keyframes pp-spinner-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- double-tap ripple ---------- */
.pp-ripple {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
  animation: pp-fade-in 0.15s ease-out;
}

.pp-ripple-left {
  left: 0;
  border-radius: 0 50% 50% 0 / 0 60% 60% 0;
}

.pp-ripple-right {
  right: 0;
  border-radius: 50% 0 0 50% / 60% 0 0 60%;
}

.pp-ripple-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* ---------- on-screen display ---------- */
.pp-osd {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  min-width: 76px;
  height: 76px;
  padding: 0 14px;
  border-radius: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: pp-osd 0.65s var(--pp-ease) forwards;
}

.pp-boost {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border-pink);
  pointer-events: none;
  animation: pp-fade-in 0.15s ease-out;
}

.pp-toast {
  position: absolute;
  left: 12px;
  bottom: 74px;
  max-width: calc(100% - 24px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  background: rgba(20, 20, 22, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: pp-fade-in 0.2s ease-out;
}

.pp-toast button {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

/* ---------- bottom controls ---------- */
.pp-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 0 12px 4px;
  transition: opacity 0.25s var(--pp-ease), transform 0.25s var(--pp-ease);
}

.pp.is-fs .pp-controls {
  padding: 0 calc(12px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}

.pp:not(.controls-on) .pp-controls {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.pp-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 46px;
}

.pp-bar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.pp-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  opacity: 0.92;
  transition: opacity 0.15s, background 0.15s, transform 0.15s;
}

.pp-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.pp-btn:active {
  transform: scale(0.88);
}

.pp-btn:focus-visible,
.pp-center-btn:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}

.pp-gear svg {
  transition: transform 0.3s var(--pp-ease);
}

.pp-gear.is-open svg {
  transform: rotate(60deg);
}

.pp-time {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.pp-chip {
  margin-right: 4px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--pink-light);
  border: 1px solid var(--border-pink);
}

.pp-volume {
  display: flex;
  align-items: center;
}

.pp-volume-slider {
  --vol: 1;
  width: 0;
  height: 4px;
  opacity: 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 2px;
  cursor: pointer;
  background: linear-gradient(to right, var(--pink) calc(var(--vol) * 100%), rgba(255, 255, 255, 0.3) 0);
  transition: width 0.2s var(--pp-ease), opacity 0.2s, margin 0.2s;
}

.pp-volume:hover .pp-volume-slider,
.pp-volume:focus-within .pp-volume-slider {
  width: 72px;
  opacity: 1;
  margin: 0 8px 0 2px;
}

.pp-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
}

.pp-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
}

@media (pointer: coarse) {
  .pp-fine-only,
  .pp-volume-slider {
    display: none;
  }

  .pp-btn {
    width: 44px;
    height: 44px;
  }
}

/* ---------- progress bar ---------- */
.pp-progress {
  --progress: 0;
  --buffered: 0;
  --hover: 0;
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

.pp-progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.22);
  transition: height 0.15s var(--pp-ease);
}

.pp-progress-buffered,
.pp-progress-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
}

.pp-progress-buffered {
  background: rgba(255, 255, 255, 0.35);
  transform: scaleX(var(--buffered));
}

.pp-progress-fill {
  background: var(--pink);
  transform: scaleX(var(--progress));
  will-change: transform;
}

.pp-progress-thumb-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  pointer-events: none;
  transform: translateX(calc(var(--progress) * 100%));
  will-change: transform;
}

.pp-progress-thumb {
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pink);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s var(--pp-ease);
}

.pp-progress:hover .pp-progress-track,
.pp-progress[data-scrubbing] .pp-progress-track {
  height: 6px;
}

.pp-progress:hover .pp-progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.pp-progress[data-scrubbing] .pp-progress-thumb {
  transform: translate(-50%, -50%) scale(1.3);
}

.pp-progress-tooltip {
  position: absolute;
  bottom: 22px;
  left: clamp(24px, calc(var(--hover) * 100%), calc(100% - 24px));
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(20, 20, 22, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

.pp-progress[data-scrubbing] .pp-progress-tooltip {
  opacity: 1;
  font-size: 14px;
  bottom: 26px;
}

@media (pointer: fine) {
  .pp-progress:hover .pp-progress-tooltip {
    opacity: 1;
  }
}

@media (pointer: coarse) {
  .pp-progress {
    height: 26px;
  }

  .pp-progress-thumb {
    transform: translate(-50%, -50%) scale(1);
  }

  .pp-progress[data-scrubbing] .pp-progress-thumb {
    transform: translate(-50%, -50%) scale(1.5);
  }
}

/* ---------- settings menu ---------- */
.pp-menu-anchor {
  position: relative;
}

.pp-menu-backdrop {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.pp-menu {
  position: absolute;
  z-index: 10;
  right: -40px;
  bottom: calc(100% + 10px);
  width: 260px;
  max-height: min(320px, 78cqh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border-radius: var(--radius-lg);
  background: rgba(20, 20, 22, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: pp-menu-in 0.18s var(--pp-ease);
}

.pp-menu-grabber {
  display: none;
}

.pp-menu-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid var(--border-subtle);
}

.pp-menu-head button {
  display: flex;
  color: var(--text-secondary);
}

.pp-menu-back {
  justify-content: flex-start;
}

.pp-menu-row,
.pp-menu-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: #fff;
  text-align: left;
  transition: background 0.12s;
}

.pp-menu-row:hover,
.pp-menu-option:hover {
  background: rgba(255, 255, 255, 0.07);
}

.pp-menu-value {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-secondary);
}

.pp-menu-option.is-active {
  color: var(--pink-light);
  font-weight: 600;
}

.pp-menu-check {
  width: 16px;
  display: inline-flex;
}

@media (pointer: coarse) {
  .pp-menu-backdrop {
    background: rgba(0, 0, 0, 0.5);
    animation: pp-fade-in 0.2s ease-out;
  }

  .pp-menu-anchor {
    position: static;
  }

  .pp-menu {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 92cqh;
    padding: 4px 10px 10px;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    animation: pp-sheet-in 0.22s var(--pp-ease);
  }

  .pp.is-fs .pp-menu {
    left: 50%;
    right: auto;
    width: min(480px, 100%);
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    animation: pp-fade-in 0.2s ease-out;
  }

  .pp-menu-grabber {
    display: block;
    width: 36px;
    height: 4px;
    margin: 6px auto 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
  }

  .pp-menu-row {
    padding: 12px;
  }

  .pp-menu-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 2px 0 4px;
  }

  .pp-menu-option {
    justify-content: center;
    gap: 0;
    padding: 11px 4px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.06);
  }

  .pp-menu-option.is-active {
    color: #fff;
    background: var(--pink);
  }

  .pp-menu-check {
    display: none;
  }
}

/* ---------- end screen ---------- */
.pp-end {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.8);
  animation: pp-fade-in 0.3s ease-out;
}

.pp-replay {
  pointer-events: auto;
}

.pp-next {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pp-next-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.pp-next-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-lg);
  text-align: left;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.15s;
}

.pp-next-card:hover {
  background: rgba(255, 255, 255, 0.12);
}

.pp-next-card img {
  width: 128px;
  aspect-ratio: 16 / 9;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.pp-next-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pp-next-play {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
}

.pp-next-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.pp-next-actions .btn {
  padding: 8px 16px;
  font-size: 13px;
}

/* ---------- error ---------- */
.pp-error {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  font-size: 14px;
  background: rgba(10, 7, 9, 0.95);
}

@container (max-height: 240px) {
  .pp-next-card img {
    width: 96px;
  }

  .pp-next-label,
  .pp-next-title {
    font-size: 12px;
  }

  .pp-center-play {
    width: 60px;
    height: 60px;
  }

  .pp-center-skip {
    width: 48px;
    height: 48px;
  }
}

/* ---------- animations ---------- */
@keyframes pp-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pp-osd {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
}

@keyframes pp-menu-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes pp-sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pp *,
  .pp::before,
  .pp::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- watch page ---------- */
.watch-player .pp:not(.is-fs) {
  max-height: calc(100svh - var(--header-h) - var(--nav-h) - 40px);
}

@media (max-width: 899px) {
  .watch-player .pp:not(.is-fs) {
    max-height: calc(100svh - var(--header-h) - 24px);
  }
}

/* Landscape phone without element fullscreen (iPhone): fill the screen once playback started */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .watch-player .pp.has-started:not(.is-fs) {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
  }

  .watch-player .pp.has-started:not(.is-fs) .pp-controls {
    padding: 0 calc(12px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }

  .watch-player .pp.has-started:not(.is-fs) .pp-top {
    display: block;
  }

  .watch-player .pp.has-started.controls-on:not(.is-fs)::before {
    opacity: 1;
  }
}

/* sticky mobile player (portrait phones) */
@media (max-width: 768px) and (orientation: portrait) {
  .watch-player {
    position: sticky;
    top: calc(var(--header-h) + 1px);
    z-index: 30;
    margin: 0 calc(-1 * var(--container-pad));
  }

  .watch-player .pp:not(.is-fs) {
    border-radius: 0;
    max-height: none;
  }
}

/* ---------- Icon states (server-rendered markup) ---------- */
.pp-ico {
  display: flex;
}

.pp .pp-ico-pause,
.pp.is-playing .pp-ico-play,
.pp .pp-ico-min,
.pp.is-fs .pp-ico-max,
.pp .pp-ico-vol-x,
.pp .pp-ico-vol-1,
.pp .pp-ico-vol-2 {
  display: none;
}

.pp.is-playing .pp-ico-pause,
.pp.is-fs .pp-ico-min,
.pp[data-vol='x'] .pp-ico-vol-x,
.pp[data-vol='1'] .pp-ico-vol-1,
.pp[data-vol='2'] .pp-ico-vol-2 {
  display: flex;
}