/* ==========================================================================
   COZONE Universal Video Player — Edition R1 (Minimalist Dark Gray / Infuse)
   Zero neon, zero colored glows, crisp monochrome #FFFFFF icons & #141416 scrim.
   ========================================================================== */

.cz-player {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 180px;
  aspect-ratio: 16 / 9;
  box-sizing: border-box;
  background: #0d0d0f;
  border-radius: var(--radius-xl, 12px);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--font-sans, "PingFang SC", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  color: #f4f4f6;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.cz-player *,
.cz-player *::before,
.cz-player *::after {
  box-sizing: border-box;
}

.cz-player:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.cz-player.is-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
  background: #000000;
}

.cz-player.is-idle {
  cursor: none;
}

.cz-player.is-muted-preview .cz-player-top,
.cz-player.is-muted-preview .cz-player-bottom,
.cz-player.is-muted-preview .cz-player-center-play {
  opacity: 0;
  pointer-events: none;
}

/* Video element */
.cz-player-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0d0d0f;
}

/* Subtitle overlay (rendered strictly via textContent spans) */
.cz-player-subtitles {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(86%, 780px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 4;
  text-align: center;
  transition: bottom 0.2s ease;
}

.cz-player.is-controls-visible .cz-player-subtitles {
  bottom: 76px;
}

.cz-player-subtitles[hidden] {
  display: none;
}

.cz-player-subtitle-line {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(20, 20, 22, 0.78);
  color: #ffffff;
  font-size: clamp(14px, 1.9vw, 22px);
  font-weight: 500;
  line-height: 1.42;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  word-break: break-word;
}

/* Transient top-center HUD pill */
.cz-player-hud {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(20, 20, 22, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f4f4f6;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.cz-player-hud.is-visible {
  opacity: 1;
}

.cz-player-hud[hidden] {
  display: none;
}

/* Buffering spinner */
.cz-player-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  animation: cz-player-fade-in 0.18s ease forwards;
}

.cz-player-loading[hidden] {
  display: none;
}

.cz-player-spinner-plate {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(20, 20, 22, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cz-player-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: #ffffff;
  border-right-color: rgba(255, 255, 255, 0.45);
  animation: cz-player-spin 0.72s linear infinite;
}

@keyframes cz-player-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes cz-player-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.cz-player-loading-text {
  padding: 4px 10px;
  border-radius: var(--radius-sm, 6px);
  background: rgba(20, 20, 22, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(244, 244, 246, 0.88);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.01em;
}

/* Subtle mobile double-tap ±10s seek indicator (monochrome matte, zero glow) */
.cz-player-tap-seek {
  position: absolute;
  top: 50%;
  z-index: 7;
  min-width: 72px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
  transition: opacity 0.16s ease, transform 0.18s ease;
}

.cz-player-tap-seek.is-left {
  left: 22%;
}

.cz-player-tap-seek.is-right {
  left: 78%;
}

.cz-player-tap-seek.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.cz-player-tap-seek[hidden] {
  display: none;
}

.cz-player-tap-seek-label {
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 12px;
  font-weight: 600;
  line-height: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Center subtle play button when paused / awaiting user gesture */
.cz-player-center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 20, 22, 0.72);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.18s ease;
}

.cz-player-center-play:hover {
  background: rgba(20, 20, 22, 0.88);
  transform: translate(-50%, -50%) scale(1.04);
}

.cz-player-center-play[hidden] {
  display: none;
}

/* Error card */
.cz-player-error-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 20, 22, 0.88);
}

.cz-player-error-layer[hidden] {
  display: none;
}

.cz-player-error-card {
  width: 100%;
  max-width: 340px;
  padding: 22px 24px;
  border-radius: var(--radius-xl, 12px);
  background: #1e1e22;
  border: 1px solid #2c2c32;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.cz-player-error-icon {
  color: #8e8e93;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.cz-player-error-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  color: #f4f4f6;
}

.cz-player-error-msg {
  font-size: 12px;
  line-height: 18px;
  color: #8e8e93;
  word-break: break-word;
}

.cz-player-error-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.cz-player-btn-primary,
.cz-player-btn-secondary {
  height: 34px;
  padding: 0 16px;
  border-radius: var(--radius-md, 8px);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.cz-player-btn-primary {
  background: #ffffff;
  color: #141416;
  border: none;
  font-weight: 600;
}

.cz-player-btn-primary:hover {
  opacity: 0.9;
}

.cz-player-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #f4f4f6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 500;
}

.cz-player-btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.cz-player-btn-secondary:disabled {
  color: #636368;
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
  cursor: default;
}

/* Top flat translucent scrim */
.cz-player-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px 38px;
  background: linear-gradient(
    180deg,
    rgba(20, 20, 22, 0.74) 0%,
    rgba(20, 20, 22, 0.3) 52%,
    rgba(20, 20, 22, 0) 100%
  );
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cz-player.is-controls-visible .cz-player-top {
  opacity: 1;
  transform: translateY(0);
}

.cz-player-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: #f4f4f6;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cz-player-top-status {
  flex-shrink: 0;
  font-size: 12px;
  color: rgba(244, 244, 246, 0.7);
  font-variant-numeric: tabular-nums;
}

/* Bottom flat translucent scrim (multi-stop to avoid gradient banding) */
.cz-player-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  padding: 38px 20px 14px;
  background: linear-gradient(
    0deg,
    rgba(20, 20, 22, 0.9) 0%,
    rgba(20, 20, 22, 0.62) 28%,
    rgba(20, 20, 22, 0.24) 64%,
    rgba(20, 20, 22, 0) 100%
  );
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cz-player.is-controls-visible .cz-player-bottom {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Seek bar: crisp 2px white line expanding to 4px on hover */
.cz-player-seek-wrap {
  position: relative;
  width: 100%;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  outline: none;
}

.cz-player-seek-track {
  position: relative;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  transition: height 0.14s ease;
}

.cz-player-seek-wrap:hover .cz-player-seek-track,
.cz-player-seek-wrap:focus-visible .cz-player-seek-track,
.cz-player-seek-wrap.is-scrubbing .cz-player-seek-track {
  height: 4px;
}

.cz-player-seek-buffered {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.34);
  pointer-events: none;
}

.cz-player-seek-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  border-radius: inherit;
  background: #ffffff;
  pointer-events: none;
}

.cz-player-seek-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.14s ease;
  pointer-events: none;
}

.cz-player-seek-wrap:hover .cz-player-seek-thumb,
.cz-player-seek-wrap:focus-visible .cz-player-seek-thumb,
.cz-player-seek-wrap.is-scrubbing .cz-player-seek-thumb {
  transform: translate(-50%, -50%) scale(1);
}

/* Hover timestamp preview bubble */
.cz-player-seek-bubble {
  position: absolute;
  bottom: 24px;
  left: 0;
  transform: translateX(-50%);
  padding: 4px 9px;
  border-radius: var(--radius-sm, 6px);
  background: rgba(20, 20, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.36);
  color: #f4f4f6;
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 15px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.cz-player-seek-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 6px;
  height: 6px;
  background: rgba(20, 20, 22, 0.92);
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  transform: translate(-50%, -50%) rotate(45deg);
}

.cz-player-seek-bubble[hidden] {
  display: none;
}

/* Bottom control bar row */
.cz-player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  width: 100%;
  min-width: 0;
}

.cz-player-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cz-player-icon-btn,
.cz-player-text-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-family: inherit;
  height: 32px;
  border-radius: var(--radius-sm, 6px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}

.cz-player-icon-btn {
  width: 32px;
  padding: 0;
}

.cz-player-text-btn {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cz-player-icon-btn:hover,
.cz-player-text-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.cz-player-icon-btn:focus-visible,
.cz-player-text-btn:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.35);
  outline-offset: 1px;
}

.cz-player-icon-btn.is-active,
.cz-player-text-btn.is-highlighted {
  color: #ffffff;
}

.cz-player-text-btn.is-highlighted {
  background: rgba(255, 255, 255, 0.12);
}

.cz-player-icon {
  display: block;
  flex-shrink: 0;
}

/* Time readout */
.cz-player-time {
  padding: 0 4px;
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 12px;
  line-height: 16px;
  color: rgba(244, 244, 246, 0.84);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Live indicator & timeshift buttons */
.cz-player-live-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cz-player-live-group[hidden] {
  display: none;
}

.cz-player-live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  font-size: 12px;
  color: #f4f4f6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cz-player-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8e8e93;
  flex-shrink: 0;
}

.cz-player-live-dot.is-live {
  background: var(--health-ok, var(--status-ok, #30d158));
}

/* Volume slider */
.cz-player-volume {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cz-player-volume-slider {
  --vol-pct: 100%;
  appearance: none;
  -webkit-appearance: none;
  width: 60px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    #ffffff 0%,
    #ffffff var(--vol-pct),
    rgba(255, 255, 255, 0.24) var(--vol-pct),
    rgba(255, 255, 255, 0.24) 100%
  );
  cursor: pointer;
  outline: none;
}

.cz-player-volume-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  cursor: pointer;
}

.cz-player-volume-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  cursor: pointer;
}

/* Quiet flat popovers (rate / route / subtitle) */
.cz-player-popover-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.cz-player-popover-anchor[hidden] {
  display: none;
}

.cz-player-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 15;
  border-radius: var(--radius-lg, 10px);
  background: #1c1c20;
  border: 1px solid #2c2c32;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  padding: 6px;
}

.cz-player-popover[hidden] {
  display: none;
}

.cz-player-menu {
  min-width: 96px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cz-player-menu-item {
  appearance: none;
  border: none;
  background: transparent;
  color: #c8c8ce;
  font-family: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.cz-player-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.cz-player-menu-item.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-weight: 600;
}

/* Subtitle settings panel */
.cz-player-sub-panel {
  width: 244px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cz-player-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cz-player-sub-meta,
.cz-player-sub-label {
  font-size: 12px;
  color: #8e8e93;
  white-space: nowrap;
}

.cz-player-offset-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cz-player-offset-val {
  appearance: none;
  border: none;
  background: transparent;
  color: #f4f4f6;
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
  padding: 4px 2px;
  border-radius: 4px;
  cursor: pointer;
}

.cz-player-offset-val:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cz-player-sub-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cz-player-chip-btn {
  appearance: none;
  border: 1px solid #2e2e34;
  background: #242429;
  color: #f4f4f6;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.cz-player-chip-btn:hover:not(:disabled) {
  background: #2e2e35;
  border-color: #3d3d45;
}

.cz-player-chip-btn.is-active {
  background: #ffffff;
  color: #141416;
  border-color: #ffffff;
  font-weight: 600;
}

.cz-player-chip-btn.is-grow {
  flex: 1;
}

.cz-player-chip-btn:disabled {
  color: #636368;
  background: #1f1f24;
  border-color: #28282d;
  cursor: default;
}

.cz-player-chip-btn[hidden] {
  display: none;
}

.cz-player-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive mobile / narrow split layout */
@media (max-width: 640px) {
  .cz-player-top {
    padding: 10px 12px 26px;
  }

  .cz-player-bottom {
    padding: 26px 12px 10px;
    gap: 5px;
  }

  .cz-player-controls {
    gap: 4px;
    min-height: 30px;
  }

  .cz-player-group {
    gap: 3px;
  }

  .cz-player-icon-btn {
    width: 28px;
    height: 28px;
  }

  .cz-player-volume-slider {
    display: none;
  }

  .cz-player-time {
    font-size: 11px;
    padding: 0 2px;
  }

  .cz-player-live-group {
    gap: 3px;
  }

  .cz-player-text-btn {
    height: 28px;
    padding: 0 5px;
    font-size: 11px;
  }

  .cz-player-sub-panel {
    width: min(220px, calc(100vw - 36px));
    right: -12px;
  }

  .cz-player.is-controls-visible .cz-player-subtitles {
    bottom: 68px;
  }

  .cz-player-tap-seek {
    min-width: 64px;
    padding: 8px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cz-player-top,
  .cz-player-bottom,
  .cz-player-subtitles,
  .cz-player-hud,
  .cz-player-tap-seek,
  .cz-player-seek-track,
  .cz-player-seek-thumb,
  .cz-player-center-play,
  .cz-player-loading {
    transition: none;
    animation: none;
  }

  .cz-player-spinner {
    animation-duration: 1.4s;
  }
}
