/* ===== TOWIBE Player ===== */
.tw-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  font-family: inherit;
  user-select: none;
}
.tw-player.fs { border-radius: 0; aspect-ratio: auto; height: 100vh; }
.tw-player.theater { border-radius: 0; aspect-ratio: 21/9; max-height: 75vh; }
body.theater-mode .watch { grid-template-columns: 1fr !important; max-width: none !important; }

.tw-player video {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
}
.tw-player.idle .tw-controls,
.tw-player.idle .tw-center-btn { opacity: 0; pointer-events: none; }
.tw-player.idle { cursor: none; }

/* Skip zones (double-tap) */
.tw-skip-zone {
  position: absolute; top: 0; bottom: 60px;
  width: 30%; z-index: 2; cursor: pointer;
}
.tw-skip-l { left: 0; }
.tw-skip-r { right: 0; }

/* Center play button (when paused) */
.tw-center-btn {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80px; height: 80px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  border: 0; border-radius: 50%;
  color: white;
  cursor: pointer; opacity: 1;
  transition: opacity .25s, transform .15s, background .15s;
  display: grid; place-items: center;
  z-index: 4;
}
.tw-center-btn:hover { transform: translate(-50%, -50%) scale(1.08); background: var(--primary, #1E92FF); }
.tw-player.playing .tw-center-btn { opacity: 0; pointer-events: none; }
.tw-center-btn svg { width: 38px; height: 38px; fill: currentColor; }

/* Loading spinner */
.tw-loading {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary, #1E92FF);
  border-radius: 50%;
  animation: twspin 0.8s linear infinite;
  display: none; z-index: 3;
}
.tw-player.buffering .tw-loading { display: block; }
.tw-player.buffering .tw-center-btn { opacity: 0; }
@keyframes twspin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* HUD flash (volume change, skip, speed) */
.tw-hud {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.75); color: white;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 700;
  opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 7;
  backdrop-filter: blur(8px);
}
.tw-hud.show { opacity: 1; }

/* Progress tooltip */
.tw-progress-tip {
  position: absolute; bottom: 64px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.9); color: white;
  padding: 4px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity .15s;
  pointer-events: none; z-index: 6;
  white-space: nowrap;
}
.tw-progress-tip.show { opacity: 1; }

/* Bottom controls */
.tw-controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 14px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.9));
  color: white;
  transition: opacity .2s;
  z-index: 5;
}

/* Progress bar */
.tw-progress {
  height: 18px; position: relative; cursor: pointer;
  display: flex; align-items: center;
  margin: 0 -4px;
  padding: 0 4px;
}
.tw-progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  transition: height .15s;
}
.tw-progress:hover .tw-progress-track,
.tw-progress.dragging .tw-progress-track { height: 6px; }
.tw-progress-buffer {
  position: absolute; left: 0; top: 0;
  height: 100%; width: 0%;
  background: rgba(255,255,255,0.35);
  border-radius: inherit;
}
.tw-progress-fill {
  position: absolute; left: 0; top: 0;
  height: 100%; width: 0%;
  background: var(--primary, #1E92FF);
  border-radius: inherit;
}
.tw-progress-thumb {
  position: absolute;
  width: 14px; height: 14px;
  background: var(--primary, #1E92FF);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  top: 50%; left: 0%;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.tw-progress:hover .tw-progress-thumb,
.tw-progress.dragging .tw-progress-thumb { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }

/* Control row */
.tw-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0;
}
.tw-row-l, .tw-row-r { display: flex; align-items: center; gap: 4px; }

.tw-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent; border: 0;
  color: white; cursor: pointer;
  border-radius: 50%;
  transition: background .15s, transform .15s;
}
.tw-btn:hover { background: rgba(255,255,255,0.15); }
.tw-btn:active { transform: scale(0.92); }
.tw-btn svg { width: 22px; height: 22px; }
.tw-btn.disabled { opacity: 0.45; cursor: not-allowed; }
.tw-btn.disabled:hover { background: transparent; }

.tw-time {
  font-size: 13px; color: rgba(255,255,255,0.95);
  margin: 0 12px 0 6px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  font-weight: 500;
}

/* === VOLUME — always visible slider === */
.tw-volume {
  display: flex; align-items: center;
  height: 38px;
}
.tw-volume-track {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  margin-left: 4px;
  margin-right: 6px;
  cursor: pointer;
  position: relative;
  transition: height .15s;
}
.tw-volume-track:hover, .tw-volume:hover .tw-volume-track { height: 6px; }
.tw-volume-fill {
  position: absolute; top: 0; left: 0;
  height: 100%;
  background: white;
  border-radius: 2px;
  width: 100%;
  pointer-events: none;
}
.tw-volume-thumb {
  position: absolute;
  width: 12px; height: 12px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  top: 50%; left: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.tw-volume:hover .tw-volume-thumb { opacity: 1; }

@media (max-width: 540px) {
  .tw-volume-track { width: 56px; }
  .tw-btn { width: 36px; height: 36px; }
  .tw-time { font-size: 11px; margin: 0 6px; }
  .tw-row-r .tw-btn:nth-child(3) { display: none; } /* hide theater */
}

/* === Settings menu === */
.tw-menu {
  position: absolute; bottom: 60px; right: 12px;
  background: rgba(20,20,28,0.97);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 0; min-width: 220px;
  z-index: 6; opacity: 0; pointer-events: none;
  transform: translateY(8px);
  transition: opacity .15s, transform .15s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.tw-menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.tw-menu-section { padding: 4px 0; }
.tw-menu-section + .tw-menu-section { border-top: 1px solid rgba(255,255,255,0.06); margin-top: 4px; padding-top: 8px; }
.tw-menu-title {
  padding: 4px 14px 8px;
  font-size: 10px; font-weight: 800;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.tw-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  font-size: 13px; cursor: pointer;
  color: white;
  font-weight: 500;
  transition: background .15s;
}
.tw-menu-item:hover { background: rgba(255,255,255,0.08); }
.tw-check { display: grid; place-items: center; width: 16px; height: 16px; opacity: 0; color: var(--primary, #1E92FF); }
.tw-check svg { width: 14px; height: 14px; }
.tw-menu-item.active .tw-check { opacity: 1; }
.tw-menu-item.active { color: var(--primary, #1E92FF); }

/* Toggle */
.tw-toggle {
  width: 32px; height: 18px;
  background: rgba(255,255,255,0.2);
  border-radius: 9px;
  position: relative;
  transition: background .15s;
}
.tw-toggle > span {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: left .15s;
}
.autoplay-toggle.on .tw-toggle { background: var(--primary, #1E92FF); }
.autoplay-toggle.on .tw-toggle > span { left: 16px; }

/* === VOLUME SLIDER FIX — expand click area === */
.tw-volume-track {
  height: 14px !important;        /* bigger click target */
  display: flex; align-items: center;
  background: transparent !important;
  position: relative;
}
.tw-volume-track::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  pointer-events: none;
  transition: height .15s;
}
.tw-volume-track:hover::before { height: 6px; }
.tw-volume-fill {
  top: 50% !important; transform: translateY(-50%);
  height: 4px !important;
  z-index: 1;
}
.tw-volume:hover .tw-volume-fill { height: 6px !important; }
.tw-volume-thumb {
  z-index: 2;
  opacity: 1 !important;
  width: 14px !important; height: 14px !important;
}
