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

:root {
  --bg-primary: #0f0f11;
  --bg-secondary: #1a1a1e;
  --bg-tertiary: #252529;
  --text-primary: #e8e8e8;
  --text-secondary: #9a9a9e;
  --accent: #e14b4b;
  --accent-hover: #c73e3e;
  --border: #2a2a2e;
  --success: #4caf50;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

.container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s, min-width 0.2s, opacity 0.2s;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-header .count {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 2px 10px;
  border-radius: 12px;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.channel-list::-webkit-scrollbar {
  width: 6px;
}

.channel-list::-webkit-scrollbar-track {
  background: transparent;
}

.channel-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.channel-item:hover {
  background: var(--bg-tertiary);
}

.channel-item.active {
  background: var(--bg-tertiary);
  border-left-color: var(--accent);
}

.channel-item .indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.2s;
}

.channel-item.active .indicator {
  background: var(--accent);
}

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

.channel-item .name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-item .status-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.channel-item.active .status-text {
  color: var(--success);
}

/* Main content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  min-width: 0;
}

.video-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #000;
  min-height: 0;
  overflow: hidden;
}

.video-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  outline: none;
}

/* Placeholder */
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  text-align: center;
  padding: 40px;
  z-index: 1;
  pointer-events: none;
}

.placeholder.hidden {
  display: none;
}

.placeholder .icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.placeholder h2 {
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.placeholder p {
  font-size: 14px;
  max-width: 320px;
}

/* Error overlay */
.error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  color: var(--text-primary);
  text-align: center;
  padding: 40px;
  z-index: 5;
}

.error-overlay.hidden {
  display: none;
}

.error-overlay .error-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.error-overlay .error-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.error-overlay .error-detail {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: 20px;
}

.error-overlay .retry-btn {
  padding: 10px 28px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.error-overlay .retry-btn:hover {
  background: var(--accent-hover);
}

/* Sidebar toggle button */
.sidebar-toggle-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Desktop sidebar collapse */
@media (min-width: 769px) {
  .container.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    opacity: 0;
    border-right: none;
  }
}

/* Controls bar */
.controls {
  height: 52px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 4;
}

.controls.hidden {
  opacity: 0;
  pointer-events: none;
}

.controls .btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.controls .btn:hover {
  background: var(--bg-tertiary);
}

.controls .btn.fullscreen-btn {
  margin-left: auto;
}

.controls .time {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.controls .quality-selector {
  display: none;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  border: none;
}

/* Progress bar */
.progress-wrap {
  height: 4px;
  background: var(--bg-tertiary);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.progress-wrap .progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s;
}

.progress-wrap .progress-buffer {
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  width: 0%;
  position: absolute;
  top: 0;
  left: 0;
}

/* Play overlay */
.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.25s;
}

.play-overlay.visible {
  opacity: 1;
}

.play-overlay.hidden {
  display: none;
}

.play-overlay .play-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #fff;
  transition: transform 0.2s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.play-overlay .play-button:hover {
  transform: scale(1.1);
}

/* Loading spinner */
.loading-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

.loading-spinner.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Mobile */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    max-height: 35vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 10;
    transition: none;
  }

  .container.sidebar-collapsed .sidebar {
    display: none;
  }

  .play-overlay {
    background: rgba(0, 0, 0, 0.5);
  }

  .play-overlay .play-button {
    width: 100px;
    height: 100px;
    font-size: 42px;
  }

  .controls .btn {
    -webkit-tap-highlight-color: transparent;
  }

  .volume-slider {
    width: 50px;
    height: 6px;
  }

  .volume-slider::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
  }

  .volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
  }

  .progress-wrap {
    height: 6px;
  }

  .placeholder .icon {
    font-size: 48px;
  }

  .sidebar-toggle-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
}

@media (max-width: 420px) {
  .volume-slider {
    width: 36px;
  }

  .controls .btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .sidebar {
    max-height: 30vh;
  }
}
