/* Player overlay */

.player {
  --pp: clamp(14px, 2.4vw, 40px);
  position: fixed; inset: 0; z-index: 100;
  background: #000;
  color: #f7f3ec;
  overflow: hidden;
  opacity: 0;
  transition: opacity 220ms var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.player.is-in { opacity: 1; }
.player:focus { outline: none; }
.player.is-idle { cursor: none; }

.p-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.p-surface { position: absolute; inset: 0; z-index: 1; }

/* Subtitles */
.p-video::cue {
  color: #fff;
  background: rgba(8, 6, 10, 0.62);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 6px rgba(0, 0, 0, 0.5);
}
/* Lift cues above the controls while they are visible (Chromium/WebKit). */
.p-video::-webkit-media-text-track-container { transition: transform 220ms var(--ease); }
.player:not(.is-idle) .p-video::-webkit-media-text-track-container { transform: translateY(-96px); }
@media (max-width: 719px) { .player:not(.is-idle) .p-video::-webkit-media-text-track-container { transform: translateY(-70px); } }

/* Chrome bars */
.p-top, .p-bottom, .p-center {
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
}
.player.is-idle .p-top, .player.is-idle .p-bottom, .player.is-idle .p-center { opacity: 0; pointer-events: none; }
.player.is-idle .p-top { transform: translateY(-8px); }
.player.is-idle .p-bottom { transform: translateY(8px); }

.p-top {
  position: absolute; inset: 0 0 auto 0; z-index: 4;
  display: flex; align-items: center; gap: 14px;
  padding: calc(var(--pp) * 0.6 + env(safe-area-inset-top)) var(--pp) 48px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
}
.p-titles { display: grid; gap: 2px; min-width: 0; flex: 1; }
.p-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-name { font-size: clamp(16px, 1.4vw, 22px); font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5); }
.p-top-end { display: flex; align-items: center; gap: 10px; flex: none; }
.p-mode { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: rgba(247, 243, 236, 0.6); white-space: nowrap; }
@media (max-width: 719px) { .p-mode { display: none; } }

.p-pill {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: min(60vw, 420px);
  padding: 6px 12px; border-radius: 999px;
  background: rgba(20, 17, 23, 0.85);
  box-shadow: inset 0 0 0 1px rgba(243, 237, 228, 0.12);
  font-size: 13px; color: var(--text-2);
}
.p-pill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-pill-spin { width: 12px; height: 12px; flex: none; border-radius: 50%; border: 2px solid rgba(243, 237, 228, 0.2); border-top-color: var(--accent); animation: spin 800ms linear infinite; }
/* The pill stays visible even when the rest of the chrome hides. */
.player.is-idle .p-top { opacity: 1; background: none; }
.player.is-idle .p-top > :not(.p-top-end), .player.is-idle .p-mode { opacity: 0; }

.p-bottom {
  position: absolute; inset: auto 0 0 0; z-index: 4;
  padding: 64px var(--pp) calc(var(--pp) * 0.5 + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.45) 55%, rgba(0, 0, 0, 0));
}

.p-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: #f7f3ec;
  transition: background-color 140ms var(--ease), color 140ms var(--ease), transform 140ms var(--ease);
}
.p-btn .icon { width: 24px; height: 24px; }
.p-btn:hover { background: rgba(255, 255, 255, 0.13); }
.p-btn:active { transform: scale(0.92); }
.p-btn:disabled { opacity: 0.35; pointer-events: none; }
.p-btn.is-on { color: var(--accent); }
.p-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.16); }
.p-close .icon { width: 26px; height: 26px; }

.p-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.p-group { display: flex; align-items: center; gap: 2px; min-width: 0; }
.p-play .icon { width: 28px; height: 28px; }

.p-time {
  margin-left: 10px; padding: 4px 6px; border-radius: 6px;
  font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  color: rgba(247, 243, 236, 0.9); white-space: nowrap;
}
.p-time:hover { background: rgba(255, 255, 255, 0.1); }

/* Volume */
.p-volume { display: flex; align-items: center; }
.p-vol {
  --val: 1;
  -webkit-appearance: none; appearance: none;
  width: 0; height: 24px; margin: 0; padding: 0;
  background: transparent; opacity: 0;
  transition: width 200ms var(--ease), opacity 200ms var(--ease), margin 200ms var(--ease);
  cursor: pointer;
}
.p-volume:hover .p-vol, .p-volume:focus-within .p-vol { width: 96px; opacity: 1; margin: 0 8px 0 2px; }
.p-vol::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #f7f3ec calc(var(--val) * 100%), rgba(255, 255, 255, 0.28) 0); }
.p-vol::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #f7f3ec calc(var(--val) * 100%), rgba(255, 255, 255, 0.28) 0); }
.p-vol::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 0; }
.p-vol::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.p-vol:focus-visible { outline: none; }
.p-vol:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent); }

/* Seek bar */
.p-seek {
  --played: 0; --buf-start: 0; --buf-end: 0; --hover: 0; --tip-x: 0px;
  position: relative; height: 26px; cursor: pointer; touch-action: none;
  display: flex; align-items: center;
}
.p-seek:focus-visible { outline: none; }
.p-seek-track {
  position: relative; width: 100%; height: 4px; border-radius: 3px; overflow: hidden;
  background: rgba(255, 255, 255, 0.22);
  transition: height 140ms var(--ease);
}
.p-seek.is-hover .p-seek-track, .p-seek.is-drag .p-seek-track, .p-seek:focus-visible .p-seek-track { height: 7px; }
.p-seek-buf { position: absolute; top: 0; bottom: 0; left: calc(var(--buf-start) * 100%); right: calc((1 - var(--buf-end)) * 100%); background: rgba(255, 255, 255, 0.32); }
.p-seek-hover { position: absolute; inset: 0; background: rgba(255, 255, 255, 0.25); transform-origin: left; transform: scaleX(var(--hover)); opacity: 0; transition: opacity 120ms; }
.p-seek.is-hover .p-seek-hover { opacity: 1; }
.p-seek-fill { position: absolute; inset: 0; background: var(--accent); transform-origin: left; transform: scaleX(var(--played)); box-shadow: 0 0 12px rgba(244, 183, 64, 0.6); }
.p-seek-thumb {
  position: absolute; top: 50%; left: calc(var(--played) * 100%);
  width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: var(--accent-hi); box-shadow: 0 0 0 4px rgba(244, 183, 64, 0.25), 0 2px 6px rgba(0, 0, 0, 0.5);
  transform: scale(0); transition: transform 140ms var(--ease);
}
.p-seek.is-hover .p-seek-thumb, .p-seek.is-drag .p-seek-thumb, .p-seek:focus-visible .p-seek-thumb { transform: scale(1); }
.p-seek:focus-visible .p-seek-thumb { box-shadow: 0 0 0 3px #000, 0 0 0 5px var(--accent); }
.p-seek-tip {
  position: absolute; bottom: 30px; left: var(--tip-x); transform: translateX(-50%);
  padding: 5px 9px; border-radius: 6px;
  background: rgba(20, 17, 23, 0.95); box-shadow: inset 0 0 0 1px rgba(243, 237, 228, 0.14);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  opacity: 0; pointer-events: none; transition: opacity 120ms;
  white-space: nowrap;
}
.p-seek.is-hover .p-seek-tip, .p-seek.is-drag .p-seek-tip { opacity: 1; }

/* Centre */
.p-center {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: clamp(28px, 8vw, 72px);
  pointer-events: none;
}
.p-center > * { pointer-events: auto; }
.player.is-idle .p-center { transform: translate(-50%, -50%); }
.p-big { width: 76px; height: 76px; background: rgba(12, 10, 14, 0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: inset 0 0 0 1.5px rgba(247, 243, 236, 0.35); }
.p-big .icon { width: 34px; height: 34px; }
.p-big-play .icon { margin-left: 3px; }
.player:not(.is-paused) .p-big-play .icon { margin-left: 0; }
.p-big-skip { width: 58px; height: 58px; }
.p-big-skip .icon { width: 30px; height: 30px; }
.p-big-skip, .p-big-play { display: none; }
.player.is-paused:not(.is-loading):not(.has-panel) .p-big-play { display: inline-grid; }
@media (pointer: coarse) {
  .player:not(.is-loading):not(.has-panel) .p-big-play, .player:not(.has-panel) .p-big-skip { display: inline-grid; }
  .player.is-loading .p-big-skip { opacity: 0.6; }
  .p-b10, .p-f10 { display: none; }
}

/* Loading */
.p-loading {
  position: absolute; left: 50%; top: 50%; z-index: 3;
  transform: translate(-50%, -50%);
  display: none; justify-items: center; gap: 16px;
  text-align: center; pointer-events: none;
}
.player.is-loading:not(.has-panel) .p-loading { display: grid; }
.p-spinner {
  width: 64px; height: 64px; border-radius: 50%;
  border: 3px solid rgba(247, 243, 236, 0.14); border-top-color: var(--accent);
  animation: spin 850ms linear infinite;
  filter: drop-shadow(0 0 8px rgba(244, 183, 64, 0.35));
}
@media (pointer: coarse) { .p-spinner { width: 76px; height: 76px; } }
.p-loading-text { max-width: 28ch; font-size: 14px; color: rgba(247, 243, 236, 0.8); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); min-height: 1em; }

/* Feedback flashes */
.p-flash {
  position: absolute; left: 50%; top: 50%; z-index: 3;
  width: 84px; height: 84px; margin: -42px 0 0 -42px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(12, 10, 14, 0.55);
  opacity: 0; pointer-events: none;
}
.p-flash .icon { width: 36px; height: 36px; }
.p-flash.is-text { width: auto; height: auto; margin: 0; transform: translate(-50%, -50%); top: 22%; padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 600; }
.p-flash.is-on { animation: flash 700ms var(--ease) both; }
.p-flash.is-text.is-on { animation: flash-text 1100ms var(--ease) both; }
@keyframes flash { 0% { opacity: 0.95; transform: scale(0.85); } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes flash-text { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@media (pointer: coarse) { .p-flash:not(.is-text) { display: none; } }

.p-skip {
  position: absolute; top: 50%; z-index: 3;
  display: grid; justify-items: center; gap: 6px;
  margin-top: -40px;
  font-size: 13px; font-weight: 600; color: rgba(247, 243, 236, 0.9);
  opacity: 0; pointer-events: none;
}
.p-skip .icon { width: 40px; height: 40px; padding: 18px; box-sizing: content-box; border-radius: 50%; background: rgba(12, 10, 14, 0.45); }
.p-skip-l { left: 14%; }
.p-skip-r { right: 14%; }
.p-skip.is-on { animation: skip 650ms var(--ease) both; }
@keyframes skip { 0% { opacity: 0; transform: scale(0.85); } 25% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* Menus */
.p-menu {
  position: absolute; right: var(--pp); bottom: 104px; z-index: 6;
  max-height: calc(100% - 190px); overflow: auto; overscroll-behavior: contain;
  min-width: 280px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(22, 18, 25, 0.96);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(243, 237, 228, 0.1);
  animation: pop 160ms var(--ease);
  scrollbar-width: thin;
}
.p-menu-cols { display: grid; grid-template-columns: repeat(3, minmax(170px, auto)); gap: 4px 10px; }
.p-menu-sec { display: grid; align-content: start; gap: 1px; }
.p-menu-title { padding: 8px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.p-menu-empty { padding: 6px 12px 10px; font-size: 13px; color: var(--muted); }
.p-mi {
  display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 8px;
  width: 100%; min-height: 40px; padding: 7px 12px 7px 8px; border-radius: 8px;
  text-align: left; font-size: 14px; color: var(--text);
}
.p-mi:hover:not(:disabled), .p-mi:focus-visible { background: rgba(243, 237, 228, 0.09); outline: none; }
.p-mi[aria-checked="true"] { color: var(--accent-hi); font-weight: 600; }
.p-mi:disabled { opacity: 0.45; }
.p-mi-check { display: grid; place-items: center; color: var(--accent); }
.p-mi-check .icon { width: 18px; height: 18px; stroke-width: 2.6; }
.p-mi-label { display: grid; gap: 1px; min-width: 0; }
.p-mi-label > span:first-child { overflow-wrap: anywhere; }
.p-mi-note { font-size: 12px; font-weight: 400; color: var(--muted); }

@media (max-width: 719px) {
  .p-menu {
    left: 0; right: 0; bottom: 0; min-width: 0;
    max-height: 72%;
    border-radius: 18px 18px 0 0;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    animation: sheet 220ms var(--ease);
  }
  .p-menu-cols { grid-template-columns: 1fr; }
  .p-mi { min-height: 48px; font-size: 15px; }
  @keyframes sheet { from { transform: translateY(30px); opacity: 0; } }
}

/* Resume chip */
.p-chip {
  position: absolute; left: var(--pp); bottom: 120px; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 6px 6px 6px 16px; border-radius: 999px;
  background: rgba(22, 18, 25, 0.92);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(243, 237, 228, 0.1);
  font-size: 14px;
  animation: rise 300ms var(--ease) both;
}
.p-chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; background: rgba(244, 183, 64, 0.16); color: var(--accent-hi); font-weight: 600; font-size: 13px; }
.p-chip-btn:hover { background: rgba(244, 183, 64, 0.26); }
.p-chip-btn .icon { width: 16px; height: 16px; }

/* Up next */
.p-upnext {
  position: absolute; right: var(--pp); bottom: 120px; z-index: 5;
  width: min(calc(100% - 2 * var(--pp)), 440px);
  display: flex; gap: 14px; padding: 10px;
  border-radius: 14px;
  background: rgba(22, 18, 25, 0.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.85), inset 0 0 0 1px rgba(244, 183, 64, 0.22);
  animation: rise 320ms var(--ease) both;
}
.player.is-idle .p-upnext, .player.is-idle .p-chip { bottom: var(--pp); }
.p-upnext, .p-chip { transition: bottom 260ms var(--ease); }
.p-up-art.art { width: 150px; flex: none; align-self: center; border-radius: 8px; }
.p-up-art .art-fallback-title { font-size: 14px; }
.p-up-body { display: grid; align-content: center; gap: 4px; min-width: 0; }
.p-up-label { display: flex; align-items: baseline; gap: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.p-up-count { font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); }
.p-up-title { font-size: 15px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-up-actions { display: flex; gap: 8px; margin-top: 6px; }
.p-up-actions .btn-primary { position: relative; overflow: hidden; }
.p-up-ring {
  position: absolute; inset: auto 0 0 0; height: 3px;
  background: rgba(27, 19, 5, 0.45);
  transform-origin: left; animation: countdown var(--dur, 15s) linear both;
}
.player.is-paused .p-up-ring { animation-play-state: paused; }
@keyframes countdown { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (max-width: 719px) {
  .p-up-art.art { width: 110px; }
  .p-upnext, .p-chip { bottom: 112px; }
}

/* Panels: errors, offline, end */
.p-panel {
  position: absolute; inset: 0; z-index: 7;
  display: grid; place-items: center; padding: 24px;
  background: rgba(5, 4, 6, 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade 200ms var(--ease);
}
.p-panel-box { width: min(100%, 500px); display: grid; justify-items: center; gap: 12px; text-align: center; }
.p-panel-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: rgba(240, 122, 104, 0.14); color: var(--danger); margin-bottom: 4px; }
.p-panel-icon .icon { width: 30px; height: 30px; }
.p-panel-title { font-family: var(--font-display); font-stretch: condensed; font-weight: 700; font-size: clamp(26px, 3vw, 38px); line-height: 1; letter-spacing: 0.03em; text-transform: uppercase; }
.p-panel-text { color: var(--text-2); font-size: 15px; max-width: 46ch; }
.p-panel-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }
.p-end .eyebrow { margin-bottom: -4px; }
@keyframes fade { from { opacity: 0; } }

.player.has-panel .p-center, .player.has-panel .p-chip, .player.has-panel .p-upnext { display: none; }

@media (max-width: 719px) {
  .p-btn { width: 42px; height: 42px; }
  .p-volume .p-vol { display: none; }
  .p-time { margin-left: 4px; font-size: 13px; }
  .p-pip { display: none; }
  .p-bottom { padding-top: 48px; }
}
@media (max-width: 420px) {
  .p-prev, .p-mute { display: none; }
}

@media (min-width: 2200px) {
  .p-btn { width: 56px; height: 56px; }
  .p-btn .icon { width: 30px; height: 30px; }
  .p-play .icon { width: 34px; height: 34px; }
  .p-close .icon { width: 32px; height: 32px; }
  .p-time { font-size: 18px; }
  .p-eyebrow { font-size: 14px; }
  .p-name { font-size: 28px; }
  .p-mode, .p-pill { font-size: 15px; }
  .p-seek { height: 34px; }
  .p-seek-track { height: 5px; }
  .p-seek.is-hover .p-seek-track, .p-seek.is-drag .p-seek-track { height: 9px; }
  .p-seek-thumb { width: 20px; height: 20px; margin: -10px 0 0 -10px; }
  .p-seek-tip { font-size: 16px; bottom: 38px; }
  .p-vol { height: 30px; }
  .p-volume:hover .p-vol, .p-volume:focus-within .p-vol { width: 130px; }
  .p-big { width: 96px; height: 96px; }
  .p-big .icon { width: 44px; height: 44px; }
  .p-menu { bottom: 130px; padding: 14px; }
  .p-menu-cols { grid-template-columns: repeat(3, minmax(220px, auto)); }
  .p-menu-title { font-size: 13px; }
  .p-mi { min-height: 50px; font-size: 17px; }
  .p-mi-note { font-size: 14px; }
  .p-upnext { width: 560px; bottom: 150px; }
  .p-up-art.art { width: 200px; }
  .p-up-title { font-size: 19px; }
  .p-chip { font-size: 17px; bottom: 150px; }
  .p-loading-text { font-size: 17px; }
  .p-spinner { width: 80px; height: 80px; }
  .p-panel-text { font-size: 18px; }
}
@media (min-width: 2200px) {
  .player:not(.is-idle) .p-video::-webkit-media-text-track-container { transform: translateY(-136px); }
}
@media (pointer: coarse) {
  .p-skip { top: 28%; }
  .p-skip-l { left: 10%; }
  .p-skip-r { right: 10%; }
}
