main:has(> .player) {
  padding: 0;
  max-width: none;
}

body:has(main > .player) > .topbar {
  display: none;
}

.player {
  display: block;
  position: relative;
  background: #000;
  color: #f5f5f7;
  outline: none;
}

.player .video-wrap {
  display: grid;
  place-items: center;
  position: relative;
  width: 100%;
  height: max(410px, 100dvh);
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  isolation: isolate;
}

.player video {
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
}

.player-top, .player-hud {
  position: absolute;
  inset-inline: 0;
  z-index: 1;
  padding-inline: max(20px, 4vw);
  transition: opacity 170ms ease;
}

.player-top {
  top: 0;
  padding-block: 20px 34px;
  background: linear-gradient(#0008, transparent);
  pointer-events: none;
}

.player-top button {
  pointer-events: auto;
}

.player-hud {
  bottom: 0;
  padding-block: 55px 22px;
  background: linear-gradient(transparent, #08090de8 48%, #08090d);
}

.player-idle :is(.player-top, .player-hud) {
  opacity: 0;
  pointer-events: none;
}

.player-idle .player-top button {
  pointer-events: none;
}

.player-idle:focus-within:not(:focus) :is(.player-top, .player-hud) {
  opacity: 1;
  pointer-events: auto;
}

.player-idle:focus-within:not(:focus) .player-top button {
  pointer-events: auto;
}

.player:has(dialog[open]) :is(.player-top, .player-hud) {
  opacity: 0;
}

.player-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 20px;
  margin-top: 10px;
}

.player-title-row h1 {
  min-width: 0;
  flex: 1 1 240px;
  font-size: clamp(23px, 2.8vw, 43px);
  line-height: 1.1;
  letter-spacing: -.025em;
}

.player-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.player .player-actions button, .player .player-top button {
  background: #171a22d9;
  border: 1px solid #ffffff19;
}

.player .player-actions button:hover, .player .player-top button:hover {
  background: #424653;
}

.player .player-actions button {
  min-height: 44px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: .82rem;
}

.player .player-actions .round {
  width: 46px;
  padding: 0;
}

.player .player-actions .player-play {
  color: #101116;
  background: #e5cff4;
}

.player .player-actions .player-play:hover {
  background: #f1dfff;
}

.player-hud > input {
  display: block;
  width: 100%;
  height: 32px;
  padding: 0;
  margin: 4px 0 0;
  cursor: pointer;
  accent-color: #e5cff4;
}

.player-time {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.player-preview {
  display: grid;
  position: absolute;
  bottom: calc(100% - 42px);
  inset-inline-start: max(20px, 4vw);
  max-width: min(250px, 80%);
  gap: 5px;
  background: #151822f0;
  border: 1px solid #ffffff33;
  border-radius: 12px;
  padding: 10px 13px;
  pointer-events: none;
}

.player-preview img {
  width: 100%;
  max-height: 112px;
  border-radius: 6px;
  object-fit: cover;
}

.player-preview span {
  color: #c1c5ce;
  font-size: .86rem;
}

.player-status {
  position: absolute;
  inset-inline: 6%;
  bottom: max(220px, 23%);
  text-align: center;
  width: fit-content;
  max-width: 88%;
  margin-inline: auto;
  padding: 8px 16px;
  border-radius: 12px;
  background: #101116db;
  color: #fff;
}

.player-status:empty, .player-info p:empty {
  display: none;
}

.player:fullscreen {
  padding: 0;
}

.player:fullscreen .video-wrap {
  height: 100%;
}

.player .player-dialog {
  position: fixed;
  inset: max(15px, 7vh) 0 auto;
  margin: 0 auto;
  width: min(89vw, 1320px);
  max-height: 82dvh;
  background: #191f2beF;
  backdrop-filter: blur(12px);
  padding: clamp(16px, 2.2vw, 32px);
  border: 1px solid #c9d3ef49;
  border-radius: 24px;
}

.player .player-dialog::backdrop {
  background: #0003;
  backdrop-filter: none;
}

.player-dialog-close {
  float: right;
  min-height: 36px;
  padding: 5px 13px;
  font-size: .84rem;
  margin: 2px 0 12px 12px;
}

.player-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 19px;
}

.player-tabs button {
  min-height: 42px;
  padding: 8px clamp(9px, 2.3vw, 38px);
  background: transparent;
  border-color: transparent;
  border-radius: 11px;
  font-size: .95rem;
}

.player-tabs button[aria-selected=true], .player-tabs button[aria-selected=true]:hover {
  background: #f1f2f3;
  color: #101116;
}

.player-info {
  display: flex;
  gap: clamp(13px, 2vw, 24px);
  align-items: flex-start;
}

.player-info img {
  width: clamp(74px, 10vw, 112px);
  border-radius: 10px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.player-info p, .player-options-grid p {
  margin-top: 9px;
}

.player-summary {
  max-width: 74ch;
}

.player-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px clamp(18px, 4vw, 55px);
}

.player-options-grid label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #c1c5ce;
  font-size: .9rem;
  font-weight: 600;
}

.player-options-grid input[type=range] {
  accent-color: #e5cff4;
}

.player-options-grid select {
  max-width: 100%;
  border-radius: 12px;
}

.player-options-grid details {
  margin-top: 12px;
}

.player-options-grid summary {
  cursor: pointer;
  width: fit-content;
}

.player-options-grid .primary {
  margin-bottom: 12px;
}

.player-chapters h2, .player-up-next h2 {
  margin-bottom: 14px;
}

.player-chapter-row {
  display: flex;
  overflow-x: auto;
  clear: both;
  gap: 12px;
  padding: 5px 5px 13px;
}

.player-chapter {
  position: relative;
  flex: 0 0 clamp(145px, 20vw, 260px);
  aspect-ratio: 16 / 9;
  align-items: flex-end;
  justify-content: flex-start;
  overflow: hidden;
  text-align: start;
  padding: 0;
  border-radius: 14px;
  background: #222b39;
}

.player-chapter img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-chapter span {
  z-index: 1;
  display: grid;
  width: 100%;
  padding: 18px 11px 9px;
  background: linear-gradient(transparent, #080b12);
}

.player-chapter strong {
  font-size: .89rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-chapter small {
  color: #c1c5ce;
}

.player .player-up-next {
  width: min(89vw, 520px);
}

.player-up-next p {
  margin-bottom: 16px;
}

@media (max-width: 650px) {
  .player-hud {
    padding-block-end: 14px;
  }

  .player .player-actions button {
    min-height: 41px;
  }

  .player .player-actions .round {
    width: 41px;
  }

  .player-options-grid {
    grid-template-columns: 1fr;
  }

  .player-tabs {
    clear: both;
    justify-content: flex-start;
  }

  .player:fullscreen .video-wrap {
    height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-top, .player-hud { transition: none; }
}
