/* ══ PLAYER SCREEN ══ */
#player-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.player-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#vid {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* ── Spinner ── */
.spinner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  z-index: 20;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spin-ring {
  position: absolute;
  width: 46px; height: 46px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
.r2 {
  width: 62px; height: 62px;
  border-width: 2px;
  border-top-color: rgba(212,168,67,0.25);
  animation-duration: 1.3s;
  animation-direction: reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Seek Zones ── */
.seek-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 38%;
  z-index: 10;
  display: flex;
  align-items: center;
  pointer-events: all;
}
.sz-left  { left: 0;  justify-content: flex-start; padding-left: 14px; }
.sz-right { right: 0; justify-content: flex-end;   padding-right: 14px; }

.seek-flash {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
  user-select: none;
}
.seek-flash.show { opacity: 1; transform: scale(1); }
.sf-icon  { font-size: 24px; line-height: 1; font-weight: 700; }
.sf-label { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; }

/* ── Controls Overlay ── */
.ctrl-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.72) 0%,
    transparent 22%,
    transparent 60%,
    rgba(0,0,0,0.92) 100%
  );
  transition: opacity 0.3s ease;
}
.ctrl-overlay.hide {
  opacity: 0;
  pointer-events: none;
}

/* ── Top Bar ── */
.ctrl-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 12px) 12px 10px;
  flex-shrink: 0;
}
.vid-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-right-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* VLC button */
.vlc-btn {
  color: #ff6600 !important;
  border: 1px solid rgba(255,102,0,0.3);
  border-radius: 8px !important;
  width: auto !important;
  padding: 0 10px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  gap: 5px;
  display: flex;
  align-items: center;
}
.vlc-btn:hover { background: rgba(255,102,0,0.15) !important; border-color: #ff6600 !important; }

/* ── Center ── */
.ctrl-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tap-pulse {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  animation: pulse-in 0.15s ease;
}
@keyframes pulse-in { from { transform: scale(0.7); opacity:0; } to { transform:scale(1); opacity:1; } }

/* ── Bottom Bar ── */
.ctrl-bottom {
  flex-shrink: 0;
  padding: 6px 12px calc(var(--safe-b) + 10px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Seekbar ── */
.seekbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.seekbar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  touch-action: none;
  transition: height 0.15s ease;
}
.seekbar:hover, .seekbar.dragging { height: 6px; }

.sb-buf {
  position: absolute; inset: 0; width: 0%;
  border-radius: 4px;
  background: rgba(255,255,255,0.22);
}
.sb-play {
  position: absolute; inset: 0; width: 0%;
  border-radius: 4px;
  background: var(--gold);
  transition: width 0.1s linear;
}
.sb-thumb {
  position: absolute;
  top: 50%; left: 0%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  transform: translate(-50%,-50%) scale(0);
  box-shadow: 0 0 8px rgba(212,168,67,0.6);
  transition: transform 0.15s ease;
  pointer-events: none;
}
.seekbar:hover .sb-thumb,
.seekbar.dragging .sb-thumb { transform: translate(-50%,-50%) scale(1); }

/* ── Time Display — tappable ── */
.time-display {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
}
.time-display:hover { background: rgba(255,255,255,0.08); }
.time-display:active { background: rgba(255,255,255,0.14); }

/* Remaining time style */
.time-display.show-remaining #t-cur {
  color: var(--gold);
}
.time-display.show-remaining #t-dur {
  color: rgba(255,255,255,0.5);
}

.t-sep { color: rgba(255,255,255,0.3); }

/* ── Button Row ── */
.btn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-left, .btn-right { display: flex; align-items: center; gap: 2px; }

.ic-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.ic-btn:hover  { background: rgba(255,255,255,0.1); color: #fff; }
.ic-btn:active { transform: scale(0.9); }

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

.speed-btn {
  border-radius: 8px;
  width: auto;
  padding: 0 9px;
  min-width: 38px;
}
#speed-lbl { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; }

.sub-toggle-btn.sub-on { color: var(--gold); }
.sub-search-btn { border-radius: 50%; }

/* ── Speed Popup ── */
.popup {
  position: absolute;
  bottom: 80px; right: 12px;
  z-index: 60;
  background: rgba(8,10,16,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  min-width: 150px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.7);
  overflow: hidden;
  animation: popup-in 0.18s cubic-bezier(0.4,0,0.2,1);
  transform-origin: bottom right;
}
@keyframes popup-in { from { opacity:0; transform:scale(0.88) translateY(6px); } to { opacity:1; transform:scale(1) translateY(0); } }

.popup-title {
  padding: 10px 14px 8px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.popup-list { padding: 5px 0; }
.popup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}
.popup-item:hover  { background: rgba(255,255,255,0.07); color: #fff; }
.popup-item.active { color: var(--gold); }
.popup-item .check { opacity: 0; font-size: 13px; }
.popup-item.active .check { opacity: 1; }

/* ══ SUBTITLE SEARCH PANEL ══ */
.sub-panel {
  position: absolute;
  inset: 0;
  z-index: 70;
  background: rgba(6,8,14,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  animation: panel-in 0.22s cubic-bezier(0.4,0,0.2,1);
}
@keyframes panel-in { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

.sub-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-t) + 16px) 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sub-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.ic-btn-sm {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.ic-btn-sm:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.sub-search-row {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  flex-shrink: 0;
}
.sub-search-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  caret-color: var(--gold);
  transition: border-color 0.2s;
  min-width: 0;
}
.sub-search-input:focus { border-color: var(--gold); }
.sub-search-input::placeholder { color: var(--dim); }

.sub-search-go {
  padding: 11px 18px;
  background: var(--gold);
  color: #1a0e00;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  white-space: nowrap;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 3px 14px rgba(212,168,67,0.3);
  flex-shrink: 0;
}
.sub-search-go:hover  { transform: translateY(-1px); }
.sub-search-go:active { transform: scale(0.96); }
.sub-search-go:disabled { opacity: 0.5; pointer-events: none; }

.sub-search-status {
  margin: 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  flex-shrink: 0;
}
.sub-search-status.loading { color: var(--dim); background: rgba(255,255,255,0.04); }
.sub-search-status.error   { color: var(--red); background: var(--red-bg); }
.sub-search-status.info    { color: var(--gold); background: rgba(212,168,67,0.08); }

.sub-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}

.sub-result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.sub-result-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.08); }
.sub-result-item:active { background: rgba(212,168,67,0.08); border-color: rgba(212,168,67,0.2); }

.sri-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}
.sri-meta {
  font-size: 12px;
  color: var(--dim);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.sri-badge {
  padding: 2px 7px;
  background: rgba(212,168,67,0.12);
  border: 1px solid rgba(212,168,67,0.2);
  border-radius: 4px;
  font-size: 10px;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sri-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 14px;
  font-size: 13px;
  color: var(--dim);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
}
.sri-loading::before {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.sub-panel-footer {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 12px 16px calc(var(--safe-b) + 12px);
  flex-shrink: 0;
}
.sub-upload-link {
  font-size: 13px;
  color: var(--dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.sub-upload-link:hover { color: var(--gold); background: rgba(212,168,67,0.06); }

/* ── Subtitle Display ── */
.sub-display {
  position: absolute;
  bottom: 80px;
  left: 0; right: 0;
  z-index: 30;
  pointer-events: none;
  text-align: center;
  padding: 0 20px;
  transition: bottom 0.2s ease;
}
.ctrl-overlay.hide ~ .sub-display { bottom: 20px; }

.sub-display .sub-line {
  display: inline-block;
  max-width: 92%;
  font-size: 17px;
  line-height: 1.55;
  font-weight: 500;
  color: #fff;
  background: rgba(0,0,0,0.78);
  padding: 4px 12px 5px;
  border-radius: 5px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Resume Banner ── */
.resume-banner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  z-index: 50;
  background: rgba(6,8,14,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 22px 26px;
  text-align: center;
  min-width: 230px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: popup-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.resume-banner p { font-size: 14px; color: var(--text); }
.resume-banner strong { color: var(--gold); }
.resume-btns { display: flex; gap: 10px; justify-content: center; }
.rbtn { padding: 9px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; font-family: 'Outfit',sans-serif; }
.rbtn-yes { background: var(--gold); color: #1a0e00; box-shadow: 0 3px 14px rgba(212,168,67,0.35); }
.rbtn-yes:hover { transform: translateY(-1px); }
.rbtn-no  { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid rgba(255,255,255,0.12); }
.rbtn-no:hover { background: rgba(255,255,255,0.12); }

/* ── Player Error ── */
.player-error {
  position: absolute; inset: 0;
  z-index: 80;
  background: rgba(6,8,14,0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
}
.pe-icon { font-size: 40px; }
.pe-text  { font-size: 15px; color: rgba(255,255,255,0.75); line-height: 1.6; max-width: 320px; }
.pe-back  { margin-top: 8px; padding: 11px 24px; background: var(--gold); color: #1a0e00; font-size: 14px; font-weight: 700; border-radius: 10px; font-family: 'Outfit',sans-serif; }

/* ── Landscape ── */
@media (orientation: landscape) and (max-height: 480px) {
  .ctrl-top    { padding-top: calc(var(--safe-t) + 6px); }
  .ctrl-bottom { padding-bottom: calc(var(--safe-b) + 4px); }
  .ic-btn      { width: 36px; height: 36px; }
  .pp-btn      { width: 40px; height: 40px; }
  .sub-display { bottom: 68px; }
  .sub-display .sub-line { font-size: 14px; }
}

/* ── Portrait ── */
@media (orientation: portrait) {
  #vid { width: 100%; height: auto; max-height: 100%; }
}

/* ══ HEVC WARNING POPUP ══ */
.hevc-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  animation: overlay-in 0.2s ease;
}

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

.hevc-popup {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #0f1219;
  border: 1px solid rgba(255,255,255,0.1);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  animation: sheet-up 0.3s cubic-bezier(0.34,1.2,0.64,1);
  box-shadow: 0 -20px 60px rgba(0,0,0,0.6);
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.hevc-popup-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.hevc-vlc-logo {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 4px 16px rgba(255,136,0,0.4));
}

.hevc-popup-badge {
  padding: 4px 12px;
  background: rgba(255,136,0,0.12);
  border: 1px solid rgba(255,136,0,0.3);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ff8800;
  text-transform: uppercase;
}

.hevc-popup-title {
  font-size: 20px;
  font-weight: 700;
  color: #e4e6f0;
  letter-spacing: -0.01em;
  margin-top: 2px;
}

.hevc-popup-desc {
  font-size: 14px;
  color: rgba(228,230,240,0.55);
  line-height: 1.6;
  max-width: 340px;
}

.hevc-popup-desc2 {
  font-size: 13px;
  color: rgba(228,230,240,0.4);
  line-height: 1.6;
  max-width: 320px;
}

.hevc-popup-desc2 strong {
  color: rgba(228,230,240,0.7);
  font-weight: 600;
}

.hevc-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.hevc-btn-vlc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 20px;
  background: linear-gradient(135deg, #ff8800 0%, #cc5500 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-radius: 14px;
  text-decoration: none;
  box-shadow: 0 4px 24px rgba(255,136,0,0.35);
  transition: transform 0.12s, box-shadow 0.12s;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.01em;
}

.hevc-btn-vlc:hover  { transform: translateY(-1px); box-shadow: 0 6px 32px rgba(255,136,0,0.5); }
.hevc-btn-vlc:active { transform: scale(0.97); }

.hevc-btn-try {
  width: 100%;
  padding: 13px 20px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  color: rgba(228,230,240,0.6);
  font-size: 14px;
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
  transition: background 0.15s, color 0.15s;
}
.hevc-btn-try:hover  { background: rgba(255,255,255,0.1); color: #e4e6f0; }
.hevc-btn-try:active { transform: scale(0.98); }

.hevc-popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  color: rgba(228,230,240,0.5);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.hevc-popup-close:hover { background: rgba(255,255,255,0.12); color: #e4e6f0; }

/* Disable scroll behind popup */
body.hevc-popup-open { overflow: hidden; }
