.player-shell {
  width: 100%;
  aspect-ratio: 390/220;
  position: relative;
  background: #000;
  overflow: hidden;
  color: white;
}
.player-shell video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.player-shade {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(
    180deg,
    #0009,
    transparent 35%,
    transparent 60%,
    #000b
  );
  pointer-events: none;
}
.player-top {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  display: flex;
  align-items: center;
}
.player-top strong {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-top a,
.player-top button,
.player-bottom button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: white;
}
.player-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 30px;
}
.player-center button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  position: relative;
  border: 0;
  background: none;
  color: white;
}
.player-center button small {
  position: absolute;
  top: 19px;
  font-size: 9px;
  font-weight: 800;
}
.player-center .round-play {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #0b0d1280;
  border: 1.5px solid #ffffffa6;
}
.caption {
  position: absolute;
  bottom: 48px;
  left: 12%;
  right: 12%;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 2px 4px #000;
}
.player-message {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  pointer-events: none;
}
.player-message:empty {
  display: none;
}
.player-bottom {
  position: absolute;
  bottom: 6px;
  left: 12px;
  right: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.player-bottom input {
  flex: 1;
  min-width: 0;
  height: 16px;
  accent-color: var(--accent);
}
.player-bottom button {
  width: 40px;
  height: 40px;
  flex: none;
}
.player-panel {
  position: absolute;
  z-index: 5;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(300px, 80%);
  overflow: auto;
  padding: 18px;
  background: rgba(15, 17, 23, 0.96);
  border-left: 1px solid #ffffff1a;
}
.player-panel[hidden] {
  display: none;
}
.player-panel button {
  color: white;
  background: none;
  border: 0;
}

.scrub-preview {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  width: 144px;
  border: 2px solid white;
  border-radius: 8px;
  overflow: hidden;
  background: #151922;
}
.scrub-preview[hidden] {
  display: none;
}
.settings-sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.settings-sheet h2 {
  font-size: 16px;
  font-weight: 800;
}
.settings-sheet header button {
  width: 40px;
  height: 40px;
  font-size: 22px;
}
.settings-group {
  margin-top: 12px;
}
.settings-group h3 {
  margin: 0 0 4px;
  color: #8a91a0;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.settings-option {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
}
.settings-option[aria-checked="true"] {
  color: var(--accent);
}
.settings-option[aria-checked="true"]:after {
  content: "✓";
  font-weight: 800;
}

.pause-icon {
  display: none;
}
#player-shell[data-playing="true"] .play-icon {
  display: none;
}
#player-shell[data-playing="true"] .pause-icon {
  display: block;
}
.caption {
  font-size: var(--caption-size, 15px);
}
#progress {
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--accent) var(--progress, 0%),
    #ffffff55 var(--progress, 0%)
  );
}
#progress::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--accent-wash);
}
#progress::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  background: var(--accent);
  border-radius: 50%;
}
.fullscreen-tools {
  display: none;
}
.fullscreen-tools button {
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 8px;
  background: #ffffff1f;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.caption[hidden],
.toast[hidden] {
  display: none;
}
.caption {
  white-space: pre-line;
}
.caption[data-size="small"] {
  --caption-size: 12px;
}
.caption[data-size="large"] {
  --caption-size: 19px;
}
.preview-image {
  width: 140px;
  background-repeat: no-repeat;
}
.preview-time {
  display: block;
  text-align: center;
  padding: 4px;
  font-size: 12px;
}
.toast {
  position: fixed;
  z-index: 40;
  bottom: calc(104px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #252a35;
  color: #f2f3f5;
  border-radius: 12px;
  padding: 10px 16px;
  max-width: min(90vw, 35ch);
  text-align: center;
  font-size: 13px;
}
.player-fullscreen {
  overflow: hidden;
}

#progress {
  height: 26px;
  background-size: 100% 3px;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}
.scrub-preview {
  pointer-events: none;
  z-index: 4;
}

.player-top,
.player-center,
.player-bottom,
.fullscreen-tools,
.player-shade {
  transition: opacity 160ms ease;
}
.player-shell[data-controls="false"]
  :is(
    .player-top,
    .player-center,
    .player-bottom,
    .fullscreen-tools,
    .player-shade,
    .scrub-preview
  ) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.player-shell[data-controls="false"] .caption {
  bottom: 8%;
}
@media (prefers-reduced-motion: reduce) {
  .player-shell * {
    transition: none;
  }
}

.player-top .fullscreen-lock,
.unlock-controls[hidden],
.panel-backdrop[hidden] {
  display: none;
}

.player-shell:is(.is-fullscreen, :fullscreen) {
  --player-safe-top: env(safe-area-inset-top, 0px);
  --player-safe-right: env(safe-area-inset-right, 0px);
  --player-safe-bottom: env(safe-area-inset-bottom, 0px);
  --player-safe-left: env(safe-area-inset-left, 0px);
  --panel-width: min(calc(300px + var(--player-safe-right)), 80%);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  aspect-ratio: auto;
}

.player-shell:is(.is-fullscreen, :fullscreen) .player-top {
  top: calc(8px + var(--player-safe-top));
  left: calc(16px + var(--player-safe-left));
  right: calc(16px + var(--player-safe-right));
}

.player-shell:is(.is-fullscreen, :fullscreen) .fullscreen-lock {
  display: grid;
}

.player-shell:is(.is-fullscreen, :fullscreen) .player-center {
  gap: clamp(20px, 7vw, 56px);
  transform: translate(-50%, -58%);
}

.player-shell:is(.is-fullscreen, :fullscreen)
  .player-center
  button:not(.round-play) {
  width: 56px;
  height: 56px;
}

.player-shell:is(.is-fullscreen, :fullscreen) .player-center button small {
  top: 22px;
}

.player-shell:is(.is-fullscreen, :fullscreen) .round-play {
  width: 72px;
  height: 72px;
}

.player-shell:is(.is-fullscreen, :fullscreen) .player-footer {
  position: absolute;
  left: calc(24px + var(--player-safe-left));
  right: calc(24px + var(--player-safe-right));
  bottom: calc(12px + var(--player-safe-bottom));
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-rows: 28px 36px;
  align-items: center;
  column-gap: 4px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.player-shell:is(.is-fullscreen, :fullscreen) .player-bottom {
  display: contents;
}

.player-shell:is(.is-fullscreen, :fullscreen) .player-bottom button {
  display: none;
}

.player-shell:is(.is-fullscreen, :fullscreen) #progress {
  margin: 0;
  width: 100%;
  height: 28px;
  background-size: 100% 4px;
  grid-column: 1 / -1;
  grid-row: 1;
}

.player-shell:is(.is-fullscreen, :fullscreen) #current-time {
  grid-area: 2 / 1;
}

.player-shell:is(.is-fullscreen, :fullscreen) #duration {
  grid-area: 2 / 2;
  color: #fffc;
}

.player-shell:is(.is-fullscreen, :fullscreen) #duration::before {
  content: "/ ";
}

.player-shell:is(.is-fullscreen, :fullscreen) .fullscreen-tools {
  display: flex;
  gap: 4px;
  grid-area: 2 / 3;
  justify-self: end;
}

.player-shell:is(.is-fullscreen, :fullscreen) .caption {
  bottom: calc(88px + var(--player-safe-bottom));
  left: max(12%, calc(16px + var(--player-safe-left)));
  right: max(12%, calc(16px + var(--player-safe-right)));
  line-height: 1.5;
}

.player-shell:is(.is-fullscreen, :fullscreen) .caption span {
  padding: 3px 8px;
  border-radius: 4px;
  background: #000a;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.player-shell.is-fullscreen[data-controls="false"] .caption {
  bottom: calc(28px + var(--player-safe-bottom));
}

.player-shell:is(.is-fullscreen, :fullscreen) .scrub-preview {
  bottom: calc(88px + var(--player-safe-bottom));
}

.panel-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  border: 0;
  background: #0006;
}

.player-panel {
  z-index: 6;
}

.player-shell:is(.is-fullscreen, :fullscreen) .player-panel {
  width: var(--panel-width);
  padding-top: calc(18px + var(--player-safe-top));
  padding-right: calc(18px + var(--player-safe-right));
  padding-bottom: calc(24px + var(--player-safe-bottom));
}

@media (orientation: landscape) {
  .player-shell.is-fullscreen[data-panel-open="true"] .caption {
    right: calc(var(--panel-width) + 12px);
    left: calc(12px + var(--player-safe-left));
  }
}

.unlock-controls {
  position: absolute;
  z-index: 4;
  left: calc(24px + var(--player-safe-left, 0px));
  top: 50%;
  transform: translateY(-50%);
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid #fff5;
  border-radius: 22px;
  background: #0009;
  font-size: 13px;
  font-weight: 700;
}

/* ---------- 手势与反馈 ---------- */
.player-shell {
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#progress {
  background-image: linear-gradient(
    to right,
    var(--accent) var(--progress, 0%),
    #ffffff8c var(--progress, 0%),
    #ffffff8c var(--buffered, 0%),
    #ffffff38 var(--buffered, 0%)
  );
  transition: background-size 0.15s ease;
}
.player-shell[data-scrubbing="true"] #progress,
#progress:active {
  background-size: 100% 6px;
}
#progress:active::-webkit-slider-thumb {
  transform: scale(1.35);
}
.time-toggle {
  width: auto !important;
  min-width: 44px;
  padding: 0 4px;
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#current-time {
  font-variant-numeric: tabular-nums;
}

/* 双击快退/快进：半边弧形涟漪 + 累计秒数 */
.seek-ripple {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  width: 42%;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.12);
}
.seek-ripple[hidden] {
  display: none;
}
.seek-ripple[data-side="left"] {
  left: 0;
  border-radius: 0 50% 50% 0 / 0 100% 100% 0;
}
.seek-ripple[data-side="right"] {
  right: 0;
  border-radius: 50% 0 0 50% / 100% 0 0 100%;
}
.seek-ripple.is-pulse {
  animation: ripple-in 0.35s ease;
}
@keyframes ripple-in {
  from { background: rgba(255, 255, 255, 0.28); }
}
.ripple-arrows {
  display: flex;
}
.ripple-arrows svg {
  margin: 0 -5px;
  animation: arrow-blink 0.6s ease infinite;
}
.ripple-arrows svg:nth-child(2) {
  animation-delay: 0.15s;
}
@keyframes arrow-blink {
  50% { opacity: 0.35; }
}
.seek-ripple b {
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 4px #000a;
}

/* 横向拖动时的大预览 */
.gesture-hud {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px 6px 8px;
  border-radius: 14px;
  background: rgba(8, 9, 14, 0.78);
  transform: translate(-50%, -50%);
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.gesture-hud[hidden] {
  display: none;
}
.hud-thumb {
  border-radius: 9px;
  background-repeat: no-repeat;
}
.hud-time {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.hud-delta {
  color: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.player-shell[data-scrubbing="true"] .player-center {
  opacity: 0;
}

/* 长按 2 倍速 */
.speed-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 5;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(8, 9, 14, 0.72);
  font-size: 12px;
  font-weight: 700;
  transform: translateX(-50%);
  pointer-events: none;
}
.speed-hud[hidden] {
  display: none;
}
.speed-hud svg {
  color: var(--accent);
}

/* 缓冲圈 */
.player-spinner {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.player-spinner[hidden] {
  display: none;
}
.player-spinner i {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  border-right-color: #ff6b8b;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 续播提示 */
.resume-chip {
  position: absolute;
  left: 10px;
  bottom: 42px;
  z-index: 4;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 3px 3px 3px 10px;
  border-radius: 999px;
  background: rgba(8, 9, 14, 0.8);
  font-size: 11.5px;
  font-weight: 700;
  animation: chip-in 0.3s ease;
}
.resume-chip[hidden] {
  display: none;
}
.resume-chip button {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
}
@keyframes chip-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* 片尾：倒计时连播下一部 */
.end-card {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: rgba(6, 7, 11, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.end-card[hidden] {
  display: none;
}
.end-next {
  display: grid;
  gap: 3px;
  width: 168px;
}
.end-next .kicker {
  margin: 0;
  color: var(--accent-soft);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.end-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 10px;
  background: #222;
}
.end-art img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.7);
}
.end-ring {
  position: relative;
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
}
.end-ring circle {
  fill: rgba(0, 0, 0, 0.45);
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 3;
}
.end-ring .end-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 132;
  stroke-dashoffset: calc(132 * (1 - var(--end-left, 1)));
  transition: stroke-dashoffset 1s linear;
}
.end-next.is-cancelled .end-ring-fill {
  stroke-dashoffset: 0;
}
.end-play {
  position: absolute;
  display: grid;
  place-items: center;
  padding-left: 2px;
}
.end-next strong {
  overflow: hidden;
  font-size: 13.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.end-next small {
  color: #c4c8d0;
  font-size: 11.5px;
}
.end-actions {
  display: grid;
  gap: 8px;
}
.end-actions button {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
}
.end-actions [data-action="replay"]:only-child,
.end-actions [data-action="cancel-next"] + [data-action="replay"] {
  background: rgba(255, 255, 255, 0.14);
}
@media (prefers-reduced-motion: reduce) {
  .ripple-arrows svg,
  .player-spinner i {
    animation: none;
  }
}

/* 手势反馈出现时，让开中间按钮和顶部标题，避免叠在一起 */
.player-shell:has(.seek-ripple:not([hidden])) .player-center,
.player-shell[data-scrubbing="true"] :is(.player-center, .resume-chip),
.player-shell[data-holding="true"] :is(.player-top, .player-center, .resume-chip) {
  opacity: 0;
  pointer-events: none;
}
.speed-hud .ripple-arrows svg {
  margin: 0 -4px;
  color: var(--accent);
}

/* 外部片源：对方的网页播放器（iframe）占满播放区，自带控件不显示 */
.player-shell.is-embed > :not(.player-embed) {
  display: none !important;
}
.player-embed {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* 跳过片头：片头期间显示在右下角，进度条上方 */
.skip-intro {
  position: absolute;
  right: 12px;
  bottom: 46px;
  z-index: 5;
  display: flex;
  gap: 4px;
  align-items: center;
  height: 34px;
  padding: 0 10px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(8, 9, 14, 0.72);
  color: #fff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  animation: chip-in 0.3s ease;
}
.skip-intro[hidden] {
  display: none;
}

/* 片尾字幕开始时的“下一部”：靠右的半透明卡片，左边仍能看到片尾 */
.end-card.at-credits {
  justify-content: flex-end;
  background: linear-gradient(to left, rgba(6, 7, 11, 0.94) 45%, rgba(6, 7, 11, 0.2));
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.end-card:not(.at-credits) .credits-only,
.end-card.at-credits .end-only {
  display: none;
}

/* 断网重连时提示更醒目 */
.player-shell[data-reconnecting="true"] .player-message {
  top: 50px;
  left: 50%;
  right: auto;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(8, 9, 14, 0.82);
  transform: translateX(-50%);
  font-weight: 700;
}
.pip-button[hidden] {
  display: none;
}

/* 成人分级的年龄确认：盖在播放器上，确认后才开始加载视频。竖屏小播放器里也要放得下 */
.age-gate {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 12px 16px;
  background: rgba(6, 7, 11, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.age-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  width: min(100%, 360px);
}
.age-card h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}
.age-card p {
  grid-column: 1 / -1;
  margin: 0 0 4px;
  color: #c9cdd4;
  font-size: 11.5px;
  line-height: 1.45;
}
.age-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 8px;
}
.age-actions .btn {
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}
.age-badge {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: #e5484d;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
}
