*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --accent: #00ff88;
  --error: #ff6b6b;
  --text: #fff;
  --text-secondary: rgba(255,255,255,0.7);
  --text-muted: rgba(255,255,255,0.5);
  --button-bg: rgba(255,255,255,0.15);
  --header-border: rgba(0,255,136,0.2);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ── Loading Screen ── */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0a0a0a, #1a1a2e, #16213e);
  transition: opacity 0.4s ease;
}
#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.logo-container { text-align: center; margin-bottom: 40px; }
.logo-main { font-size: 56px; font-weight: 900; letter-spacing: 8px; }
.logo-sub { font-size: 32px; font-weight: 300; color: var(--text-secondary); letter-spacing: 4px; margin-top: -5px; }
.logo-accent { font-size: 48px; font-weight: 900; color: var(--accent); letter-spacing: 6px; margin-top: -5px; }
.logo-us { font-size: 24px; font-weight: 700; color: var(--accent); letter-spacing: 2px; margin-top: 4px; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-subtext {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
}

/* ── App Shell ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ── */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(10,10,10,0.95);
  border-bottom: 1px solid var(--header-border);
  flex-shrink: 0;
}
.header-logo { display: flex; align-items: baseline; }
.header-logo-text { font-size: 16px; font-weight: 900; letter-spacing: 2px; }
.header-dot { font-size: 16px; font-weight: 700; color: var(--accent); }
#counter { font-size: 14px; color: var(--text-muted); font-weight: 500; }

/* ── Player Wrapper ── */
#player-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 0;
  padding: 16px;
  gap: 16px;
}

/* ── Nav Arrows ── */
.nav-arrow {
  background: var(--button-bg);
  border: none;
  color: var(--text-muted);
  width: 48px; height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.nav-arrow:hover { color: var(--text); background: rgba(255,255,255,0.25); }
.nav-arrow:disabled { opacity: 0.2; cursor: default; }

/* ── Player ── */
#player {
  position: relative;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  max-height: calc(100vh - 130px);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 1;
}

#video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
  transition: opacity 0.15s ease;
}

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.7);
  z-index: 5;
}

.loading-text {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

#pause-overlay { background: rgba(0,0,0,0.3); cursor: pointer; z-index: 4; }

.error-text { color: var(--error); font-size: 16px; margin: 16px 0 24px; }
.retry-button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.retry-button:hover { filter: brightness(1.1); }

/* ── Info Overlay ── */
#info-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 60px 20px 56px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  display: flex;
  align-items: flex-end;
  gap: 16px;
  z-index: 3;
  pointer-events: none;
}
#info-overlay > * { pointer-events: auto; }

.info-content { flex: 1; min-width: 0; }

.video-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-meta {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}
.video-description {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-description.visible { display: -webkit-box; }

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.action-button {
  width: 44px; height: 44px;
  border-radius: 22px;
  background: var(--button-bg);
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}
.action-button:hover { background: rgba(255,255,255,0.3); }
.action-button.accent { color: var(--accent); }

/* ── Player Bar ── */
#player-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0.4), transparent);
  z-index: 6;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
#player:hover #player-bar,
#player:fullscreen #player-bar,
#player-bar.active {
  opacity: 1;
  pointer-events: auto;
}

.bar-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.bar-btn:hover { color: var(--accent); }

.bar-time {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.bar-progress {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: height 0.1s;
}
.bar-progress:hover { height: 6px; }

.bar-buffered {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  pointer-events: none;
}

.bar-filled {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
}

.bar-scrubber {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.bar-progress:hover .bar-scrubber { opacity: 1; }

/* ── Swipe Hint ── */
.swipe-hint {
  position: absolute;
  bottom: 48px;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  font-size: 11px;
  gap: 2px;
  opacity: 0.5;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.3s;
}
.swipe-hint.fade-out { opacity: 0; }

/* ── Keyboard Hint ── */
.keyboard-hint {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 8px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: opacity 0.5s;
}
.keyboard-hint.fade-out { opacity: 0; }
kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 11px;
  margin: 0 2px;
}

/* ── Footer ── */
#footer {
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(10,10,10,0.95);
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
#footer a { color: var(--accent); font-weight: 600; text-decoration: none; }
#footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 600px) {
  #player {
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    aspect-ratio: auto;
    max-height: none;
  }
  #player-wrapper { padding: 0; gap: 0; }
  .nav-arrow { display: none; }
  .keyboard-hint { display: none; }
  #info-overlay { padding-bottom: 40px; }
}

/* ── Filter Toggle Button ── */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.filter-toggle {
  background: var(--button-bg);
  border: none;
  color: var(--text-muted);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.filter-toggle:hover { color: var(--text); background: rgba(255,255,255,0.25); }
.filter-toggle.active { color: var(--accent); background: rgba(0,255,136,0.15); }

/* ── Filter Panel Backdrop ── */
.filter-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  transition: opacity 0.3s ease;
}
.filter-backdrop.visible { opacity: 1; }

/* ── Filter Panel ── */
.filter-panel {
  position: fixed;
  top: 0; right: 0;
  width: 340px;
  max-width: 85vw;
  height: 100vh;
  background: #111118;
  border-left: 1px solid rgba(255,255,255,0.1);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 30px rgba(0,0,0,0.5);
}
.filter-panel.open {
  transform: translateX(0);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.filter-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}
.filter-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.filter-close:hover { color: var(--text); background: var(--button-bg); }

.filter-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.filter-action-btn {
  background: var(--button-bg);
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.filter-action-btn:hover { color: var(--text); background: rgba(255,255,255,0.25); }

.filter-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.filter-item:hover { background: rgba(255,255,255,0.06); }

.filter-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.filter-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.filter-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 2px;
  width: 6px; height: 10px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.filter-item.disabled {
  opacity: 0.35;
}

.filter-icon {
  width: 24px; height: 24px;
  flex-shrink: 0;
  stroke: var(--accent);
  transition: opacity 0.15s;
}
.filter-item.disabled .filter-icon { stroke: var(--text-muted); }

.filter-label { display: flex; flex-direction: column; min-width: 0; }
.filter-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: color 0.15s;
}
.filter-item.disabled .filter-name { color: var(--text-muted); }
.filter-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Fullscreen ── */
#player:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
}
#player:fullscreen #video-player {
  width: 100%;
  height: 100%;
}

/* ── Cinema mode cursor hide ── */
#player.cinema-mode { cursor: none; }
